AliPhysics  59e0e03 (59e0e03)
runEMCALTimeCalibTask.C
Go to the documentation of this file.
1 
31 void runEMCALTimeCalibTask(Int_t type=0, Bool_t isESD=kTRUE, Bool_t isPhysicsSelection=kFALSE, Bool_t isCentralitySelection=kFALSE)
32 {
33  //type = 0: local
34  //type = 1: grid
35 
36  TStopwatch timer;
37  timer.Start();
38  printf("*** the task is: AliAnalysisTaskEMCALTimeCalib ***\n");
39  // Grid connection
40  printf("*** Connect to AliEn ***\n");
41  TGrid::Connect("alien://");
42  //printf("*** Connected to AliEn? in ***\n");
43  cout<< "Connected to AliEn" <<endl;
44  timer.Print();
45 
46  //libraries
47  gSystem->Load("libTree.so");
48  gSystem->Load("libGeom.so");
49  //gSystem->Load("libVMC.so");
50  gSystem->Load("libSTEERBase.so");
51  gSystem->Load("libESD.so");
52  gSystem->Load("libAOD.so");
53 
54  // load analysis framework
55  gSystem->Load("libANALYSIS");
56  gSystem->Load("libANALYSISalice");
57  gSystem->Load("libANALYSISalice.so");
58 
59  gSystem->Load("libEMCALUtils.so");
60  gSystem->Load("libPWGPPEMCAL.so");
61 
62  gSystem->AddIncludePath("-I$ALICE_ROOT");
63  gSystem->AddIncludePath("-I$ALICE_PHYSICS");
64  gSystem->AddIncludePath("-I./");
65 
66  //ANALYSIS PART
67  const char *collectionfile;
68  if(isESD==kTRUE) collectionfile = "esd_156889.xml";
69  else collectionfile= "aod_156889.xml";
70  TChain* chain = NULL;
71  if(type==0){//local files
72  if(isESD==kTRUE) {
73  gROOT->LoadMacro("$ALICE_PHYSICS/PWG/EMCAL/macros/CreateESDChain.C");
74  chain = CreateESDChain("files.txt", 1);
75  } else {
76  gROOT->LoadMacro("$ALICE_PHYSICS/PWG/EMCAL/macros/CreateAODChain.C");
77  chain = CreateAODChain("filesAOD.txt", 1);
78  }
79  }
80  else if(type==1){//grid files
81  if(isESD==kTRUE) chain = CreateChainFromCollection(collectionfile, "esdTree");
82  else chain = CreateChainFromCollection(collectionfile, "aodTree");
83  }
84 
85  // for includes use either global setting in $HOME/.rootrc
86  // ACLiC.IncludePaths: -I$(ALICE_ROOT)/include
87  // or in each macro
88  gSystem->AddIncludePath("-I$ALICE_ROOT/include");
89  gSystem->AddIncludePath("-I$ALICE_PHYSICS/include");
90 
91 
92 
93  // Create the analysis manager
94  AliAnalysisManager *mgr = new AliAnalysisManager("MyEmcalAnalysis");
95  AliInputEventHandler *inputHandler=NULL;
96 
97  // AliESDInputHandler* esdH = new AliESDInputHandler();
98  // mgr->SetInputEventHandler(esdH);
99 
100  if(isESD==kTRUE) inputHandler = new AliESDInputHandler();
101  else inputHandler = new AliAODInputHandler();
102 
103  mgr->SetInputEventHandler(inputHandler);
104 
105  AliPhysicsSelectionTask* physselTask=NULL;
106  if(isPhysicsSelection){
107  gROOT->LoadMacro("$ALICE_PHYSICS/PWGPP/PilotTrain/AddTaskPhysicsSelection.C");
108  // AliPhysicsSelectionTask* physselTask = AddTaskPhysicsSelection();
109  physselTask = AddTaskPhysicsSelection();
110  // physselTask->AddCollisionTriggerClass("+CINT1WU-B-NOPF-ALL");
111  }
112  AliCentralitySelectionTask* centralityTask=NULL;
113  if(isCentralitySelection){
114  gROOT->LoadMacro("$ALICE_PHYSICS/OADB/macros/AddTaskCentrality.C");
115  // AliCentralitySelectionTask* centralityTask = AddTaskCentrality(); // Create task
116  centralityTask = AddTaskCentrality(); // Create task
117  }
118 
119  //AliCalorimeterUtils *cu = new AliCalorimeterUtils();
120  // cu->SwitchOnBadChannelsRemoval();
121 
122  // Create task
123  //UInt_t kTriggerInt = AliVEvent::kAnyINT;
124  //UInt_t kTriggerEMC = AliVEvent::kEMC8 || AliVEvent::kEMC7 || AliVEvent::kEMCEJE || AliVEvent::kEMCEGA;
125 
126  AliAnalysisTaskEMCALTimeCalib *taskmbemcal = new AliAnalysisTaskEMCALTimeCalib("TimeCalibTask");
127  // AliEMCALRecoUtils *reco = taskmbemcal->GetEMCALRecoUtils();
128  // taskmbemcal->PrintInfo();
129  // reco->SwitchOnRejectExoticCluster();
130 
131  taskmbemcal->SelectCollisionCandidates(AliVEvent::kEMC1|AliVEvent::kEMC7|AliVEvent::kEMC8|AliVEvent::kEMCEJE|AliVEvent::kEMCEGA);
132  //taskmbemcal->SetGeometryName("EMCAL_COMPLETE12SMV1_DCAL_8SM");
133  //taskmbemcal->SwithOffFillHeavyHisto();
134 
135  // to load reference histograms run-by-run in pass2
136  //taskmbemcal->SetReferenceRunByRunFileName("ReferenceSM_LHC15n.root");
137  //taskmbemcal->LoadReferenceRunByRunHistos();
139  //taskmbemcal->SetMinTime(200);
140  //taskmbemcal->SetMaxTime(800);
141  //taskmbemcal->SetPassTimeHisto(800,400.,800.);
142 
143  //to apply L1 shift correction for badly reconstructed runs in muon_calo_pass1 LHC15f-m in run2
144  //additionally do in pass2:
145  //taskmbemcal->SwitchOnBadReco();
146  //taskmbemcal->SetMinTime(-200);
147  //taskmbemcal->SetMaxTime(200);
148  //taskmbemcal->SetPassTimeHisto(800,-200.,200.);
149 
150 
151  // to load reference calibration constants in pass3
152  //taskmbemcal->SetReferenceFileName("Reference_LHC15i.root");
153  //taskmbemcal->LoadReferenceHistos();
154  //taskmbemcal->SetPassTimeHisto(1400,-350.,350.);
155 
156  taskmbemcal->SetBadChannelMapSource(0);
157  if(taskmbemcal->GetBadChannelMapSource()==2) {
158  taskmbemcal->SetBadChannelFileName("badMap.root");
159  taskmbemcal->LoadBadChannelMapFile();
160  }
161 
162  //calibration with each cell
163  taskmbemcal->SwitchOffMostEneCellOnly();
164 
165  //taskmbemcal->SelectCollisionCandidates(AliVEvent::kAnyINT);
166  //taskmbemcal->SetDebugLevel(10);
167 
168  // Add task(s)
169  // taskmbemcal->PrintInfo();
170  if(isPhysicsSelection) mgr->AddTask(physselTask);
171  if(isCentralitySelection) mgr->AddTask(centralityTask);
172  mgr->AddTask(taskmbemcal);
173 
174  TString outputFileName;
175  if(type==0)outputFileName="timeOutput.root";
176  else if(type==1)outputFileName="timeResults.root";
177 
178  // Create containers for input/output
179  AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
180  AliAnalysisDataContainer *coutputList = mgr->CreateContainer("chistolist", TList::Class(),
181  AliAnalysisManager::kOutputContainer, outputFileName.Data());
182 
183 
184  // Connect input/output
185  mgr->ConnectInput(taskmbemcal, 0, cinput);
186 
187  // No need to connect to a common AOD output container if the task does not
188  // fill AOD info.
189  // mgr->ConnectOutput(task, 0, coutput0);
190  mgr->ConnectOutput(taskmbemcal, 1, coutputList);
191 
192  // Enable debug printouts
193  if(type==0) mgr->SetDebugLevel(12);
194 
195  if (!mgr->InitAnalysis()) return;
196  mgr->PrintStatus();
197  mgr->StartAnalysis("local", chain);
198 
199 
200  timer.Stop();
201  timer.Print();
202 
203 }
204 
205 //______________________________________________________________________________
206 TChain *CreateChainFromCollection(const char* xmlfile, const char *treeName="esdTree")
207 {
208 // Create a chain from an alien collection.
209  TAlienCollection * myCollection = TAlienCollection::Open(xmlfile);
210 
211  if (!myCollection) {
212  ::Error("CreateChainSingle", "Cannot create an AliEn collection from %s", xmlfile) ;
213  return NULL ;
214  }
215 
216  TChain* chain = new TChain(treeName);
217  myCollection->Reset() ;
218  while ( myCollection->Next() ) chain->Add(myCollection->GetTURL("")) ;
219  chain->ls();
220  return chain;
221 }
222 
223 // End of macro
void runEMCALTimeCalibTask(Int_t type=0, Bool_t isESD=kTRUE, Bool_t isPhysicsSelection=kFALSE, Bool_t isCentralitySelection=kFALSE)
TChain * CreateChainFromCollection(const char *xmlfile, const char *treeName="esdTree")
TSystem * gSystem
int Int_t
Definition: External.C:63
Task to work on Time Calibration for EMCal/DCal.
bool Bool_t
Definition: External.C:53