AliPhysics  ee192bd (ee192bd)
ana.C
Go to the documentation of this file.
1 
15 #if !defined(__CINT__) || defined(__MAKECINT__)
16 
17 // ROOT
18 #include <Riostream.h>
19 #include <TString.h>
20 #include <TFile.h>
21 #include <TChain.h>
22 #include <TROOT.h>
23 #include <TSystem.h>
24 #include <TApplication.h>
25 #include <TKey.h>
26 #include <TProfile.h>
27 #include <TH1F.h>
28 
29 #include "TGrid.h"
30 #include "TGridCollection.h"
31 #include "TAlienCollection.h"
32 #include "TGridResult.h"
33 //#include "TProof.h"
34 //#include "TFileCollection.h"
35 //#include "TFileInfo.h"
36 
37 // ALIROOT
38 #include "AliLog.h"
39 #include "AliAnalysisGrid.h"
40 #include "AliAnalysisManager.h"
41 #include "AliMCEventHandler.h"
42 #include "AliAnalysisTaskSE.h"
43 #include "AliESDEvent.h"
44 #include "AliAODEvent.h"
45 #include "AliESDInputHandler.h"
46 #include "AliAODInputHandler.h"
47 #include "AliAODHandler.h"
48 #include "AliMultiInputEventHandler.h"
49 #include "AliAnalysisDataContainer.h"
50 #include "AliESDtrack.h"
51 #include "AliAODTrack.h"
52 
53 // Main AddTasks and associated classes
57 //#include "AddTaskMultipleTrackCutIsoConeAnalysis.C" // comment, does not compile with AddTaskGammaHadronCorrelationSelectAnalysis.C
58 //#include "AddTaskPi0IMGammaCorrQA.C" // comment, does not compile with AddTaskGammaHadronCorrelationSelectAnalysis.C
59 
60 #include "AliPhysicsSelection.h"
61 #include "AliPhysicsSelectionTask.h"
62 #include "AddTaskPhysicsSelection.C"
63 
64 //#include "AliCentralitySelectionTask.h"
65 //#include "AddTaskCentrality.C"
66 
67 #include "AliMultSelectionTask.h"
68 #include "AddTaskMultSelection.C"
69 
70 //#include "AliVZEROEPSelectionTask.h"
71 //#include "AliEPSelectionTask.h"
72 //#include "AddTaskVZEROEPSelection.C"
73 //#include "AddTaskEventplane.C"
74 
75 //#include "CreateAlienHandler.C"
76 
77 //#include "AliAnalysisTaskCounter.h"
78 //#include "AddTaskCounter.C"
79 
80 //#include "AliTender.h"
81 //#include "AliEmcalTenderTask.h"
82 //#include "AliEMCALTenderSupply.h"
83 //#include "AliEMCALRecParam.h"
84 //#include "AddTaskEMCALTender.C"
85 
86 #include "AliTaskCDBconnect.h"
87 #include "AddTaskCDBconnect.C"
88 
90 #include "AddTaskEMCALClusterize.C"
91 
92 #include "AliEmcalCorrectionTask.h"
93 #include "AddTaskEmcalCorrectionTask.C"
94 
95 #endif
96 
97 //---------------------------------------------------------------------------
100 {
101  mLocal = 0,
102  mPROOF = 1,
103  mPlugin = 2,
104  mGRID = 3
105 };
106 
107 //---------------------------------------------------------------------------
111 
112 char * kInDir = (char*)"/user/data/files/";
113 char * kPattern = (char*)"";
114 Int_t kFile = 10;
115 
116 //---------------------------------------------------------------------------
117 // Old PROOF settings, not used, here for historical reference
118 // Dataset for proof analysis, mode=mPROOF
119 // char * kDataset = (char*)"/alice/vernet/PbPb_LHC10h_ESD";
120 //
121 //char * kDatasetPROOF = (char*)"/alice/vernet/LHC11b_149646";
122 //Int_t kDatasetNMaxFiles = 20;
123 //TString ccin2p3UserName = "arbor" ;
124 //TString alienUserName = "narbor" ;
125 
126 //---------------------------------------------------------------------------
128 char * kXML = (char*)"collection.xml";
129 
130 //---------------------------------------------------------------------------
135 const char * kXSFileName = (char*)"pyxsec.root";
136 
137 // Container of xs if xs in file pyxsec_hist.root
138 TArrayF* xsArr;
140 
141 //---------------------------------------------------------------------------
143 Bool_t kMC = kFALSE;
145 Int_t kYear = 2011;
146 TString kPeriod ="LHC11c";
148 Bool_t outAOD = kFALSE;
151 Int_t kRun = 0;
152 
153 //---------------------------------------------------------------------------
155 Bool_t bEMCCluster = kFALSE;
156 Bool_t bEMCCorrFra = kFALSE;
158 
159 Bool_t bAnalysis = kTRUE;
160 //Bool_t bAnalysisQA = kFALSE; /// Execute analysis QA train wagon, comment, does not compile with bAnalysis
162 
163 //_________________________________
167 //_________________________________
168 void SetupPar(char* pararchivename)
169 {
170  TString cdir(Form("%s", gSystem->WorkingDirectory() )) ;
171  TString parpar(Form("%s.par", pararchivename)) ;
172 
173  if ( gSystem->AccessPathName(pararchivename) )
174  {
175  TString processline = Form(".! tar xvzf %s",parpar.Data()) ;
176  gROOT->ProcessLine(processline.Data());
177  }
178 
179  TString ocwd = gSystem->WorkingDirectory();
180  gSystem->ChangeDirectory(pararchivename);
181 
182  // check for BUILD.sh and execute
183  if ( !gSystem->AccessPathName("PROOF-INF/BUILD.sh") )
184  {
185  printf("*******************************\n");
186  printf("*** Building PAR archive ***\n");
187  cout<<pararchivename<<endl;
188  printf("*******************************\n");
189 
190  if ( gSystem->Exec("PROOF-INF/BUILD.sh") )
191  {
192  Error("runProcess","Cannot Build the PAR Archive! - Abort!");
193  return ;
194  }
195  }
196  // check for SETUP.C and execute
197  if ( !gSystem->AccessPathName("PROOF-INF/SETUP.C") )
198  {
199  printf("*******************************\n");
200  printf("*** Setup PAR archive ***\n");
201  cout<<pararchivename<<endl;
202  printf("*******************************\n");
203  gROOT->Macro("PROOF-INF/SETUP.C");
204  }
205 
206  gSystem->ChangeDirectory(ocwd.Data());
207  printf("Current dir: %s\n", ocwd.Data());
208 }
209 
210 //______________________________________
212 //______________________________________
214 {
215  TString ocwd = gSystem->WorkingDirectory();
216 
217  //---------------------------------------
218  // Local files analysis
219  //---------------------------------------
220  if ( mode == mLocal )
221  {
222  // If you want to add several ESD files sitting in a common directory INDIR
223  // Specify as environmental variables the directory (INDIR), the number of files
224  // to analyze (NFILES) and the pattern name of the directories with files (PATTERN)
225 
226  if ( gSystem->Getenv("INDIR") )
227  kInDir = (char*)gSystem->Getenv("INDIR") ;
228  else
229  cout<<"INDIR not set, use default: "<<kInDir<<endl;
230 
231  TString sindir(kInDir);
232  if ( sindir.Contains("pass1") ) kPass = "pass1";
233  else if ( sindir.Contains("pass2") ) kPass = "pass2";
234  else if ( sindir.Contains("pass3") ) kPass = "pass3";
235  else if ( sindir.Contains("pass4") ) kPass = "pass4";
236 
237  if ( gSystem->Getenv("PATTERN") )
238  kPattern = (char*) gSystem->Getenv("PATTERN") ;
239  else
240  cout<<"PATTERN not set, use default: "<<kPattern<<endl;
241 
242  cout<<"INDIR : "<<kInDir<<endl;
243  cout<<"NFILES : "<<kFile<<endl;
244 
245  char fileE[120] ;
246  char fileA[120] ;
247  char fileG[120] ;
248  char fileEm[120] ;
249  for (Int_t event = 0 ; event < kFile ; event++)
250  {
251  sprintf(fileE, "%s/%s%d/AliESDs.root", kInDir,kPattern,event) ;
252  sprintf(fileA, "%s/%s%d/AliAOD.root", kInDir,kPattern,event) ;
253  sprintf(fileG, "%s/%s%d/galice.root", kInDir,kPattern,event) ;
254  sprintf(fileEm, "%s/%s%d/embededAOD.root", kInDir,kPattern,event) ;
255 
256  TFile * fESD = TFile::Open(fileE) ;
257  TFile * fAOD = TFile::Open(fileA) ;
258 
259  // Check if file exists and add it, if not skip it
260  if ( fESD )
261  {
262  kTreeName = "esdTree";
263  kInputData = "ESD";
264  TFile * fG = TFile::Open(fileG);
265  if(fG) { kMC = kTRUE; fG->Close();}
266  else kMC = kFALSE;
267 
268  // Get run number
269  TTree* esdTree = (TTree*)fESD->Get("esdTree");
270  AliESDEvent* esd = new AliESDEvent();
271  esd->ReadFromTree(esdTree);
272  esdTree->GetEvent(0);
273  kRun = esd->GetRunNumber();
274 
275  return;
276  }
277  else if ( fAOD )
278  {
279  kTreeName = "aodTree";
280  kInputData = "AOD";
281  if(((TTree*) fAOD->Get("aodTree"))->GetBranch("mcparticles")) kMC=kTRUE;
282  else kMC = kFALSE;
283 
284  // Get run number
285  TTree* aodTree = (TTree*)fAOD->Get("aodTree");
286  AliAODEvent* aod = new AliAODEvent();
287  aod->ReadFromTree(aodTree);
288  aodTree->GetEvent(0);
289  kRun = aod->GetRunNumber();
290  return;
291  }
292  else if ( TFile::Open(fileEm) )
293  {
294  kTreeName = "aodTree";
295  kInputData = "AOD";
296  kMC = kTRUE;
297 
298  return;
299  }
300  else if ( TFile::Open(fileG) )
301  {
302  kTreeName = "TE";
303  kInputData = "MC";
304  kMC = kTRUE;
305  return;
306  }
307 
308  if ( fESD ) fESD->Close();
309  if ( fAOD ) fAOD->Close();
310  }
311 
312  }// local files analysis
313 
314  //------------------------------
315  // GRID xml files
316  //-----------------------------
317  else if ( mode == mGRID )
318  {
319  // Get colection file. It is specified by the environmental
320  // variable XML, if non provided, collection.xml is expected.
321  if ( gSystem->Getenv("XML") )
322  kXML = (char*) gSystem->Getenv("XML");
323  else
324  sprintf(kXML, "collection.xml") ;
325 
326  if ( !TFile::Open(kXML) )
327  {
328  printf("No collection file with name -- %s -- was found\n",kXML);
329  return ;
330  }
331  else
332  cout<<"XML file "<<kXML<<endl;
333 
334  // Load necessary libraries and connect to the GRID
335  gSystem->Load("libNetx.so") ;
336  gSystem->Load("libRAliEn.so");
337  TGrid::Connect("alien://") ;
338 
339  // Feed Grid with collection file
340  TGridCollection * collection = (TGridCollection*) TAlienCollection::Open(kXML);
341  if ( !collection )
342  {
343  printf("%s not found\n", kXML) ;
344  return ;
345  }
346 
347  TGridResult* result = collection->GetGridResult("",0 ,0);
348 
349  for (Int_t index = 0; index < result->GetEntries(); index++)
350  {
351  TString alienURL = result->GetKey(index, "turl") ;
352  cout << "================== " << alienURL << endl ;
353 
354  if (alienURL.Contains("pass1")) kPass = "pass1";
355  else if(alienURL.Contains("pass2")) kPass = "pass2";
356  else if(alienURL.Contains("pass3")) kPass = "pass3";
357  else if(alienURL.Contains("pass4")) kPass = "pass4";
358 
359  kRun = AliAnalysisManager::GetRunFromAlienPath(alienURL.Data());
360  printf("Run number from alien path = %d\n",kRun);
361 
362  TFile * fAOD = 0 ;
363  // Check if file exists and add it, if not skip it
364  if ( alienURL.Contains("AliESDs.root") )
365  {
366  kTreeName = "esdTree";
367  kInputData = "ESD";
368  alienURL.ReplaceAll("AliESDs.root","galice.root");
369  if(TFile::Open(alienURL)) kMC=kTRUE;
370  else kMC = kFALSE;
371  return;
372  }
373  else if ( alienURL.Contains("AliAOD.root") )
374  {
375  kTreeName = "aodTree";
376  kInputData = "AOD";
377  fAOD = TFile::Open(alienURL);
378  if(((TTree*) fAOD->Get("aodTree"))->GetBranch("mcparticles")) kMC=kTRUE;
379  else kMC = kFALSE;
380  return;
381  }
382  else if ( alienURL.Contains("embededAOD.root") )
383  {
384  kTreeName = "aodTree";
385  kInputData = "AOD";
386  kMC=kTRUE;
387  return;
388  }
389  else if ( alienURL.Contains("galice.root") )
390  {
391  kTreeName = "TE";
392  kInputData = "MC";
393  kMC=kTRUE;
394  return;
395  }
396  }
397  }// xml analysis
398  //------------------------------
399  //PROOF files
400  //-----------------------------
401 // else if(mode == mPROOF)
402 // {
403 //
404 // TFileCollection* coll = gProof->GetDataSet(kDatasetPROOF)->GetStagedSubset();
405 //
406 // TIter iter(coll->GetList());
407 //
408 // TFileInfo* fileInfo = 0;
409 // while ((fileInfo = dynamic_cast<TFileInfo*> (iter())))
410 // {
411 // if (fileInfo->GetFirstUrl())
412 // {
413 // TString ProofURL = fileInfo->GetFirstUrl()->GetUrl();
414 // cout << "================== " << ProofURL << endl ;
415 //
416 // if (ProofURL.Contains("pass1")) kPass = "pass1";
417 // else if(ProofURL.Contains("pass2")) kPass = "pass2";
418 // else if(ProofURL.Contains("pass3")) kPass = "pass3";
419 //
420 // kRun = AliAnalysisManager::GetRunFromAlienPath(ProofURL.Data());
421 // printf("Run number from alien path = %d\n",kRun);
422 //
423 // TFile * fAOD = 0 ;
424 // //Check if file exists and add it, if not skip it
425 // if (ProofURL.Contains("AliESDs.root"))
426 // {
427 // kTreeName = "esdTree";
428 // kInputData = "ESD";
429 // alienURL.ReplaceAll("AliESDs.root","galice.root");
430 // if(TFile::Open(ProofURL)) kMC=kTRUE;
431 // else kMC = kFALSE;
432 //
433 // return;
434 // }
435 // else if(ProofURL.Contains("AliAOD.root"))
436 // {
437 // kTreeName = "aodTree";
438 // kInputData = "AOD";
439 // fAOD = TFile::Open(ProofURL);
440 // if(((TTree*) fAOD->Get("aodTree"))->GetBranch("mcparticles")) kMC=kTRUE;
441 // else kMC = kFALSE;
442 // return;
443 // }
444 // else if(ProofURL.Contains("embededAOD.root"))
445 // {
446 // kTreeName = "aodTree";
447 // kInputData = "AOD";
448 // kMC=kTRUE;
449 // return;
450 // }
451 // else if(ProofURL.Contains("galice.root"))
452 // {
453 // kTreeName = "TE";
454 // kInputData = "MC";
455 // kMC=kTRUE;
456 // return;
457 // }
458 // }
459 // }
460 // }// proof analysis
461 
462  gSystem->ChangeDirectory(ocwd.Data());
463 }
464 
465 //_____________________________________________________________________
467 //_____________________________________________________________________
468 void CreateChain(const Int_t mode, TChain * chain, TChain * chainxs)
469 {
470  TString ocwd = gSystem->WorkingDirectory();
471 
472  if ( kInputData == "AOD" )
473  {
474  xsArr = new TArrayF;
475  trArr = new TArrayI;
476  }
477 
478  //---------------------------------------
479  // Local files analysis
480  //---------------------------------------
481  if ( mode == mLocal )
482  {
483  // If you want to add several ESD files sitting in a common directory INDIR
484  // Specify as environmental variables the directory (INDIR), the number of files
485  // to analyze (NFILES) and the pattern name of the directories with files (PATTERN)
486 
487  if ( gSystem->Getenv("INDIR") )
488  kInDir = (char*)gSystem->Getenv("INDIR") ;
489  else
490  cout<<"INDIR not set, use default: "<<kInDir<<endl;
491 
492  if ( gSystem->Getenv("PATTERN") )
493  kPattern = (char*) gSystem->Getenv("PATTERN") ;
494  else
495  cout<<"PATTERN not set, use default: "<<kPattern<<endl;
496 
497  if ( gSystem->Getenv("NFILES") )
498  kFile = atoi(gSystem->Getenv("NFILES")) ;
499  else
500  cout<<"NFILES not set, use default: "<<kFile<<endl;
501 
502  // Check if env variables are set and are correct
503  if ( kInDir && kFile)
504  {
505  printf("Get %d files from directory %s\n",kFile,kInDir);
506  // Check if ESDs directory exist
507  if ( ! gSystem->cd(kInDir) )
508  {
509  printf("%s does not exist\n", kInDir) ;
510  return ;
511  }
512 
513  // if(gSystem->Getenv("XSFILE"))
514  // kXSFileName = gSystem->Getenv("XSFILE") ;
515  // else cout<<" XS file name not set, use default: "<<kXSFileName<<endl;
516 
517  char * kGener = (char*) gSystem->Getenv("GENER");
518  if ( kGener )
519  {
520  cout<<"GENER "<<kGener<<endl;
521  if (!strcmp(kGener,"PYTHIA")) kXSFileName = "pyxsec.root";
522  else if(!strcmp(kGener,"HERWIG")) kXSFileName = "hexsec.root";
523  else cout<<" UNKNOWN GENER, use default: "<<kXSFileName<<endl;
524  }
525  else
526  cout<<" GENER not set, use default xs file name: "<<kXSFileName<<endl;
527 
528  if ( kInputData == "AOD" )
529  {
530  kXSFileName = "pyxsec_hists.root";
531  xsArr->Set(kFile);
532  trArr->Set(kFile);
533  }
534 
535  cout<<"INDIR : "<<kInDir <<endl;
536  cout<<"NFILES : "<<kFile <<endl;
537  cout<<"PATTERN : "<<kPattern <<endl;
538  cout<<"XSFILE : "<<kXSFileName<<endl;
539 
540  TString datafile="";
541  if (kInputData == "ESD") datafile = "AliESDs.root" ;
542  else if(kInputData.Contains("AOD")) datafile = "AliAOD.root" ;
543  else if(kInputData == "MC") datafile = "galice.root" ;
544 
545  //Loop on ESD/AOD/MC files, add them to chain
546  Int_t event =0;
547  Int_t skipped=0 ;
548  char file[120] ;
549  char filexs[120] ;
550 
551  for (event = 0 ; event < kFile ; event++)
552  {
553  sprintf(file, "%s/%s%d/%s", kInDir,kPattern,event,datafile.Data()) ;
554  sprintf(filexs, "%s/%s%d/%s", kInDir,kPattern,event,kXSFileName) ;
555 
556  TFile * fData = TFile::Open(file) ;
557  // Check if file exists and add it, if not skip it
558  if ( fData )
559  {
560  if ( fData->Get(kTreeName) )
561  {
562  printf("++++ Adding %s\n", file) ;
563  chain->AddFile(file);
564 
565  if(kInputData != "AOD")
566  {
567  chainxs->Add(filexs) ;
568  }
569  else
570  {
571  TFile* fxsec = TFile::Open(filexs);
572  if(fxsec)
573  {
574  TKey* key = (TKey*)fxsec->GetListOfKeys()->At(0);
575  if(!key)
576  {
577  fxsec->Close();
578  printf("No key!");
579  continue;
580  }
581 
582  TList *list = dynamic_cast<TList*>(key->ReadObj());
583  if(!list)
584  {
585  fxsec->Close();
586  printf("No list!");
587  continue;
588  }
589 
590  Float_t xsection = ((TProfile*)list->FindObject("h1Xsec")) ->GetBinContent(1);
591  Int_t ntrials = ((TH1F*) list->FindObject("h1Trials"))->GetBinContent(1);
592  fxsec->Close();
593 
594  xsArr->SetAt(xsection,event);
595  trArr->SetAt(ntrials,event);
596 
597  printf("recovered xs %f, ntrials %d, event %d\n",xsection,ntrials, event);
598  //chainxs->Add(tree);
599  //fileTMP->Close();
600  } // fxsec exists
601  } // xs in AODs
602  }
603  }
604  else
605  {
606  printf("---- Skipping %s\n", file) ;
607  skipped++ ;
608  }
609  }
610  }
611  else
612  {
613  TString input = "AliESDs.root" ;
614  cout<<">>>>>> No list added, take a single file <<<<<<<<< "<<input<<endl;
615  chain->AddFile(input);
616  }
617 
618  }// local files analysis
619 
620  //------------------------------
621  // GRID xml files
622  //------------------------------
623  else if ( mode == mGRID )
624  {
625  // Get colection file. It is specified by the environmental
626  // variable XML
627 
628  // Feed Grid with collection file
629  TGridCollection * collection = (TGridCollection*) TAlienCollection::Open(kXML);
630  if (! collection )
631  {
632  printf("%s not found \n", kXML) ;
633  return ;
634  }
635 
636  TGridResult* result = collection->GetGridResult("",0 ,0);
637 
638  // Makes the ESD chain
639  printf("*** Getting the Chain ***\n");
640  for (Int_t index = 0; index < result->GetEntries(); index++)
641  {
642  TString alienURL = result->GetKey(index, "turl") ;
643  cout << "================== " << alienURL << endl ;
644  chain->Add(alienURL) ;
645 
646  if ( kInputData != "AOD" )
647  {
648  alienURL.ReplaceAll("AliESDs.root",kXSFileName);
649  alienURL.ReplaceAll("AliAOD.root" ,kXSFileName);
650  chainxs->Add(alienURL) ;
651  }
652  else
653  {
654  alienURL.ReplaceAll("AliESDs.root","pyxsec_hists.root");
655  alienURL.ReplaceAll("AliAOD.root", "pyxsec_hists.root");
656 
657  TFile* fxsec = TFile::Open(alienURL);
658  if ( fxsec )
659  {
660  TKey* key = (TKey*)fxsec->GetListOfKeys()->At(0);
661  if(!key)
662  {
663  fxsec->Close();
664  printf("No key!");
665  continue;
666  }
667 
668  TList *list = dynamic_cast<TList*>(key->ReadObj());
669  if ( !list )
670  {
671  fxsec->Close();
672  printf("No list!");
673  continue;
674  }
675 
676  Float_t xsection = ((TProfile*)list->FindObject("h1Xsec")) ->GetBinContent(1);
677  Int_t ntrials = ((TH1F*) list->FindObject("h1Trials"))->GetBinContent(1);
678  fxsec->Close();
679 
680  xsArr->SetAt(xsection,index);
681  trArr->SetAt(ntrials,index);
682 
683  printf("recovered xs %f, ntrials %d, event %d\n",xsection,ntrials, index);
684 
685  } // fxsec exists
686  } // xs in AODs
687  }
688  }// xml analysis
689 
690  //------------------------------
691  // PROOF
692  //------------------------------
693 // else if (mode == mPROOF)
694 // {
695 //
696 // TFileCollection* ds= gProof->GetDataSet(kDatasetPROOF)->GetStagedSubset();
697 //
698 // gROOT->LoadMacro("/afs/in2p3.fr/group/alice/laf/dataset_management/CreateChainFromDataSet.C");
699 // chain = CreateChainFromDataSet(ds, kTreeName , kDatasetNMaxFiles);
700 // printf("chain has %d entries\n",chain->GetEntries());
701 // }
702 
703  gSystem->ChangeDirectory(ocwd.Data());
704 }
705 
706 //______________________________
710 //______________________________
712 {
713  Bool_t bRecalibrate = kFALSE;
714  Bool_t bBadChannel = kFALSE;
715 
716  TString sRun = "";
717 
718  for (int i=0; i< gApplication->Argc();i++)
719  {
720 #ifdef VERBOSEARGS
721  printf("Arg %d: %s\n",i,gApplication->Argv(i));
722 #endif
723 
724  sRun = "";
725 
726  if (!(strcmp(gApplication->Argv(i),"--recalibrate")))
727  bRecalibrate = atoi(gApplication->Argv(i+1));
728 
729  if (!(strcmp(gApplication->Argv(i),"--badchannel")))
730  bBadChannel = atoi(gApplication->Argv(i+1));
731 
732  if (!(strcmp(gApplication->Argv(i),"--year")))
733  kYear = atoi(gApplication->Argv(i+1));
734 
735  if (!(strcmp(gApplication->Argv(i),"--run")))
736  {
737  sRun = gApplication->Argv(i+1);
738  if ( sRun.Contains("LHC10") )
739  {
740  kYear = 2010;
741  }
742  else
743  {
744  if ( kRun <=0 )
745  {
746  kRun = atoi(gApplication->Argv(i+1));
747  }
748  else
749  printf("** Run number already set to %d, do not set to %d\n",kRun,atoi(gApplication->Argv(i+1)));
750  } // numeric run
751  } // --run available
752 
753  }// args loop
754 
755  // Check run number and decide kYear and kCollision, by default kCollision = "pp"
756  if ( !sRun.Contains("LHC") )
757  {
758  if ( kRun < 140000)
759  {
760  kYear = 2010;
761  kPeriod = "LHC10";
762  if( kRun >= 136851 )
763  {
764  kPeriod = "LHC10h";
765  kCollision = "PbPb";
766  }
767  }
768  else if( kRun < 170600)
769  {
770  kYear = 2011;
771  kPeriod = "LHC11";
772  if( kRun >= 166500 )
773  {
774  kPeriod = "LHC11h";
775  kCollision = "PbPb";
776  }
777  }
778  else if( kRun < 200000 )
779  {
780  kYear = 2012;
781  kPeriod = "LHC12";
782  if( kRun >= 194000 )
783  {
784  kPeriod = "LHC13";
785  kCollision = "pPb";
786  }
787  }
788  else if( kRun < 247000 )
789  {
790  kYear = 2015;
791  kPeriod = "LHC15";
792  if( kRun >= 244820 )
793  {
794  kPeriod = "LHC15o";
795  kCollision = "PbPb";
796  }
797  }
798  else if( kRun < 268875 )
799  {
800  kYear = 2016;
801  kPeriod = "LHC16";
802  if( kRun >= 265015 )
803  {
804  kPeriod = "LHC16q";
805  kCollision = "pPb";
806  }
807  }
808  else if( kRun < 283616 )
809  {
810  kYear = 2017;
811  kPeriod = "LHC17";
812  if( kRun == 280235 || kRun == 280234 )
813  {
814  kPeriod = "LHC17n";
815  kCollision = "PbPb"; // XeXe
816  }
817  }
818  else
819  {
820  kYear = 2018;
821  kPeriod = "LHC18";
822  // To be defined
823  //if( kRun >= XXXX )
824  //{
825  // kPeriod = "LHC18X";
826  // kCollision = "PbPb";
827  //}
828  }
829  }
830 
831  printf("*********************************************\n");
832  //printf("*** Settings recalibrate %d, remove bad channels %d, year %d, collision %s, run %d ***\n",
833  // bRecalibrate,bBadChannel, kYear,kCollision.Data(), kRun);
834  printf("*** Settings year %d, collision %s, run %d ***\n",kYear,kCollision.Data(), kRun);
835  printf("*********************************************\n");
836 
837 }
838 
839 //______________________________________________________________________________
853 //______________________________________________________________________________
855 {
856  Double_t xsection = 0 ;
857  UInt_t ntrials = 0 ;
858  Int_t nfiles = 0 ;
859 
860  xs = 0;
861  ntr = 0;
862  n = 0;
863  if( kInputData != "AOD" && tree )
864  {
865  nfiles = tree->GetEntries() ;
866 
867  tree->SetBranchAddress("xsection",&xsection);
868  tree->SetBranchAddress("ntrials" ,&ntrials );
869  for(Int_t i = 0; i < nfiles; i++)
870  {
871  tree->GetEntry(i);
872  if(xsection > 0)
873  {
874  xs += xsection ;
875  ntr += ntrials ;
876  n++;
877  }
878  cout << "xsection " <<xsection<<" ntrials "<<ntrials<<endl;
879  } // loop
880  }
881  else if( kInputData == "AOD" && xsArr )
882  {
883  nfiles = xsArr->GetSize();
884 
885  for(Int_t i = 0; i < nfiles; i++)
886  {
887  if(xsArr->GetAt(i) > 0)
888  {
889  xs += xsArr->GetAt(i) ;
890  ntr += trArr->GetAt(i) ;
891  n++;
892  }
893  cout << "xsection " <<xsArr->GetAt(i)<<" ntrials "<<trArr->GetAt(i)<<endl;
894  } // loop
895  }
896  else return kFALSE;
897 
898  xs = xs / n;
899  ntr = ntr / n;
900  cout << "-----------------------------------------------------------------"<<endl;
901  cout << "Average of "<< n <<" files: xsection " <<xs<<" ntrials "<<ntr<<endl;
902  cout << "-----------------------------------------------------------------"<<endl;
903 
904  return kTRUE;
905 }
906 
907 //_____________________________
911 //_____________________________
912 void LoadLibraries(Int_t /*mode*/)
913 {
914  // if (mode == mPROOF)
915  // {
916  // //TProof::Mgr("ccalpmaster")->SetROOTVersion("ALICE_v5-27-06b");
917  // gROOT->LoadMacro("/afs/in2p3.fr/group/alice/laf/EnableAliRootForLAF.C");
918  // TProof* proof = EnableAliRootForLAF("ccaplmaster",nPROOFWorkers.Data(),ccin2p3UserName.Data(),alienUserName.Data(),"",kFALSE,kTRUE,kTRUE,"OADB:ANALYSIS:ANALYSISalice:AOD:ESD:CORRFW:STEERBase:EMCALUtils:PHOSUtils:PWGCaloTrackCorrBase:PWGGACaloTrackCorrelations:PWGPPEMCAL");
919  //
920  // // TProof* proof = TProof::Open("ccaplmaster",Form("workers=%s",nPROOFWorkers.Data()));
921  //
922  // // //proof->ClearPackages();
923  // // proof->UploadPackage("STEERBase");
924  // // proof->UploadPackage("ESD");
925  // // proof->UploadPackage("AOD");
926  // // proof->UploadPackage("ANALYSIS");
927  // // proof->UploadPackage("OADB");
928  // // proof->UploadPackage("ANALYSISalice");
929  // // proof->UploadPackage("CORRFW");
930  // // //proof->UploadPackage("JETAN");
931  // // proof->UploadPackage("PHOSUtils");
932  // // proof->UploadPackage("EMCALUtils");
933  // // proof->UploadPackage("PWGCaloTrackCorrBase");
934  // // proof->UploadPackage("PWGGACaloTrackCorrelations");
935  // // proof->UploadPackage("PWGPPEMCAL");
936  //
937  // // proof->EnablePackage("STEERBase");
938  // // proof->EnablePackage("ESD");
939  // // proof->EnablePackage("AOD");
940  // // proof->EnablePackage("ANALYSIS");
941  // // proof->EnablePackage("OADB");
942  // // proof->EnablePackage("ANALYSISalice");
943  // // proof->EnablePackage("CORRFW");
944  // // //proof->EnablePackage("JETAN");
945  // // proof->EnablePackage("PHOSUtils");
946  // // proof->EnablePackage("EMCALUtils");
947  // // proof->EnablePackage("PWGCaloTrackCorrBase");
948  // // proof->EnablePackage("PWGGACaloTrackCorrelations");
949  // // proof->EnablePackage("PWGPPEMCAL");
950  // return;
951  // }
952 
953  //--------------------------------------
954  // Load the needed libraries via par files if modified
955  //--------------------------------------
956  //SetupPar("EMCALUtils");
957  //SetupPar("EMCALraw");
958  //SetupPar("EMCALbase");
959  //SetupPar("EMCALsim");
960  //SetupPar("EMCALrec");
961 
962  //SetupPar("PWGPPEMCAL");
963 
964  //SetupPar("PWGCaloTrackCorrBase");
965  //SetupPar("PWGGACaloTrackCorrelations");
966 
967  //SetupPar("PWGGAGammaConv");
968 
969  // needed for plugin?
970  gSystem->AddIncludePath("-I$ALICE_ROOT");
971  gSystem->AddIncludePath("-I$ALICE_PHYSICS");
972  gSystem->AddIncludePath("-I./");
973 }
974 
975 //___________________________
989 //________________________
991 {
992  //--------------------------------------------------------------------
993  // Load analysis libraries
994 
996  //gSystem->ListLibraries();
997 
998  //-----------------------------------------------------------------------------
999  // Create chain from ESD and from cross sections files, look below for options.
1000 
1001  // Set kInputData and kTreeName looking to the kINDIR
1003 
1004  // Check global analysis settings
1006 
1007  printf("*********************************************\n");
1008  printf("*** Input data < %s >, pass %s, tree < %s >, MC? < %d > ***\n",
1009  kInputData.Data(),kPass.Data(),kTreeName.Data(),kMC);
1010  printf("*********************************************\n");
1011 
1012  TChain * chain = new TChain(kTreeName) ;
1013  TChain * chainxs = new TChain("Xsection") ;
1014  CreateChain(mode, chain, chainxs);
1015 
1016  Double_t scale = -1;
1017  printf("===== kMC %d, chainxs %p\n",kMC,chainxs);
1018 
1019  if ( kMC )
1020  {
1021  //Get the cross section
1022  Double_t xsection = 0;
1023  Float_t ntrials = 0;
1024  Int_t nfiles = 0;
1025 
1026  Bool_t ok = GetAverageXsection(chainxs, xsection, ntrials, nfiles);
1027 
1028  printf("n xs files %d ntrials %f \n",nfiles, ntrials);
1029  if ( nfiles > 0 && ntrials > 0 )
1030  {
1031  if ( ok )
1032  {
1033  Int_t nEventsPerFile = chain->GetEntries() / nfiles;
1034 
1035  Double_t trials = ntrials / nEventsPerFile ;
1036 
1037  scale = xsection / trials;
1038 
1039  printf("Get Cross section : nfiles %d, nevents %lld, nevents per file %d \n",
1040  nfiles, chain->GetEntries(),nEventsPerFile);
1041  printf(" ntrials %2.2f, trials %2.2f, xs %2.2e, scale factor %2.2e\n",
1042  ntrials,trials,xsection,scale);
1043 
1044  if ( chainxs->GetEntries() != chain->GetEntries() )
1045  printf("CAREFUL: Number of files in data chain %lld, in cross section chain %lld \n",
1046  chainxs->GetEntries(),chain->GetEntries());
1047  } // ok
1048 
1049  // comment out this line in case the simulation did not have the cross section files produced in the directory
1050  if ( scale <= 0 || !ok )
1051  { printf( "STOP, cross section not available! nfiles %lld \n", chainxs->GetEntries() ) ; return ; }
1052  }
1053  }
1054 
1055  printf("*********************************************\n");
1056  printf("number of entries # %lld \n", chain->GetEntries()) ;
1057  printf("*********************************************\n");
1058 
1059  if ( !chain )
1060  {
1061  printf("STOP, no chain available\n");
1062  return;
1063  }
1064 
1065  AliLog::SetGlobalLogLevel(AliLog::kError);//Minimum prints on screen
1066 
1067  //------------------------------------------
1068  // Alien handler part
1069  //------------------------------------------
1070 // AliAnalysisGrid * alienHandler =0x0;
1071 // if ( mode==mPlugin )
1072 // {
1073 // // Create and configure the alien handler plugin
1074 // gROOT->LoadMacro("CreateAlienHandler.C");
1075 // alienHandler = CreateAlienHandler();
1076 // if ( !alienHandler ) return;
1077 // }
1078 
1079  //--------------------------------------
1080  //--------------------------------------
1081  // If automatic check does not work,
1082  // force here the collision type, period etc
1083 // kYear = 2011;
1084 // kPeriod = "LHC11c";
1085 // kCollision = "pp";
1086 // kMC = kTRUE;
1087 // kInputData = "AOD";
1088  //--------------------------------------
1089  //--------------------------------------
1090 
1091  //--------------------------------------
1092  // Make the analysis manager
1093  //-------------------------------------
1094  AliAnalysisManager *mgr = new AliAnalysisManager("Manager", "Manager");
1095  //AliAnalysisManager::SetUseProgressBar(kTRUE);
1096  //mgr->SetSkipTerminate(kTRUE);
1097  //mgr->SetNSysInfo(1);
1098 
1099  // Connect plugin to the analysis manager
1100 // if ( mode == mPlugin )
1101 // {
1102 // mgr->SetGridHandler(alienHandler);
1103 // }
1104 
1105  // MC handler
1106  if ( (kMC || kInputData == "MC") && !kInputData.Contains("AOD") )
1107  {
1108  AliMCEventHandler* mcHandler = new AliMCEventHandler();
1109  mcHandler->SetReadTR(kFALSE);//Do not search TrackRef file
1110  mgr->SetMCtruthEventHandler(mcHandler);
1111  if ( kInputData == "MC" )
1112  {
1113  cout<<"MC INPUT EVENT HANDLER"<<endl;
1114  mgr->SetInputEventHandler(NULL);
1115  }
1116  }
1117 
1118  // AOD output handler, very special analysis
1119  if ( kInputData != "deltaAOD" && outAOD)
1120  {
1121  cout<<"Init output handler"<<endl;
1122  AliAODHandler* aodoutHandler = new AliAODHandler();
1123  aodoutHandler->SetOutputFileName("aod.root");
1125  mgr->SetOutputEventHandler(aodoutHandler);
1126  }
1127 
1128  //=========
1129  // Input
1130 
1131  if ( kInputData == "ESD" )
1132  {
1133  // ESD handler
1134  AliESDInputHandler *esdHandler = new AliESDInputHandler();
1135  esdHandler->SetReadFriends(kFALSE);
1136  mgr->SetInputEventHandler(esdHandler);
1137  cout<<"ESD handler "<<mgr->GetInputEventHandler()<<endl;
1138  }
1139  else if ( kInputData.Contains("AOD") )
1140  {
1141  // AOD handler
1142  AliAODInputHandler *aodHandler = new AliAODInputHandler();
1143  mgr->SetInputEventHandler(aodHandler);
1144  if(kInputData == "deltaAOD") aodHandler->AddFriend((char*)"deltaAODCaloTrackCorr.root");
1145  cout<<"AOD handler "<<mgr->GetInputEventHandler()<<endl;
1146  }
1147 
1148  //mgr->RegisterExternalFile("deltaAODCaloTrackCorr.root");
1149  //mgr->SetDebugLevel(1); // For debugging, do not uncomment if you want no messages.
1150 
1151  TString outputFile = AliAnalysisManager::GetCommonFileName();
1152 
1153  //-------------------------------------------------------------------------
1154  // Define task, put here any other task that you want to use.
1155  //-------------------------------------------------------------------------
1156 
1157  // Physics selection
1158  if ( !kMC )
1159  {
1160  gROOT->LoadMacro("$ALICE_PHYSICS/OADB/macros/AddTaskPhysicsSelection.C");
1161  AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection(kMC,kTRUE);
1162  }
1163 
1164  // Centrality, valid for Run1, but superseeded by new task below
1165 // if ( bMultiplicity && kCollision.Contains("Pb") )
1166 // {
1167 // if ( kYear < 200000 && kInputData=="ESD" )
1168 // gROOT->LoadMacro("$ALICE_PHYSICS/OADB/macros/AddTaskCentrality.C");
1169 // AliCentralitySelectionTask *taskCentrality = AddTaskCentrality();
1170 // }
1171 
1172  if ( bMultiplicity )
1173  {
1174  // New centrality/multiplicity selector
1175  gROOT->LoadMacro("$ALICE_PHYSICS/OADB/COMMON/MULTIPLICITY/macros/AddTaskMultSelection.C");
1176  AliMultSelectionTask * task = AddTaskMultSelection(kFALSE); // user mode:
1177 
1178  // use the default calibration for runs which have not yet been calibrated
1179  task->SetUseDefaultCalib (kTRUE); // data
1180  task->SetUseDefaultMCCalib(kTRUE); // MC
1181  }
1182 
1183 // if ( kCollision=="PbPb" )
1184 // {
1185 // gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskVZEROEPSelection.C");
1186 // AliVZEROEPSelectionTask * EPV0 = AddTaskVZEROEPSelection();
1187 //
1188 // gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskEventplane.C");
1189 // AliEPSelectionTask * EP = AddTaskEventplane();
1190 // }
1191 
1192  // OCDB connect
1193  //
1194  if ( bEMCCorrFra || bEMCCluster )
1195  {
1196  //gROOT->LoadMacro("$ALICE_PHYSICS/PWGPP/PilotTrain/AddTaskCDBconnect.C");
1197  gROOT->LoadMacro("AddTaskCDBconnect.C");
1198  AddTaskCDBconnect();
1199  ((AliTaskCDBconnect*)(AliAnalysisManager::GetAnalysisManager()->GetTask("CDBconnect")))->SetFallBackToRaw(kTRUE);
1200  }
1201 
1202  // EMCAL correction framework
1203  //
1204  if ( bEMCCorrFra && !bEMCCluster )
1205  {
1206  printf("INIT EMCal corrections\n");
1207  gROOT->LoadMacro("$ALICE_PHYSICS/PWG/EMCAL/macros/AddTaskEmcalCorrectionTask.C");
1208  AliEmcalCorrectionTask * emcorr = AddTaskEmcalCorrectionTask();
1209 
1210  // Data or MC specific configurations
1211  if ( !kMC )
1212  {
1213  emcorr->SetUserConfigurationFilename("$ALICE_PHYSICS_SRC/PWGGA/CaloTrackCorrelations/yaml/EMCalCorrConfig_Gamma_Data.yaml");
1214  }
1215  else
1216  {
1217  // Without cross-talk
1218  if ( xTalkEmul == 0 )
1219  emcorr->SetUserConfigurationFilename("$ALICE_PHYSICS_SRC/PWGGA/CaloTrackCorrelations/yaml/EMCalCorrConfig_MC_ClV1.yaml");
1220  // With cross-talk
1221  else
1222  {
1223  //emcorr->SetUserConfigurationFilename("$ALICE_PHYSICS_SRC/PWGGA/CaloTrackCorrelations/yaml/EMCalCorrConfig_MC_Run1_ClV1_xTalk.yaml");
1224  emcorr->SetUserConfigurationFilename("$ALICE_PHYSICS_SRC/PWGGA/CaloTrackCorrelations/yaml/EMCalCorrConfig_MC_Run1_ClV1_xTalk_ECellCut.yaml");
1225  //emcorr->SetUserConfigurationFilename("$ALICE_PHYSICS_SRC/PWGGA/CaloTrackCorrelations/yaml/EMCalCorrConfig_MC_Run1_ClV1_xTalk_ECellCut_Leak5MeV.yaml");
1226  }
1227  }
1228 
1229  //emcorr->SelectCollisionCandidates( AliVEvent::kAnyINT | AliVEvent::kEMC7 | AliVEvent::kEMC8 | AliVEvent::kEMC1 | AliVEvent::kEMCEGA | AliVEvent::kEMCEJE );
1230 
1232  emcorr->Initialize();
1233  }
1234 
1235  // Clusterization task
1236  // For experts
1237  //
1238  TString clustersArray = "";
1239  TString cellsArray = "";
1240  if ( !bEMCCorrFra && bEMCCluster )
1241  {
1242  printf("INIT EMCal Clusterizer\n");
1243  gROOT->LoadMacro("$ALICE_PHYSICS/PWGPP/EMCAL/macros/AddTaskEMCALClusterize.C");
1244 
1245  Int_t clTM = 2; // Do track matching, 0 no, 1 TPC only, 2 hybrid
1246  Bool_t exo = kTRUE; // Remove exotic cells
1247 
1248  Bool_t clnonlin = kTRUE; // Apply non linearity (clusterizer), CAREFUL check that not done in analysis
1249  Int_t minEcell = 100; // 50 MeV (10 MeV used in reconstruction)
1250  Int_t minEseed = 500; // 100 MeV
1251  Int_t dTime = 10000; // open
1252  Int_t wTime = 10000; // open
1253  Int_t unfMinE = 15; // Remove cells with less than 15 MeV from cluster after unfolding
1254  Int_t unfFrac = 1; // Remove cells with less than 1% of cluster energy after unfolding
1255  Bool_t updateCell= kTRUE; // Calibrate cells and modify them on the fly
1256  Bool_t filterEvents = kFALSE; // Filter events with activity in EMCal
1257  Int_t cenBin[] = {-1,-1}; // Centrality bin min-max of accepted events. {-1,-1} take all
1258  // Calibration, bad map ...
1259 
1260  Bool_t calibEE = kFALSE; // It is set automatically, but here we force to use ir or not in any case
1261  Bool_t calibTT = kFALSE; // It is set automatically, but here we force to use ir or not in any case
1262  Bool_t badMap = kTRUE; // It is set automatically, but here we force to use it or not in any case
1263 
1265  AddTaskEMCALClusterize(clustersArray, outAOD, kMC, exo,"V1","", clTM,
1266  minEcell,minEseed,dTime,wTime,unfMinE,unfFrac,
1267  calibEE,badMap,calibTT,clnonlin,
1268  cenBin[0],cenBin[1],-1,1,1,filterEvents,xTalkEmul,updateCell);
1269 
1270  //cl->GetRecoUtils()->SwitchOffRunDepCorrection(); // Off for Run2 for the moment
1271 
1272  // Force option different than clTM
1273  // cl->GetRecoUtils()->SwitchOnAODHybridTracksMatch();
1274  // cl->GetRecoUtils()->SwitchOnAODTPCOnlyTracksMatch();
1275  // cl->GetRecoUtils()->SetAODTrackFilterMask(128);
1276  //
1277  if ( kMC )
1278  {
1279  cl->SwitchOnUseClusterMCLabelForCell(0) ; // For Old Run1 MC
1281  }
1282 
1283  // cl->GetRecoUtils()->SetWarmChannelAsGood();
1284  // cl->GetRecoUtils()->SetDeadChannelAsGood();
1285  // cl->GetRecoUtils()->SetHotChannelAsGood();
1286 
1287  clustersArray = Form("V1_Ecell%d_Eseed%d",minEcell,minEseed);
1288  cl->SetAODBranchName(clustersArray);
1289 
1290  if ( updateCell )
1291  {
1292  cellsArray = "Cells_Updated";
1293  if ( xTalkEmul > 0 )
1294  cellsArray = "Cells_xTalkEmulation";
1295  }
1296  cl->SetAODCellsName (cellsArray);
1297 
1298  // cl->SetMaxEvent(20);
1299  // cl->SetDebugLevel(100);
1300  }
1301 
1302  /*
1303  // -----------------
1304  // Photon conversion
1305  // -----------------
1306 
1307  if(kInputData=="ESD"){
1308  printf("* Configure photon conversion analysis in macro \n");
1309  TString arguments = "-run-on-train -use-own-xyz -force-aod -mc-off ";
1310  gROOT->LoadMacro("$ALICE_PHYSICS/PWGGA/GammaConversion/macros/ConfigGammaConversion.C");
1311  AliAnalysisTaskGammaConversion * taskGammaConversion =
1312  ConfigGammaConversion(arguments,mgr->GetCommonInputContainer());
1313  taskGammaConversion->SelectCollisionCandidates();
1314 
1315  // Gamma Conversion AOD to AODPWG4Particle
1316  AliAnalysisTaskGCPartToPWG4Part * taskGCToPC = new AliAnalysisTaskGCPartToPWG4Part("GCPartToPWG4Part");
1317  taskGCToPC->SetGammaCutId("90035620401003321022000000090");
1318  mgr->AddTask(taskGCToPC);
1319  mgr->ConnectInput (taskGCToPC, 0, mgr->GetCommonInputContainer() );
1320  mgr->ConnectOutput (taskGCToPC, 0, mgr->GetCommonOutputContainer());
1321  }
1322  */
1323 
1324  // -----------------
1325  // CaloTrack Correlations Task
1326  // -----------------
1327 
1328  // Common settings for Correlation and QA tasks
1329  Bool_t calibrate = kFALSE;
1330  Int_t minCen = -1;
1331  Int_t maxCen = -1;
1332  Int_t debug = -1;
1333 
1334  // Possible triggered events
1335  TString lTrig[] = {"default","EMCAL_L0","EMCAL_L1","EMCAL_L2"};
1336  Int_t nTrig = 4;
1337  Int_t trig0 = 0;
1338  Int_t fixTrig = -1;
1339  if ( fixTrig >= 0 )
1340  {
1341  trig0 = fixTrig;
1342  nTrig = fixTrig+1;
1343  }
1344 
1345  // -----------------
1346  // Photon/Pi0/Isolation/Correlation etc
1347  // -----------------
1348 
1349  if ( bAnalysis )
1350  {
1351  Int_t rejectEMCTrig = 0;
1352  Bool_t nonLinOn = kFALSE;
1353  Float_t shshMax = 0.27;
1354  Float_t isoCone = 0.4;
1355  Float_t isoConeMin = -1;
1356  Float_t isoPtTh = 1;
1357  Int_t isoMethod = AliIsolationCut::kSumPtIC;
1359  Int_t leading = 0;
1360  Int_t tm = 2;
1361  Bool_t mixOn = kFALSE;
1362  TString outputfile = "";
1363  Bool_t printSettings = kFALSE;
1364  TString cutSelected = "SPDPileUp";//"_ITSonly";
1365  TString analysisSelected = "Photon_InvMass"; // Activate photon selection and invariant mass analysis
1366  //"Photon_InvMass_MergedPi0_Isolation_Correlation_ClusterShape_PerSM_PerTCard_QA_Charged_Bkg"; // More options
1367 
1368  gROOT->LoadMacro("$ALICE_PHYSICS/PWGGA/CaloTrackCorrelations/macros/AddTaskGammaHadronCorrelationSelectAnalysis.C");
1369 
1370  for(Int_t itrig = trig0; itrig < nTrig; itrig++)
1371  {
1372  if ( itrig > 0 && kMC ) continue; // Any MC has only one kind of trigger
1373 
1375  ("EMCAL",kMC,kYear,kCollision,kPeriod,rejectEMCTrig,clustersArray,cutSelected,calibrate,nonLinOn, analysisSelected,
1376  shshMax,isoCone,isoConeMin,isoPtTh,isoMethod ,isoContent,leading,
1377  tm,minCen,maxCen,mixOn,outputfile,printSettings,debug,lTrig[itrig]);
1378 
1379  emc->GetAnalysisMaker()->GetReader()->SetEMCALCellsListName(cellsArray);
1381 
1382  // Careful, need time calibration to use time cuts defined in macro
1383  if ( !bEMCCluster && !bEMCCorrFra && !calibrate )
1384  {
1386  emc->GetAnalysisMaker()->GetReader()->SetEMCALTimeCut(-1e10,1e10); // Open time cut
1387  }
1388 
1389  // emc ->SelectCollisionCandidates( AliVEvent::kINT7 | AliVEvent::kCentral | AliVEvent::kSemiCentral | AliVEvent::kMB ); // Done internally, here as example
1390  // emc->GetAnalysisMaker()->GetReader()->SetNameOfMCEventHederGeneratorToAccept("Pythia");
1391  // emc->GetAnalysisMaker()->GetReader()->SwitchOffShowerShapeSmearing();
1392  // emc->GetAnalysisMaker()->GetReader()->SetSmearingFunction(AliCaloTrackReader::kNoSmearing);
1393 
1394  // emc ->GetAnalysisMaker()->GetReader()->SwitchOnAliCentrality () ;
1395  // emc->SetLastEvent(maxEvent);
1396 
1397  // // Example on how to modify settings of a sub-wagon if not in corresponding macro
1398  // TList * anaList = emc->GetAnalysisMaker()->GetListOfAnalysisContainers();
1399  // AliAnaClusterShapeCorrelStudies * shapeAna = (AliAnaClusterShapeCorrelStudies*) anaList->At(9);
1400  // shapeAna->SetNCellBinLimits(3); // no analysis on predefined bins in nCell
1401  // shapeAna->SetDistToBadMin(2);
1402  // shapeAna->SwitchOnStudyColRowFromCellMax() ;
1403  // shapeAna->Print("");
1404 
1405  if ( kYear < 2014 ) continue;
1406 
1407  TString dcalTrig = lTrig[itrig];
1408  dcalTrig.ReplaceAll("EM","D");
1409 
1411  ("DCAL",kMC,kYear,kCollision,kPeriod,rejectEMCTrig,clustersArray,cutSelected,calibrate,nonLinOn, analysisSelected,
1412  shshMax,isoCone,isoConeMin,isoPtTh,isoMethod ,isoContent,leading,
1413  tm,minCen,maxCen,mixOn,outputfile,printSettings,-1,lTrig[itrig]);
1414  dmc->GetAnalysisMaker()->GetReader()->SetEMCALCellsListName(cellsArray);
1416 
1417  // Careful, need time calibration to use time cuts defined in macro
1418  if ( !bEMCCluster && !bEMCCorrFra && !calibrate )
1419  {
1421  dmc->GetAnalysisMaker()->GetReader()->SetEMCALTimeCut(-1e10,1e10); // Open time cut
1422  }
1423  } // trigger loop
1424  } // bAnalysis
1425 
1426  // -----------------
1427  // QA train analysis, comment out since it cannot compile with bAnalysis uncommented
1428  // -----------------
1429 
1430 // if ( bAnalysisQA )
1431 // {
1432 // Int_t minTime = -1000;
1433 // Int_t maxTime = 1000;
1434 // Bool_t qaan = kTRUE;
1435 // Bool_t hadronan = kTRUE;
1436 //
1437 // gROOT->LoadMacro("$ALICE_PHYSICS/PWGGA/CaloTrackCorrelations/macros/QA/AddTaskPi0IMGammaCorrQA.C");
1438 //
1439 // // To test the train environment variables
1440 // //
1441 // {
1442 // char col [1024];
1443 // char tag [1024];
1444 // char mc [1024];
1445 //
1446 // sprintf(col,"%s",kCollision.Data());
1447 // sprintf(tag,"%s",kPeriod .Data());
1448 // if ( kMC ) sprintf(mc,"MC" );
1449 // else sprintf(mc,"RAW");
1450 //
1451 // gSystem->Setenv("ALIEN_JDL_LPMINTERACTIONTYPE",col);
1452 // gSystem->Setenv("ALIEN_JDL_LPMPRODUCTIONTAG" ,tag);
1453 // gSystem->Setenv("ALIEN_JDL_LPMPRODUCTIONTYPE" ,mc );
1454 // }
1455 //
1456 // for(Int_t itrig = trig0; itrig < nTrig; itrig++)
1457 // {
1458 // if ( itrig > 0 && kMC ) continue; // Any MC has only one kind of trigger
1459 //
1460 // AliAnalysisTaskCaloTrackCorrelation * qaTrain = AddTaskPi0IMGammaCorrQA
1461 // ("EMCAL",kMC,"","",qaan,hadronan,calibrate,minTime,maxTime,
1462 // minCen,maxCen,debug,lTrig[itrig]);
1463 // }
1464 //
1465 // // Other QA
1466 // // Detector QA
1467 // // gROOT->LoadMacro("$ALICE_PHYSICS/PWGGA/CaloTrackCorrelations/macros/QA/AddTaskCalorimeterQA.C");
1468 // // AliAnalysisTaskCaloTrackCorrelation * qatask = AddTaskCalorimeterQA(kInputData,kYear,kPrint,kMC);
1469 // //
1470 // // Very old Trigger QA, not in use
1471 // // gROOT->LoadMacro("$ALICE_PHYSICS/PWGPP/EMCAL/macros/AddTaskEMCALTriggerQA.C");
1472 // // AliAnalysisTaskEMCALTriggerQA * qatrigtask = AddTaskEMCALTriggerQA();
1473 // } // bAnalysis QA
1474 
1475  // // Simple event counting tasks
1476  //
1477  // gROOT->LoadMacro("$ALICE_PHYSICS/PWGGA/CaloTrackCorrelations/macros/AddTaskCounter.C");
1478  //
1479  // AliAnalysisTaskCounter* count = AddTaskCounter("",kMC); // All, fill histo with cross section and trials if kMC is true
1480  // AliAnalysisTaskCounter* countmb = AddTaskCounter("MB"); // Min Bias
1481  // AliAnalysisTaskCounter* countany = AddTaskCounter("Any");
1482  // AliAnalysisTaskCounter* countint = AddTaskCounter("AnyINT");// Min Bias
1483  //
1484  // if ( !kMC )
1485  // {
1486  // AliAnalysisTaskCounter* countemg = AddTaskCounter("EMCEGA");
1487  // AliAnalysisTaskCounter* countemj = AddTaskCounter("EMCEJE");
1488  // if ( kCollision=="PbPb" )
1489  // {
1490  // AliAnalysisTaskCounter* countcen = AddTaskCounter("Central");
1491  // AliAnalysisTaskCounter* countsce = AddTaskCounter("SemiCentral");
1492  // AliAnalysisTaskCounter* countssce= AddTaskCounter("SemiOrCentral");
1493  // AliAnalysisTaskCounter* countphP = AddTaskCounter("PHOSPb");
1494  // }
1495  // else
1496  // {
1497  // AliAnalysisTaskCounter* countem1 = AddTaskCounter("EMC1"); // Trig Th > 1.5 GeV approx
1498  // AliAnalysisTaskCounter* countem7 = AddTaskCounter("EMC7"); // Trig Th > 4-5 GeV
1499  // AliAnalysisTaskCounter* countphp = AddTaskCounter("PHOS");
1500  // }
1501  // }
1502  //
1503  //
1504 
1505 
1506  //-----------------------
1507  // Run the analysis
1508  //-----------------------
1509  mgr->InitAnalysis();
1510  mgr->PrintStatus();
1511 
1512  if (mode == mPlugin) mgr->StartAnalysis("grid");
1513  else if (mode == mPROOF ) mgr->StartAnalysis("proof",chain);
1514  else mgr->StartAnalysis("local",chain);
1515 
1516  cout <<" Analysis ended sucessfully "<< endl ;
1517 }
1518 
1519 
Bool_t bMultiplicity
Do photon/pi0 isolation correlation analysis.
Definition: ana.C:161
Steering task for the EMCal correction framework.
Analyze locally files in your computer.
Definition: ana.C:102
AliAnalysisTaskCaloTrackCorrelation * AddTaskGammaHadronCorrelationSelectAnalysis(TString calorimeter="EMCAL", Bool_t simulation=kFALSE, Int_t year=-1, TString col="", TString period="", Int_t rejectEMCTrig=0, TString clustersArray="", TString gloCutsString="", Bool_t calibrate=kFALSE, Bool_t nonLinOn=kFALSE, TString analysisString="Photon_MergedPi0_DecayPi0_Isolation_Correlation_QA_Charged", Float_t shshMax=0.27, Float_t isoCone=0.4, Float_t isoConeMin=-1, Float_t isoPtTh=2, Int_t isoMethod=AliIsolationCut::kSumPtIC, Int_t isoContent=AliIsolationCut::kNeutralAndCharged, Int_t leading=0, Int_t tm=2, Int_t minCen=-1, Int_t maxCen=-1, Bool_t mixOn=kTRUE, TString outputfile="", Bool_t printSettings=kFALSE, Int_t debug=0, const char *trigSuffix="EMC7")
anaModes
Different analysis modes.
Definition: ana.C:99
double Double_t
Definition: External.C:58
Bool_t GetAverageXsection(TTree *tree, Double_t &xs, Float_t &ntr, Int_t &n)
Definition: ana.C:854
char * kXML
Maximum number of files to analyze.
Definition: ana.C:128
void SetEMCALCellsListName(TString name)
void CreateChain(const Int_t mode, TChain *chain, TChain *chainxs)
Fills chain with data files paths.
Definition: ana.C:468
TSystem * gSystem
char * kPattern
Directory path to files.
Definition: ana.C:113
TArrayF * xsArr
Name of file with pT-hard cross sections.
Definition: ana.C:138
void SetNonLinearityFunction(Int_t fun)
TString kPass
"esdTree" or "aodTree" or "TE" for pure MC kinematics analysis
Definition: ana.C:150
void ana(Int_t mode=mLocal)
Definition: ana.C:990
Int_t xTalkEmul
Use the EMCal correction framework.
Definition: ana.C:157
void SetUserConfigurationFilename(std::string name)
Set the path to the user configuration filename.
TString kCollision
Run period.
Definition: ana.C:147
Bool_t kMC
Set some default values, but used values are set in the code!
Definition: ana.C:143
Int_t kYear
ESD, AOD, MC, deltaAOD.
Definition: ana.C:145
TArrayI * trArr
Definition: ana.C:139
void CheckEnvironmentVariables()
Definition: ana.C:711
TString kPeriod
Year of data.
Definition: ana.C:146
Bool_t bEMCCluster
Run number.
Definition: ana.C:155
char * kInDir
Definition: ana.C:112
TString kTreeName
Create output AOD, needed by some.
Definition: ana.C:149
int Int_t
Definition: External.C:63
unsigned int UInt_t
Definition: External.C:33
float Float_t
Definition: External.C:68
Int_t kRun
"passX"
Definition: ana.C:151
Bool_t outAOD
Collision type: pp, pPb, PbPb.
Definition: ana.C:148
Int_t mode
Definition: anaM.C:41
Analyze files on GRID with Plugin.
Definition: ana.C:104
Analyze files on GRID with Plugin.
Definition: ana.C:103
Configuration of (isolated) gamma/pi0-hadron analysis with multiple cuts.
void CheckInputData(const Int_t mode)
Sets input data and tree strings.
Definition: ana.C:213
void SetupPar(char *pararchivename)
Execute multiplicity task.
Definition: ana.C:168
void LoadLibraries(Int_t)
Definition: ana.C:912
void SetEMCALTimeCut(Double_t a, Double_t b)
Main class conecting the CaloTrackCorrelations package and Analysis Frame.
TFile * file
TList with histograms for a given trigger.
const char * kXSFileName
Global name for the xml collection file with data on grid.
Definition: ana.C:135
AliAnalysisTaskEMCALClusterize * AddTaskEMCALClusterize(const char *clusArrTit="EMCAL_Clusters_New", const Bool_t bFillAOD=kFALSE, const Int_t bMC=kFALSE, const Bool_t exotic=kTRUE, const TString name="V1Unfold", const TString trigger="", const Int_t tm=1, const Int_t minEcell=50, const Int_t minEseed=100, const Int_t maxDeltaT=250, const Int_t timeWindow=1000, const Int_t minEUnf=15, const Int_t minFrac=1, const Bool_t bRecalE=kTRUE, const Bool_t bBad=kTRUE, const Bool_t bRecalT=kTRUE, const Bool_t bNonLine=kFALSE, const Int_t minCen=-1, const Int_t maxCen=-1, const Float_t clusterEnergyCutEvent=-1, const Int_t nRowDiff=1, const Int_t nColDiff=1, const Bool_t skipOrReject=kFALSE, const Int_t tCardMimic=0, const Bool_t cellUpd=kTRUE)
Int_t kFile
Common pattern in directory name containing files.
Definition: ana.C:114
Configuration of EMCal re-clusterization analysis task.
bool Bool_t
Definition: External.C:53
AliCaloTrackReader * GetReader()
TString kInputData
With real data kMC = kFALSE.
Definition: ana.C:144
Bool_t bAnalysis
Activate cross-talk emulation, 0 -no, 1 do not subtract induced energy from reference cell...
Definition: ana.C:159
Bool_t bEMCCorrFra
Use the EMCal clusterization task.
Definition: ana.C:156
void Initialize(bool removeDummyTask=false)
Reclusterize EMCal clusters, put them in a new branch for other following analysis.
Definition: ana.C:101