AliPhysics  a0db429 (a0db429)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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 
66  //ANALYSIS PART
67  // const char *collectionfile = "wn_1run.xml";
68  // const char *collectionfile = "wn.xml";
69  const char *collectionfile;
70  if(isESD==kTRUE) collectionfile = "esd_156889.xml";
71  else collectionfile= "aod_156889.xml";
72  //const char *collectionfile = "esd_156889.xml";
73  TChain* chain = NULL;
74  if(type==0){//local files
75  if(isESD==kTRUE) {
76  gROOT->LoadMacro("$ALICE_PHYSICS/PWG/EMCAL/macros/CreateESDChain.C");
77  chain = CreateESDChain("files.txt", 1);
78  } else {
79  gROOT->LoadMacro("$ALICE_PHYSICS/PWG/EMCAL/macros/CreateAODChain.C");
80  chain = CreateAODChain("filesAOD.txt", 1);
81  }
82  }
83  else if(type==1){//grid files
84  if(isESD==kTRUE) chain = CreateChainFromCollection(collectionfile, "esdTree");
85  else chain = CreateChainFromCollection(collectionfile, "aodTree");
86  }
87 
88  // for includes use either global setting in $HOME/.rootrc
89  // ACLiC.IncludePaths: -I$(ALICE_ROOT)/include
90  // or in each macro
91  gSystem->AddIncludePath("-I$ALICE_ROOT/include");
92  gSystem->AddIncludePath("-I$ALICE_PHYSICS/include");
93 
94 
95 
96  // Create the analysis manager
97  AliAnalysisManager *mgr = new AliAnalysisManager("MyEmcalAnalysis");
98  AliInputEventHandler *inputHandler=NULL;
99 
100  // AliESDInputHandler* esdH = new AliESDInputHandler();
101  // mgr->SetInputEventHandler(esdH);
102 
103  if(isESD==kTRUE) inputHandler = new AliESDInputHandler();
104  else inputHandler = new AliAODInputHandler();
105 
106  mgr->SetInputEventHandler(inputHandler);
107 
108  AliPhysicsSelectionTask* physselTask=NULL;
109  if(isPhysicsSelection){
110  gROOT->LoadMacro("$ALICE_PHYSICS/PWGPP/PilotTrain/AddTaskPhysicsSelection.C");
111  // AliPhysicsSelectionTask* physselTask = AddTaskPhysicsSelection();
112  physselTask = AddTaskPhysicsSelection();
113  // physselTask->AddCollisionTriggerClass("+CINT1WU-B-NOPF-ALL");
114  }
115  AliCentralitySelectionTask* centralityTask=NULL;
116  if(isCentralitySelection){
117  gROOT->LoadMacro("$ALICE_PHYSICS/OADB/macros/AddTaskCentrality.C");
118  // AliCentralitySelectionTask* centralityTask = AddTaskCentrality(); // Create task
119  centralityTask = AddTaskCentrality(); // Create task
120  }
121 
122  //AliCalorimeterUtils *cu = new AliCalorimeterUtils();
123  // cu->SwitchOnBadChannelsRemoval();
124 
125  // Create task
126  //UInt_t kTriggerInt = AliVEvent::kAnyINT;
127  //UInt_t kTriggerEMC = AliVEvent::kEMC8 || AliVEvent::kEMC7 || AliVEvent::kEMCEJE || AliVEvent::kEMCEGA;
128 
129  AliAnalysisTaskEMCALTimeCalib *taskmbemcal = new AliAnalysisTaskEMCALTimeCalib("TimeCalibTask");
130  // AliEMCALRecoUtils *reco = taskmbemcal->GetEMCALRecoUtils();
131  // taskmbemcal->PrintInfo();
132  // reco->SwitchOnRejectExoticCluster();
133 
134  taskmbemcal->SelectCollisionCandidates(AliVEvent::kEMC1|AliVEvent::kEMC7|AliVEvent::kEMC8|AliVEvent::kEMCEJE|AliVEvent::kEMCEGA);
135  //taskmbemcal->SetGeometryName("EMCAL_COMPLETE12SMV1_DCAL_8SM");
136 
137  // to load reference histograms run-by-run in pass2
138  //taskmbemcal->SetReferenceRunByRunFileName("ReferenceSM_v3.root");
139  //taskmbemcal->SetMinTime(300);
140  //taskmbemcal->SetMaxTime(900);
141  //taskmbemcal->SetPassTimeHisto(1200,300.,900.);
142 
143  // to load reference calibration constants in pass3
144  //taskmbemcal->SetReferenceFileName("Reference_LHC15i.root");
145  //taskmbemcal->LoadReferenceHistos();
146  //taskmbemcal->SetPassTimeHisto(1400,-350.,350.);
147 
148  //taskmbemcal->SelectCollisionCandidates(AliVEvent::kAnyINT);
149  //taskmbemcal->SetDebugLevel(10);
150 
151  // Add task(s)
152  // taskmbemcal->PrintInfo();
153  if(isPhysicsSelection) mgr->AddTask(physselTask);
154  if(isCentralitySelection) mgr->AddTask(centralityTask);
155  mgr->AddTask(taskmbemcal);
156 
157  TString outputFileName;
158  if(type==0)outputFileName="timeOutput.root";
159  else if(type==1)outputFileName="timeResults.root";
160 
161  // Create containers for input/output
162  AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
163  AliAnalysisDataContainer *coutputList = mgr->CreateContainer("chistolist", TList::Class(),
164  AliAnalysisManager::kOutputContainer, outputFileName.Data());
165 
166 
167  // Connect input/output
168  mgr->ConnectInput(taskmbemcal, 0, cinput);
169 
170  // No need to connect to a common AOD output container if the task does not
171  // fill AOD info.
172  // mgr->ConnectOutput(task, 0, coutput0);
173  mgr->ConnectOutput(taskmbemcal, 1, coutputList);
174 
175  // Enable debug printouts
176  if(type==0) mgr->SetDebugLevel(12);
177 
178  if (!mgr->InitAnalysis()) return;
179  mgr->PrintStatus();
180  mgr->StartAnalysis("local", chain);
181 
182 
183  timer.Stop();
184  timer.Print();
185 
186 }
187 
188 //______________________________________________________________________________
189 TChain *CreateChainFromCollection(const char* xmlfile, const char *treeName="esdTree")
190 {
191 // Create a chain from an alien collection.
192  TAlienCollection * myCollection = TAlienCollection::Open(xmlfile);
193 
194  if (!myCollection) {
195  ::Error("CreateChainSingle", "Cannot create an AliEn collection from %s", xmlfile) ;
196  return NULL ;
197  }
198 
199  TChain* chain = new TChain(treeName);
200  myCollection->Reset() ;
201  while ( myCollection->Next() ) chain->Add(myCollection->GetTURL("")) ;
202  chain->ls();
203  return chain;
204 }
205 
206 // 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
Task to work on Time Calibration for EMCal/DCal.