void SaveCanvas(TCanvas * c, string fileNameAndDir, string FileTypes){
/*
 Supply a canvas, a name you'd like the file to have (possibly prefixed by a directory), 
 and a string containing the names of file extensons.  The default is to save as .C, .root, .pdf, .jpg, .gif, .png, and .eps
 The filetype string is case insensitive. 
 
 For example 
 SaveCanvas(myCanvas, "plots/mycanvas") 
       saves canvas in dir plots as mycanvas.C, mycanvas.root, mycanvas.jpg 
       all types are saved.
 SaveCanvas(myCanvas, "mycanvas","jpgif")
       saves the canvas as mycanvas.jpg and mycanvas.gif
 */
	
	TString TFileTypes = FileTypes;
	TFileTypes.ToLower();
	string lc_types = TFileTypes.Data();
	if(lc_types.find("c")!=string::npos) c->SaveAs((char*)(fileNameAndDir+".C").c_str());
	if(lc_types.find("root")!=string::npos) c->SaveAs((char*)(fileNameAndDir+".root").c_str());
	if(lc_types.find("pdf")!=string::npos) c->SaveAs((char*)(fileNameAndDir+".pdf").c_str());
	if(lc_types.find("jpg")!=string::npos) c->SaveAs((char*)(fileNameAndDir+".jpg").c_str());
	if(lc_types.find("gif")!=string::npos) c->SaveAs((char*)(fileNameAndDir+".gif").c_str());
	if(lc_types.find("png")!=string::npos) c->SaveAs((char*)(fileNameAndDir+".png").c_str());
	if(lc_types.find("eps")!=string::npos) c->SaveAs((char*)(fileNameAndDir+".eps").c_str());
}
Example #2
0
void SaveCanvas(TCanvas* canv,const char* path="canv",const Option_t *option="ecg")
{
  TString name;
  TString opt = option; opt.ToLower();
  //
  TString name0 = path;
  if (name0.IsNull()) name0 = "defCanv";
  //
  TFrame* fr = GetFrame();
  if (fr) fr->SetBorderMode(0);
  if (opt.Contains("c")) {
    name = name0; name+=".C";
    canv->Print(name.Data());
  }
  //
  if (opt.Contains("e")) {
    name = name0; name+=".eps";
    canv->Print(name.Data());
  }
  //
  if (opt.Contains("g")) {
    name = name0; name+=".gif";
    canv->Print(name.Data());
  }
  //
  if (opt.Contains("p")) {
    name = name0; name+=".ps";
    canv->Print(name.Data());
  }
  //
}
Example #3
0
void GausBF::Print(Option_t *option) const
{
  TString sopt = option; sopt.ToLower();
  if (sopt == "dump") {
    for (Int_t i = 0; i < Ns1*Ns9*Np; i++) {
      cout << Form(" %10.3e,", _par[i]);
      if (i%6 == 5) cout << endl;
    }
    cout << endl;
  }
  if (sopt.BeginsWith("p")) {
    TString ss = sopt(1, 2);
    if (ss.IsDigit()) {
      Int_t ip = ss.Atoi();
      if (0 <= ip && ip < Np)
	for (Int_t i = 0; i < Ns1; i++) {
	  for (Int_t j = 0; j < Ns9; j++) {
	    AMSPoint p1 = GetP1(i);
	    AMSPoint p9 = GetP9(j);
	    cout << Form("%3d %3d %6.2f %6.2f %7.2f %7.2f %10.3e",
			 i, j, p1.x(), p1.y(),
			       p9.x(), p9.y(), _par[(i*Ns9+j)*Np+ip]) << endl;
	  }
	}
    }
  }
}
Example #4
0
//___________________________________________________________
void runAlien(TString data, TString mode = "test", Bool_t MC = kFALSE){  
  if(!gSystem->Getenv("ALICE_ROOT")){
    printf("AliRoot has to be initialized\n");  
    return;
  }
  
  // check for valid modes
  const int kModes = 5;
  TString allowed_modes[kModes] = {"proof", "prooftest", "test", "full", "submit"}; 
  Bool_t isValid = kFALSE;
  mode.ToLower();
  for(int imode = 0; imode < kModes; imode++){
    if(!mode.CompareTo(allowed_modes[imode])) isValid = kTRUE;
  }
  if(!isValid){
    printf("invalid analysis mode selected\n");
    return;
  }
  analysis_mode = mode; 
  Bool_t proofmode = mode.Contains("proof");
  // libraries to be loaded
  gSystem->Load("libANALYSIS");
  gSystem->Load("libANALYSISalice");
  gSystem->Load("libCORRFW");
  gSystem->Load("libPWGhfe");
  
  // Create Analysis Manager
  AliAnalysisManager *runAnalysis = new AliAnalysisManager("Heavy Flavour Electron Analysis");
  runAnalysis->SetCommonFileName(output_file.Data());
  runAnalysis->SetInputEventHandler(new AliESDInputHandler); 
  if(MC) runAnalysis->SetMCtruthEventHandler(new AliMCEventHandler);
  AliAnalysisAlien *alienhandler = CreateAlienHandler(proofmode);
  printf("alienhandler %p\n", alienhandler);
  runAnalysis->SetGridHandler(alienhandler);
  //return;
  
  // Specify input (runs or dataset)
  if(!proofmode){
    // Query sample ID and runs
    TString sample;
    TArrayI listofruns;
    DecodeDataString(data, sample, listofruns);
    AddInput(alienhandler, sample, listofruns, MC);
  } else {
    alienhandler->SetProofDataSet(data);
  }

  // Add Tasks
  gROOT->LoadMacro(Form("%s/OADB/macros/AddTaskPhysicsSelection.C", gSystem->Getenv("ALICE_ROOT")));
  gROOT->LoadMacro(Form("%s/PWG3/hfe/macros/AddTaskHFE.C", gSystem->Getenv("ALICE_ROOT")));
  AddTaskPhysicsSelection(MC);
  AddTaskHFE();     // @TODO: MC and PbPb flag to be fixed

  // Run Analysis
  TString anamode = proofmode ? "proof" : "grid";
  if(runAnalysis->InitAnalysis()){
    runAnalysis->PrintStatus();
    runAnalysis->StartAnalysis(anamode);
  }
}
Example #5
0
//________________________________________________________________________________
TChain* CreateChain(const char *xmlfile, const char *type)
{
// Create a chain using url's from xml file
   TString treename = type;
   treename.ToLower();
   treename += "Tree";
   printf("***************************************\n");
   printf("    Getting chain of trees %s\n", treename.Data());
   printf("***************************************\n");
   TGridCollection *coll = gGrid->OpenCollection(xmlfile);
   if (!coll) {
      ::Error("CreateChain", "Cannot create an AliEn collection from %s", xmlfile);
      return NULL;
   }
   TChain *chain = new TChain(treename);
   coll->Reset();
   while (coll->Next()) {
      chain->Add(coll->GetTURL(""));
   }
   if (!chain->GetNtrees()) {
      ::Error("CreateChain", "No tree found from collection %s", xmlfile);
      return NULL;
   }
   return chain;
}
Example #6
0
Bool_t InputHandlerSetup(TString format = "esd", Bool_t useKine = kTRUE)
{
  format.ToLower();

  IlcAnalysisManager *mgr = IlcAnalysisManager::GetAnalysisManager();

  IlcAnalysisDataContainer *cin = mgr->GetCommonInputContainer();

  if (cin) return;

  if (!format.CompareTo("esd"))
    {
      IlcESDInputHandler *esdInputHandler = 
	dynamic_cast<IlcESDInputHandler*>(IlcAnalysisManager::GetAnalysisManager()->
					  GetInputEventHandler());

      if (!esdInputHandler)
	{
	  Info("CustomAnalysisTaskInputSetup", "Creating esdInputHandler ...");
	  esdInputHandler = new IlcESDInputHandler();
	  mgr->SetInputEventHandler(esdInputHandler);
	}

      if (useKine)
	{
	  IlcMCEventHandler* mcInputHandler = 
	    dynamic_cast<IlcMCEventHandler*>(IlcAnalysisManager::GetAnalysisManager()->
					     GetMCtruthEventHandler());

	  if (!mcInputHandler)
	    {
	      Info("CustomAnalysisTaskInputSetup", "Creating mcInputHandler ...");
	      IlcMCEventHandler* mcInputHandler = new IlcMCEventHandler();
	      mgr->SetMCtruthEventHandler(mcInputHandler);
	    }
	}

    }
  else if (!format.CompareTo("aod"))
    {
      IlcAODInputHandler *aodInputHandler = 
	dynamic_cast<IlcAODInputHandler*>(IlcAnalysisManager::GetAnalysisManager()->
					  GetInputEventHandler());

      if (!aodInputHandler)
	{
	  Info("CustomAnalysisTaskInputSetup", "Creating aodInputHandler ...");
	  aodInputHandler = new IlcAODInputHandler();
	  mgr->SetInputEventHandler(aodInputHandler);
	}
    }
  else
    {
      IlcWarning("Wrong input format!!! Only ESD and AOD are supported. Skipping Task ...");
      return kFALSE;
    }

  return kTRUE;
}
Example #7
0
  /** 
   * Create the input handler.  This is overwritten from the base
   * class to allow using AliESDInputHandlerRP for rec. points., and
   * AliMixInputEventHandler if requested.
   * 
   * @param type Type of analysis 
   * @param needRec if true, also get rec-points 
   * 
   * @return The input handler 
   */
  AliVEventHandler* CreateInputHandler(UShort_t type, Bool_t needRec=false)
  {
    TString  recMode = fOptions.AsString("reconstruct");
    recMode.ToLower();
    Bool_t needRP = (recMode.Contains("nor") ||
		     recMode.Contains("inj") ||
		     recMode.Contains("rot") || needRec);
    // Info("CreateInputHandler", "Will create for %d (%d)", type, needRP);
    return TrainSetup::CreateInputHandler(type, needRP);
  }
Example #8
0
bool rdphi::string_true_false(TString tf)
{
  tf.ToLower();
  bool b = false;
  if ( tf == "true" ){
    b = true;
  }
  else if ( tf != "false" ) {
    throw(" option value must be \"true\" or \"false\" ");
  }
  return b;
}
Bool_t AddAMEventMixingTest(TString analysisSource = "proof", TString analysisMode = "test",TString input="aod",TString inputMC="", TString postfix = "",TString idStr="0")
{
  
   Bool_t useEventMixingPar      = 1;
   Int_t usePhysSel              = 1;
   Bool_t useMC = !inputMC.CompareTo("mc");

   input.ToLower();

   // ALICE stuff
   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
   if (!mgr) { Printf("Error[AddAMEventMixingTest] mgr is null !!!"); return kFALSE; }
   
   
   AliAnalysisGrid *analysisPlugin = mgr->GetGridHandler();
   if (!analysisPlugin) { Printf("Error[AddAMEventMixingTest] : analysisPlugin is null !!!"); return kFALSE; }

   TString myAdditionalLibs;
   if (useEventMixingPar) { AliAnalysisAlien::SetupPar("EventMixing"); myAdditionalLibs += " EventMixing.par"; }
   else { gSystem->Load("libEventMixing.so"); myAdditionalLibs += " libEventMixing.so"; }
   
   gROOT->LoadMacro("AliAnalysisTaskEx02.cxx++g");
   analysisPlugin->SetAnalysisSource("AliAnalysisTaskEx02.cxx+");
   myAdditionalLibs+=" AliAnalysisTaskEx02.h AliAnalysisTaskEx02.cxx";
   analysisPlugin->SetAdditionalLibs(myAdditionalLibs.Data());
   

  AliMultiInputEventHandler *multiInputHandler = mgr->GetInputEventHandler();

   if (usePhysSel && !input.CompareTo("esd")) {
      gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
      AddTaskPhysicsSelection(useMC);

      // maybe we can put it in $ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C
      AliMultiInputEventHandler *multiIH = dynamic_cast<AliMultiInputEventHandler *>(mgr->GetInputEventHandler());
      if (multiIH){
         AliESDInputHandler *esdIH = dynamic_cast<AliESDInputHandler *>(multiIH->GetFirstInputEventHandler());
         if (esdIH) esdIH->SetEventSelection(multiIH->GetEventSelection());
         AliAODInputHandler *aodIH = dynamic_cast<AliAODInputHandler *>(multiIH->GetFirstInputEventHandler());
         if (aodIH) aodIH->SetEventSelection(multiIH->GetEventSelection());
      }
   }

  // add mixing handler (uncomment to turn on Mixnig)
  gROOT->LoadMacro("AddMixingHandler.C");
  AddMixingHandler(multiInputHandler, input, useMC,postfix);

   // load and run AddTask macro
   gROOT->LoadMacro("AddEventMixingTestTask.C");
   AddEventMixingTestTask(input, useMC, postfix);

   return kTRUE;
}
TString get_sample_name(TString name)
{
  TObjArray* arr = name.Tokenize(".");
  
  TString out = ((TObjString*)arr->At(arr->GetEntries()-2))->GetString();
  out.ReplaceAll("_JER_up", "");
  out.ReplaceAll("_JER_down", "");
  out.ReplaceAll("_JEC_up", "");
  out.ReplaceAll("_JEC_down", "");

  out.ReplaceAll("_PU_down", "");
  out.ReplaceAll("_PU_up", "");
  out.ReplaceAll("_LJets_up", "");
  out.ReplaceAll("_LJets_down", "");
  out.ReplaceAll("_BJets_up", "");
  out.ReplaceAll("_BJets_down", "");
  out.ReplaceAll("_MuonSF_down", "");
  out.ReplaceAll("_MuonSF_up", "");
  out.ReplaceAll("_BJets_down", "");
  out.ReplaceAll("_BJets_down", "");
  out.ReplaceAll("_matching_down", "");
  out.ReplaceAll("_matching_up", "");
  out.ReplaceAll("_scale_down", "");
  out.ReplaceAll("_scale_up", "");

  out.ToLower();

  out.ReplaceAll("dyjets_50toinf", "zlight");
  out.ReplaceAll("dyjets", "zlight");
  out.ReplaceAll("dy", "zlight");
  out.ReplaceAll("wjets_bflavor", "wb");
  out.ReplaceAll("wjets_cflavor", "wc");
  out.ReplaceAll("wjets_lflavor", "wlight");
  //out.ReplaceAll("tt", "ttbar");

  
  if (out.Contains("zp")){
    TString temp = out;
    temp.ReplaceAll("zp","");
    temp.ReplaceAll("p", ".");
    TObjArray* arr2 = temp.Tokenize("w");
    TString nom = ((TObjString*)arr2->At(1))->GetString();
    TString denom = ((TObjString*)arr2->At(0))->GetString();
    cout << "nom = " << nom << " denom = " << denom << endl;
    Int_t p = (100*nom.Atof())/denom.Atof();
    cout << "p = " << p << endl;
    out = TString::Format("zp %d w %d p",denom.Atoi(), p);
    out.ReplaceAll(" ", "");
  }
  
  return out;
}
Example #11
0
Bool_t CreateInputHandlers(TString input,TString inputMC,Bool_t useAODOut=kFALSE,Bool_t useMultiHandler=kTRUE) {

   input.ToLower();
   inputMC.ToLower();

   Bool_t useMC = !inputMC.CompareTo("mc");


   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
   if (!mgr) { Printf("Error [CreateInputHandlers] : mgr is null !!!"); return kFALSE; }

   if (useMultiHandler) {
      AliMultiInputEventHandler *inputHandler = new AliMultiInputEventHandler();
      if (!input.CompareTo("esd")) {
         Printf("Adding ESD Input Handler ...");
         inputHandler->AddInputEventHandler(new AliESDInputHandler());
         if (useMC) inputHandler->AddInputEventHandler(new AliMCEventHandler());
      } else if (!input.CompareTo("aod")) {
         inputHandler->AddInputEventHandler(new AliAODInputHandler());
      }

      mgr->SetInputEventHandler(inputHandler);
   } else {
      if (!input.CompareTo("esd")) {
         mgr->SetInputEventHandler(new AliESDInputHandler());
         if (useMC) mgr->SetMCtruthEventHandler(new AliMCEventHandler());
      } else if (!input.CompareTo("aod")) {
         mgr->SetInputEventHandler(new AliAODInputHandler());
      }
   }

   if (useAODOut) {
      AliAODHandler *aodHandler   = new AliAODHandler();
      aodHandler->SetOutputFileName("AliAOD.root");
      mgr->SetOutputEventHandler(aodHandler);
   }

   return kTRUE;
}
Example #12
0
void KVIVReconIdent::InitAnalysis(void)
{

   TString dt;
   dt = gDataSet->GetDataSetEnv("KVIVReconIdent.DataToAnalyse", "INDRA VAMOS");
   dt.ToLower();
   Info("InitAnalysis", "Analysing data of %s", dt.Data());
   if (dt.Contains("indra")) SetBit(kINDRAdata);
   if (dt.Contains("vamos")) SetBit(kVAMOSdata);

   if (TestBit(kINDRAdata)) cout << "INDRA" << endl;
   if (TestBit(kVAMOSdata)) cout << "VAMOS" << endl;
}
//______________________________________________________________________________
HtmlObjTable *HtmlSummary::AddTable(const char *name, Int_t nfields, 
	Bool_t exp, Option_t *option)
{
	// Add a new table in our list of tables.
	
	TString opt = option;
	opt.ToLower();
	HtmlObjTable *table = new HtmlObjTable(name, nfields, exp);
	fNTables++;
	if (opt.Contains("first"))
		fObjTables->AddFirst(table);
	else
		fObjTables->Add(table);
	return table;
}
Example #14
0
//______________________________________________________________________________
Long64_t ROMETree::AutoSave(Option_t *option)
{
   Long64_t ret = 0;
   if (fAutoSaveSize > 0 && isWrite() && fTree && fTree->GetCurrentFile()) {
      ret = fTree->AutoSave(option);
#if (ROOT_VERSION_CODE > ROOT_VERSION(4,4,2))
      fLastSaveSize = fTree->GetCurrentFile()->GetBytesWritten();
#else
      fLastSaveSize = static_cast<Long64_t>(fTree->GetCurrentFile()->GetBytesWritten());
#endif
      TString opt = option;
      opt.ToLower();
   }
   return ret;
}
void TDSPMultiEcho::Draw(Option_t *o, Double_t x0, Double_t x1, UInt_t num) {
  TString opt = o;
  opt.ToLower();

  Ssiz_t pos;

  if ((pos = opt.Index("multi"))!= kNPOS) {
    opt.Remove(pos,5);
    TMultiGraph *m = MultiGraph(NULL,x0,x1,num);
    m->Draw(o);
    m->GetXaxis()->SetTitle("#tau / #mu s");
    gPad->Update();
    return;
  }
  TGraph *a = Graph(NULL,x0,x1,num);
  a->Draw(o);
  a->GetXaxis()->SetTitle("#tau / #mu s");
  gPad->Update();
}
Example #16
0
//________________________________________________________
Double_t GFHistManager::MinOfHist(const TH1* h) const
{
  // Take bin with min content, subtract error and returns (no *1.05 applied!),
  // but cares that - together with an error bar - another bin might be lower...
  // If the hists option contains nothing about errors: error is NOT subtracted!

  TString option = h->GetOption();
  option.ToLower();
  option.ReplaceAll("same", 0);
  
  const Int_t minBin = h->GetMinimumBin();
  Double_t result = h->GetBinContent(minBin);
  if(option.Contains('e') || (h->GetSumw2N() && !option.Contains("hist"))){
    for(Int_t bin = 1; bin <= h->GetNbinsX(); ++bin){ //FIXME: for 2/3D: loop over y/z!
      result = TMath::Min(result, (h->GetBinContent(bin) - h->GetBinError(bin))); 
    }
  }
  return result;
}
Example #17
0
void Merge_MuonJet(TString type, int id = 0, int N = 1){

  gROOT->Reset();
  
  type.ToLower();
  if (type=="mc") MC = true; else
    if (type=="data") MC = false; else
      {cout<<"Choose mc or data"<<endl; return; }

  TString sample = "QCDPPb";//bJetPPb
  TString name,outname;
  
  if (MC) {name = Form("%s_AccCut.root",sample.Data());outname = "QCDPPb_genmuonmerged.root"; }
  else {name =  "jettrig_weight_AccCut.root"; outname = "jettrig_weight_AccCut_muons.root"; }


  vector<TString> newbranches = {"Njetmuon/I:jetmuonpt/F,jetmuoneta/F,jetmuonphi/F,jetmuonptrel/F,jetmuonip3d/F"};

  ProcessFile(name, outname, "jet", vector<TString> ({"muon"}), vector<TString> {"nref","Glb_nptl"}, newbranches, ProcessEvent, id, N);



  //  ProcessFile(name, outname, "jet", vector<TString> ({"QCDPPb_AccCut.root:m=muon","evt"}), jetbranches, newbranches, ProcessEvent);  
}
Example #18
0
  /** 
   * Analyse the reweighting option string and set options on task
   * appropriately.  The string is a comma or space separated list of
   * what to reweigh and how to do it. 
   *
   * What to reweigh can be specfied using one or more of the strings 
   *
   * - pt  Reweight in pT 
   * - pid Reweight particle abundance of pi, K, proton 
   * - str Reweight particles from strange weak decays 
   *
   * How to reweigh can be specifed as 
   *
   * - + or up   Increase weights (for pt < 0.05 by +30%)
   * - - or down Decrease weights (for pt < 0.05 by -30%)
   * - If none of these are given, then the weights are used as is. 
   * 
   * If pid rewighting is done and one of up or down are given, then
   * one can specify which particle type to reweigh
   *
   * - pi or pion    Reweight (up or down) pions 
   * - K  or kaon    Reweight (up or down) kaons
   * - p  or proton  Reweight (up or down) protons 
   *
   * Note, if PID, with explicit selection of pions, and strangeness
   * reweighting are specified, then the up/down flag applies to both
   * PID reweighting and the strangeness reweighting
   * 
   * @param task The task to modify 
   */
  void SetupReweighting(AliAnalysisTaskSE* task)
  {
    TString sel = fOptions.AsString("reweight");
    sel.ToLower();
    if (sel.IsNull() || sel.BeginsWith("no"))
      return;

    TList       files;
    Int_t       what = 0;
    Int_t       opt  = 0;
    TObjArray*  tokens = sel.Tokenize(", ");
    TIter       next(tokens);
    TObjString* ostr;
    // First find what should be done 
    while ((ostr = static_cast<TObjString*>(next()))) {
      const TString& token = ostr->String();
      
      if      (token.EqualTo("pt"))   {
	what |= 0x1;
	files.Add(new TObjString("REWEIGHTpt.root"));
	Printf("Will reweigh in pT");
      }
      else if (token.EqualTo("pid")) {
	what |= 0x2;
	Printf("Will reweigh particle species");
      }
      else if (token.EqualTo("str"))  {
	what |= 0x4;
	Printf("Will reweight particles from strange weak decays");
      }
    }
    if (what == 0x0) return;
    
    // Now figure out how to do it 
    next.Reset();
    TString part;
    while ((ostr = static_cast<TObjString*>(next()))) {
      const TString& token = ostr->String();
      Int_t aOpt = TMath::Abs(opt);
      if      (token.EqualTo("up")   || token.EqualTo("+")) 
	opt = (aOpt==0 ? +1 : +aOpt); 
      else if (token.EqualTo("down") || token.EqualTo("-"))
	opt = (aOpt==0 ? -1 : -aOpt);
      else if (token.EqualTo("pi")   || token.EqualTo("pion")){
	  opt = 1; part = "pi";
      }
      else if (token.EqualTo("k")    || token.EqualTo("kaon")) {
	opt = 2; part = "ka";
      }
      else if (token.EqualTo("p")    || token.EqualTo("proton")) {	  
	opt = 3; part = "pr";
      }
    }
    if (opt != 0)
      Printf("Will reweigh %s (%c30%% for pT<0.05)",
	     opt < 0 ? "down" : "up", opt < 0 ? '-' : '+');
    if (what & 0x2) {
      if (!part.IsNull()) {
	Printf("Will reweight %s in particular", part.Data());
	part.Prepend("_");
	part.Append(opt < 0 ? "-" : "+");
      }
      files.Add(new TObjString(Form("REWEIGHTpid%s.root", part.Data())));
    }
    if (what & 0x4)
      files.Add(new TObjString(Form("REWEIGHTstr%s.root",
				    opt == -1 ? "-" :
				    opt == +1 ? "+" : "")));
    delete tokens;

    Printf("Setting reweighing flag=0x%x with option=%d", what, opt);
    SetOnTask(task, "ReweightStack", what);
    SetOnTask(task, "ReweightFlag",  opt);

    TIter nextF(&files);
    while ((ostr = static_cast<TObjString*>(nextF()))) {
      Printf("Loading reweighting file %s", ostr->GetName());
      fRailway->LoadAux(ostr->GetName());
    }
  }
Example #19
0
//     const char*   cDataType      = "AOD",       // set the analysis type, AOD or ESD
//##################################################
AliAnalysisManager* EmcalJetCDF (
    const char*   cRunPeriod     = "LHC11d",    // set the run period
    const char*   cLocalFiles    = "data.txt",  // set the local list file
    const Int_t   arg_sel_chg    = 3145763,   // "mykEMC_noGA",  // physics selection
    const Int_t   arg_sel_full   = 3145763,   // "mykEMC_noGA",  // physics selection
    const Int_t   mgr_mode       = 0,         // local = 0, proof = 1, grid = 2, mixing = 3
    const Int_t   alien_mode     = 0,         // test = 0, offline = 1, submit = 2, merge = 3, full = 4
    const char*   cTaskName      = "CDFJets",   // sets name of task manager
    unsigned int  iNumFiles      = 100,         // numger of files to process from list file
    unsigned int  iNumEvents     = 999999999,   // number of events to be analyzed
    bool          bDoChargedJets = true,        // enable charge jets
    bool          bDoFullJets    = false        // enable full jets
) {
//Load needed libs
TString     ListLibs      = ""; // string list of loaded libs
TString     ListLibsExtra = ""; // string list of loaded extra libs
LoadLibs( ListLibs, ListLibsExtra );

AnalysisType  ManagerMode = static_cast<AnalysisType>(mgr_mode);
PluginType    PluginMode  = static_cast<PluginType>(alien_mode);

namespace CDF = PWGJE::EMCALJetTasks::AliAnalysisTaskEmcalJetCDF_NS; // shortcut to task namespace
unsigned int       kGridFilesPerJob         = iNumFiles;      // Maximum number of files per job (gives size of AOD)
unsigned int       kTTL                     = 64800 ;         // Time To Live; 18h = 64800; 12h = 43200

bool bDoBackgroundSubtraction = true;
bool bDoEmbedding = false;

// Embeded Configuration options
// Embedding files list
const TString embeddedFilesList = "aodFilesEmbed.txt";
// If true, events that are not selected in the PbPb will not be used for embedding.
// This ensures that good embedded events are not wasted on bad PbPb events.
const bool internalEventSelection = true;
// Do jet matching
const bool useJetTagger = true;


TString sGridMode ("test");
if ( PluginMode == PluginType::offline ) { sGridMode = "offline"; }
if ( PluginMode == PluginType::submit )  { sGridMode = "submit"; }
if ( PluginMode == PluginType::merge )   { sGridMode = "merge"; }
if ( PluginMode == PluginType::full )    { sGridMode = "full"; }
const char* cGridMode = sGridMode.Data();

TString sAnalysisType ("local");
if ( ManagerMode == AnalysisType::proof )  { sAnalysisType = "proof"; }
if ( ManagerMode == AnalysisType::grid )   { sAnalysisType = "grid"; }
if ( ManagerMode == AnalysisType::mixing ) { sAnalysisType = "mix"; }
const char* cAnalysisType = sAnalysisType.Data();

cout << std::endl << ">>>>>>>> ManagerMode : " << ManagerMode << " ; String value : " << cAnalysisType << std::endl << ">>>>>>>> PluginMode : " << PluginMode << " ; String value : " << cGridMode << std::endl << std::endl;

//---------------------------------------------------------------------------------------------
TRegexp false_regex ("[f,F][a,A][l,L][s,S][e,E]");
TRegexp true_regex ("[t,T][r,R][u,U][e,E]");
TRegexp enable_regex ("[e,E][n,N][a,A][b,B][l,L][e,E]");
TRegexp disable_regex ("[d,D][i,I][s,S][a,A][b,B][l,L][e,E]");

bool  bDoSample = false;
TString ENV_doSAMPLE = gSystem->Getenv("CDF_doSAMPLE");
if (!ENV_doSAMPLE.IsNull() && ( ENV_doSAMPLE.EqualTo("0") || ENV_doSAMPLE.Contains(false_regex) ) ) { bDoSample = kFALSE; }
if (!ENV_doSAMPLE.IsNull() && ( ENV_doSAMPLE.EqualTo("1") || ENV_doSAMPLE.Contains(true_regex)  ) ) { bDoSample = kTRUE; }

bool  bDoCDF    = true;
TString ENV_doCDF = gSystem->Getenv("CDF_doCDF");
if (!ENV_doCDF.IsNull() && ( ENV_doCDF.EqualTo("0") || ENV_doCDF.Contains(false_regex) ) ) { bDoCDF = kFALSE; }
if (!ENV_doCDF.IsNull() && ( ENV_doCDF.EqualTo("1") || ENV_doCDF.Contains(true_regex)  ) ) { bDoCDF = kTRUE; }

// ######   DEBUG    ######
Int_t           debug              =  0 ; // kFatal = 0, kError, kWarning, kInfo, kDebug, kMaxType
UInt_t          mgr_debug          =  0 ; // AliAnalysisManager debug level
UInt_t          kUseSysInfo        =  0 ; // activate debugging

TString ENV_DEBUG = gSystem->Getenv("CDF_DEBUG");
if (!ENV_DEBUG.IsNull() && ENV_DEBUG.IsDigit() ) { debug = ENV_DEBUG.Atoi(); }

TString ENV_DEBUG_MGR = gSystem->Getenv("CDF_DEBUG_MGR");
if (!ENV_DEBUG_MGR.IsNull() && ENV_DEBUG_MGR.IsDigit() ) { mgr_debug = ENV_DEBUG_MGR.Atoi(); }

TString ENV_NSYSINFO = gSystem->Getenv("CDF_NSYSINFO");
if (!ENV_NSYSINFO.IsNull() && ENV_NSYSINFO.IsDigit() ) { kUseSysInfo = ENV_NSYSINFO.Atoi(); }

if ( debug == 0 ) { AliLog::SetGlobalLogLevel ( AliLog::kFatal   ); }
if ( debug == 1 ) { AliLog::SetGlobalLogLevel ( AliLog::kError   ); }
if ( debug == 2 ) { AliLog::SetGlobalLogLevel ( AliLog::kWarning ); }
if ( debug == 3 ) { AliLog::SetGlobalLogLevel ( AliLog::kInfo    ); }
if ( debug >= 4 ) { AliLog::SetGlobalLogLevel ( AliLog::kDebug   ); }

// Progress bar
Bool_t bUseProgBar = kFALSE; // N.B. !! if true will set fDebug to 0
TString ENV_USEPROGBAR = gSystem->Getenv("PROGRESSBAR");
if (!ENV_USEPROGBAR.IsNull() && ( ENV_USEPROGBAR.EqualTo("1") || ENV_USEPROGBAR.Contains(true_regex) ) )  { bUseProgBar = kTRUE; }

//##################################################
//        AliEN plugin variables
//##################################################
const char* curdir = gSystem->BaseName(gSystem->pwd());
TString     kJobTag (curdir);

TString execArgs (" -l -b -q -x");
TString exec =
//               "aliroot";
              "root.exe";

TString     kPluginExecutableCommand = exec + execArgs;

TString     kAliPhysicsVersion       = "vAN-20190304-1";

// == grid plugin files rules
TString     kGridExtraFiles          = ""; // extra files that will be added to the input list in the JDL
TString     kGridMergeExclude        = "AliAOD.root AliAOD.Jets.root"; // Files that should not be merged
TString     kGridOutputStorages      = "disk=2"; // Make replicas on the storages

// FILES USED IN MACRO
TString     kCommonOutputFileName    = "AnalysisResults.root";

//--------------------
//   PROOF SETTINGS
//--------------------
TString kAAF        = "";
Int_t   kProofReset = 0; (void)kProofReset;
Int_t   kWorkers    = 20; (void)kWorkers;
Int_t   kCores      = 8  ; (void)kCores;
// AliRoot mode among the list supported by the proof cluster.
// TString     kAlirootMode             = "ALIROOT";     // STEERBase,ESD,AOD,ANALYSIS,ANALYSISalice (default aliroot mode)

//############################################################
// const AliAnalysisTaskEmcal::EDataType_t kAod = AliAnalysisTaskEmcal::kAOD;
// const AliAnalysisTaskEmcal::EDataType_t kEsd = AliAnalysisTaskEmcal::kESD;

const AliJetContainer::EJetType_t    fulljet = AliJetContainer::kFullJet;
const AliJetContainer::EJetType_t     chgjet = AliJetContainer::kChargedJet;
const AliJetContainer::EJetAlgo_t     antikt = AliJetContainer::antikt_algorithm;
const AliJetContainer::EJetAlgo_t         kt = AliJetContainer::kt_algorithm;
const AliJetContainer::ERecoScheme_t  recomb = AliJetContainer::pt_scheme;

// kTPC, kTPCfid, kEMCAL, kEMCALfid, kDCAL, kDCALfid, kDCALonly, kDCALonlyfid, kPHOS, kPHOSfid, kUser
const AliEmcalJet::JetAcceptanceType acc_chgjets  = AliEmcalJet::kTPCfid;
const AliEmcalJet::JetAcceptanceType acc_fulljets = AliEmcalJet::kEMCALfid;
//############################################################

// data source name
TString kDataSource (cLocalFiles);

// label of dataset from InputData.C
TString kGridDataSet ("");
if ( ManagerMode == AnalysisType::grid ) { kGridDataSet = kDataSource;}

//############################################################
// SETUP OF TRIGGERS
const AliEmcalPhysicsSelection::EOfflineEmcalTypes mykEMCAL  = AliEmcalPhysicsSelection::kEmcalOk;
const AliVEvent::EOfflineTriggerTypes  mykEMC             = static_cast<AliVEvent::EOfflineTriggerTypes>(AliVEvent::kEMC1 | AliVEvent::kEMC7 | AliVEvent::kEMC8 | AliVEvent::kEMCEJE | AliVEvent::kEMCEGA);
const AliVEvent::EOfflineTriggerTypes  mykEMC_noGA        = static_cast<AliVEvent::EOfflineTriggerTypes>(AliVEvent::kEMC1 | AliVEvent::kEMC7 | AliVEvent::kEMC8 | AliVEvent::kEMCEJE);

const AliVEvent::EOfflineTriggerTypes  mykMB              = AliVEvent::kAnyINT;
const AliVEvent::EOfflineTriggerTypes  mykMB_central      = static_cast<AliVEvent::EOfflineTriggerTypes>(AliVEvent::kAnyINT | AliVEvent::kCentral);
const AliVEvent::EOfflineTriggerTypes  mykMB_semicentral  = static_cast<AliVEvent::EOfflineTriggerTypes>(AliVEvent::kAnyINT | AliVEvent::kSemiCentral);
const AliVEvent::EOfflineTriggerTypes  mykMB_mostcentral  = static_cast<AliVEvent::EOfflineTriggerTypes>(AliVEvent::kAnyINT | AliVEvent::kCentral | AliVEvent::kSemiCentral);

AliVEvent::EOfflineTriggerTypes kPhysSel   = mykMB; //AliVEvent::kAnyINT; // physics selection
// AliVEvent::EOfflineTriggerTypes kSel_tasks = mykMB;

AliVEvent::EOfflineTriggerTypes kSel_chg   = static_cast<AliVEvent::EOfflineTriggerTypes>(arg_sel_chg);
AliVEvent::EOfflineTriggerTypes kSel_full  = static_cast<AliVEvent::EOfflineTriggerTypes>(arg_sel_full);

//############################################################
// Analysis manager
  AliAnalysisManager* pMgr = new AliAnalysisManager(cTaskName);
  pMgr->SetDebugLevel(mgr_debug);
  if ( kUseSysInfo > 0 ) { pMgr->SetNSysInfo ( kUseSysInfo ); }

  // actual runName in the form of LHCXXX....
  TString sRunName;
  Bool_t kIsAOD = kTRUE;
  AliAnalysisTaskEmcal::EDataType_t iDataType = AliAnalysisTaskEmcal::kAOD; // assuming default is to process AOD
  TString file;
  AliAnalysisAlien* plugin = NULL;
  if ( ManagerMode == AnalysisType::grid ) {  // start grid analysis
    // ( const char* gridMode, const char* tag, unsigned int nr_test_files, unsigned int TTL, const char* outdir, const char subworkdir, const char* extradirlvl);
    plugin = CreateAlienHandler(cGridMode, kJobTag.Data(), kGridFilesPerJob, kTTL);
    if ( !plugin ) { ::Error ( "runEMCalJetSampleTask.C - StartGridAnalysis", "plugin invalid" ); return NULL; }
    pMgr->SetGridHandler(plugin);

    // use this command to run the macro
    plugin->SetExecutableCommand(kPluginExecutableCommand.Data());

    // AliPhysics version.
    plugin->SetAliPhysicsVersion ( kAliPhysicsVersion.Data() ); // Here you can set the (Ali)PHYSICS version you want to use

    gROOT->LoadMacro("InputData.C");
    InputData(kGridDataSet);
    sRunName = CDF::GetPeriod( plugin->GetGridDataDir() );

    file = CDF::GetFileFromPath(plugin->GetDataPattern());
    if (file.Contains("AliESD")) { iDataType = AliAnalysisTaskEmcal::kESD; kIsAOD = kFALSE; }

    plugin->SetMergeExcludes(kGridMergeExclude.Data());
    }

  if ( ManagerMode == AnalysisType::local ) { // start local analysis
    if ( kDataSource.IsNull() ) { Printf("You need to provide the list of local files!"); return NULL; }
    TChain* pChain = CDF::CreateChain(kDataSource.Data(), "auto", "", iNumFiles);
    if (!pChain) { std::cout << ">>>>>>>>>>>>>>   CHAIN NOT CREATED   <<<<<<<<<<<<<<" << std::endl; return NULL; }
    Printf("Setting local analysis for %d files from list %s, max events = %d", iNumFiles, kDataSource.Data(), iNumEvents);

    // get the path of first file
    file = pChain->GetFile()->GetEndpointUrl()->GetUrl();
    sRunName = CDF::GetPeriod(file.Data()); // get the run name : first token beggining with lhc
    if ( CDF::GetFileFromPath(file).Contains("AliESD") ) { iDataType = AliAnalysisTaskEmcal::kESD; kIsAOD = kFALSE; }
    }

  TString sDataType ("AOD");
  if (!kIsAOD) { sDataType = "ESD"; }
  std::cout << ">>> Analysis data type : " << sDataType.Data() << std::endl;

  // name of de period (for MC is the name of "achored to" production)
  TString sRunPeriod (cRunPeriod);
  sRunPeriod.ToLower();

  bool isMC = false;
  isMC = CDF::PeriodIsMC(sRunName.Data());

  // EMCAL corrections task configuration file
  TString EMCALcfg ("CDF_CorrectionsConf.yaml");
  if (isMC) {EMCALcfg = "CDF_MC_CorrectionsConf.yaml";}

  if ( !kGridExtraFiles.IsNull() ) {kGridExtraFiles += " ";}
  kGridExtraFiles += EMCALcfg;

  AliAnalysisTaskEmcal::BeamType iBeamType = AliAnalysisTaskEmcal::kpp;
  Bool_t bIsRun2 = kFALSE;

  if (sRunPeriod.Length() == 6 && (sRunPeriod.BeginsWith("lhc15") || sRunPeriod.BeginsWith("lhc16") || sRunPeriod.BeginsWith("lhc17") || sRunPeriod.BeginsWith("lhc18") ) ) { bIsRun2 = kTRUE; }

  if (sRunPeriod == "lhc10h" || sRunPeriod == "lhc11h" || sRunPeriod == "lhc15o" || sRunPeriod == "lhc17n" )                            { iBeamType = AliAnalysisTaskEmcal::kAA; }
  if (sRunPeriod == "lhc12g" || sRunPeriod == "lhc13b" || sRunPeriod == "lhc13c" || sRunPeriod == "lhc13d" || sRunPeriod == "lhc13e" ||
      sRunPeriod == "lhc13f" || sRunPeriod == "lhc16q" || sRunPeriod == "lhc16r" || sRunPeriod == "lhc16s" || sRunPeriod == "lhc16t" )  { iBeamType = AliAnalysisTaskEmcal::kpA; }

  Double_t kGhostArea = 0.01;
  if (iBeamType != AliAnalysisTaskEmcal::kpp) { kGhostArea = 0.005; }

  AliTrackContainer::SetDefTrackCutsPeriod(sRunPeriod);
  Printf("Default track cut period set to: %s", AliTrackContainer::GetDefTrackCutsPeriod().Data());

  Bool_t bDoEmcalCorrections  = kFALSE;
  if (bDoFullJets) { bDoEmcalCorrections  = kTRUE; }

// ###   Containers and string definitions
  TString name_tracks   = "usedefault";
  TString name_clusters = "usedefault";
  TString name_cells    = "usedefault";
  // Set centrality estimator for centrality task
  TString cent_est_chg  = "V0M" ;
  TString cent_est_full = "V0M" ;

  TString mc_container ("");
  if (isMC) { mc_container = "mcparticles"; }

/*
  // General input object names
  TString tracksName             = AliEmcalContainerUtils::DetermineUseDefaultName(AliEmcalContainerUtils::kTrack);
  TString clustersName           = AliEmcalContainerUtils::DetermineUseDefaultName(AliEmcalContainerUtils::kCluster);
  TString emcalCellsName         = AliEmcalContainerUtils::DetermineUseDefaultName(AliEmcalContainerUtils::kCaloCells);
  // Combined (PbPb + embedded det level)
  TString emcalCellsCombined = emcalCellsName + "Combined";
  TString clustersCombined = clustersName + "Combined";
*/

//##########################
//   TASKS DEFINITIONS   ###
//##########################
  AliAODInputHandler* pAODHandler = NULL;
  AliESDInputHandler* pESDHandler = NULL;
  if (kIsAOD)
    { pAODHandler = AliAnalysisTaskEmcal::AddAODHandler(); }
  else
    { pESDHandler = AliAnalysisTaskEmcal::AddESDHandler(); }

  // CDBconnect task
  AliTaskCDBconnect* taskCDB = AliTaskCDBconnect::AddTaskCDBconnect();
  taskCDB->SetFallBackToRaw(kTRUE); // Needed for the moment as not all grid sites do support cvmfs OCDB for the moment
  if (!taskCDB) { std::cout << "--------->>>>  taskCDB :: could not connect!!!! CHECK CVMFS" << std::endl; return NULL;}

  // Physics selection task
  AliPhysicsSelectionTask* pPhysSelTask = NULL;
  if (!kIsAOD) {
    // signature : (Bool_t mCAnalysisFlag = kFALSE, Bool_t applyPileupCuts = kFALSE, UInt_t deprecatedFlag2 = 0, Bool_t useSpecialOutput=kFALSE)
    pPhysSelTask = AliPhysicsSelectionTask::AddTaskPhysicsSelection();
    }

  // Centrality task
  // The Run 2 condition is too restrictive, but until the switch to MultSelection is complete, it is the best we can do
  AliCentralitySelectionTask* pCentralityTask = NULL;
  if ( !kIsAOD && (iBeamType != AliAnalysisTaskEmcal::kpp && bIsRun2) ) {
    //signature : (Bool_t fillHistos=kTRUE, Bool_t aod=kFALSE)
    pCentralityTask = AliCentralitySelectionTask::AddTaskCentrality(kFALSE, kIsAOD);
    pCentralityTask->SelectCollisionCandidates(AliVEvent::kAny);
    }

  // AliMultSelection
  AliMultSelectionTask* pMultSelTask = NULL;
  if (bIsRun2) {
    // signature : ( Bool_t lCalibration = kFALSE, TString lExtraOptions = "", Int_t lNDebugEstimators = 1, const TString lMasterJobSessionFlag = "")
    pMultSelTask = AliMultSelectionTask::AddTaskMultSelection();
    pMultSelTask->SelectCollisionCandidates(AliVEvent::kAny);
    }

  // Embedding task
  if (bDoEmbedding) {
    // Debug options
    //AliLog::SetClassDebugLevel("AliAnalysisTaskEmcalEmbeddingHelper", AliLog::kDebug+0);

    // Setup embedding task
    AliAnalysisTaskEmcalEmbeddingHelper * embeddingHelper = AliAnalysisTaskEmcalEmbeddingHelper::AddTaskEmcalEmbeddingHelper();
    embeddingHelper->SelectCollisionCandidates(kPhysSel);
    // The pt hard bin should be set via the filenames in this file
    // If using a file pattern, it could be configured via embeddingHelper->SetPtHardBin(ptHardBin);
    embeddingHelper->SetFileListFilename(embeddedFilesList.Data());

    // Some example settings for LHC12a15e_fix (anchored to LHC11h)
    embeddingHelper->SetNPtHardBins(11);
    embeddingHelper->SetMCRejectOutliers();

    // Setup internal event selection and additional configuration options
    embeddingHelper->SetConfigurationPath("EmbeddingConfigurationExample.yaml");

    // Initialize the task to complete the setup.
    embeddingHelper->Initialize();
    }

  // EMCal corrections
  AliEmcalCorrectionTask* correctionTask = NULL;
  if (bDoEmcalCorrections) {
    // Configuration of the Correction Task is handled via a YAML file, which is setup below
    // signature : (TString suffix)
    correctionTask = AliEmcalCorrectionTask::AddTaskEmcalCorrectionTask();
//  correctionTask = AliEmcalCorrectionTask::ConfigureEmcalCorrectionTaskOnLEGOTrain(suffix);
    correctionTask->SelectCollisionCandidates(kPhysSel);
    correctionTask->SetUseNewCentralityEstimation(bIsRun2);
    correctionTask->SetForceBeamType(static_cast<AliEmcalCorrectionTask::BeamType>(iBeamType));

    // Configure and initialize
    correctionTask->SetUserConfigurationFilename( EMCALcfg.Data() );
    //correctionTask->SetUserConfigurationFilename("alien:///alice/cern.ch/user/m/mfasel/EMCALCorrectionConfig/ConfigDataPWGJEhighClusterThresholds.yaml");
    correctionTask->Initialize(true);

    }

//     TObjArray correctionTasks;
//
//     // Create the Correction Tasks
//     // "data" corresponds to the PbPb level
//     // "embed" corresponds to the embedded detector level
//     // "combined" corresponds to the hybrid (PbPb + embedded detector) level
//     correctionTasks.Add(AliEmcalCorrectionTask::AddTaskEmcalCorrectionTask("data"));
//     correctionTasks.Add(AliEmcalCorrectionTask::AddTaskEmcalCorrectionTask("embed"));
//     // It is important that combined is last!
//     correctionTasks.Add(AliEmcalCorrectionTask::AddTaskEmcalCorrectionTask("combined"));
//
//     // Loop over all of the correction tasks to configure them
//     AliEmcalCorrectionTask * tempCorrectionTask = 0;
//     TIter next(&correctionTasks);
//     while (( tempCorrectionTask = static_cast<AliEmcalCorrectionTask *>(next()))) {
//       tempCorrectionTask->SelectCollisionCandidates(kPhysSel);
//       // Configure centrality
//       tempCorrectionTask->SetNCentBins(5);
//       tempCorrectionTask->SetUseNewCentralityEstimation(bIsRun2);
//       tempCorrectionTask->SetUserConfigurationFilename("$ALICE_PHYSICS/PWGJE/EMCALJetTasks/macros/EMCalCorrectionTaskEmbeddingExample.yaml");
//
//       tempCorrectionTask->Initialize(true);
//       }

  // Background
  TString sRhoChName;
  TString sRhoFuName;
  AliAnalysisTaskRho* pRhoTask = NULL;
  if ( bDoBackgroundSubtraction && iBeamType != AliAnalysisTaskEmcal::kpp ) {
    sRhoChName = "Rho";
    sRhoFuName = "Rho_Scaled";

    AliEmcalJetTask* pKtChJetTask = AliEmcalJetTask::AddTaskEmcalJet(name_tracks.Data(), "", kt, 0.4, chgjet, 0.15, 0, kGhostArea, recomb, "Jet", 0., kFALSE, kFALSE);
    pKtChJetTask->SelectCollisionCandidates(kPhysSel);

    //signature :
    // const char* nTracks = "usedefault", const char* nClusters = "usedefault", const char* nRho = "Rho", Double_t jetradius = 0.2, UInt_t acceptance = AliEmcalJet::kTPCfid,
    // AliJetContainer::EJetType_t jetType = AliJetContainer::kChargedJet, const Bool_t histo = kFALSE, AliJetContainer::ERecoScheme_t rscheme = AliJetContainer::pt_scheme, const char* suffix = ""
    pRhoTask = AliAnalysisTaskRho::AddTaskRhoNew(name_tracks.Data(), name_clusters.Data(), sRhoChName, 0.4);
    pRhoTask->SetExcludeLeadJets(2);
    pRhoTask->SelectCollisionCandidates(kPhysSel);
    pRhoTask->SetRecycleUnusedEmbeddedEventsMode(internalEventSelection);

    if (bDoFullJets) {
      TString sFuncPath = "alien:///alice/cern.ch/user/s/saiola/LHC11h_ScaleFactorFunctions.root";
      TString sFuncName = "LHC11h_HadCorr20_ClustersV2";
      pRhoTask->LoadRhoFunction(sFuncPath, sFuncName);
      }
    }

  // Find Charged jets
  AliEmcalJetTask* pChJet02Task = NULL;
  AliEmcalJetTask* pChJet04Task = NULL;
  AliEmcalJetTask* pChJet02Task_MC = NULL;
  AliEmcalJetTask* pChJet04Task_MC = NULL;
  if (bDoChargedJets) {
    pChJet02Task = AliEmcalJetTask::AddTaskEmcalJet(name_tracks.Data(), "", antikt, 0.2, chgjet, 0.15, 0, kGhostArea, recomb, "Jet", 1., kFALSE, kFALSE);
    pChJet02Task->SelectCollisionCandidates(kSel_chg);

    pChJet04Task = AliEmcalJetTask::AddTaskEmcalJet(name_tracks.Data(), "", antikt, 0.4, chgjet, 0.15, 0, kGhostArea, recomb, "Jet", 1., kFALSE, kFALSE);
    pChJet04Task->SelectCollisionCandidates(kSel_chg);

    if (isMC) {
      pChJet02Task_MC = AliEmcalJetTask::AddTaskEmcalJet(mc_container.Data(), "", antikt, 0.2, chgjet, 0.15, 0, kGhostArea, recomb, "Jet", 1., kFALSE, kFALSE);
      pChJet02Task_MC->SelectCollisionCandidates(kSel_chg);
      if (bDoEmbedding) {
        pChJet02Task_MC->SetRecycleUnusedEmbeddedEventsMode(internalEventSelection);
        AliParticleContainer* partLevelTracks02Task_MC = pChJet02Task_MC->GetParticleContainer(0);
        // Called Embedded, but really just means get from an external event!
        partLevelTracks02Task_MC->SetIsEmbedding(kTRUE);
        }

      pChJet04Task_MC = AliEmcalJetTask::AddTaskEmcalJet(mc_container.Data(), "", antikt, 0.4, chgjet, 0.15, 0, kGhostArea, recomb, "Jet", 1., kFALSE, kFALSE);
      pChJet04Task_MC->SelectCollisionCandidates(kSel_chg);
      if (bDoEmbedding) {
        pChJet04Task_MC->SetRecycleUnusedEmbeddedEventsMode(internalEventSelection);
        AliParticleContainer* partLevelTracks04Task_MC = pChJet04Task_MC->GetParticleContainer(0);
        // Called Embedded, but really just means get from an external event!
        partLevelTracks04Task_MC->SetIsEmbedding(kTRUE);
        }
      } // isMC
    } // bDoChargedJets

  // Find Full jets
  AliEmcalJetTask* pFuJet02Task = NULL;
  AliEmcalJetTask* pFuJet04Task = NULL;
  AliEmcalJetTask* pFuJet02Task_MC = NULL;
  AliEmcalJetTask* pFuJet04Task_MC = NULL;
  if (bDoFullJets) {
    pFuJet02Task = AliEmcalJetTask::AddTaskEmcalJet(name_tracks.Data(), name_clusters.Data(), antikt, 0.2, fulljet, 0.15, 0.30, kGhostArea, recomb, "Jet", 1., kFALSE, kFALSE);
    pFuJet02Task->SelectCollisionCandidates(kSel_full);
    pFuJet02Task->GetClusterContainer(0)->SetDefaultClusterEnergy(AliVCluster::kHadCorr);

    pFuJet04Task = AliEmcalJetTask::AddTaskEmcalJet(name_tracks.Data(), name_clusters.Data(), antikt, 0.4, fulljet, 0.15, 0.30, kGhostArea, recomb, "Jet", 1., kFALSE, kFALSE);
    pFuJet04Task->SelectCollisionCandidates(kSel_full);
    pFuJet04Task->GetClusterContainer(0)->SetDefaultClusterEnergy(AliVCluster::kHadCorr);

    if (isMC) {
      pFuJet02Task_MC = AliEmcalJetTask::AddTaskEmcalJet(mc_container.Data(), name_clusters.Data(), antikt, 0.2, fulljet, 0.15, 0, kGhostArea, recomb, "Jet", 1., kFALSE, kFALSE);
      pFuJet02Task_MC->SelectCollisionCandidates(kSel_chg);
      if (bDoEmbedding) {
        pFuJet02Task_MC->SetRecycleUnusedEmbeddedEventsMode(internalEventSelection);
        AliParticleContainer* partLevelTracks02Task_MC = pFuJet02Task_MC->GetParticleContainer(0);
        // Called Embedded, but really just means get from an external event!
        partLevelTracks02Task_MC->SetIsEmbedding(kTRUE);
        }

      pFuJet04Task_MC = AliEmcalJetTask::AddTaskEmcalJet(mc_container.Data(), name_clusters.Data(), antikt, 0.4, fulljet, 0.15, 0, kGhostArea, recomb, "Jet", 1., kFALSE, kFALSE);
      pFuJet04Task_MC->SelectCollisionCandidates(kSel_chg);
      pFuJet04Task_MC->SetRecycleUnusedEmbeddedEventsMode(internalEventSelection);
      if (bDoEmbedding) {
        pFuJet04Task_MC->SetRecycleUnusedEmbeddedEventsMode(internalEventSelection);
        AliParticleContainer* partLevelTracks04Task_MC = pFuJet04Task_MC->GetParticleContainer(0);
        // Called Embedded, but really just means get from an external event!
        partLevelTracks04Task_MC->SetIsEmbedding(kTRUE);
        }
      } // isMC
    } // bDoFullJets

////////////////////////
//   ANALYSIS TASKS   //
////////////////////////

  // Sample task - charge jets
  AliAnalysisTaskEmcalJetSample* sampleTaskchg = NULL;
  if (bDoSample && bDoChargedJets) {
    sampleTaskchg = AliAnalysisTaskEmcalJetSample::AddTaskEmcalJetSample(name_tracks.Data(), "", "", "SMPCHG");
    sampleTaskchg->SetHistoBins(600, 0, 300);
    sampleTaskchg->SelectCollisionCandidates(kSel_chg);
    sampleTaskchg->SetDebugLevel(debug);

    AliParticleContainer* sampleTaskchg_partCont = sampleTaskchg->GetParticleContainer(0);
    sampleTaskchg_partCont->SetParticlePtCut(0.15);

    if (bDoEmbedding) { sampleTaskchg_partCont->SetIsEmbedding(kTRUE); }

    if ( pMultSelTask ) {
      sampleTaskchg->SetUseNewCentralityEstimation(bIsRun2);
      sampleTaskchg->SetNCentBins(5);
      }
    }

  // Sample task - full jets
  AliAnalysisTaskEmcalJetSample* sampleTaskfull = NULL;
  if (bDoSample && bDoFullJets) {
    sampleTaskfull = AliAnalysisTaskEmcalJetSample::AddTaskEmcalJetSample(name_tracks.Data(), name_clusters.Data(), name_cells.Data(), "SMPFULL");
    sampleTaskfull->SetHistoBins(600, 0, 300);
    sampleTaskfull->SelectCollisionCandidates(kSel_full);
    sampleTaskfull->SetDebugLevel(debug);

    AliParticleContainer* sampleTaskfull_partCont = sampleTaskfull->GetParticleContainer(0);
    sampleTaskfull_partCont->SetParticlePtCut(0.15);

    AliClusterContainer* sampleTaskfull_clusCont = sampleTaskfull->GetClusterContainer(0);
    sampleTaskfull_clusCont->SetClusECut(0.);
    sampleTaskfull_clusCont->SetClusPtCut(0.);
    sampleTaskfull_clusCont->SetClusNonLinCorrEnergyCut(0.);
    sampleTaskfull_clusCont->SetClusHadCorrEnergyCut(0.30);
    sampleTaskfull_clusCont->SetDefaultClusterEnergy(AliVCluster::kHadCorr);

    if (bDoEmbedding) {
      sampleTaskfull_partCont->SetIsEmbedding(kTRUE);
      sampleTaskfull_clusCont->SetIsEmbedding(kTRUE);
      }

    if ( pMultSelTask ) {
      sampleTaskfull->SetUseNewCentralityEstimation(bIsRun2);
      sampleTaskfull->SetNCentBins(5);
      }
    }


  //###   CDF task - charged jets
  AliAnalysisTaskEmcalJetCDF* anaTaskCDFchg = NULL;
  AliAnalysisTaskEmcalJetCDF* anaTaskCDFchg_MC = NULL;
  if (bDoCDF && bDoChargedJets) {
    anaTaskCDFchg = CDF::AddTaskEmcalJetCDF ( name_tracks.Data(), "", "", "", "CDFchg" );
    anaTaskCDFchg->SetHistoBins(600, 0, 300);
    anaTaskCDFchg->SelectCollisionCandidates(kSel_chg);
    anaTaskCDFchg->SetDebugLevel(debug);

    AliParticleContainer* anaTaskCDFchg_partCont = anaTaskCDFchg->GetParticleContainer(0);
    anaTaskCDFchg_partCont->SetParticlePtCut(0.15);

    if (bDoEmbedding) { anaTaskCDFchg_partCont->SetIsEmbedding(kTRUE); }

    if ( pMultSelTask ) {
      anaTaskCDFchg->SetUseNewCentralityEstimation(bIsRun2);
      anaTaskCDFchg->SetNCentBins(5);
      anaTaskCDFchg->SetCentralityEstimator(cent_est_chg.Data());
      }

    //#################################################
    if (isMC){
      anaTaskCDFchg_MC = CDF::AddTaskEmcalJetCDF ( mc_container.Data(), "", "", "", "CDFchgMC" );
      anaTaskCDFchg_MC->SetHistoBins(600, 0, 300);
      anaTaskCDFchg_MC->SelectCollisionCandidates(kSel_chg);
      anaTaskCDFchg_MC->SetDebugLevel(debug);

      AliParticleContainer* anaTaskCDFchg_partCont_MC = anaTaskCDFchg_MC->GetMCParticleContainer(0);
      anaTaskCDFchg_partCont->SetParticlePtCut(0.15);

      if (bDoEmbedding) { anaTaskCDFchg_partCont_MC->SetIsEmbedding(kTRUE); }

      if ( pMultSelTask ) {
        anaTaskCDFchg_MC->SetUseNewCentralityEstimation(bIsRun2);
        anaTaskCDFchg_MC->SetNCentBins(5);
        anaTaskCDFchg_MC->SetCentralityEstimator(cent_est_chg.Data());
        }
      }
    }

  //###   CDF task - full jets
  AliAnalysisTaskEmcalJetCDF* anaTaskCDFfull = NULL;
  if (bDoCDF && bDoFullJets) {
    anaTaskCDFfull = CDF::AddTaskEmcalJetCDF ( name_tracks.Data(), name_clusters.Data(), name_cells.Data(), mc_container.Data(), "CDFfull" );
    anaTaskCDFfull->SetHistoBins(600, 0, 300);
    anaTaskCDFfull->SelectCollisionCandidates(kSel_full);
    anaTaskCDFfull->SetDebugLevel(debug);

    AliParticleContainer* anaTaskCDFfull_partCont = anaTaskCDFfull->GetParticleContainer(0);
    anaTaskCDFfull_partCont->SetParticlePtCut(0.15);

    AliClusterContainer* anaTaskCDFfull_clusCont = anaTaskCDFfull->GetClusterContainer(0);
    anaTaskCDFfull_clusCont->SetClusECut(0.);
    anaTaskCDFfull_clusCont->SetClusPtCut(0.);
    anaTaskCDFfull_clusCont->SetClusNonLinCorrEnergyCut(0.);
    anaTaskCDFfull_clusCont->SetClusHadCorrEnergyCut(0.30);
    anaTaskCDFfull_clusCont->SetDefaultClusterEnergy(AliVCluster::kHadCorr);

    if (bDoEmbedding) {
      anaTaskCDFfull_partCont->SetIsEmbedding(kTRUE);
      anaTaskCDFfull_clusCont->SetIsEmbedding(kTRUE);
      }

    if ( pMultSelTask ) {
      anaTaskCDFfull->SetUseNewCentralityEstimation(bIsRun2);
      anaTaskCDFfull->SetNCentBins(5);
      anaTaskCDFfull->SetCentralityEstimator(cent_est_full.Data());
      }
    }

//########################
//   ANALYSIS TASKS - CONTAINERS SETUP
//########################

//   AliEmcalJetTask* pChJet02Task_MC = NULL;
//   AliEmcalJetTask* pChJet04Task_MC = NULL;

// add jet containers to CDF task for charged jets
  if (bDoChargedJets && bDoCDF) {
    AliJetContainer* jetcont_chg = NULL;
    for ( Float_t fi = 0 ; fi<=100 ; fi+=10) {
      // CHG JETS 0.2
      jetcont_chg  = anaTaskCDFchg->AddJetContainer(chgjet, antikt, recomb, 0.2, acc_chgjets, "Jet");
      CDF::jetContSetParams (jetcont_chg,    fi,   fi+10, 0, 0);

      // CHG JETS 0.4
      jetcont_chg  = anaTaskCDFchg->AddJetContainer(chgjet, antikt, recomb, 0.4, acc_chgjets, "Jet");
      CDF::jetContSetParams (jetcont_chg,    fi,   fi+10, 0, 0);

      if (isMC) {
        // CHG JETS MC 0.2
        jetcont_chg = AddJetContainerJetTask(dynamic_cast<AliAnalysisTaskEmcalJetCDF*>(anaTaskCDFchg_MC), pChJet02Task_MC, acc_chgjets);
        CDF::jetContSetParams (jetcont_chg,    fi,   fi+10, 0, 0);

        // CHG JETS MC 0.4
        jetcont_chg = AddJetContainerJetTask(dynamic_cast<AliAnalysisTaskEmcalJetCDF*>(anaTaskCDFchg_MC), pChJet04Task_MC, acc_chgjets);
        CDF::jetContSetParams (jetcont_chg,    fi,   fi+10, 0, 0);
        }
      }

    jetcont_chg   = anaTaskCDFchg->AddJetContainer(chgjet, antikt, recomb, 0.2, acc_chgjets, "Jet");
    CDF::jetContSetParams (jetcont_chg,     1., 500., 0, 0);
    jetcont_chg   = anaTaskCDFchg->AddJetContainer(chgjet, antikt, recomb, 0.4, acc_chgjets, "Jet");
    CDF::jetContSetParams (jetcont_chg,     1., 500., 0, 0);

    if (isMC) {
      jetcont_chg = AddJetContainerJetTask(dynamic_cast<AliAnalysisTaskEmcalJetCDF*>(anaTaskCDFchg_MC), pChJet02Task_MC, acc_chgjets);
      CDF::jetContSetParams (jetcont_chg,     1., 500., 0, 0);

      jetcont_chg = AddJetContainerJetTask(dynamic_cast<AliAnalysisTaskEmcalJetCDF*>(anaTaskCDFchg_MC), pChJet04Task_MC, acc_chgjets);
      CDF::jetContSetParams (jetcont_chg,     1., 500., 0, 0);
      }

    jetcont_chg = NULL;
    }

  // add jet containers to CDF task for full jets
  if (bDoFullJets && bDoCDF) {
    AliJetContainer* jetcont_full = NULL;
    for ( Float_t fi = 0 ; fi<=100 ; fi+=10) {
      // FULL JETS 0.2
      jetcont_full  = anaTaskCDFfull->AddJetContainer(fulljet, antikt, recomb, 0.2, acc_fulljets, "Jet");
      CDF::jetContSetParams (jetcont_full,    fi,   fi+10, 0, 2);

      // FULL JETS 0.4
      jetcont_full  = anaTaskCDFfull->AddJetContainer(fulljet, antikt, recomb, 0.4, acc_fulljets, "Jet");
      CDF::jetContSetParams (jetcont_full,    fi,   fi+10, 0, 2);

      if (isMC) {
        // CHG JETS MC 0.2
        jetcont_full = AddJetContainerJetTask(dynamic_cast<AliAnalysisTaskEmcalJetCDF*>(anaTaskCDFfull_MC), pFuJet02Task_MC, acc_fulljets);
        CDF::jetContSetParams (jetcont_full,    fi,   fi+10, 0, 0);

        // CHG JETS MC 0.4
        jetcont_full = AddJetContainerJetTask(dynamic_cast<AliAnalysisTaskEmcalJetCDF*>(anaTaskCDFfull_MC), pFuJet04Task_MC, acc_fulljets);
        CDF::jetContSetParams (jetcont_full,    fi,   fi+10, 0, 0);
        }
      }

    jetcont_full   = anaTaskCDFfull->AddJetContainer(fulljet, antikt, recomb, 0.2, acc_fulljets, "Jet");
    CDF::jetContSetParams (jetcont_full,     1., 500., 0, 2);

    jetcont_full   = anaTaskCDFfull->AddJetContainer(fulljet, antikt, recomb, 0.4, acc_fulljets, "Jet");
    CDF::jetContSetParams (jetcont_full,     1., 500., 0, 2);

    if (isMC) {
      jetcont_full = AddJetContainerJetTask(dynamic_cast<AliAnalysisTaskEmcalJetCDF*>(anaTaskCDFfull_MC), pFuJet02Task_MC, acc_fulljets);
      CDF::jetContSetParams (jetcont_full,     1., 500., 0, 0);

      jetcont_full = AddJetContainerJetTask(dynamic_cast<AliAnalysisTaskEmcalJetCDF*>(anaTaskCDFfull_MC), pFuJet04Task_MC, acc_fulljets);
      CDF::jetContSetParams (jetcont_full,     1., 500., 0, 0);
      }
    jetcont_full = NULL;
    }

  // add jet containers to sample task for charged jets
  if (bDoChargedJets && bDoSample) {
    AliJetContainer* jetCont02chg_sample = sampleTaskchg->AddJetContainer(chgjet, antikt, recomb, 0.2, acc_chgjets, "Jet");
    AliJetContainer* jetCont04chg_sample = sampleTaskchg->AddJetContainer(chgjet, antikt, recomb, 0.4, acc_chgjets, "Jet");

    if (iBeamType != AliAnalysisTaskEmcal::kpp) {
      jetCont02chg_sample->SetRhoName(sRhoChName);
      jetCont02chg_sample->SetPercAreaCut(0.6);

      jetCont04chg_sample->SetRhoName(sRhoChName);
      jetCont04chg_sample->SetPercAreaCut(0.6);
      }
    }

  // add jet containers to sample task for full jets
  if (bDoFullJets && bDoSample) {
    AliJetContainer* jetCont02full_sample = sampleTaskfull->AddJetContainer(fulljet, antikt, recomb, 0.2, acc_fulljets, "Jet");
    AliJetContainer* jetCont04full_sample = sampleTaskfull->AddJetContainer(fulljet, antikt, recomb, 0.4, acc_fulljets, "Jet");

    if (iBeamType != AliAnalysisTaskEmcal::kpp) {
      jetCont02full_sample->SetRhoName(sRhoFuName);
      jetCont02full_sample->SetPercAreaCut(0.6);

      jetCont04full_sample->SetRhoName(sRhoFuName);
      jetCont04full_sample->SetPercAreaCut(0.6);
      }
    }


  TObjArray* tasks_list = pMgr->GetTasks(); TIter task_iter (tasks_list); AliAnalysisTaskSE* task = NULL;
  while (( task = dynamic_cast<AliAnalysisTaskSE*>(task_iter.Next()) )) {
    if (task->InheritsFrom("AliAnalysisTaskEmcal")) {
      Printf("Setting beam type %d for task %s", iBeamType, static_cast<AliAnalysisTaskEmcal*>(task)->GetName());
      static_cast<AliAnalysisTaskEmcal*>(task)->SetForceBeamType(iBeamType);
      }
    }

  //   Let's start #########################################################################################################
  if ( !pMgr->InitAnalysis() ) { std::cout << ">>>>>>>>>>>>>> AliAnalysisManager Initialising FAILED!!! " << std::endl; return NULL; }
  std::cout << "##-->> Initialising Analysis :: Status :" << std::endl;
  pMgr->PrintStatus();
  pMgr->SetUseProgressBar(bUseProgBar, 100);

  // task profiling
  if ( kUseSysInfo > 0 ) {
    for ( int i = 0; i < pMgr->GetTopTasks()->GetEntries(); i++ ) { pMgr->ProfileTask (i); }
    }

  CDF::SaveManager("train.root");

  if ( ManagerMode == AnalysisType::local ) { // start local analysis
    // enable class level debugging for these classes
    if ( debug > 2 ) {
    //   pMgr->AddClassDebug("AliJetContainer", 100);
    //   pMgr->AddClassDebug("AliEmcalJetTask", 100);
      if (bDoCDF)    { pMgr->AddClassDebug("AliAnalysisTaskEmcalJetCDF", 100); }
      if (bDoSample) { pMgr->AddClassDebug("AliAnalysisTaskEmcalJetSample", 100); }
      }

    TChain* pChain = CDF::CreateChain(kDataSource.Data(), "auto", "", iNumFiles);
    if (!pChain) { std::cout << ">>>>>>>>>>>>>>   CHAIN NOT CREATED   <<<<<<<<<<<<<<" << std::endl; return NULL; }

    // start analysis
    Printf("Starting LOCAL Analysis...");
    pMgr->StartAnalysis( cAnalysisType, pChain, iNumEvents );
    }

  if ( ManagerMode == AnalysisType::grid ) {  // start grid analysis
    // start analysis
    Printf("Starting GRID Analysis...");

    ListLibs += kGridExtraFiles;
    if ( ListLibs.Length() )       { plugin->SetAdditionalLibs     ( ListLibs.Data() ); }
    if ( ListLibsExtra.Length() )  { plugin->SetAdditionalRootLibs ( ListLibsExtra.Data() ); }

    if ( PluginMode == PluginType::test )
      { plugin->StartAnalysis(iNumEvents); }
    else {
      pMgr->SetDebugLevel(0);
      plugin->StartAnalysis();
      }
    }

cout << "END of EmcalJetCDF.C" << std::endl;
return pMgr;
}
Example #20
0
int Perform::Init()
{
  TH1::SetDefaultSumw2();   
  coll = "";
  TString temp = OutputFileName;
  temp.ToLower();
  if(temp.Contains("pp") && (temp.Contains("minbias") || temp.Contains("mb"))) coll = "ppminbias";
  else if(temp.Contains("pal") && (temp.Contains("minbias") || temp.Contains("mb"))) coll = "pAlminbias";
  else if(temp.Contains("pau") && (temp.Contains("minbias") || temp.Contains("mb"))) coll = "pAuminbias";
  else if(temp.Contains("pp") && temp.Contains("fvtxand")) coll = "ppfvtxand";
  else if(temp.Contains("pal") && temp.Contains("fvtxand")) coll = "pAlfvtxand";
  else if(temp.Contains("pp") && temp.Contains("fvtxor")) coll = "ppfvtxor";
  else if(temp.Contains("pal") && temp.Contains("fvtxor")) coll = "pAlfvtxor";
  else return 0;

//  OutputFileName.Insert(OutputFileName.Length()-5,coll);

  d_outfile = new TFile(OutputFileName,"recreate");
  d_infile = TFile::Open(InputFileName,"ReadOnly");
  if(!d_infile) return 0;
  tree = (TTree*)d_infile->Get("tree");
  if(!tree) return 0;
  
  tree -> SetBranchAddress("run", &run);
  tree -> SetBranchAddress("trig", &trig);
  tree -> SetBranchAddress("npc1hits", &npc1hits);
  tree -> SetBranchAddress("bbc_s", &bbc_s);
  tree -> SetBranchAddress("bbc_n", &bbc_n);
  tree -> SetBranchAddress("bbcv", &bbcv);
  if(coll.Contains("pp") || coll.Contains("pau"))
  tree -> SetBranchAddress("vtxz", &vtxz);
//  tree -> SetBranchAddress("fvtxz", &fvtxz);
  tree -> SetBranchAddress("ntrack", &ntrack);
  tree -> SetBranchAddress("nbbc", &nbbc);
  if(coll.Contains("pp") || coll.Contains("pau")){
  tree -> SetBranchAddress("nvtx", &nvtx);
  tree -> SetBranchAddress("nvtxtrack", &nvtxtrack);
  }
//  tree -> SetBranchAddress("nmpc", &nmpc);
//  tree -> SetBranchAddress("nfvtxtrack", &nfvtxtrack);

  tree -> SetBranchAddress("mom", &mom);
  tree -> SetBranchAddress("phi0", &phi0);
  tree -> SetBranchAddress("the0", &the0);
  tree -> SetBranchAddress("charge", &charge);
  tree -> SetBranchAddress("arm", &arm);
  tree -> SetBranchAddress("pc3dphi", &pc3dphi);
  tree -> SetBranchAddress("pc3dz", &pc3dz);
  tree -> SetBranchAddress("slat", &slat);
  tree -> SetBranchAddress("tofdphi", &tofdphi);
  tree -> SetBranchAddress("tofdz", &tofdz);
  tree -> SetBranchAddress("tofpl", &tofpl);
  tree -> SetBranchAddress("qtof", &qtof);
  tree -> SetBranchAddress("ttof", &ttof);

  tree -> SetBranchAddress("bbccharge", &bbccharge);
  tree -> SetBranchAddress("bbcx", &bbcx);
  tree -> SetBranchAddress("bbcy", &bbcy);
  tree -> SetBranchAddress("bbcz", &bbcz);

  if(coll.Contains("pp") || coll.Contains("pau")){
  tree -> SetBranchAddress("layer", &layer);
  tree -> SetBranchAddress("vtxX", &vtxX);
  tree -> SetBranchAddress("vtxY", &vtxY);
  tree -> SetBranchAddress("vtxZ", &vtxZ);

  tree -> SetBranchAddress("vtxnhits", &vtxnhits);
  tree -> SetBranchAddress("vtxpx", &vtxpx);
  tree -> SetBranchAddress("vtxpy", &vtxpy);
  tree -> SetBranchAddress("vtxpz", &vtxpz);
  }
 /*
  tree -> SetBranchAddress("mpc_e", &mpc_e);
  tree -> SetBranchAddress("mpc_x", &mpc_x);
  tree -> SetBranchAddress("mpc_y", &mpc_y);
  tree -> SetBranchAddress("mpc_z", &mpc_z);
*/
  /*
  tree -> SetBranchAddress("farm", &farm);
  tree -> SetBranchAddress("fnhits", &fnhits);
  tree -> SetBranchAddress("fthe", &fthe);
  tree -> SetBranchAddress("feta", &feta);
  tree -> SetBranchAddress("fphi", &fphi);
  tree -> SetBranchAddress("fvtxX", &fvtxX);
  tree -> SetBranchAddress("fvtxY", &fvtxY);
  tree -> SetBranchAddress("fvtxZ", &fvtxZ);
*/
char name[512];
float pi = acos(-1);

//Tracks
sprintf(name,"hcntetaphi"); hcntetaphi = new TH2F(name,name,200,-1,1,200,-2*pi,2*pi);
sprintf(name,"hcntpt"); hcntpt = new TH1F(name,name,2000,0,10);
for(int i=0;i<50;i++){
sprintf(name,"pc3dphidz_arm0_pos_%d",i),pc3dphidz_arm0_pos[i] = new TH2F(name,name,200,-0.1,0.1,100,-10,10);
sprintf(name,"pc3dphidz_arm1_pos_%d",i),pc3dphidz_arm1_pos[i] = new TH2F(name,name,200,-0.1,0.1,100,-10,10);
sprintf(name,"pc3dphidz_arm0_neg_%d",i),pc3dphidz_arm0_neg[i] = new TH2F(name,name,200,-0.1,0.1,100,-10,10);
sprintf(name,"pc3dphidz_arm1_neg_%d",i),pc3dphidz_arm1_neg[i] = new TH2F(name,name,200,-0.1,0.1,100,-10,10);
}

//tof
for(int ich=0;ich<2;ich++){
sprintf(name,"tofdphidz_%d",ich);  tofdphidz[ich] = new TH2F(name,name,200,-0.2,0.2,200,-10,10);
sprintf(name,"tofwdphidz_%d",ich);  tofwdphidz[ich] = new TH2F(name,name,200,-0.2,0.2,200,-10,10);
}
sprintf(name,"ttofqpratio");  ttofqpratio = new TH2F(name,name,500,0,100,500,-8,8);
sprintf(name,"m2qpratio");  m2qpratio = new TH2F(name,name,500,0,2,500,-8,8);
sprintf(name,"ttofp");  ttofp = new TH2F(name,name,500,0,100,500,0,10);
sprintf(name,"pinv2chbeta"); pinv2chbeta = new TH2F(name,name,500,0,10,500,-0.8,0.8);
sprintf(name,"m2p");  m2p = new TH2F(name,name,500,0,2,500,0,10);
sprintf(name,"deltattofeis"); deltattofeis = new TH2F(name,name,960,0,960,1600,-20,60);
sprintf(name,"deltattofwis"); deltattofwis = new TH2F(name,name,512,0,512,1600,-20,60);

//vtx
for(int i=0;i<4;i++){
sprintf(name,"hcluetaphi_%d",i); hcluetaphi[i] = new TH2F(name,name,300,-3.0,3.0,100,-4,4);
}

//bbc
sprintf(name,"bbcet"); bbcet = new TH1F(name,name,500,0,20);

//fvtx
  for(int iarm=0; iarm<2; iarm++){
    sprintf(name,"DCAxydis_%d",iarm); DCAxydis[iarm] = new TH2D(name,name, 100, -2, 2, 100, -2, 2);
    sprintf(name,"DCAxy2dis_%d",iarm); DCAxy2dis[iarm] = new TH2D(name,name, 100, -2, 2, 100, -2, 2);
    sprintf(name,"DCAcentdis_%d",iarm); DCAcentdis[iarm] = new TH2D(name,name, 10, 0, 10, 100, 0, 10);
  }
 // sprintf(name,"fvtxdphidis"); fvtxdphidis = new TH1F(name, name, 100, -10.0, 10.0);
 // sprintf(name,"fvtxdphidis2"); fvtxdphidis2 = new TH1F(name, name, 100, -10.0, 10.0);
  sprintf(name,"hvtx0etaz"); hvtx0etaz = new TH2D(name,name,240, -12, 12, 600, -3.0, 3.0);
  sprintf(name,"hvtx1etaz"); hvtx1etaz = new TH2D(name,name,240, -12, 12, 600, -3.0, 3.0);
  sprintf(name,"hvtx0etaphi"); hvtx0etaphi = new TH2D(name,name, 240, -3.14*1.1, 3.14*1.1, 600, -3.0, 3.0);
  sprintf(name,"hvtx1etaphi"); hvtx1etaphi = new TH2D(name,name, 240, -3.14*1.1, 3.14*1.1, 600, -3.0, 3.0);

//mpc
  sprintf(name,"mpc_south_cent"); mpc_south_cent = new TH2F(name, name, 100, -0.5, 99.5, 250, -0.5, 249.5);
  sprintf(name,"mpc_north_cent"); mpc_north_cent = new TH2F(name, name, 100, -0.5, 99.5, 250, -0.5, 249.5);
  sprintf(name,"mpc_south_north"); mpc_south_north = new TH2F(name, name, 600, -0.5, 599.5, 600, -0.5, 599.5);
  sprintf(name,"south_mpc_north_mpc");  south_mpc_north_mpc = new TH2F(name, name, 600, -0.5, 19.5, 600, -0.5, 19.5);
for (int i=0; i<centbin; i++) {
 sprintf(name,"mpcetetasouth_%d", i);    mpcetetasouth[i] = new TH2F(name,name,30, 3.0, 4.0, 60,0.0,6.0);
 sprintf(name,"mpcetetanorth_%d", i);    mpcetetanorth[i] = new TH2F(name,name,30, 3.0, 4.0, 60,0.0,6.0);
}

//correlate
  sprintf(name,"hnpc3hitsntof"); hnpc3hitsntof = new TH2F(name,name,200,0,200,100,0,100);
  sprintf(name,"hbbcnbbc"); hbbcnbbc = new TH2F(name,name,1800,0,600,1800,0,600);
  sprintf(name,"hpc1hitsbbc"); hpc1hitsbbc = new TH2F(name, name, 100, 0, 100, 1800, 0, 600);
  sprintf(name,"hvtxzfvtxz"); hvtxzfvtxz = new TH2F(name,name,100,-25.,25.,100,-25.,25.);
  for(int i=0;i<4;i++){
	sprintf(name,"hbbcsnvtx_%d",i);  hbbcsnvtx[i] = new TH2F(name,name,1800,0,600,500,0,500);
	sprintf(name,"hbbcnnvtx_%d",i);  hbbcnnvtx[i] = new TH2F(name,name,1800,0,600,500,0,500);
	sprintf(name,"hbbcnvtx_%d",i);  hbbcnvtx[i] = new TH2F(name,name,1800,0,600,500,0,500);
        sprintf(name,"hnvtxnmpc_%d",i); hnvtxnmpc[i] = new TH2F(name,name,500,0,500,500,0,500);
        sprintf(name,"hnvtxntrk_%d",i); hnvtxntrk[i] = new TH2F(name,name,500,0,500,500,0,500);
  	sprintf(name,"hnvtxnfvtxtrk_%d",i); hnvtxnfvtxtrk[i] = new TH2F(name,name,500,0,500,500,0,500);
  }
  sprintf(name,"hnbbcnclu"); hnbbcnclu = new TH2F(name,name,600,0,600,500,0,500);
  sprintf(name,"hbbcsbbcn"); hbbcsbbcn = new TH2F(name,name,1800,0,600,1800,0,600);
  sprintf(name,"hntracknmpc"); hntracknmpc = new TH2F(name,name,100,0,100,500,0,500);
  sprintf(name,"hnfvtxtrkbbc"); hnfvtxtrkbbc = new TH2F(name,name,500,0,500,1800,0,600);
  sprintf(name,"hnfvtxtrksnmpcs"); hnfvtxtrksnmpcs = new TH2F(name,name,200,0,200,500,0,500);
  sprintf(name,"hnfvtxtrksnmpcn"); hnfvtxtrknnmpcn = new TH2F(name,name,200,0,200,500,0,500);
  sprintf(name,"south_mpc_south_bbc");  south_mpc_south_bbc = new TH2F(name, name, 600, -0.5, 19.5, 600, -0.5, 199.5);
  sprintf(name,"north_mpc_north_bbc");  north_mpc_north_bbc = new TH2F(name, name, 600, -0.5, 19.5, 600, -0.5, 199.5);

  return 0;
}
Example #21
0
void rdphi::ParseOptions(TString p_option)
{

  do_50_50 = false;
  left_50 = false;
  do_mc = false;
  do_muon = false;
  ident = "ident_test";
  input_path = "./";
  output_path = "../output";
  lepton_mass = Ok_el_mass;


  try
  {
    TObjArray *s = p_option.Tokenize(",; \n\015\012");
    cout << endl << "Okla_ParseOptions: input=" << endl 
      << p_option << endl;

    for( int i = 0 ; i < s->GetEntriesFast() ; i++)
    {
      TString c = ((TObjString *)(*s)[i])->GetString();
      c.ToLower();
      cout << endl << "Okla_ParseOptions: directive \"" << c << "\": " << endl;

      TObjArray *t = c.Tokenize("=:");

      if ( 
        (s->GetEntriesFast() == 1 ) &&
        ( t->GetEntriesFast() == 1 ) ) throw "Error processing parameters";

      if ( t->GetEntriesFast() != 2 ) throw("invalid var=val or var:val (no space or \",\" allowed around\"=\" or \":\")");
      TString var = ((TObjString *)(*t)[0])->GetString();
      TString val = ((TObjString *)(*t)[1])->GetString();


      if( var == "identifier" ){
        ident = val;
      }
      else if( var == "input_path" ){
        input_path = val;
      }
      else if( var == "output_path" ){
        output_path = val;
      }
      else if( var == "do_50_50" ){
        do_50_50 = string_true_false(val);
      }
      else if( var == "left_50" ){
        left_50 = string_true_false(val);
      }
      else if( var == "do_mc" ){
        do_mc = string_true_false(val);
      }
      
      else if( var == "do_muon" ){
        do_muon = string_true_false(val);
        if ( do_muon ) lepton_mass = Ok_mu_mass;
      }
      
      else{
        cout << endl << "throwing exception c:" << c << "   var: "<< var << "  val: " << val << endl; 
        throw( (const char *)(TString(" unknown var ") + var) );
      }
    }
  }
  catch(char * e)
  {
    cout << endl << "OklaParseOptions: Error: " << e << endl;
    exit(0);
  }
  catch(...)
  {
    cout << endl << "OklaParseOptions: Error: invalid parameter: " << endl;
    cout << p_option << endl;
    exit(0);
  }
}
Example #22
0
TH2F* Smooth(TH2F* thish, Int_t ntimes, Option_t *option, Int_t offset) {

   // Smooth bin contents of this 2-d histogram using kernel algorithms
   // similar to the ones used in the raster graphics community.
   // Bin contents in the active range are replaced by their smooth values.
   // If Errors are defined via Sumw2, they are scaled.
   // 3 kernels are proposed k5a, k5b and k3a.
   // k5a and k5b act on 5x5 cells (i-2,i-1,i,i+1,i+2, and same for j)
   // k5b is a bit more stronger in smoothing
   // k3a acts only on 3x3 cells (i-1,i,i+1, and same for j).
   // By default the kernel "k5a" is used. You can select the kernels "k5b" or "k3a"
   // via the option argument.
   // If TAxis::SetRange has been called on the x or/and y axis, only the bins
   // in the specified range are smoothed.
   // In the current implementation if the first argument is not used (default value=1).
   //
   // implementation by David McKee ([email protected]). Extended by Rene Brun

   Double_t k5a[5][5] =  { { 0, 0, 1, 0, 0 },
                           { 0, 2, 2, 2, 0 },
                           { 1, 2, 5, 2, 1 },
                           { 0, 2, 2, 2, 0 },
                           { 0, 0, 1, 0, 0 } };
   Double_t k5b[5][5] =  { { 0, 1, 2, 1, 0 },
                           { 1, 2, 4, 2, 1 },
                           { 2, 4, 8, 4, 2 },
                           { 1, 2, 4, 2, 1 },
                           { 0, 1, 2, 1, 0 } };
   Double_t k3a[3][3] =  { { 0, 1, 0 },
                           { 1, 2, 1 },
                           { 0, 1, 0 } };

   if (ntimes > 1) {
      Warning("Smooth","Currently only ntimes=1 is supported");
   }
   TString opt = option;
   opt.ToLower();
   Int_t ksize_x=5;
   Int_t ksize_y=5;
   Double_t *kernel = &k5a[0][0];
   if (opt.Contains("k5b")) kernel = &k5b[0][0];
   if (opt.Contains("k3a")) {
      kernel = &k3a[0][0];
      ksize_x=3;
      ksize_y=3;
   }

   TH2F* hworking = (TH2F*)thish->Clone();

   // find i,j ranges
   Int_t ifirst = thish->GetXaxis()->GetFirst();
   Int_t ilast  = thish->GetXaxis()->GetLast();
   Int_t jfirst = thish->GetYaxis()->GetFirst();
   Int_t jlast  = thish->GetYaxis()->GetLast();

   // Determine the size of the bin buffer(s) needed
   Int_t nx = thish->GetNbinsX();
   Int_t ny = thish->GetNbinsY();
  cout << nx << " " << ny << endl; 
   Int_t bufSize  = (nx+2)*(ny+2);
   Double_t *buf  = new Double_t[bufSize];
   Double_t *ebuf = new Double_t[bufSize];

   // Copy all the data to the temporary buffers
   Int_t i,j,bin;
   for (i=ifirst; i<=ilast; i++){
      for (j=jfirst; j<=jlast; j++){
         Int_t bin = thish->GetBin(i,j);
         buf[bin] =thish->GetBinContent(bin);
         ebuf[bin]=thish->GetBinError(bin);
      }
   }

   // Kernel tail sizes (kernel sizes must be odd for this to work!)
   Int_t x_push = (ksize_x-1)/2;
   Int_t y_push = (ksize_y-1)/2;

   // main work loop
   for (int i=ifirst; i<=ilast; i++){
      for (int j=jfirst; j<=jlast; j++) {
         if (i-j<offset) continue;

         Double_t content = 0.0;
         Double_t error = 0.0;
         Double_t norm = 0.0;

         for (Int_t n=0; n<ksize_x; n++) {
            for (Int_t m=0; m<ksize_y; m++) {
               Int_t xb = i+(n-x_push);
               Int_t yb = j+(m-y_push);
               if ( (xb >= 1) && (xb <= nx) && (yb >= 1) && (yb <= ny) ) {
                  Int_t bin = thish->GetBin(xb,yb);
                  Double_t k = kernel[n*ksize_y +m];
                  //if ( (k != 0.0 ) && (buf[bin] != 0.0) ) { // General version probably does not want the second condition
                  if ( k != 0.0 ) {
                     norm    += k;
                     content += k*buf[bin];
                     error   += k*k*buf[bin]*buf[bin];
                  }
               }
            }
         }

         if ( norm != 0.0 ) {
            hworking->SetBinContent(i,j,content/norm);
            error /= (norm*norm);
            hworking->SetBinError(i,j,sqrt(error));
         }
      }
   }

   delete [] buf;
   delete [] ebuf;
   return hworking;
}
Example #23
0
Bool_t RunALICE(TString anSrc = "grid",
                TString anMode = "terminate",
                TString input="aod" /*or "esd"*/,
                TString inputMC="" /*or "mc"*/,
                Long64_t nEvents = 1e10,
                Long64_t nSkip = 0,
                TString dsName="",
                TString alirsnliteManagers ="AddAMRsn",
                Bool_t useMultiHandler=kTRUE,
                TString alirsnlitesrc ="$ALICE_ROOT",
                TString alirsnlitetasks =""
               ) {

   // some init work
   anSrc.ToLower(); anMode.ToLower(); input.ToLower(); inputMC.ToLower();

   // loads libs and setup include paths
   if (LoadLibsBase(alirsnlitesrc)) return kFALSE;

   // reset manager if already exists
   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
   if (mgr) delete mgr;
   mgr = new AliAnalysisManager("AliRsnLiteAM","AliRsnLite Analysis Manager");

   Bool_t useAODOut = kFALSE;
   CreateInputHandlers(input,inputMC,useAODOut,useMultiHandler);

   // add default grid handler
   gROOT->LoadMacro("SetupAnalysisPlugin.C");
   AliAnalysisGrid *analysisPlugin = SetupAnalysisPlugin(anMode.Data());
   if (!analysisPlugin) { Printf("Error : analysisPlugin is null !!!"); return kFALSE; }
   mgr->SetGridHandler(analysisPlugin);
   if (!dsName.IsNull()) {
      if (!anSrc.CompareTo("proof") && !anMode.CompareTo("full")) {
         analysisPlugin->SetProofDataSet(dsName.Data());
         Printf(Form("Using DataSet %s ...",dsName.Data()));
      } else {
         analysisPlugin->SetFileForTestMode(dsName.Data());
         Printf(Form("Using Test file %s ...",dsName.Data()));
      }
   }

   TList *listManagers = CreateListOfManagersFromDir(alirsnliteManagers,alirsnlitetasks);
   if (!listManagers) { Printf("Error : CreateListOfManagersFromDir failed !!!"); return kFALSE;}

   // adds all tasks
   if (!AddAllManagers(listManagers, anSrc, anMode,input,inputMC)) { Printf("Error : AddAllManagers failed !!!"); return kFALSE;}

   gSystem->ListLibraries("ls");

   TStopwatch timer;
   timer.Start();
   // runs analysis
   if (!RunAnalysisManager(anSrc, anMode.Data(), nEvents, nSkip)) { Printf("Error : RunAnalysisManager failed !!!"); return kFALSE;}

   timer.Stop();
   timer.Print();
   Printf("Working directory is %s ...", gSystem->WorkingDirectory());
   Printf("Done OK");
   return kTRUE;

}
void TDSPMultiEcho::SetOption(Option_t *o) {

  TString opt = o;
  opt.ToLower();

  Ssiz_t pos;

  UInt_t mg=0;
  UInt_t mo=0;
                        
  if ((pos = opt.Index("randomphases=yes"))!=kNPOS) {
    opt.Remove(pos,16);
    fRandomPhases=kTRUE;
  }
  if ((pos = opt.Index("randomphases=no"))!=kNPOS) {
    opt.Remove(pos,15);
    fRandomPhases=kFALSE;
  }

  if ((pos = opt.Index("std"))!= kNPOS) {
    opt.Remove(pos,3);
    mg = MODELGROUP_STD;
  }

  if ((pos = opt.Index("id"))!=kNPOS) {
    opt.Remove(pos,2);
    mo      = STD_ID;
    fRandomPhases=kFALSE;
    SetTitle("STD - Identity");
  }
 
  if ((pos = opt.Index("cost207"))!= kNPOS) {
    opt.Remove(pos,7);
    mg = MODELGROUP_COST207;
  }

  if ((pos = opt.Index("tu"))!=kNPOS) {
    opt.Remove(pos,2);
    mo      = COST207_TU;
    SetTitle("COST207 - Typical Urban  (non-hilly urban environment)");
  }
  if ((pos = opt.Index("ra"))!=kNPOS) {
    opt.Remove(pos,2);
    mo      = COST207_RA;
    SetTitle("COST207 - Rural Area     (non-hilly rural environment)");
  }
  if ((pos = opt.Index("bu"))!=kNPOS) {
    opt.Remove(pos,2);
    mo      = COST207_BU;
    SetTitle("COST207 - Bad Urban      (hilly urban environment)");
  }
  if ((pos = opt.Index("ht"))!=kNPOS) {
    opt.Remove(pos,2);
    mo      = COST207_HT;
    SetTitle("COST207 - Hilly Terrain  (hilly rural environment)");
  }
  
  if ((mg)&&(mo)) SetModel(mg,mo);

  if (opt.Strip().Length())
    Error("SetOption","Unknown Option(s) \"%s\" !!",opt.Strip().Data());
  
}
Example #25
0
// input: - Input file (result from TMVA),
//        - normal/decorrelated/PCA
//        - use of TMVA plotting TStyle
void variables( TString fin = "TMVA.root", TString dirName = "InputVariables_Id", TString title = "TMVA Input Variables",
                Bool_t isRegression = kFALSE, Bool_t useTMVAStyle = kTRUE )
{
   TString outfname = dirName;
   outfname.ToLower(); outfname.ReplaceAll( "input", ""  );

   // set style and remove existing canvas'
   TMVAGlob::Initialize( useTMVAStyle );

   // obtain shorter histogram title 
   TString htitle = title; 
   htitle.ReplaceAll("variables ","variable");
   htitle.ReplaceAll("and target(s)","");
   htitle.ReplaceAll("(training sample)","");

   // checks if file with name "fin" is already open, and if not opens one
   TFile* file = TMVAGlob::OpenFile( fin );

   TDirectory* dir = (TDirectory*)file->Get( dirName );
   if (dir==0) {
      cout << "No information about " << title << " available in directory " << dirName << " of file " << fin << endl;
      return;
   }
   dir->cd();

   // how many plots are in the directory?
   Int_t noPlots = TMVAGlob::GetNumberOfInputVariables( dir ) +
      TMVAGlob::GetNumberOfTargets( dir );

   // define Canvas layout here!
   // default setting
   Int_t xPad;  // no of plots in x
   Int_t yPad;  // no of plots in y
   Int_t width; // size of canvas
   Int_t height;
   switch (noPlots) {
   case 1:
      xPad = 1; yPad = 1; width = 550; height = 0.90*width; break;
   case 2:
      xPad = 2; yPad = 1; width = 600; height = 0.50*width; break;
   case 3:
      xPad = 3; yPad = 1; width = 900; height = 0.4*width; break;
   case 4:
      xPad = 2; yPad = 2; width = 600; height = width; break;
   default:
//       xPad = 3; yPad = 2; width = 800; height = 0.55*width; break;
     xPad = 1; yPad = 1; width = 550; height = 0.90*width; break;
   }

   Int_t noPadPerCanv = xPad * yPad ;

   // counter variables
   Int_t countCanvas = 0;
   Int_t countPad    = 0;

   // loop over all objects in directory
   TCanvas* canv = 0;
   TKey*    key  = 0;
   Bool_t   createNewFig = kFALSE;
   TIter next(dir->GetListOfKeys());
   while ((key = (TKey*)next())) {
      if (key->GetCycle() != 1) continue;

      if (!TString(key->GetName()).Contains("__Signal") && 
          !(isRegression && TString(key->GetName()).Contains("__Regression"))) continue;

      // make sure, that we only look at histograms
      TClass *cl = gROOT->GetClass(key->GetClassName());
      if (!cl->InheritsFrom("TH1")) continue;
      TH1 *sig = (TH1*)key->ReadObj();
      TString hname(sig->GetName());

      //normalize to 1
      NormalizeHist(sig);      

      // create new canvas
      if (countPad%noPadPerCanv==0) {
         ++countCanvas;
         canv = new TCanvas( Form("canvas%d", countCanvas), title,
                             countCanvas*50+50, countCanvas*20, width, height );
         canv->Divide(xPad,yPad);
         canv->SetFillColor(kWhite);
         canv->Draw();
      }

      TPad* cPad = (TPad*)canv->cd(countPad++%noPadPerCanv+1);
      cPad->SetFillColor(kWhite);

      // find the corredponding backgrouns histo
      TString bgname = hname;
      bgname.ReplaceAll("__Signal","__Background");
      TH1 *bgd = (TH1*)dir->Get(bgname);
      if (bgd == NULL) {
         cout << "ERROR!!! couldn't find background histo for" << hname << endl;
         exit;
      }
      //normalize to 1
      NormalizeHist(bgd);


      // this is set but not stored during plot creation in MVA_Factory
      TMVAGlob::SetSignalAndBackgroundStyle( sig, (isRegression ? 0 : bgd) );            

      sig->SetTitle( TString( htitle ) + ": " + sig->GetTitle() );
      TMVAGlob::SetFrameStyle( sig, 1.2 );

      // normalise both signal and background
//       if (!isRegression) TMVAGlob::NormalizeHists( sig, bgd );
//       else {
//          // change histogram title for target
//          TString nme = sig->GetName();
//          if (nme.Contains( "_target" )) {
//             TString tit = sig->GetTitle();
//             sig->SetTitle( tit.ReplaceAll("Input variable", "Regression target" ) );
//          }
//       }
      sig->SetTitle( "" );            
      

      // finally plot and overlay
      Float_t sc = 1.1;
      if (countPad == 1) sc = 1.3;
      sig->SetMaximum( TMath::Max( sig->GetMaximum(), bgd->GetMaximum() )*sc );
      sig->Draw( "hist" );
      cPad->SetLeftMargin( 0.17 );

      sig->GetYaxis()->SetTitleOffset( 1.50 );
      if (!isRegression) {
         bgd->Draw("histsame");
         TString ytit = TString("(1/N) ") + sig->GetYaxis()->GetTitle();
         ytit = TString("Fraction of Events");
         sig->GetYaxis()->SetTitle( ytit ); // histograms are normalised
      }

      if (countPad == 1) sig->GetXaxis()->SetTitle("Leading Lepton p_{T} [GeV/c]");
      if (countPad == 2) sig->GetXaxis()->SetTitle("Trailing Lepton p_{T} [GeV/c]");
      if (countPad == 3) sig->GetXaxis()->SetTitle("#Delta#phi(l,l)");
      if (countPad == 4) sig->GetXaxis()->SetTitle("#Delta R(l,l)");
      if (countPad == 5) sig->GetXaxis()->SetTitle("Dilepton Mass [GeV/c^{2}]");
      if (countPad == 6) sig->GetXaxis()->SetTitle("Dilepton Flavor Final State");
      if (countPad == 7) sig->GetXaxis()->SetTitle("M_{T} (Higgs) [GeV/c^{2}]");
      if (countPad == 8) sig->GetXaxis()->SetTitle("#Delta#phi(Dilepton System, MET)");
      if (countPad == 9) sig->GetXaxis()->SetTitle("#Delta#phi(Dilepton System, Jet)");


      // Draw legend
//       if (countPad == 1 && !isRegression) {
         TLegend *legend= new TLegend( cPad->GetLeftMargin(), 
                                       1-cPad->GetTopMargin()-.15, 
                                       cPad->GetLeftMargin()+.4, 
                                       1-cPad->GetTopMargin() );

         if(countPad == 1 || countPad == 2 ||countPad == 3 ||countPad == 4 ||countPad == 5 ||countPad == 7  ) {
           legend= new TLegend( 0.50, 
                                1-cPad->GetTopMargin()-.15, 
                                0.90, 
                                1-cPad->GetTopMargin() );
         }

         legend->SetFillStyle(0);
         legend->AddEntry(sig,"Signal","F");
         legend->AddEntry(bgd,"Background","F");
         legend->SetBorderSize(0);
         legend->SetMargin( 0.3 );
         legend->SetTextSize( 0.03 );
         legend->Draw("same");
//       } 

      // redraw axes
      sig->Draw("sameaxis");

      // text for overflows
      Int_t    nbin = sig->GetNbinsX();
      Double_t dxu  = sig->GetBinWidth(0);
      Double_t dxo  = sig->GetBinWidth(nbin+1);
      TString uoflow = "";
      if (isRegression) {
         uoflow = Form( "U/O-flow: %.1f%% / %.1f%%", 
                        sig->GetBinContent(0)*dxu*100, sig->GetBinContent(nbin+1)*dxo*100 );
      }
      else {
         uoflow = Form( "U/O-flow (S,B): (%.1f, %.1f)%% / (%.1f, %.1f)%%", 
                        sig->GetBinContent(0)*dxu*100, bgd->GetBinContent(0)*dxu*100,
                        sig->GetBinContent(nbin+1)*dxo*100, bgd->GetBinContent(nbin+1)*dxo*100 );
      }
  
      TText* t = new TText( 0.98, 0.14, uoflow );
      t->SetNDC();
      t->SetTextSize( 0.040 );
      t->SetTextAngle( 90 );
//       t->AppendPad();    

      // save canvas to file
      if (countPad%noPadPerCanv==0) {
         TString fname = Form( "plots/%s_c%i", outfname.Data(), countCanvas );
         TMVAGlob::plot_logo();
         TMVAGlob::imgconv( canv, fname );
         createNewFig = kFALSE;
      }
      else {
         createNewFig = kTRUE;
      }
   }
   
   if (createNewFig) {
      TString fname = Form( "plots/%s_c%i", outfname.Data(), countCanvas );
      TMVAGlob::plot_logo();
      TMVAGlob::imgconv( canv, fname );
      createNewFig = kFALSE;
   }

   return;
}
//_____________________________________________________________________________________________________
AliAnalysisTask* AddTask_TrainTreeAnalysis(Bool_t isGrid=kFALSE, TString prod="LHC10h", Int_t reducedEventType=-1, Bool_t writeTree=kTRUE, TString tasks="dst", TString pathForMacros="$ALICE_PHYSICS/PWGDQ/reducedTree/macros") {
   //
   //  AddTask macro for the TreeMaker analysis task and eventual other dependent tasks
   //
   
   //TString alienPath = alienPathForMacros;
   //TString alirootPath("$ALICE_PHYSICS/PWGDQ/reducedTree/macros");
   
   TObjArray* tasksArray = tasks.Tokenize(";");
   if(tasksArray->GetEntries()==0) {
      printf("ERROR: In AddTask_TrainTreeAnalysis(), no tasks are provided as argument, nothing to add to the AliAnalysisManager! \n");
      return 0x0;
   }
   
   AliAnalysisManager* mgr = AliAnalysisManager::GetAnalysisManager();
   
   //++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   // check if the dst TreeMaker is included in the list of tasks and add it to the train if needed
   Bool_t makeTrees = kFALSE;
   AliAnalysisTask* treeMaker = 0x0;
   // NOTE: if the tree maker needs to be in the train, then this has to be the first task specified in the tasks string
   //         Also, the name specified in the "tasks" argument has to contain the keyword "dst", case insensitive
   TString treeTask = tasksArray->At(0)->GetName();   
   treeTask.ToLower();
   if(treeTask.Contains("dst")) makeTrees = kTRUE;
   
   if(makeTrees) {
      TString addTaskFullPath = "";
      if(isGrid) {
         //Int_t errCode = gSystem->Exec(Form("alien_cp %s/AddTask_%s.C .", alienPath.Data(), tasksArray->At(0)->GetName()));
         Int_t errCode = gSystem->Exec(Form("alien_cp %s/AddTask_%s.C .", pathForMacros.Data(), tasksArray->At(0)->GetName()));
         if(errCode) {
            //printf("ERROR: In AddTask_TrainTreeAnalysis(), could not copy %s/AddTask_%s.C from the grid directory %s \n", alienPath.Data(), tasksArray->At(0)->GetName(), alienPath.Data());
            printf("ERROR: In AddTask_TrainTreeAnalysis(), could not copy %s/AddTask_%s.C from the grid directory %s \n", pathForMacros.Data(), tasksArray->At(0)->GetName(), pathForMacros.Data());
            return 0x0;
         }
         else addTaskFullPath = gSystem->pwd();
      }
      else {
         //addTaskFullPath = alirootPath.Data();
         addTaskFullPath = pathForMacros.Data();
      }
      addTaskFullPath += "/AddTask_";
      addTaskFullPath += tasksArray->At(0)->GetName();
      addTaskFullPath += ".C";
      if (!gROOT->GetListOfGlobalFunctions()->FindObject(Form("AddTask_%s", tasksArray->At(0)->GetName()))){
         gROOT->LoadMacro(addTaskFullPath.Data());
      }
      gROOT->ProcessLine(Form("AddTask_%s(%d,%d,\"%s\")", tasksArray->At(0)->GetName(), reducedEventType, (writeTree ? 1 : 0), prod.Data()));
      treeMaker = (AliAnalysisTask*)mgr->GetTasks()->FindObject("DSTTreeMaker");
      if(!treeMaker) {
         printf("ERROR: In AddTask_TrainTreeAnalysis(), something went wrong! The tree maker could not be added to the analysis manager!");
         return 0x0;
      }
      
      if(tasksArray->GetEntries()==1)     // no other tasks to be included, return
         return treeMaker;
   } // end if(makeTrees)
   
   //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   // check if there are consumer tasks for the tree maker and add them to the train
   AliAnalysisTask* firstConsumerTask = 0x0;
   for(Int_t i=(makeTrees ? 1 : 0); i<tasksArray->GetEntries(); ++i) {
      TString task = tasksArray->At(i)->GetName();
      TString addTaskFullPath = "";
      if(isGrid) {
         //Int_t errCode = gSystem->Exec(Form("alien_cp %s/AddTask_%s.C .", alienPath.Data(), task.Data()));
         Int_t errCode = gSystem->Exec(Form("alien_cp %s/AddTask_%s.C .", pathForMacros.Data(), task.Data()));
         if(errCode) {
            //printf("ERROR: In AddTask_TrainTreeAnalysis(), could not copy %s/AddTask_%s.C from the grid directory %s \n", alienPath.Data(), task.Data(), alienPath.Data());
            printf("ERROR: In AddTask_TrainTreeAnalysis(), could not copy %s/AddTask_%s.C from the grid directory %s \n", pathForMacros.Data(), task.Data(), pathForMacros.Data());
            return 0x0;
         }
         else addTaskFullPath = gSystem->pwd();
      }
      else {
         //addTaskFullPath = alirootPath.Data();
         addTaskFullPath = pathForMacros.Data();
      }
      addTaskFullPath = Form("%s/AddTask_%s.C", addTaskFullPath.Data(), task.Data());
      if (!gROOT->GetListOfGlobalFunctions()->FindObject(Form("AddTask_%s", task.Data()))){
         gROOT->LoadMacro(addTaskFullPath.Data());
      }
      
      Int_t runMode = AliAnalysisTaskReducedEventProcessor::kUseOnTheFlyReducedEvents;
      if(!makeTrees) runMode = AliAnalysisTaskReducedEventProcessor::kUseEventsFromTree;
      
      gROOT->ProcessLine(Form("AddTask_%s(kTRUE,%d,\"%s\")", tasksArray->At(i)->GetName(), runMode, prod.Data()));
      if(!firstConsumerTask) firstConsumerTask = (AliAnalysisTask*)mgr->GetTasks()->At(mgr->GetTasks()->GetEntries()-1);
   }
   
   if(treeMaker) return treeMaker;
   if(firstConsumerTask) return firstConsumerTask;
   return 0x0;
}
Example #27
0
int Ridgecntbbc::Init()
{
  coll = "";
  TString temp = OutputFileName;
  temp.ToLower();
  fetchdphidz();
  if(temp.Contains("pp") && temp.Contains("mbst")) coll = "ppminbias";
  else if(temp.Contains("pal") && temp.Contains("mbst")) coll = "pAlminbias";
  else if(temp.Contains("pal") && temp.Contains("mbcentral")) coll = "pAlcentral";
  else if(temp.Contains("pp") && temp.Contains("fvtxand")) coll = "ppfvtxand";
  else if(temp.Contains("pal") && temp.Contains("fvtxand")) coll = "pAlfvtxand";
  else if(temp.Contains("pp") && temp.Contains("fvtxor")) coll = "ppfvtxor";
  else if(temp.Contains("pal") && temp.Contains("fvtxor")) coll = "pAlfvtxor";
  else if(temp.Contains("pal") && temp.Contains("fvtxsouth")) coll = "pAlfvtxsouth";
  else if(temp.Contains("pal") && temp.Contains("fvtxnorth")) coll = "pAlfvtxnorth";
  else return 0;

//  OutputFileName.Insert(OutputFileName.Length()-5,coll);

  d_outfile = new TFile(OutputFileName,"recreate");
      d_infile = TFile::Open(InputFileName,"ReadOnly");
  if(!d_infile) return 0;
  tree = (TTree*)d_infile->Get("tree");
  if(!tree) return 0;
  
  tree -> SetBranchAddress("run", &run);
  tree -> SetBranchAddress("trig", &trig);
  tree -> SetBranchAddress("npc1hits", &npc1hits);
  tree -> SetBranchAddress("bbc_s", &bbc_s);
  tree -> SetBranchAddress("bbc_n", &bbc_n);
  tree -> SetBranchAddress("bbcv", &bbcv);
  if(coll.Contains("pp"))
  tree -> SetBranchAddress("vtxz", &vtxz);
//  tree -> SetBranchAddress("fvtxz", &fvtxz);
  tree -> SetBranchAddress("ntrack", &ntrack);
  tree -> SetBranchAddress("nbbc", &nbbc);
  if(coll.Contains("pp")){
  tree -> SetBranchAddress("nvtx", &nvtx);
  tree -> SetBranchAddress("nvtxtrack", &nvtxtrack);
  }
//  tree -> SetBranchAddress("nmpc", &nmpc);
// tree -> SetBranchAddress("nfvtxtrack", &nfvtxtrack);

  tree -> SetBranchAddress("mom", &mom);
  tree -> SetBranchAddress("phi0", &phi0);
  tree -> SetBranchAddress("the0", &the0);
  tree -> SetBranchAddress("charge", &charge);
  tree -> SetBranchAddress("arm", &arm);
  tree -> SetBranchAddress("pc3dphi", &pc3dphi);
  tree -> SetBranchAddress("pc3dz", &pc3dz);
  tree -> SetBranchAddress("slat", &slat);
  tree -> SetBranchAddress("tofdphi", &tofdphi);
  tree -> SetBranchAddress("tofdz", &tofdz);
  tree -> SetBranchAddress("tofpl", &tofpl);
  tree -> SetBranchAddress("qtof", &qtof);
  tree -> SetBranchAddress("ttof", &ttof);

  tree -> SetBranchAddress("bbccharge", &bbccharge);
  tree -> SetBranchAddress("bbcx", &bbcx);
  tree -> SetBranchAddress("bbcy", &bbcy);
  tree -> SetBranchAddress("bbcz", &bbcz);

  if(coll.Contains("pp")){
  tree -> SetBranchAddress("layer", &layer);
  tree -> SetBranchAddress("vtxX", &vtxX);
  tree -> SetBranchAddress("vtxY", &vtxY);
  tree -> SetBranchAddress("vtxZ", &vtxZ);

  tree -> SetBranchAddress("vtxnhits", &vtxnhits);
  tree -> SetBranchAddress("vtxpx", &vtxpx);
  tree -> SetBranchAddress("vtxpy", &vtxpy);
  tree -> SetBranchAddress("vtxpz", &vtxpz);
  }
 /*
  tree -> SetBranchAddress("mpc_e", &mpc_e);
  tree -> SetBranchAddress("mpc_x", &mpc_x);
  tree -> SetBranchAddress("mpc_y", &mpc_y);
  tree -> SetBranchAddress("mpc_z", &mpc_z);
*/
  /*
  tree -> SetBranchAddress("farm", &farm);
  tree -> SetBranchAddress("fnhits", &fnhits);
  tree -> SetBranchAddress("fthe", &fthe);
  tree -> SetBranchAddress("feta", &feta);
  tree -> SetBranchAddress("fphi", &fphi);
  tree -> SetBranchAddress("fvtxX", &fvtxX);
  tree -> SetBranchAddress("fvtxY", &fvtxY);
  tree -> SetBranchAddress("fvtxZ", &fvtxZ);
*/
char name[512];
 pi = acos(-1);


   sprintf(name,"hevent");
   hevent = new TH1F(name,name,1,0,1);

  for (int icent=0; icent<centbin; icent++) {
    //bbc correlation
    for(int ipt=0; ipt<ptbin; ipt++){
      //cnt with bbc
      sprintf(name,"hforesouthbbc_%d_%d",icent,ipt);
      hforesouthbbc[icent][ipt] = new TH1F(name,name,40, -0.5*pi, 1.5*pi);

      sprintf(name,"hbacksouthbbc_%d_%d",icent,ipt);
      hbacksouthbbc[icent][ipt] = new TH1F(name,name,40, -0.5*pi, 1.5*pi);

      sprintf(name,"hforenorthbbc_%d_%d",icent,ipt);
      hforenorthbbc[icent][ipt] = new TH1F(name,name,40, -0.5*pi, 1.5*pi);

      sprintf(name,"hbacknorthbbc_%d_%d",icent,ipt);
      hbacknorthbbc[icent][ipt] = new TH1F(name,name,40, -0.5*pi, 1.5*pi);

      //flip
      sprintf(name,"kforesouthbbc_%d_%d",icent,ipt);
      kforesouthbbc[icent][ipt] = new TH1F(name,name,40, -0.5*pi, 1.5*pi);

      sprintf(name,"kbacksouthbbc_%d_%d",icent,ipt);
      kbacksouthbbc[icent][ipt] = new TH1F(name,name,40, -0.5*pi, 1.5*pi);

      sprintf(name,"kforenorthbbc_%d_%d",icent,ipt);
      kforenorthbbc[icent][ipt] = new TH1F(name,name,40, -0.5*pi, 1.5*pi);

      sprintf(name,"kbacknorthbbc_%d_%d",icent,ipt);
      kbacknorthbbc[icent][ipt] = new TH1F(name,name,40, -0.5*pi, 1.5*pi);
//with weight
      sprintf(name,"hforesouthbbcw_%d_%d",icent,ipt);
      hforesouthbbcw[icent][ipt] = new TH1F(name,name,40, -0.5*pi, 1.5*pi);

      sprintf(name,"hbacksouthbbcw_%d_%d",icent,ipt);
      hbacksouthbbcw[icent][ipt] = new TH1F(name,name,40, -0.5*pi, 1.5*pi);

      sprintf(name,"hforenorthbbcw_%d_%d",icent,ipt);
      hforenorthbbcw[icent][ipt] = new TH1F(name,name,40, -0.5*pi, 1.5*pi);

      sprintf(name,"hbacknorthbbcw_%d_%d",icent,ipt);
      hbacknorthbbcw[icent][ipt] = new TH1F(name,name,40, -0.5*pi, 1.5*pi);

      //flip
      sprintf(name,"kforesouthbbcw_%d_%d",icent,ipt);
      kforesouthbbcw[icent][ipt] = new TH1F(name,name,40, -0.5*pi, 1.5*pi);

      sprintf(name,"kbacksouthbbcw_%d_%d",icent,ipt);
      kbacksouthbbcw[icent][ipt] = new TH1F(name,name,40, -0.5*pi, 1.5*pi);

      sprintf(name,"kforenorthbbcw_%d_%d",icent,ipt);
      kforenorthbbcw[icent][ipt] = new TH1F(name,name,40, -0.5*pi, 1.5*pi);

      sprintf(name,"kbacknorthbbcw_%d_%d",icent,ipt);
      kbacknorthbbcw[icent][ipt] = new TH1F(name,name,40, -0.5*pi, 1.5*pi);



      //mixing with bbc
      sprintf(name,"hbacksouthbbc2_%d_%d",icent,ipt);
      hbacksouthbbc2[icent][ipt] = new TH1F(name,name,40, -0.5*pi, 1.5*pi);

      sprintf(name,"hbacknorthbbc2_%d_%d",icent,ipt);
      hbacknorthbbc2[icent][ipt] = new TH1F(name,name,40, -0.5*pi, 1.5*pi);

      //flip
      sprintf(name,"kbacksouthbbc2_%d_%d",icent,ipt);
      kbacksouthbbc2[icent][ipt] = new TH1F(name,name,40, -0.5*pi, 1.5*pi);

      sprintf(name,"kbacknorthbbc2_%d_%d",icent,ipt);
      kbacknorthbbc2[icent][ipt] = new TH1F(name,name,40, -0.5*pi, 1.5*pi);

      //with weight
      sprintf(name,"hbacksouthbbcw2_%d_%d",icent,ipt);
      hbacksouthbbcw2[icent][ipt] = new TH1F(name,name,40, -0.5*pi, 1.5*pi);

      sprintf(name,"hbacknorthbbcw2_%d_%d",icent,ipt);
      hbacknorthbbcw2[icent][ipt] = new TH1F(name,name,40, -0.5*pi, 1.5*pi);

      //flip
      sprintf(name,"kbacksouthbbcw2_%d_%d",icent,ipt);
      kbacksouthbbcw2[icent][ipt] = new TH1F(name,name,40, -0.5*pi, 1.5*pi);

      sprintf(name,"kbacknorthbbcw2_%d_%d",icent,ipt);
      kbacknorthbbcw2[icent][ipt] = new TH1F(name,name,40, -0.5*pi, 1.5*pi);


      //2D
      sprintf(name,"kforesouthetabbc_%d_%d",icent,ipt);
      kforesouthetabbc[icent][ipt] = new TH2F(name, name, 100, -5.0, 5.0, 40, -0.5*pi, 1.5*pi);

      sprintf(name,"kbacksouthetabbc_%d_%d",icent,ipt);
      kbacksouthetabbc[icent][ipt] = new TH2F(name, name, 100, -5.0, 5.0, 40, -0.5*pi, 1.5*pi);

      sprintf(name,"kforenorthetabbc_%d_%d",icent,ipt);
      kforenorthetabbc[icent][ipt] = new TH2F(name, name, 100, -5.0, 5.0, 40, -0.5*pi, 1.5*pi);

      sprintf(name,"kbacknorthetabbc_%d_%d",icent,ipt);
      kbacknorthetabbc[icent][ipt] = new TH2F(name, name, 100, -5.0, 5.0, 40, -0.5*pi, 1.5*pi);

      sprintf(name,"kbacksouthetabbc2_%d_%d",icent,ipt);
      kbacksouthetabbc2[icent][ipt] = new TH2F(name, name, 100, -5.0, 5.0, 40, -0.5*pi, 1.5*pi);

      sprintf(name,"kbacknorthetabbc2_%d_%d",icent,ipt);
      kbacknorthetabbc2[icent][ipt] = new TH2F(name, name, 100, -5.0, 5.0, 40, -0.5*pi, 1.5*pi);

      //with weight
      sprintf(name,"kforesouthetabbcw_%d_%d",icent,ipt);
      kforesouthetabbcw[icent][ipt] = new TH2F(name, name, 100, -5.0, 5.0, 40, -0.5*pi, 1.5*pi);

      sprintf(name,"kbacksouthetabbcw_%d_%d",icent,ipt);
      kbacksouthetabbcw[icent][ipt] = new TH2F(name, name, 100, -5.0, 5.0, 40, -0.5*pi, 1.5*pi);

      sprintf(name,"kforenorthetabbcw_%d_%d",icent,ipt);
      kforenorthetabbcw[icent][ipt] = new TH2F(name, name, 100, -5.0, 5.0, 40, -0.5*pi, 1.5*pi);

      sprintf(name,"kbacknorthetabbcw_%d_%d",icent,ipt);
      kbacknorthetabbcw[icent][ipt] = new TH2F(name, name, 100, -5.0, 5.0, 40, -0.5*pi, 1.5*pi);

      sprintf(name,"kbacksouthetabbcw2_%d_%d",icent,ipt);
      kbacksouthetabbcw2[icent][ipt] = new TH2F(name, name, 100, -5.0, 5.0, 40, -0.5*pi, 1.5*pi);

      sprintf(name,"kbacknorthetabbcw2_%d_%d",icent,ipt);
      kbacknorthetabbcw2[icent][ipt] = new TH2F(name, name, 100, -5.0, 5.0, 40, -0.5*pi, 1.5*pi);
    }
  }

  memset(ntrack_buff, 0, sizeof(ntrack_buff));
  memset(dtrack_buff, 0, sizeof(dtrack_buff));
  memset(buff_ntrack, 0, sizeof(buff_ntrack));

  memset(nbbcau_buff, 0, sizeof(nbbcau_buff));
  memset(dbbcau_buff, 0, sizeof(dbbcau_buff));
  memset(buff_nbbcau, 0, sizeof(buff_nbbcau));

  memset(nbbcde_buff, 0, sizeof(nbbcde_buff));
  memset(dbbcde_buff, 0, sizeof(dbbcde_buff));
  memset(buff_nbbcde, 0, sizeof(buff_nbbcde));

  return 0;
}
Example #28
0
Bool_t SETUP_SetAliRootCoreMode(TString &mode, const TString &extraLibs) {

  // Sets a certain AliRoot mode, defining a set of libraries to load. Extra
  // libraries to load can be specified as well. Returns kTRUE on success, or
  // kFALSE in case library loading failed.

  mode.ToLower();
  TString libs = extraLibs;
  Long_t rv = -9999;

  // Load needed ROOT libraries
  if (!SETUP_LoadLibraries("VMC:Tree:Physics:Matrix:Minuit:XMLParser:Gui")) {
    ::Error(gMessTag.Data(), "Loading of extra ROOT libraries failed");
    return kFALSE;
  }

  if (mode == "aliroot") {
    ::Info(gMessTag.Data(), "Loading libraries for AliRoot mode...");
    rv = gROOT->LoadMacro(
      gSystem->ExpandPathName("$ALICE_ROOT/macros/loadlibs.C") );
    if (rv == 0) loadlibs();
  }
  else if (mode == "sim") {
    ::Info(gMessTag.Data(), "Loading libraries for simulation mode...");
    rv = gROOT->LoadMacro(
      gSystem->ExpandPathName("$ALICE_ROOT/macros/loadlibssim.C") );
    if (rv == 0) loadlibssim();
  }
  else if (mode == "rec") {
    ::Info(gMessTag.Data(), "Loading libraries for reconstruction mode...");
    rv = gROOT->LoadMacro(
      gSystem->ExpandPathName("$ALICE_ROOT/macros/loadlibsrec.C") );
    if (rv == 0) loadlibsrec();
  }
  else if (mode == "base") {
    // "Base" mode: load standard libraries, and also fix loading order
    ::Info(gMessTag.Data(), "No mode specified: loading standard libraries...");
    TPMERegexp reLibs("(ANALYSISalice|ANALYSIS|STEERBase|ESD|AOD)(:|$)");
    while (reLibs.Substitute(libs, "")) {}
    libs.Prepend("STEERBase:ESD:AOD:ANALYSIS:ANALYSISalice:");
  }

  // Check status code
  if (rv == 0) {
    ::Info(gMessTag.Data(), "Successfully loaded AliRoot base libraries");
  }
  else if (rv != -9999) {
    ::Error(gMessTag.Data(), "Loading of base AliRoot libraries failed");
    return kFALSE;
  }

  // Load extra AliRoot libraries
  ::Info(gMessTag.Data(), "Loading extra AliRoot libraries...");
  if (!SETUP_LoadLibraries(libs)) {
    ::Error(gMessTag.Data(), "Loading of extra AliRoot libraries failed");
    return kFALSE;
  }
  else {
    ::Info(gMessTag.Data(), "Successfully loaded extra AliRoot libraries");
  }

  return kTRUE;
}