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