AliPhysics  59e0e03 (59e0e03)
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());
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");
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 // gROOT->LoadMacro("/afs/in2p3.fr/group/alice/laf/dataset_management/CreateChainFromDataSet.C");
695 // chain = CreateChainFromDataSet(ds, kTreeName , kDatasetNMaxFiles);
696 // printf("chain has %d entries\n",chain->GetEntries());
697 // }
698 
699  gSystem->ChangeDirectory(ocwd.Data());
700 }
701 
702 //______________________________
706 //______________________________
708 {
709  Bool_t bRecalibrate = kFALSE;
710  Bool_t bBadChannel = kFALSE;
711 
712  TString sRun = "";
713 
714  for (int i=0; i< gApplication->Argc();i++)
715  {
716 #ifdef VERBOSEARGS
717  printf("Arg %d: %s\n",i,gApplication->Argv(i));
718 #endif
719 
720  sRun = "";
721 
722  if (!(strcmp(gApplication->Argv(i),"--recalibrate")))
723  bRecalibrate = atoi(gApplication->Argv(i+1));
724 
725  if (!(strcmp(gApplication->Argv(i),"--badchannel")))
726  bBadChannel = atoi(gApplication->Argv(i+1));
727 
728  if (!(strcmp(gApplication->Argv(i),"--year")))
729  kYear = atoi(gApplication->Argv(i+1));
730 
731  if (!(strcmp(gApplication->Argv(i),"--run")))
732  {
733  sRun = gApplication->Argv(i+1);
734  if ( sRun.Contains("LHC10") )
735  {
736  kYear = 2010;
737  }
738  else
739  {
740  if ( kRun <=0 )
741  {
742  kRun = atoi(gApplication->Argv(i+1));
743  }
744  else
745  printf("** Run number already set to %d, do not set to %d\n",kRun,atoi(gApplication->Argv(i+1)));
746  } // numeric run
747  } // --run available
748 
749  }// args loop
750 
751  // Check run number and decide kYear and kCollision, by default kCollision = "pp"
752  if ( !sRun.Contains("LHC") )
753  {
754  if ( kRun < 140000)
755  {
756  kYear = 2010;
757  kPeriod = "LHC10";
758  if( kRun >= 136851 )
759  {
760  kPeriod = "LHC10h";
761  kCollision = "PbPb";
762  }
763  }
764  else if( kRun < 170600)
765  {
766  kYear = 2011;
767  kPeriod = "LHC11";
768  if( kRun >= 166500 )
769  {
770  kPeriod = "LHC11h";
771  kCollision = "PbPb";
772  }
773  }
774  else if( kRun < 200000 )
775  {
776  kYear = 2012;
777  kPeriod = "LHC12";
778  if( kRun >= 194000 )
779  {
780  kPeriod = "LHC13";
781  kCollision = "pPb";
782  }
783  }
784  else if( kRun < 247000 )
785  {
786  kYear = 2015;
787  kPeriod = "LHC15";
788  if( kRun >= 244820 )
789  {
790  kPeriod = "LHC15o";
791  kCollision = "PbPb";
792  }
793  }
794  else if( kRun < 268875 )
795  {
796  kYear = 2016;
797  kPeriod = "LHC16";
798  if( kRun >= 265015 )
799  {
800  kPeriod = "LHC16q";
801  kCollision = "pPb";
802  }
803  }
804  else if( kRun < 283616 )
805  {
806  kYear = 2017;
807  kPeriod = "LHC17";
808  if( kRun == 280235 || kRun == 280234 )
809  {
810  kPeriod = "LHC17n";
811  kCollision = "PbPb"; // XeXe
812  }
813  }
814  else
815  {
816  kYear = 2018;
817  kPeriod = "LHC18";
818  // To be defined
819  //if( kRun >= XXXX )
820  //{
821  // kPeriod = "LHC18X";
822  // kCollision = "PbPb";
823  //}
824  }
825  }
826 
827  printf("*********************************************\n");
828  //printf("*** Settings recalibrate %d, remove bad channels %d, year %d, collision %s, run %d ***\n",
829  // bRecalibrate,bBadChannel, kYear,kCollision.Data(), kRun);
830  printf("*** Settings year %d, collision %s, run %d ***\n",kYear,kCollision.Data(), kRun);
831  printf("*********************************************\n");
832 
833 }
834 
835 //______________________________________________________________________________
849 //______________________________________________________________________________
851 {
852  Double_t xsection = 0 ;
853  UInt_t ntrials = 0 ;
854  Int_t nfiles = 0 ;
855 
856  xs = 0;
857  ntr = 0;
858  n = 0;
859  if( kInputData != "AOD" && tree )
860  {
861  nfiles = tree->GetEntries() ;
862 
863  tree->SetBranchAddress("xsection",&xsection);
864  tree->SetBranchAddress("ntrials" ,&ntrials );
865  for(Int_t i = 0; i < nfiles; i++)
866  {
867  tree->GetEntry(i);
868  if(xsection > 0)
869  {
870  xs += xsection ;
871  ntr += ntrials ;
872  n++;
873  }
874  cout << "xsection " <<xsection<<" ntrials "<<ntrials<<endl;
875  } // loop
876  }
877  else if( kInputData == "AOD" && xsArr )
878  {
879  nfiles = xsArr->GetSize();
880 
881  for(Int_t i = 0; i < nfiles; i++)
882  {
883  if(xsArr->GetAt(i) > 0)
884  {
885  xs += xsArr->GetAt(i) ;
886  ntr += trArr->GetAt(i) ;
887  n++;
888  }
889  cout << "xsection " <<xsArr->GetAt(i)<<" ntrials "<<trArr->GetAt(i)<<endl;
890  } // loop
891  }
892  else return kFALSE;
893 
894  xs = xs / n;
895  ntr = ntr / n;
896  cout << "-----------------------------------------------------------------"<<endl;
897  cout << "Average of "<< n <<" files: xsection " <<xs<<" ntrials "<<ntr<<endl;
898  cout << "-----------------------------------------------------------------"<<endl;
899 
900  return kTRUE;
901 }
902 
903 //_____________________________
907 //_____________________________
908 void LoadLibraries(Int_t /*mode*/)
909 {
910  // if (mode == mPROOF)
911  // {
912  // //TProof::Mgr("ccalpmaster")->SetROOTVersion("ALICE_v5-27-06b");
913  // gROOT->LoadMacro("/afs/in2p3.fr/group/alice/laf/EnableAliRootForLAF.C");
914  // 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");
915  //
916  // // TProof* proof = TProof::Open("ccaplmaster",Form("workers=%s",nPROOFWorkers.Data()));
917  //
918  // // //proof->ClearPackages();
919  // // proof->UploadPackage("STEERBase");
920  // // proof->UploadPackage("ESD");
921  // // proof->UploadPackage("AOD");
922  // // proof->UploadPackage("ANALYSIS");
923  // // proof->UploadPackage("OADB");
924  // // proof->UploadPackage("ANALYSISalice");
925  // // proof->UploadPackage("CORRFW");
926  // // //proof->UploadPackage("JETAN");
927  // // proof->UploadPackage("PHOSUtils");
928  // // proof->UploadPackage("EMCALUtils");
929  // // proof->UploadPackage("PWGCaloTrackCorrBase");
930  // // proof->UploadPackage("PWGGACaloTrackCorrelations");
931  // // proof->UploadPackage("PWGPPEMCAL");
932  //
933  // // proof->EnablePackage("STEERBase");
934  // // proof->EnablePackage("ESD");
935  // // proof->EnablePackage("AOD");
936  // // proof->EnablePackage("ANALYSIS");
937  // // proof->EnablePackage("OADB");
938  // // proof->EnablePackage("ANALYSISalice");
939  // // proof->EnablePackage("CORRFW");
940  // // //proof->EnablePackage("JETAN");
941  // // proof->EnablePackage("PHOSUtils");
942  // // proof->EnablePackage("EMCALUtils");
943  // // proof->EnablePackage("PWGCaloTrackCorrBase");
944  // // proof->EnablePackage("PWGGACaloTrackCorrelations");
945  // // proof->EnablePackage("PWGPPEMCAL");
946  // return;
947  // }
948 
949  //--------------------------------------
950  // Load the needed libraries via par files if modified
951  //--------------------------------------
952  //SetupPar("EMCALUtils");
953  //SetupPar("EMCALraw");
954  //SetupPar("EMCALbase");
955  //SetupPar("EMCALsim");
956  //SetupPar("EMCALrec");
957 
958  //SetupPar("PWGPPEMCAL");
959 
960  //SetupPar("PWGCaloTrackCorrBase");
961  //SetupPar("PWGGACaloTrackCorrelations");
962 
963  //SetupPar("PWGGAGammaConv");
964 
965  // needed for plugin?
966  gSystem->AddIncludePath("-I$ALICE_ROOT");
967  gSystem->AddIncludePath("-I$ALICE_PHYSICS");
968  gSystem->AddIncludePath("-I./");
969 }
970 
971 //___________________________
985 //________________________
987 {
988  //--------------------------------------------------------------------
989  // Load analysis libraries
991  //gSystem->ListLibraries();
992 
993  //-----------------------------------------------------------------------------
994  // Create chain from ESD and from cross sections files, look below for options.
995 
996  // Set kInputData and kTreeName looking to the kINDIR
998 
999  // Check global analysis settings
1001 
1002  printf("*********************************************\n");
1003  printf("*** Input data < %s >, pass %s, tree < %s >, MC? < %d > ***\n",
1004  kInputData.Data(),kPass.Data(),kTreeName.Data(),kMC);
1005  printf("*********************************************\n");
1006 
1007  TChain * chain = new TChain(kTreeName) ;
1008  TChain * chainxs = new TChain("Xsection") ;
1009  CreateChain(mode, chain, chainxs);
1010 
1011  Double_t scale = -1;
1012  printf("===== kMC %d, chainxs %p\n",kMC,chainxs);
1013 
1014  if ( kMC )
1015  {
1016  //Get the cross section
1017  Double_t xsection = 0;
1018  Float_t ntrials = 0;
1019  Int_t nfiles = 0;
1020 
1021  Bool_t ok = GetAverageXsection(chainxs, xsection, ntrials, nfiles);
1022 
1023  printf("n xs files %d ntrials %f \n",nfiles, ntrials);
1024  if ( nfiles > 0 && ntrials > 0 )
1025  {
1026  if ( ok )
1027  {
1028  Int_t nEventsPerFile = chain->GetEntries() / nfiles;
1029 
1030  Double_t trials = ntrials / nEventsPerFile ;
1031 
1032  scale = xsection / trials;
1033 
1034  printf("Get Cross section : nfiles %d, nevents %lld, nevents per file %d \n",
1035  nfiles, chain->GetEntries(),nEventsPerFile);
1036  printf(" ntrials %2.2f, trials %2.2f, xs %2.2e, scale factor %2.2e\n",
1037  ntrials,trials,xsection,scale);
1038 
1039  if ( chainxs->GetEntries() != chain->GetEntries() )
1040  printf("CAREFUL: Number of files in data chain %lld, in cross section chain %lld \n",
1041  chainxs->GetEntries(),chain->GetEntries());
1042  } // ok
1043 
1044  // comment out this line in case the simulation did not have the cross section files produced in the directory
1045  if ( scale <= 0 || !ok )
1046  { printf( "STOP, cross section not available! nfiles %lld \n", chainxs->GetEntries() ) ; return ; }
1047  }
1048  }
1049 
1050  printf("*********************************************\n");
1051  printf("number of entries # %lld \n", chain->GetEntries()) ;
1052  printf("*********************************************\n");
1053 
1054  if ( !chain )
1055  {
1056  printf("STOP, no chain available\n");
1057  return;
1058  }
1059 
1060  AliLog::SetGlobalLogLevel(AliLog::kError);//Minimum prints on screen
1061 
1062  //------------------------------------------
1063  // Alien handler part
1064  //------------------------------------------
1065 // AliAnalysisGrid * alienHandler =0x0;
1066 // if ( mode==mPlugin )
1067 // {
1068 // // Create and configure the alien handler plugin
1069 // gROOT->LoadMacro("CreateAlienHandler.C");
1070 // alienHandler = CreateAlienHandler();
1071 // if ( !alienHandler ) return;
1072 // }
1073 
1074  //--------------------------------------
1075  //--------------------------------------
1076  // If automatic check does not work,
1077  // force here the collision type, period etc
1078 // kYear = 2011;
1079 // kPeriod = "LHC11c";
1080 // kCollision = "pp";
1081 // kMC = kTRUE;
1082 // kInputData = "AOD";
1083  //--------------------------------------
1084  //--------------------------------------
1085 
1086  //--------------------------------------
1087  // Make the analysis manager
1088  //-------------------------------------
1089  AliAnalysisManager *mgr = new AliAnalysisManager("Manager", "Manager");
1090  //AliAnalysisManager::SetUseProgressBar(kTRUE);
1091  //mgr->SetSkipTerminate(kTRUE);
1092  //mgr->SetNSysInfo(1);
1093 
1094  // Connect plugin to the analysis manager
1095 // if ( mode == mPlugin )
1096 // {
1097 // mgr->SetGridHandler(alienHandler);
1098 // }
1099 
1100  // MC handler
1101  if ( (kMC || kInputData == "MC") && !kInputData.Contains("AOD") )
1102  {
1103  AliMCEventHandler* mcHandler = new AliMCEventHandler();
1104  mcHandler->SetReadTR(kFALSE);//Do not search TrackRef file
1105  mgr->SetMCtruthEventHandler(mcHandler);
1106  if ( kInputData == "MC" )
1107  {
1108  cout<<"MC INPUT EVENT HANDLER"<<endl;
1109  mgr->SetInputEventHandler(NULL);
1110  }
1111  }
1112 
1113  // AOD output handler, very special analysis
1114  if ( kInputData != "deltaAOD" && outAOD)
1115  {
1116  cout<<"Init output handler"<<endl;
1117  AliAODHandler* aodoutHandler = new AliAODHandler();
1118  aodoutHandler->SetOutputFileName("aod.root");
1120  mgr->SetOutputEventHandler(aodoutHandler);
1121  }
1122 
1123  //=========
1124  // Input
1125 
1126  if ( kInputData == "ESD" )
1127  {
1128  // ESD handler
1129  AliESDInputHandler *esdHandler = new AliESDInputHandler();
1130  esdHandler->SetReadFriends(kFALSE);
1131  mgr->SetInputEventHandler(esdHandler);
1132  cout<<"ESD handler "<<mgr->GetInputEventHandler()<<endl;
1133  }
1134  else if ( kInputData.Contains("AOD") )
1135  {
1136  // AOD handler
1137  AliAODInputHandler *aodHandler = new AliAODInputHandler();
1138  mgr->SetInputEventHandler(aodHandler);
1139  if(kInputData == "deltaAOD") aodHandler->AddFriend((char*)"deltaAODCaloTrackCorr.root");
1140  cout<<"AOD handler "<<mgr->GetInputEventHandler()<<endl;
1141  }
1142 
1143  //mgr->RegisterExternalFile("deltaAODCaloTrackCorr.root");
1144  //mgr->SetDebugLevel(1); // For debugging, do not uncomment if you want no messages.
1145 
1146  TString outputFile = AliAnalysisManager::GetCommonFileName();
1147 
1148  //-------------------------------------------------------------------------
1149  // Define task, put here any other task that you want to use.
1150  //-------------------------------------------------------------------------
1151 
1152  // Physics selection
1153  if ( !kMC )
1154  {
1155  gROOT->LoadMacro("$ALICE_PHYSICS/OADB/macros/AddTaskPhysicsSelection.C");
1156  AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection(kMC,kTRUE);
1157  }
1158 
1159  // Centrality, valid for Run1, but superseeded by new task below
1160 // if ( bMultiplicity && kCollision.Contains("Pb") )
1161 // {
1162 // if ( kYear < 200000 && kInputData=="ESD" )
1163 // gROOT->LoadMacro("$ALICE_PHYSICS/OADB/macros/AddTaskCentrality.C");
1164 // AliCentralitySelectionTask *taskCentrality = AddTaskCentrality();
1165 // }
1166 
1167  if ( bMultiplicity )
1168  {
1169  // New centrality/multiplicity selector
1170  gROOT->LoadMacro("$ALICE_PHYSICS/OADB/COMMON/MULTIPLICITY/macros/AddTaskMultSelection.C");
1171  AliMultSelectionTask * task = AddTaskMultSelection(kFALSE); // user mode:
1172 
1173  // use the default calibration for runs which have not yet been calibrated
1174  task->SetUseDefaultCalib (kTRUE); // data
1175  task->SetUseDefaultMCCalib(kTRUE); // MC
1176  }
1177 
1178 // if ( kCollision=="PbPb" )
1179 // {
1180 // gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskVZEROEPSelection.C");
1181 // AliVZEROEPSelectionTask * EPV0 = AddTaskVZEROEPSelection();
1182 //
1183 // gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskEventplane.C");
1184 // AliEPSelectionTask * EP = AddTaskEventplane();
1185 // }
1186 
1187  // OCDB connect
1188  //
1189  if ( bEMCCorrFra || bEMCCluster )
1190  {
1191  //gROOT->LoadMacro("$ALICE_PHYSICS/PWGPP/PilotTrain/AddTaskCDBconnect.C");
1192  gROOT->LoadMacro("AddTaskCDBconnect.C");
1193  AddTaskCDBconnect();
1194  ((AliTaskCDBconnect*)(AliAnalysisManager::GetAnalysisManager()->GetTask("CDBconnect")))->SetFallBackToRaw(kTRUE);
1195  }
1196 
1197  // EMCAL correction framework
1198  //
1199  if ( bEMCCorrFra && !bEMCCluster )
1200  {
1201  printf("INIT EMCal corrections\n");
1202  gROOT->LoadMacro("$ALICE_PHYSICS/PWG/EMCAL/macros/AddTaskEmcalCorrectionTask.C");
1203  AliEmcalCorrectionTask * emcorr = AddTaskEmcalCorrectionTask();
1204 
1205  // Data or MC specific configurations
1206  if ( !kMC )
1207  {
1208  emcorr->SetUserConfigurationFilename("$ALICE_PHYSICS_SRC/PWGGA/CaloTrackCorrelations/yaml/EMCalCorrConfig_Gamma_Data.yaml");
1209  }
1210  else
1211  {
1212  // Without cross-talk
1213  if ( xTalkEmul == 0 )
1214  emcorr->SetUserConfigurationFilename("$ALICE_PHYSICS_SRC/PWGGA/CaloTrackCorrelations/yaml/EMCalCorrConfig_MC_ClV1.yaml");
1215  // With cross-talk
1216  else
1217  {
1218  //emcorr->SetUserConfigurationFilename("$ALICE_PHYSICS_SRC/PWGGA/CaloTrackCorrelations/yaml/EMCalCorrConfig_MC_Run1_ClV1_xTalk.yaml");
1219  emcorr->SetUserConfigurationFilename("$ALICE_PHYSICS_SRC/PWGGA/CaloTrackCorrelations/yaml/EMCalCorrConfig_MC_Run1_ClV1_xTalk_ECellCut.yaml");
1220  //emcorr->SetUserConfigurationFilename("$ALICE_PHYSICS_SRC/PWGGA/CaloTrackCorrelations/yaml/EMCalCorrConfig_MC_Run1_ClV1_xTalk_ECellCut_Leak5MeV.yaml");
1221  }
1222  }
1223 
1224  //emcorr->SelectCollisionCandidates( AliVEvent::kAnyINT | AliVEvent::kEMC7 | AliVEvent::kEMC8 | AliVEvent::kEMC1 | AliVEvent::kEMCEGA | AliVEvent::kEMCEJE );
1225 
1227  emcorr->Initialize();
1228  }
1229 
1230  // Clusterization task
1231  // For experts
1232  //
1233  TString clustersArray = "";
1234  TString cellsArray = "";
1235  if ( !bEMCCorrFra && bEMCCluster )
1236  {
1237  printf("INIT EMCal Clusterizer\n");
1238  gROOT->LoadMacro("$ALICE_PHYSICS/PWGPP/EMCAL/macros/AddTaskEMCALClusterize.C");
1239 
1240  Int_t clTM = 2; // Do track matching, 0 no, 1 TPC only, 2 hybrid
1241  Bool_t exo = kTRUE; // Remove exotic cells
1242 
1243  Bool_t clnonlin = kTRUE; // Apply non linearity (clusterizer), CAREFUL check that not done in analysis
1244  Int_t minEcell = 100; // 50 MeV (10 MeV used in reconstruction)
1245  Int_t minEseed = 500; // 100 MeV
1246  Int_t dTime = 10000; // open
1247  Int_t wTime = 10000; // open
1248  Int_t unfMinE = 15; // Remove cells with less than 15 MeV from cluster after unfolding
1249  Int_t unfFrac = 1; // Remove cells with less than 1% of cluster energy after unfolding
1250  Bool_t updateCell= kTRUE; // Calibrate cells and modify them on the fly
1251  Bool_t filterEvents = kFALSE; // Filter events with activity in EMCal
1252  Int_t cenBin[] = {-1,-1}; // Centrality bin min-max of accepted events. {-1,-1} take all
1253  // Calibration, bad map ...
1254 
1255  Bool_t calibEE = kFALSE; // It is set automatically, but here we force to use ir or not in any case
1256  Bool_t calibTT = kFALSE; // It is set automatically, but here we force to use ir or not in any case
1257  Bool_t badMap = kTRUE; // It is set automatically, but here we force to use it or not in any case
1258 
1260  AddTaskEMCALClusterize(clustersArray, outAOD, kMC, exo,"V1","", clTM,
1261  minEcell,minEseed,dTime,wTime,unfMinE,unfFrac,
1262  calibEE,badMap,calibTT,clnonlin,
1263  cenBin[0],cenBin[1],-1,1,1,filterEvents,xTalkEmul,updateCell);
1264 
1265  //cl->GetRecoUtils()->SwitchOffRunDepCorrection(); // Off for Run2 for the moment
1266 
1267  // Force option different than clTM
1268  // cl->GetRecoUtils()->SwitchOnAODHybridTracksMatch();
1269  // cl->GetRecoUtils()->SwitchOnAODTPCOnlyTracksMatch();
1270  // cl->GetRecoUtils()->SetAODTrackFilterMask(128);
1271  //
1272  if ( kMC )
1273  {
1274  cl->SwitchOnUseClusterMCLabelForCell(0) ; // For Old Run1 MC
1276  }
1277 
1278  // cl->GetRecoUtils()->SetWarmChannelAsGood();
1279  // cl->GetRecoUtils()->SetDeadChannelAsGood();
1280  // cl->GetRecoUtils()->SetHotChannelAsGood();
1281 
1282  clustersArray = Form("V1_Ecell%d_Eseed%d",minEcell,minEseed);
1283  cl->SetAODBranchName(clustersArray);
1284 
1285  if ( updateCell )
1286  {
1287  cellsArray = "Cells_Updated";
1288  if ( xTalkEmul > 0 )
1289  cellsArray = "Cells_xTalkEmulation";
1290  }
1291  cl->SetAODCellsName (cellsArray);
1292 
1293  // cl->SetMaxEvent(20);
1294  // cl->SetDebugLevel(100);
1295  }
1296 
1297  /*
1298  // -----------------
1299  // Photon conversion
1300  // -----------------
1301 
1302  if(kInputData=="ESD"){
1303  printf("* Configure photon conversion analysis in macro \n");
1304  TString arguments = "-run-on-train -use-own-xyz -force-aod -mc-off ";
1305  gROOT->LoadMacro("$ALICE_PHYSICS/PWGGA/GammaConversion/macros/ConfigGammaConversion.C");
1306  AliAnalysisTaskGammaConversion * taskGammaConversion =
1307  ConfigGammaConversion(arguments,mgr->GetCommonInputContainer());
1308  taskGammaConversion->SelectCollisionCandidates();
1309 
1310  // Gamma Conversion AOD to AODPWG4Particle
1311  AliAnalysisTaskGCPartToPWG4Part * taskGCToPC = new AliAnalysisTaskGCPartToPWG4Part("GCPartToPWG4Part");
1312  taskGCToPC->SetGammaCutId("90035620401003321022000000090");
1313  mgr->AddTask(taskGCToPC);
1314  mgr->ConnectInput (taskGCToPC, 0, mgr->GetCommonInputContainer() );
1315  mgr->ConnectOutput (taskGCToPC, 0, mgr->GetCommonOutputContainer());
1316  }
1317  */
1318 
1319  // -----------------
1320  // CaloTrack Correlations Task
1321  // -----------------
1322 
1323  // Common settings for Correlation and QA tasks
1324  Bool_t calibrate = kFALSE;
1325  Int_t minCen = -1;
1326  Int_t maxCen = -1;
1327  Int_t debug = -1;
1328 
1329  // Possible triggered events
1330  TString lTrig[] = {"default","EMCAL_L0","EMCAL_L1","EMCAL_L2"};
1331  Int_t nTrig = 4;
1332  Int_t trig0 = 0;
1333  Int_t fixTrig = -1;
1334  if ( fixTrig >= 0 )
1335  {
1336  trig0 = fixTrig;
1337  nTrig = fixTrig+1;
1338  }
1339 
1340  // -----------------
1341  // Photon/Pi0/Isolation/Correlation etc
1342  // -----------------
1343 
1344  if ( bAnalysis )
1345  {
1346  Int_t rejectEMCTrig = 0;
1347  Bool_t nonLinOn = kFALSE;
1348  Float_t shshMax = 0.27;
1349  Float_t isoCone = 0.4;
1350  Float_t isoConeMin = -1;
1351  Float_t isoPtTh = 1;
1352  Int_t isoMethod = AliIsolationCut::kSumPtIC;
1354  Int_t leading = 0;
1355  Int_t tm = 2;
1356  Bool_t mixOn = kFALSE;
1357  TString outputfile = "";
1358  Bool_t printSettings = kFALSE;
1359  TString cutSelected = "SPDPileUp";//"_ITSonly";
1360  TString analysisSelected = "Photon_InvMass"; // Activate photon selection and invariant mass analysis
1361  // More options:
1362  // "Photon_InvMass_MergedPi0_Isolation_Correlation_ClusterShape_PerSM_PerTCard_QA_Charged_Bkg";
1363 
1364  gROOT->LoadMacro("$ALICE_PHYSICS/PWGGA/CaloTrackCorrelations/macros/AddTaskGammaHadronCorrelationSelectAnalysis.C");
1365 
1366  for(Int_t itrig = trig0; itrig < nTrig; itrig++)
1367  {
1368  if ( itrig > 0 && kMC ) continue; // Any MC has only one kind of trigger
1369 
1371  ("EMCAL",kMC,kYear,kCollision,kPeriod,rejectEMCTrig,clustersArray,cutSelected,calibrate,nonLinOn, analysisSelected,
1372  shshMax,isoCone,isoConeMin,isoPtTh,isoMethod ,isoContent,leading,
1373  tm,minCen,maxCen,mixOn,outputfile,printSettings,debug,lTrig[itrig]);
1374 
1375  emc->GetAnalysisMaker()->GetReader()->SetEMCALCellsListName(cellsArray);
1377 
1378  // Careful, need time calibration to use time cuts defined in macro
1379  if ( !bEMCCluster && !bEMCCorrFra && !calibrate )
1380  {
1382  emc->GetAnalysisMaker()->GetReader()->SetEMCALTimeCut(-1e10,1e10); // Open time cut
1383  }
1384 
1385  // emc ->SelectCollisionCandidates( AliVEvent::kINT7 | AliVEvent::kCentral | AliVEvent::kSemiCentral | AliVEvent::kMB ); // Done internally, here as example
1386  // emc->GetAnalysisMaker()->GetReader()->SetNameOfMCEventHederGeneratorToAccept("Pythia");
1387  // emc->GetAnalysisMaker()->GetReader()->SwitchOffShowerShapeSmearing();
1388  // emc->GetAnalysisMaker()->GetReader()->SetSmearingFunction(AliCaloTrackReader::kNoSmearing);
1389 
1390  // emc ->GetAnalysisMaker()->GetReader()->SwitchOnAliCentrality () ;
1391  // emc->SetLastEvent(maxEvent);
1392 
1393  // // Example on how to modify settings of a sub-wagon if not in corresponding macro
1394  // TList * anaList = emc->GetAnalysisMaker()->GetListOfAnalysisContainers();
1395  // AliAnaClusterShapeCorrelStudies * shapeAna = (AliAnaClusterShapeCorrelStudies*) anaList->At(9);
1396  // shapeAna->SetNCellBinLimits(3); // no analysis on predefined bins in nCell
1397  // shapeAna->SetDistToBadMin(2);
1398  // shapeAna->SwitchOnStudyColRowFromCellMax() ;
1399  // shapeAna->Print("");
1400 
1401  if ( kYear < 2014 ) continue;
1402 
1403  TString dcalTrig = lTrig[itrig];
1404  dcalTrig.ReplaceAll("EM","D");
1405 
1407  ("DCAL",kMC,kYear,kCollision,kPeriod,rejectEMCTrig,clustersArray,cutSelected,calibrate,nonLinOn, analysisSelected,
1408  shshMax,isoCone,isoConeMin,isoPtTh,isoMethod ,isoContent,leading,
1409  tm,minCen,maxCen,mixOn,outputfile,printSettings,-1,lTrig[itrig]);
1410  dmc->GetAnalysisMaker()->GetReader()->SetEMCALCellsListName(cellsArray);
1412 
1413  // Careful, need time calibration to use time cuts defined in macro
1414  if ( !bEMCCluster && !bEMCCorrFra && !calibrate )
1415  {
1417  dmc->GetAnalysisMaker()->GetReader()->SetEMCALTimeCut(-1e10,1e10); // Open time cut
1418  }
1419  } // trigger loop
1420  } // bAnalysis
1421 
1422  // -----------------
1423  // QA train analysis, comment out since it cannot compile with bAnalysis uncommented
1424  // -----------------
1425 
1426 // if ( bAnalysisQA )
1427 // {
1428 // Int_t minTime = -1000;
1429 // Int_t maxTime = 1000;
1430 // Bool_t qaan = kTRUE;
1431 // Bool_t hadronan = kTRUE;
1432 //
1433 // gROOT->LoadMacro("$ALICE_PHYSICS/PWGGA/CaloTrackCorrelations/macros/QA/AddTaskPi0IMGammaCorrQA.C");
1434 //
1435 // // To test the train environment variables
1436 // //
1437 // {
1438 // char col [1024];
1439 // char tag [1024];
1440 // char mc [1024];
1441 //
1442 // sprintf(col,"%s",kCollision.Data());
1443 // sprintf(tag,"%s",kPeriod .Data());
1444 // if ( kMC ) sprintf(mc,"MC" );
1445 // else sprintf(mc,"RAW");
1446 //
1447 // gSystem->Setenv("ALIEN_JDL_LPMINTERACTIONTYPE",col);
1448 // gSystem->Setenv("ALIEN_JDL_LPMPRODUCTIONTAG" ,tag);
1449 // gSystem->Setenv("ALIEN_JDL_LPMPRODUCTIONTYPE" ,mc );
1450 // }
1451 //
1452 // for(Int_t itrig = trig0; itrig < nTrig; itrig++)
1453 // {
1454 // if ( itrig > 0 && kMC ) continue; // Any MC has only one kind of trigger
1455 //
1456 // AliAnalysisTaskCaloTrackCorrelation * qaTrain = AddTaskPi0IMGammaCorrQA
1457 // ("EMCAL",kMC,"","",qaan,hadronan,calibrate,minTime,maxTime,
1458 // minCen,maxCen,debug,lTrig[itrig]);
1459 // }
1460 //
1461 // // Other QA
1462 // // Detector QA
1463 // // gROOT->LoadMacro("$ALICE_PHYSICS/PWGGA/CaloTrackCorrelations/macros/QA/AddTaskCalorimeterQA.C");
1464 // // AliAnalysisTaskCaloTrackCorrelation * qatask = AddTaskCalorimeterQA(kInputData,kYear,kPrint,kMC);
1465 // //
1466 // // Very old Trigger QA, not in use
1467 // // gROOT->LoadMacro("$ALICE_PHYSICS/PWGPP/EMCAL/macros/AddTaskEMCALTriggerQA.C");
1468 // // AliAnalysisTaskEMCALTriggerQA * qatrigtask = AddTaskEMCALTriggerQA();
1469 // } // bAnalysis QA
1470 
1471  // // Simple event counting tasks
1472  //
1473  // gROOT->LoadMacro("$ALICE_PHYSICS/PWGGA/CaloTrackCorrelations/macros/AddTaskCounter.C");
1474  //
1475  // AliAnalysisTaskCounter* count = AddTaskCounter("",kMC); // All, fill histo with cross section and trials if kMC is true
1476  // AliAnalysisTaskCounter* countmb = AddTaskCounter("MB"); // Min Bias
1477  // AliAnalysisTaskCounter* countany = AddTaskCounter("Any");
1478  // AliAnalysisTaskCounter* countint = AddTaskCounter("AnyINT");// Min Bias
1479  //
1480  // if ( !kMC )
1481  // {
1482  // AliAnalysisTaskCounter* countemg = AddTaskCounter("EMCEGA");
1483  // AliAnalysisTaskCounter* countemj = AddTaskCounter("EMCEJE");
1484  // if ( kCollision=="PbPb" )
1485  // {
1486  // AliAnalysisTaskCounter* countcen = AddTaskCounter("Central");
1487  // AliAnalysisTaskCounter* countsce = AddTaskCounter("SemiCentral");
1488  // AliAnalysisTaskCounter* countssce= AddTaskCounter("SemiOrCentral");
1489  // AliAnalysisTaskCounter* countphP = AddTaskCounter("PHOSPb");
1490  // }
1491  // else
1492  // {
1493  // AliAnalysisTaskCounter* countem1 = AddTaskCounter("EMC1"); // Trig Th > 1.5 GeV approx
1494  // AliAnalysisTaskCounter* countem7 = AddTaskCounter("EMC7"); // Trig Th > 4-5 GeV
1495  // AliAnalysisTaskCounter* countphp = AddTaskCounter("PHOS");
1496  // }
1497  // }
1498  //
1499  //
1500 
1501 
1502  //-----------------------
1503  // Run the analysis
1504  //-----------------------
1505  mgr->InitAnalysis();
1506  mgr->PrintStatus();
1507 
1508  if (mode == mPlugin) mgr->StartAnalysis("grid");
1509  else if (mode == mPROOF ) mgr->StartAnalysis("proof",chain);
1510  else mgr->StartAnalysis("local",chain);
1511 
1512  cout <<" Analysis ended sucessfully "<< endl ;
1513 }
1514 
1515 
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:850
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:986
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:707
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:908
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