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