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