AliPhysics  vAN-20150723 (baea2bf)
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros
runEMCALTimeCalibTask.C
Go to the documentation of this file.
1 
19 void runEMCALTimeCalibTask(Int_t type=0, Bool_t isESD=kTRUE, Bool_t isPhysicsSelection=kFALSE, Bool_t isCentralitySelection=kFALSE)
20 {
21  //type = 0: local
22  //type = 1: grid
23 
24  TStopwatch timer;
25  timer.Start();
26  printf("*** the task is: AliAnalysisTaskEMCALTimeCalib ***\n");
27  // Grid connection
28  printf("*** Connect to AliEn ***\n");
29  TGrid::Connect("alien://");
30  //printf("*** Connected to AliEn? in ***\n");
31  cout<< "Connected to AliEn" <<endl;
32  timer.Print();
33 
34  //libraries
35  gSystem->Load("libTree.so");
36  gSystem->Load("libGeom.so");
37  //gSystem->Load("libVMC.so");
38  gSystem->Load("libSTEERBase.so");
39  gSystem->Load("libESD.so");
40  gSystem->Load("libAOD.so");
41 
42  // load analysis framework
43  gSystem->Load("libANALYSIS");
44  gSystem->Load("libANALYSISalice");
45  gSystem->Load("libANALYSISalice.so");
46 
47  gSystem->Load("libEMCALUtils.so");
48  gSystem->Load("libPWGPPEMCAL.so");
49 
50  gSystem->AddIncludePath("-I$ALICE_ROOT");
51  gSystem->AddIncludePath("-I$ALICE_PHYSICS");
52  gSystem->AddIncludePath("-I./");
53 
54  // // test with lib from PWGGA train
55 
56 
57 
58 
59  //ANALYSIS PART
60  // const char *collectionfile = "wn_1run.xml";
61  // const char *collectionfile = "wn.xml";
62  const char *collectionfile;
63  if(isESD==kTRUE) collectionfile = "esd_156889.xml";
64  else collectionfile= "aod_156889.xml";
65  //const char *collectionfile = "esd_156889.xml";
66  TChain* chain = NULL;
67  if(type==0){//local files
68  if(isESD==kTRUE) {
69  gROOT->LoadMacro("$ALICE_PHYSICS/PWG/EMCAL/macros/CreateESDChain.C");
70  chain = CreateESDChain("files.txt", 1);
71  } else {
72  gROOT->LoadMacro("$ALICE_PHYSICS/PWG/EMCAL/macros/CreateAODChain.C");
73  chain = CreateAODChain("filesAOD.txt", 1);
74  }
75  }
76  else if(type==1){//grid files
77  if(isESD==kTRUE) chain = CreateChainFromCollection(collectionfile, "esdTree");
78  else chain = CreateChainFromCollection(collectionfile, "aodTree");
79  }
80 
81  // for includes use either global setting in $HOME/.rootrc
82  // ACLiC.IncludePaths: -I$(ALICE_ROOT)/include
83  // or in each macro
84  gSystem->AddIncludePath("-I$ALICE_ROOT/include");
85  gSystem->AddIncludePath("-I$ALICE_PHYSICS/include");
86 
87 
88 
89  // Create the analysis manager
90  AliAnalysisManager *mgr = new AliAnalysisManager("MyEmcalAnalysis");
91  AliInputEventHandler *inputHandler=NULL;
92 
93  // AliESDInputHandler* esdH = new AliESDInputHandler();
94  // mgr->SetInputEventHandler(esdH);
95 
96  if(isESD==kTRUE) inputHandler = new AliESDInputHandler();
97  else inputHandler = new AliAODInputHandler();
98 
99  mgr->SetInputEventHandler(inputHandler);
100 
101  AliPhysicsSelectionTask* physselTask=NULL;
102  if(isPhysicsSelection){
103  gROOT->LoadMacro("$ALICE_PHYSICS/PWGPP/PilotTrain/AddTaskPhysicsSelection.C");
104  // AliPhysicsSelectionTask* physselTask = AddTaskPhysicsSelection();
105  physselTask = AddTaskPhysicsSelection();
106  // physselTask->AddCollisionTriggerClass("+CINT1WU-B-NOPF-ALL");
107  }
108  AliCentralitySelectionTask* centralityTask=NULL;
109  if(isCentralitySelection){
110  gROOT->LoadMacro("$ALICE_PHYSICS/OADB/macros/AddTaskCentrality.C");
111  // AliCentralitySelectionTask* centralityTask = AddTaskCentrality(); // Create task
112  centralityTask = AddTaskCentrality(); // Create task
113  }
114 
115  //AliCalorimeterUtils *cu = new AliCalorimeterUtils();
116  // cu->SwitchOnBadChannelsRemoval();
117 
118  // Create task
119  //UInt_t kTriggerInt = AliVEvent::kAnyINT;
120  //UInt_t kTriggerEMC = AliVEvent::kEMC8 || AliVEvent::kEMC7 || AliVEvent::kEMCEJE || AliVEvent::kEMCEGA;
121 
122  AliAnalysisTaskEMCALTimeCalib *taskmbemcal = new AliAnalysisTaskEMCALTimeCalib("TimeCalibTask");
123  // AliEMCALRecoUtils *reco = taskmbemcal->GetEMCALRecoUtils();
124  // taskmbemcal->PrintInfo();
125  // reco->SwitchOnRejectExoticCluster();
126 
127  taskmbemcal->SelectCollisionCandidates(AliVEvent::kEMC1|AliVEvent::kEMC7|AliVEvent::kEMC8|AliVEvent::kEMCEJE|AliVEvent::kEMCEGA);
128  taskmbemcal->SetGeometryName("EMCAL_COMPLETE12SMV1_DCAL_8SM");
129 
130  //taskmbemcal->SelectCollisionCandidates(AliVEvent::kAnyINT);
131  //taskmbemcal->SetDebugLevel(10);
132 
133  // Add task(s)
134  // taskmbemcal->PrintInfo();
135  if(isPhysicsSelection) mgr->AddTask(physselTask);
136  if(isCentralitySelection) mgr->AddTask(centralityTask);
137  mgr->AddTask(taskmbemcal);
138 
139  TString outputFileName;
140  if(type==0)outputFileName="timeOutput.root";
141  else if(type==1)outputFileName="timeResults.root";
142 
143  // Create containers for input/output
144  AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
145  AliAnalysisDataContainer *coutputList = mgr->CreateContainer("chistolist", TList::Class(),
146  AliAnalysisManager::kOutputContainer, outputFileName.Data());
147 
148 
149  // Connect input/output
150  mgr->ConnectInput(taskmbemcal, 0, cinput);
151 
152  // No need to connect to a common AOD output container if the task does not
153  // fill AOD info.
154  // mgr->ConnectOutput(task, 0, coutput0);
155  mgr->ConnectOutput(taskmbemcal, 1, coutputList);
156 
157  // Enable debug printouts
158  if(type==0) mgr->SetDebugLevel(12);
159 
160  if (!mgr->InitAnalysis()) return;
161  mgr->PrintStatus();
162  mgr->StartAnalysis("local", chain);
163 
164 
165  timer.Stop();
166  timer.Print();
167 
168 }
169 
170 //______________________________________________________________________________
171 TChain *CreateChainFromCollection(const char* xmlfile, const char *treeName="esdTree")
172 {
173 // Create a chain from an alien collection.
174  TAlienCollection * myCollection = TAlienCollection::Open(xmlfile);
175 
176  if (!myCollection) {
177  ::Error("CreateChainSingle", "Cannot create an AliEn collection from %s", xmlfile) ;
178  return NULL ;
179  }
180 
181  TChain* chain = new TChain(treeName);
182  myCollection->Reset() ;
183  while ( myCollection->Next() ) chain->Add(myCollection->GetTURL("")) ;
184  chain->ls();
185  return chain;
186 }
187 
188 // 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")
Task to work on Time Calibration for EMCal/DCal.