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