]>
Commit | Line | Data |
---|---|---|
83f5f758 | 1 | //------------------------------------------------------\r |
2 | // AliAnalysisTaskFemto - A task for the analysis framework\r | |
3 | // from the FEMTOSCOPY analysis of PWG2. Creates the necessary\r | |
4 | // connection between the ESD or AOD input and the femtoscopic\r | |
5 | // code.\r | |
6 | // Author: Adam Kisiel, OSU; Adam.Kisiel@cern.ch\r | |
7 | //------------------------------------------------------\r | |
77f44ccf | 8 | #include "TROOT.h"\r |
9 | #include "TChain.h"\r | |
10 | #include "TH1.h"\r | |
11 | #include "TCanvas.h"\r | |
12 | #include "TSystem.h"\r | |
13 | #include "TFile.h"\r | |
06b454c7 | 14 | #include "TInterpreter.h"\r |
77f44ccf | 15 | \r |
16 | #include "AliAnalysisTask.h"\r | |
17 | \r | |
18 | #include "AliESDEvent.h"\r | |
19 | \r | |
83f5f758 | 20 | #include "AliFemtoAnalysis.h"\r |
77f44ccf | 21 | #include "AliAnalysisTaskFemto.h"\r |
78add4e9 | 22 | #include "AliVHeader.h"\r |
23 | #include "AliGenEventHeader.h"\r | |
24 | #include "AliGenHijingEventHeader.h"\r | |
25 | #include "AliGenCocktailEventHeader.h"\r | |
77f44ccf | 26 | \r |
27 | ClassImp(AliAnalysisTaskFemto)\r | |
28 | \r | |
78add4e9 | 29 | // Default name for the setup macro of femto analysis \r |
30 | // This function MUST be defined in the separate file !!!\r | |
06b454c7 | 31 | // extern AliFemtoManager *ConfigFemtoAnalysis();\r |
78add4e9 | 32 | \r |
77f44ccf | 33 | //________________________________________________________________________\r |
817751c7 | 34 | AliAnalysisTaskFemto::AliAnalysisTaskFemto(const char *name, const char *aConfigMacro="ConfigFemtoAnalysis.C"): \r |
83f5f758 | 35 | AliAnalysisTask(name,""), \r |
36 | fESD(0), \r | |
37 | fAOD(0),\r | |
5e301b78 | 38 | fStack(0),\r |
83f5f758 | 39 | fOutputList(0), \r |
78add4e9 | 40 | fReader(0x0),\r |
83f5f758 | 41 | fManager(0x0),\r |
817751c7 | 42 | fAnalysisType(0),\r |
43 | fConfigMacro(0)\r | |
83f5f758 | 44 | {\r |
77f44ccf | 45 | // Constructor.\r |
46 | // Input slot #0 works with an Ntuple\r | |
47 | DefineInput(0, TChain::Class());\r | |
77f44ccf | 48 | // Output slot #0 writes into a TH1 container\r |
83f5f758 | 49 | DefineOutput(0, TList::Class());\r |
817751c7 | 50 | fConfigMacro = (char *) malloc(sizeof(char) * strlen(aConfigMacro));\r |
51 | strcpy(fConfigMacro, aConfigMacro);\r | |
77f44ccf | 52 | }\r |
53 | \r | |
04328c66 | 54 | AliAnalysisTaskFemto::AliAnalysisTaskFemto(const AliAnalysisTaskFemto& aFemtoTask):\r |
55 | AliAnalysisTask(aFemtoTask), \r | |
56 | fESD(0), \r | |
57 | fAOD(0),\r | |
58 | fStack(0),\r | |
59 | fOutputList(0), \r | |
60 | fReader(0x0),\r | |
61 | fManager(0x0),\r | |
817751c7 | 62 | fAnalysisType(0),\r |
63 | fConfigMacro(0)\r | |
04328c66 | 64 | {\r |
5e301b78 | 65 | // copy constructor\r |
66 | fESD = aFemtoTask.fESD; \r | |
67 | fAOD = aFemtoTask.fAOD; \r | |
68 | fStack = aFemtoTask.fStack;\r | |
69 | fOutputList = aFemtoTask.fOutputList; \r | |
70 | fReader = aFemtoTask.fReader; \r | |
71 | fManager = aFemtoTask.fManager; \r | |
72 | fAnalysisType = aFemtoTask.fAnalysisType; \r | |
817751c7 | 73 | fConfigMacro = (char *) malloc(sizeof(char) * strlen(aFemtoTask.fConfigMacro));\r |
74 | strcpy(fConfigMacro, aFemtoTask.fConfigMacro);\r | |
5e301b78 | 75 | }\r |
76 | \r | |
77 | \r | |
78 | AliAnalysisTaskFemto& AliAnalysisTaskFemto::operator=(const AliAnalysisTaskFemto& aFemtoTask){\r | |
79 | // assignment operator\r | |
80 | if (this == &aFemtoTask)\r | |
81 | return *this;\r | |
82 | \r | |
83 | fESD = aFemtoTask.fESD; \r | |
84 | fAOD = aFemtoTask.fAOD; \r | |
85 | fStack = aFemtoTask.fStack;\r | |
86 | fOutputList = aFemtoTask.fOutputList; \r | |
87 | fReader = aFemtoTask.fReader; \r | |
88 | fManager = aFemtoTask.fManager; \r | |
89 | fAnalysisType = aFemtoTask.fAnalysisType; \r | |
817751c7 | 90 | if (fConfigMacro) free(fConfigMacro);\r |
91 | fConfigMacro = (char *) malloc(sizeof(char) * strlen(aFemtoTask.fConfigMacro));\r | |
92 | strcpy(fConfigMacro, aFemtoTask.fConfigMacro);\r | |
5e301b78 | 93 | \r |
94 | return *this;\r | |
95 | }\r | |
96 | \r | |
817751c7 | 97 | AliAnalysisTaskFemto::~AliAnalysisTaskFemto() \r |
98 | {\r | |
99 | if (fConfigMacro) free(fConfigMacro);\r | |
100 | }\r | |
101 | \r | |
102 | \r | |
77f44ccf | 103 | //________________________________________________________________________\r |
104 | void AliAnalysisTaskFemto::ConnectInputData(Option_t *) {\r | |
105 | printf(" ConnectInputData %s\n", GetName());\r | |
106 | \r | |
83f5f758 | 107 | fESD = 0;\r |
108 | fAOD = 0;\r | |
109 | fAnalysisType = 0;\r | |
77f44ccf | 110 | \r |
83f5f758 | 111 | TTree* tree = dynamic_cast<TTree*> (GetInputData(0));\r |
112 | if (!tree) {\r | |
113 | Printf("ERROR: Could not read chain from input slot 0");\r | |
114 | } \r | |
115 | else {\r | |
116 | AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());\r | |
117 | \r | |
118 | if(esdH) {\r | |
119 | cout << "Selected ESD analysis" << endl;\r | |
120 | fAnalysisType = 1;\r | |
121 | \r | |
122 | if (!esdH) {\r | |
123 | Printf("ERROR: Could not get ESDInputHandler");\r | |
124 | } \r | |
125 | else {\r | |
126 | fESD = esdH->GetEvent();\r | |
127 | }\r | |
128 | }\r | |
129 | else {\r | |
130 | AliAODInputHandler *aodH = dynamic_cast<AliAODInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());\r | |
131 | \r | |
132 | if (!aodH) {\r | |
133 | Printf("ERROR: Could not get AODInputHandler");\r | |
134 | } \r | |
135 | else {\r | |
136 | cout << "Selected AOD analysis" << endl;\r | |
137 | fAnalysisType = 2;\r | |
77f44ccf | 138 | \r |
83f5f758 | 139 | fAOD = aodH->GetEvent();\r |
140 | }\r | |
141 | }\r | |
142 | if ((!fAOD) && (!fESD)) {\r | |
143 | Printf("Wrong analysis type: Only ESD and AOD types are allowed!");\r | |
144 | }\r | |
145 | }\r | |
146 | \r | |
147 | \r | |
77f44ccf | 148 | }\r |
149 | \r | |
150 | //________________________________________________________________________\r | |
151 | void AliAnalysisTaskFemto::CreateOutputObjects() {\r | |
78add4e9 | 152 | printf("Creating Femto Analysis objects\n");\r |
153 | \r | |
e7155bf6 | 154 | gSystem->SetIncludePath("-I$ROOTSYS/include -I./STEERBase/ -I./ESD/ -I./AOD/ -I./ANALYSIS/ -I./ANALYSISalice/ -I./PWG2AOD/AOD -I./PWG2femtoscopy/FEMTOSCOPY/AliFemto -I./PWG2femtoscopyUser/FEMTOSCOPY/AliFemtoUser");\r |
69c1c8ff | 155 | char fcm[2000];\r |
156 | // sprintf(fcm, "%s++", fConfigMacro);\r | |
157 | // gROOT->LoadMacro(fcm);\r | |
817751c7 | 158 | gROOT->LoadMacro(fConfigMacro);\r |
06b454c7 | 159 | // fJetFinder = (AliJetFinder*) gInterpreter->ProcessLine("ConfigJetAnalysis()");\r |
160 | SetFemtoManager((AliFemtoManager *) gInterpreter->ProcessLine("ConfigFemtoAnalysis()"));\r | |
2f496816 | 161 | \r |
162 | TList *tOL;\r | |
163 | fOutputList = fManager->Analysis(0)->GetOutputList();\r | |
164 | \r | |
165 | for (unsigned int ian = 1; ian<fManager->AnalysisCollection()->size(); ian++) {\r | |
166 | tOL = fManager->Analysis(ian)->GetOutputList();\r | |
167 | \r | |
168 | TIter nextListCf(tOL);\r | |
169 | while (TObject *obj = nextListCf()) {\r | |
170 | fOutputList->Add(obj);\r | |
171 | }\r | |
172 | \r | |
173 | delete tOL;\r | |
174 | }\r | |
77f44ccf | 175 | }\r |
176 | \r | |
177 | //________________________________________________________________________\r | |
178 | void AliAnalysisTaskFemto::Exec(Option_t *) {\r | |
83f5f758 | 179 | // Task making a femtoscopic analysis.\r |
78add4e9 | 180 | \r |
83f5f758 | 181 | if (fAnalysisType==1) {\r |
182 | if (!fESD) {\r | |
183 | Printf("ERROR: fESD not available");\r | |
184 | return;\r | |
185 | }\r | |
186 | \r | |
78add4e9 | 187 | //Get MC data\r |
188 | AliMCEventHandler* mctruth = (AliMCEventHandler*) \r | |
189 | ((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler());\r | |
190 | \r | |
5e301b78 | 191 | AliGenHijingEventHeader *hdh = 0;\r |
78add4e9 | 192 | if(mctruth) {\r |
193 | fStack = mctruth->MCEvent()->Stack();\r | |
194 | \r | |
195 | AliGenCocktailEventHeader *hd = dynamic_cast<AliGenCocktailEventHeader *> (mctruth->MCEvent()->GenEventHeader());\r | |
196 | \r | |
197 | if (hd) {\r | |
198 | \r | |
e7155bf6 | 199 | // printf ("Got MC cocktail event header %p\n", (void *) hd);\r |
78add4e9 | 200 | TList *lhd = hd->GetHeaders();\r |
e7155bf6 | 201 | // printf ("Got list of headers %d\n", lhd->GetEntries());\r |
78add4e9 | 202 | \r |
203 | for (int iterh=0; iterh<lhd->GetEntries(); iterh++) \r | |
204 | {\r | |
205 | hdh = dynamic_cast<AliGenHijingEventHeader *> (lhd->At(iterh));\r | |
e7155bf6 | 206 | // printf ("HIJING header at %i is %p\n", iterh, (void *) hdh);\r |
78add4e9 | 207 | }\r |
208 | } \r | |
209 | }\r | |
210 | \r | |
dcbc2957 | 211 | // Get ESD\r |
212 | AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());\r | |
213 | \r | |
214 | if (!esdH) {\r | |
215 | Printf("ERROR: Could not get ESDInputHandler");\r | |
216 | return;\r | |
217 | } \r | |
218 | else {\r | |
219 | fESD = esdH->GetEvent();\r | |
220 | }\r | |
221 | \r | |
83f5f758 | 222 | printf("Tracks in ESD: %d \n",fESD->GetNumberOfTracks());\r |
78add4e9 | 223 | \r |
83f5f758 | 224 | if (fESD->GetNumberOfTracks() >= 0) {\r |
77f44ccf | 225 | \r |
78add4e9 | 226 | if (!fReader) {\r |
227 | printf("ERROR: No ESD reader for ESD analysis !\n");\r | |
83f5f758 | 228 | }\r |
78add4e9 | 229 | \r |
230 | AliFemtoEventReaderESDChain* fesdc = dynamic_cast<AliFemtoEventReaderESDChain *> (fReader);\r | |
231 | if (fesdc)\r | |
232 | {\r | |
233 | // Process the event with no Kine information\r | |
234 | fesdc->SetESDSource(fESD);\r | |
235 | fManager->ProcessEvent();\r | |
236 | }\r | |
237 | AliFemtoEventReaderESDChainKine* fesdck = dynamic_cast<AliFemtoEventReaderESDChainKine *> (fReader);\r | |
238 | if (fesdck) \r | |
239 | {\r | |
240 | // Process the event with Kine information\r | |
241 | fesdck->SetESDSource(fESD);\r | |
242 | fesdck->SetStackSource(fStack);\r | |
243 | \r | |
244 | fesdck->SetGenEventHeader(hdh);\r | |
245 | fManager->ProcessEvent();\r | |
246 | }\r | |
03decc29 | 247 | AliFemtoEventReaderStandard* fstd = dynamic_cast<AliFemtoEventReaderStandard *> (fReader);\r |
248 | if (fstd) \r | |
249 | {\r | |
250 | // Process the event with Kine information\r | |
251 | fstd->SetESDSource(fESD);\r | |
252 | if (mctruth) {\r | |
253 | fstd->SetStackSource(fStack);\r | |
254 | fstd->SetGenEventHeader(hdh);\r | |
255 | fstd->SetInputType(AliFemtoEventReaderStandard::kESDKine);\r | |
256 | }\r | |
257 | else\r | |
258 | fstd->SetInputType(AliFemtoEventReaderStandard::kESD);\r | |
259 | fManager->ProcessEvent();\r | |
260 | }\r | |
83f5f758 | 261 | } \r |
2f496816 | 262 | \r |
78add4e9 | 263 | // Post the output histogram list\r |
83f5f758 | 264 | PostData(0, fOutputList);\r |
265 | }\r | |
77f44ccf | 266 | \r |
83f5f758 | 267 | if (fAnalysisType==2) { \r |
268 | if (!fAOD) {\r | |
269 | Printf("ERROR: fAOD not available");\r | |
270 | return;\r | |
271 | }\r | |
dcbc2957 | 272 | \r |
273 | // Get AOD\r | |
274 | AliAODInputHandler *aodH = dynamic_cast<AliAODInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());\r | |
275 | \r | |
276 | if (!aodH) {\r | |
277 | Printf("ERROR: Could not get AODInputHandler");\r | |
278 | return;\r | |
279 | } \r | |
280 | else {\r | |
281 | \r | |
282 | fAOD = aodH->GetEvent();\r | |
283 | }\r | |
284 | \r | |
83f5f758 | 285 | printf("Tracks in AOD: %d \n",fAOD->GetNumberOfTracks());\r |
286 | \r | |
287 | if (fAOD->GetNumberOfTracks() > 0) {\r | |
78add4e9 | 288 | if (!fReader) {\r |
83f5f758 | 289 | printf("ERROR: No AOD reader for AOD analysis! \n");\r |
290 | }\r | |
291 | else {\r | |
78add4e9 | 292 | AliFemtoEventReaderAODChain* faodc = dynamic_cast<AliFemtoEventReaderAODChain *> (fReader);\r |
293 | \r | |
294 | if (faodc) {\r | |
295 | // Process the event\r | |
296 | faodc->SetAODSource(fAOD);\r | |
297 | fManager->ProcessEvent();\r | |
298 | }\r | |
03decc29 | 299 | AliFemtoEventReaderStandard* fstd = dynamic_cast<AliFemtoEventReaderStandard *> (fReader);\r |
300 | \r | |
301 | if (fstd) {\r | |
302 | // Process the event\r | |
303 | fstd->SetAODSource(fAOD);\r | |
304 | fstd->SetInputType(AliFemtoEventReaderStandard::kAOD);\r | |
305 | fManager->ProcessEvent();\r | |
306 | }\r | |
83f5f758 | 307 | }\r |
308 | } \r | |
2f496816 | 309 | \r |
310 | // Post the output histogram list\r | |
83f5f758 | 311 | PostData(0, fOutputList);\r |
77f44ccf | 312 | }\r |
313 | } \r | |
314 | \r | |
315 | //________________________________________________________________________\r | |
316 | void AliAnalysisTaskFemto::Terminate(Option_t *) {\r | |
83f5f758 | 317 | // Do the final processing\r |
81401f04 | 318 | if (fManager) {\r |
319 | fManager->Finish();\r | |
320 | }\r | |
321 | }\r | |
322 | //________________________________________________________________________\r | |
323 | void AliAnalysisTaskFemto:: FinishTaskOutput() {\r | |
324 | // Do the final processing\r | |
325 | if (fManager) {\r | |
326 | fManager->Finish();\r | |
327 | }\r | |
77f44ccf | 328 | }\r |
329 | //________________________________________________________________________\r | |
83f5f758 | 330 | void AliAnalysisTaskFemto::SetFemtoReaderESD(AliFemtoEventReaderESDChain *aReader)\r |
77f44ccf | 331 | {\r |
03decc29 | 332 | printf("Selecting Femto reader for ESD\n");\r |
78add4e9 | 333 | fReader = aReader;\r |
334 | }\r | |
335 | //________________________________________________________________________\r | |
336 | void AliAnalysisTaskFemto::SetFemtoReaderESDKine(AliFemtoEventReaderESDChainKine *aReader)\r | |
337 | {\r | |
03decc29 | 338 | printf("Selecting Femto reader for ESD with Kinematics information\n");\r |
78add4e9 | 339 | fReader = aReader;\r |
83f5f758 | 340 | }\r |
341 | //________________________________________________________________________\r | |
342 | void AliAnalysisTaskFemto::SetFemtoReaderAOD(AliFemtoEventReaderAODChain *aReader)\r | |
343 | {\r | |
55dda989 | 344 | printf("Selecting Femto reader for AOD\n");\r |
78add4e9 | 345 | fReader = aReader;\r |
77f44ccf | 346 | }\r |
03decc29 | 347 | void AliAnalysisTaskFemto::SetFemtoReaderStandard(AliFemtoEventReaderStandard *aReader)\r |
348 | {\r | |
349 | printf("Selecting Standard all-purpose Femto reader\n");\r | |
350 | fReader = aReader;\r | |
351 | }\r | |
77f44ccf | 352 | //________________________________________________________________________\r |
353 | void AliAnalysisTaskFemto::SetFemtoManager(AliFemtoManager *aManager)\r | |
354 | {\r | |
355 | fManager = aManager;\r | |
78add4e9 | 356 | printf("Got reader %p\n", (void *) aManager->EventReader());\r |
357 | AliFemtoEventReaderESDChain *tReaderESDChain = dynamic_cast<AliFemtoEventReaderESDChain *> (aManager->EventReader());\r | |
358 | AliFemtoEventReaderESDChainKine *tReaderESDChainKine = dynamic_cast<AliFemtoEventReaderESDChainKine *> (aManager->EventReader());\r | |
359 | AliFemtoEventReaderAODChain *tReaderAODChain = dynamic_cast<AliFemtoEventReaderAODChain *> (aManager->EventReader());\r | |
03decc29 | 360 | AliFemtoEventReaderStandard *tReaderStandard = dynamic_cast<AliFemtoEventReaderStandard *> (aManager->EventReader());\r |
78add4e9 | 361 | \r |
03decc29 | 362 | if ((!tReaderESDChain) && (!tReaderESDChainKine) && (!tReaderAODChain) && (!tReaderStandard)) {\r |
78add4e9 | 363 | printf("No AliFemto event reader created. Will not run femto analysis.\n");\r |
364 | return;\r | |
365 | }\r | |
366 | if (tReaderESDChain) SetFemtoReaderESD(tReaderESDChain);\r | |
367 | if (tReaderESDChainKine) SetFemtoReaderESDKine(tReaderESDChainKine);\r | |
368 | if (tReaderAODChain) SetFemtoReaderAOD(tReaderAODChain);\r | |
03decc29 | 369 | if (tReaderStandard) SetFemtoReaderStandard(tReaderStandard);\r |
77f44ccf | 370 | }\r |
77f44ccf | 371 | \r |