]>
Commit | Line | Data |
---|---|---|
1c1d4332 | 1 | /************************************************************************* |
2 | * Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
fdff44c8 | 16 | //////////////////////////////////////////////////// |
17 | // AliAnalysisTaskFlowEvent: | |
18 | // | |
19 | // analysis task for filling the flow event | |
20 | // from MCEvent, ESD, AOD .... | |
21 | // and put it in an output stream so it can | |
22 | // be used by the various flow analysis methods | |
23 | // for cuts the correction framework is used | |
24 | // which also outputs QA histograms to view | |
25 | // the effects of the cuts | |
26 | //////////////////////////////////////////////////// | |
27 | ||
1c1d4332 | 28 | #include "Riostream.h" //needed as include |
29 | #include "TChain.h" | |
30 | #include "TTree.h" | |
31 | #include "TFile.h" //needed as include | |
32 | #include "TList.h" | |
489fdf79 | 33 | #include "TRandom3.h" |
34 | #include "TTimeStamp.h" | |
1c1d4332 | 35 | |
7183fe85 | 36 | // ALICE Analysis Framework |
1c1d4332 | 37 | class AliAnalysisTask; |
38 | #include "AliAnalysisManager.h" | |
39 | ||
7183fe85 | 40 | // ESD interface |
1c1d4332 | 41 | #include "AliESDEvent.h" |
42 | #include "AliESDInputHandler.h" | |
43 | ||
7183fe85 | 44 | // AOD interface |
1c1d4332 | 45 | #include "AliAODEvent.h" |
46 | #include "AliAODInputHandler.h" | |
47 | ||
7183fe85 | 48 | // Monte Carlo Event |
1c1d4332 | 49 | #include "AliMCEventHandler.h" |
50 | #include "AliMCEvent.h" | |
51 | ||
7183fe85 | 52 | // ALICE Correction Framework |
1c1d4332 | 53 | #include "AliCFManager.h" |
54 | ||
7183fe85 | 55 | // Interface to Event generators to get Reaction Plane Angle |
56 | #include "AliGenCocktailEventHeader.h" | |
57 | #include "AliGenHijingEventHeader.h" | |
48ad51a1 | 58 | #include "AliGenGeVSimEventHeader.h" |
26f120fa | 59 | #include "AliGenEposEventHeader.h" |
7183fe85 | 60 | |
61 | // Interface to make the Flow Event Simple used in the flow analysis methods | |
1c1d4332 | 62 | #include "AliFlowEventSimpleMaker.h" |
63 | ||
7183fe85 | 64 | #include "AliAnalysisTaskFlowEvent.h" |
65 | ||
1c1d4332 | 66 | |
67 | ClassImp(AliAnalysisTaskFlowEvent) | |
73160af6 | 68 | |
1c1d4332 | 69 | //________________________________________________________________________ |
70 | AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent(const char *name, Bool_t on) : | |
71 | AliAnalysisTask(name, ""), | |
46bec39c | 72 | // fOutputFile(NULL), |
1c1d4332 | 73 | fESD(NULL), |
74 | fAOD(NULL), | |
75 | fEventMaker(NULL), | |
76 | fAnalysisType("ESD"), | |
77 | fCFManager1(NULL), | |
78 | fCFManager2(NULL), | |
79 | fQAInt(NULL), | |
80 | fQADiff(NULL), | |
fdff44c8 | 81 | fMinMult(0), |
82 | fMaxMult(10000000), | |
489fdf79 | 83 | fQA(on), |
84 | fMCReactionPlaneAngle(0.), | |
85 | fCount(0), | |
86 | fNoOfLoops(1), | |
87 | fEllipticFlowValue(0.), | |
88 | fSigmaEllipticFlowValue(0.), | |
89 | fMultiplicityOfEvent(1000000000), | |
90 | fSigmaMultiplicityOfEvent(0), | |
91 | fMyTRandom3(NULL) | |
1c1d4332 | 92 | { |
93 | // Constructor | |
94 | cout<<"AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent(const char *name)"<<endl; | |
95 | ||
96 | // Define input and output slots here | |
97 | // Input slot #0 works with a TChain | |
98 | DefineInput(0, TChain::Class()); | |
46bec39c | 99 | // Define here the flow event output |
100 | DefineOutput(0, AliFlowEventSimple::Class()); | |
1c1d4332 | 101 | if(on) { |
102 | DefineOutput(1, TList::Class()); | |
103 | DefineOutput(2, TList::Class()); } | |
46bec39c | 104 | // and for testing open an output file |
489fdf79 | 105 | // fOutputFile = new TFile("FlowEvents.root","RECREATE"); |
1c1d4332 | 106 | |
107 | } | |
108 | ||
109 | //________________________________________________________________________ | |
110 | AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent() : | |
46bec39c | 111 | // fOutputFile(NULL), |
1c1d4332 | 112 | fESD(NULL), |
113 | fAOD(NULL), | |
114 | fEventMaker(NULL), | |
115 | fAnalysisType("ESD"), | |
116 | fCFManager1(NULL), | |
117 | fCFManager2(NULL), | |
118 | fQAInt(NULL), | |
119 | fQADiff(NULL), | |
fdff44c8 | 120 | fMinMult(0), |
121 | fMaxMult(10000000), | |
489fdf79 | 122 | fQA(kFALSE), |
123 | fMCReactionPlaneAngle(0.), | |
124 | fCount(0), | |
125 | fNoOfLoops(1), | |
126 | fEllipticFlowValue(0.), | |
127 | fSigmaEllipticFlowValue(0.), | |
128 | fMultiplicityOfEvent(1000000000), | |
129 | fSigmaMultiplicityOfEvent(0), | |
130 | fMyTRandom3(NULL) | |
1c1d4332 | 131 | { |
132 | // Constructor | |
133 | cout<<"AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent()"<<endl; | |
134 | } | |
135 | ||
489fdf79 | 136 | //________________________________________________________________________ |
137 | AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent(const char *name, Bool_t on, UInt_t iseed) : | |
138 | AliAnalysisTask(name, ""), | |
139 | // fOutputFile(NULL), | |
140 | fESD(NULL), | |
141 | fAOD(NULL), | |
142 | fEventMaker(NULL), | |
143 | fAnalysisType("ESD"), | |
144 | fCFManager1(NULL), | |
145 | fCFManager2(NULL), | |
146 | fQAInt(NULL), | |
147 | fQADiff(NULL), | |
fdff44c8 | 148 | fMinMult(0), |
149 | fMaxMult(10000000), | |
489fdf79 | 150 | fQA(on), |
151 | fMCReactionPlaneAngle(0.), | |
152 | fCount(0), | |
153 | fNoOfLoops(1), | |
154 | fEllipticFlowValue(0.), | |
155 | fSigmaEllipticFlowValue(0.), | |
156 | fMultiplicityOfEvent(1000000000), | |
157 | fSigmaMultiplicityOfEvent(0), | |
158 | fMyTRandom3(NULL) | |
159 | { | |
160 | // Constructor | |
161 | cout<<"AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent(const char *name, Bool_t on, UInt_t iseed)"<<endl; | |
162 | ||
163 | fMyTRandom3 = new TRandom3(iseed); | |
164 | gRandom->SetSeed(fMyTRandom3->Integer(65539)); | |
165 | ||
166 | // Define input and output slots here | |
167 | // Input slot #0 works with a TChain | |
168 | DefineInput(0, TChain::Class()); | |
169 | // Define here the flow event output | |
170 | DefineOutput(0, AliFlowEventSimple::Class()); | |
171 | if(on) { | |
172 | DefineOutput(1, TList::Class()); | |
173 | DefineOutput(2, TList::Class()); } | |
174 | // and for testing open an output file | |
175 | // fOutputFile = new TFile("FlowEvents.root","RECREATE"); | |
176 | ||
177 | } | |
178 | ||
1c1d4332 | 179 | //________________________________________________________________________ |
180 | AliAnalysisTaskFlowEvent::~AliAnalysisTaskFlowEvent() | |
181 | { | |
182 | // | |
183 | // Destructor | |
184 | // | |
489fdf79 | 185 | if (fMyTRandom3) delete fMyTRandom3; |
1c1d4332 | 186 | // objects in the output list are deleted |
187 | // by the TSelector dtor (I hope) | |
188 | ||
189 | } | |
190 | ||
191 | //________________________________________________________________________ | |
192 | void AliAnalysisTaskFlowEvent::ConnectInputData(Option_t *) | |
193 | { | |
194 | // Connect ESD or AOD here | |
195 | // Called once | |
196 | cout<<"AliAnalysisTaskFlowEvent::ConnectInputData(Option_t *)"<<endl; | |
197 | ||
198 | TTree* tree = dynamic_cast<TTree*> (GetInputData(0)); | |
199 | if (!tree) { | |
200 | Printf("ERROR: Could not read chain from input slot 0"); | |
3507ac7e | 201 | } |
202 | else { | |
203 | if (fAnalysisType == "ESD" || fAnalysisType == "ESDMC0" || fAnalysisType == "ESDMC1" || fAnalysisType == "MC") { | |
1c1d4332 | 204 | AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()); |
1c1d4332 | 205 | if (!esdH) { |
206 | Printf("ERROR: Could not get ESDInputHandler"); | |
3507ac7e | 207 | } |
208 | else {fESD = esdH->GetEvent();} | |
1c1d4332 | 209 | } |
210 | else if (fAnalysisType == "AOD") { | |
211 | AliAODInputHandler *aodH = dynamic_cast<AliAODInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()); | |
1c1d4332 | 212 | if (!aodH) { |
213 | Printf("ERROR: Could not get AODInputHandler"); | |
214 | } | |
3507ac7e | 215 | else { fAOD = aodH->GetEvent();} |
1c1d4332 | 216 | } |
217 | else { | |
218 | Printf("!!!!!Wrong analysis type: Only ESD, ESDMC0, ESDMC1, AOD and MC types are allowed!"); | |
219 | exit(1); | |
1c1d4332 | 220 | } |
221 | } | |
222 | } | |
223 | ||
224 | //________________________________________________________________________ | |
225 | void AliAnalysisTaskFlowEvent::CreateOutputObjects() | |
226 | { | |
227 | // Called at every worker node to initialize | |
228 | cout<<"AliAnalysisTaskFlowEvent::CreateOutputObjects()"<<endl; | |
229 | ||
230 | if (!(fAnalysisType == "AOD" || fAnalysisType == "ESD" || fAnalysisType == "ESDMC0" || fAnalysisType == "ESDMC1" || fAnalysisType == "MC")) { | |
231 | cout<<"WRONG ANALYSIS TYPE! only ESD, ESDMC0, ESDMC1, AOD and MC are allowed."<<endl; | |
232 | exit(1); | |
233 | } | |
234 | ||
235 | // Flow Event maker | |
236 | fEventMaker = new AliFlowEventSimpleMaker(); | |
237 | } | |
238 | ||
239 | //________________________________________________________________________ | |
240 | void AliAnalysisTaskFlowEvent::Exec(Option_t *) | |
241 | { | |
242 | // Main loop | |
243 | // Called for each event | |
89f41a6a | 244 | AliFlowEventSimple* fEvent = NULL; |
7183fe85 | 245 | Double_t fRP = 0.; // the monte carlo reaction plane angle |
246 | AliMCEvent* mcEvent = NULL; | |
247 | // See if we can get Monte Carlo Information and if so get the reaction plane | |
248 | ||
249 | AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()); | |
250 | if (eventHandler) { | |
251 | mcEvent = eventHandler->MCEvent(); | |
252 | if (mcEvent) { | |
26f120fa | 253 | |
d5acfb36 | 254 | //COCKTAIL with HIJING |
c9f92d16 | 255 | if (!strcmp(mcEvent-> GenEventHeader()->GetName(),"Cocktail Header")) { //returns 0 if matches |
256 | AliGenCocktailEventHeader *headerC = dynamic_cast<AliGenCocktailEventHeader *> (mcEvent-> GenEventHeader()); | |
257 | if (headerC) { | |
258 | TList *lhd = headerC->GetHeaders(); | |
259 | if (lhd) { | |
260 | AliGenHijingEventHeader *hdh = dynamic_cast<AliGenHijingEventHeader *> (lhd->At(0)); | |
261 | if (hdh) { | |
262 | fRP = hdh->ReactionPlaneAngle(); | |
489fdf79 | 263 | //cout<<"The reactionPlane from Hijing is: "<< fRP <<endl; |
c9f92d16 | 264 | } |
7183fe85 | 265 | } |
266 | } | |
c9f92d16 | 267 | //else { cout<<"headerC is NULL"<<endl; } |
268 | } | |
26f120fa | 269 | |
d5acfb36 | 270 | //GEVSIM |
c9f92d16 | 271 | else if (!strcmp(mcEvent-> GenEventHeader()->GetName(),"GeVSim header")) { //returns 0 if matches |
272 | AliGenGeVSimEventHeader* headerG = (AliGenGeVSimEventHeader*)(mcEvent->GenEventHeader()); | |
273 | if (headerG) { | |
274 | fRP = headerG->GetEventPlane(); | |
275 | //cout<<"The reactionPlane from GeVSim is: "<< fRP <<endl; | |
276 | } | |
277 | //else { cout<<"headerG is NULL"<<endl; } | |
7183fe85 | 278 | } |
26f120fa | 279 | |
d5acfb36 | 280 | //HIJING |
281 | else if (!strcmp(mcEvent-> GenEventHeader()->GetName(),"Hijing")) { //returns 0 if matches | |
282 | AliGenHijingEventHeader* headerH = (AliGenHijingEventHeader*)(mcEvent->GenEventHeader()); | |
283 | if (headerH) { | |
284 | fRP = headerH->ReactionPlaneAngle(); | |
285 | //cout<<"The reactionPlane from Hijing is: "<< fRP <<endl; | |
286 | } | |
287 | //else { cout<<"headerH is NULL"<<endl; } | |
288 | } | |
26f120fa | 289 | |
290 | //EPOS | |
291 | else if (!strcmp(mcEvent->GenEventHeader()->GetName(),"EPOS")) { | |
292 | AliGenEposEventHeader* headerE = (AliGenEposEventHeader*)(mcEvent->GenEventHeader()); | |
293 | if (headerE) { | |
294 | fRP = headerE->ReactionPlaneAngle(); | |
295 | //cout<<"The reactionPlane from EPOS is: "<< fR <<endl; | |
296 | } | |
297 | //else { cout<<"headerE is NULL"<<endl; } | |
298 | } | |
299 | ||
7183fe85 | 300 | } |
489fdf79 | 301 | //else {cout<<"No MC event!"<<endl; } |
d5acfb36 | 302 | |
7183fe85 | 303 | } |
c9f92d16 | 304 | //else {cout<<"No eventHandler!"<<endl; } |
fdff44c8 | 305 | |
fdff44c8 | 306 | |
f1f90185 | 307 | fEventMaker->SetMCReactionPlaneAngle(fRP); |
fdff44c8 | 308 | //setting event cuts |
309 | fEventMaker->SetMinMult(fMinMult); | |
310 | fEventMaker->SetMaxMult(fMaxMult); | |
f1f90185 | 311 | |
312 | if (fEllipticFlowValue != 0.) { | |
313 | // set the value of the monte carlo event plane for the flow event | |
314 | cout << "settings for afterburner in TaskFlowEvent.cxx:" << endl; | |
315 | cout << "fCount" << fCount << endl; | |
316 | cout << "fNoOfLoops" << fNoOfLoops << endl; | |
317 | cout << "fEllipticFlowValue" << fEllipticFlowValue << endl; | |
318 | cout << "fSigmaEllipticFlowValue" << fSigmaEllipticFlowValue << endl; | |
319 | cout << "fMultiplicityOfEvent" << fMultiplicityOfEvent << endl; | |
320 | cout << "fSigmaMultiplicityOfEvent" << fSigmaMultiplicityOfEvent << endl; | |
321 | ||
322 | Double_t xRPangle=0.; | |
323 | Double_t xNewFlowValue = 0.; | |
324 | Int_t nNewMultOfEvent = 100000000; | |
325 | ||
326 | if (fMyTRandom3) { | |
327 | xRPangle = TMath::TwoPi()*(fMyTRandom3->Rndm()); | |
328 | xNewFlowValue = fMyTRandom3->Gaus(fEllipticFlowValue,fSigmaEllipticFlowValue); | |
329 | nNewMultOfEvent = fMyTRandom3->Gaus(fMultiplicityOfEvent,fSigmaMultiplicityOfEvent); | |
330 | } | |
331 | else { | |
332 | cout << "no random generator pointer initialized " << endl; | |
333 | } | |
334 | cout << "xRPangle = " << xRPangle << endl; | |
335 | cout << "xNewFlowValue = " << xNewFlowValue << endl; | |
336 | cout << "nNewMultOfEvent = " << nNewMultOfEvent << endl; | |
337 | cout << "settings for after burner" << endl; | |
338 | ||
339 | fEventMaker->SetMCReactionPlaneAngle(xRPangle); | |
340 | fEventMaker->SetNoOfLoops(fNoOfLoops); | |
341 | fEventMaker->SetEllipticFlowValue(xNewFlowValue); | |
342 | fEventMaker->SetMultiplicityOfEvent(nNewMultOfEvent); | |
343 | //end settings afterburner | |
344 | } | |
345 | ||
d5acfb36 | 346 | |
62726ef0 | 347 | // Fill the FlowEventSimple for MC input |
1c1d4332 | 348 | if (fAnalysisType == "MC") { |
587b0a35 | 349 | if (!fCFManager1) {cout << "ERROR: No pointer to correction framework cuts! " << endl; return; } |
350 | if (!fCFManager2) {cout << "ERROR: No pointer to correction framework cuts! " << endl; return; } | |
1c1d4332 | 351 | |
352 | // Process MC truth, therefore we receive the AliAnalysisManager and ask it for the AliMCEventHandler | |
353 | // This handler can return the current MC event | |
587b0a35 | 354 | if (!mcEvent) { Printf("ERROR: Could not retrieve MC event"); return;} |
1c1d4332 | 355 | |
356 | fCFManager1->SetEventInfo(mcEvent); | |
357 | fCFManager2->SetEventInfo(mcEvent); | |
587b0a35 | 358 | |
1c1d4332 | 359 | // analysis |
7183fe85 | 360 | Printf("Number of MC particles: %d", mcEvent->GetNumberOfTracks()); |
89f41a6a | 361 | fEvent = fEventMaker->FillTracks(mcEvent,fCFManager1,fCFManager2); |
1c1d4332 | 362 | // here we have the fEvent and want to make it available as an output stream |
7183fe85 | 363 | // so no delete fEvent; |
1c1d4332 | 364 | } |
62726ef0 | 365 | // Fill the FlowEventSimple for ESD input |
1c1d4332 | 366 | else if (fAnalysisType == "ESD") { |
587b0a35 | 367 | if (!fCFManager1) {cout << "ERROR: No pointer to correction framework cuts! " << endl; return; } |
368 | if (!fCFManager2) {cout << "ERROR: No pointer to correction framework cuts! " << endl; return; } | |
369 | ||
370 | if (!fESD) { Printf("ERROR: fESD not available"); return;} | |
1c1d4332 | 371 | Printf("There are %d tracks in this event", fESD->GetNumberOfTracks()); |
372 | ||
373 | // analysis | |
89f41a6a | 374 | fEvent = fEventMaker->FillTracks(fESD,fCFManager1,fCFManager2); |
1c1d4332 | 375 | } |
62726ef0 | 376 | // Fill the FlowEventSimple for ESD input combined with MC info |
1c1d4332 | 377 | else if (fAnalysisType == "ESDMC0" || fAnalysisType == "ESDMC1" ) { |
587b0a35 | 378 | if (!fCFManager1) {cout << "ERROR: No pointer to correction framework cuts! " << endl; return; } |
379 | if (!fCFManager2) {cout << "ERROR: No pointer to correction framework cuts! " << endl; return; } | |
380 | if (!fESD) { Printf("ERROR: fESD not available"); return;} | |
1c1d4332 | 381 | Printf("There are %d tracks in this event", fESD->GetNumberOfTracks()); |
382 | ||
587b0a35 | 383 | if (!mcEvent) {Printf("ERROR: Could not retrieve MC event"); return;} |
1c1d4332 | 384 | |
385 | fCFManager1->SetEventInfo(mcEvent); | |
386 | fCFManager2->SetEventInfo(mcEvent); | |
387 | ||
489fdf79 | 388 | |
1c1d4332 | 389 | if (fAnalysisType == "ESDMC0") { |
390 | fEvent = fEventMaker->FillTracks(fESD, mcEvent, fCFManager1, fCFManager2, 0); //0 = kine from ESD, 1 = kine from MC | |
391 | } else if (fAnalysisType == "ESDMC1") { | |
392 | fEvent = fEventMaker->FillTracks(fESD, mcEvent, fCFManager1, fCFManager2, 1); //0 = kine from ESD, 1 = kine from MC | |
393 | } | |
1c1d4332 | 394 | } |
62726ef0 | 395 | // Fill the FlowEventSimple for AOD input |
1c1d4332 | 396 | else if (fAnalysisType == "AOD") { |
587b0a35 | 397 | if (!fAOD) {Printf("ERROR: fAOD not available"); return;} |
1c1d4332 | 398 | Printf("There are %d tracks in this event", fAOD->GetNumberOfTracks()); |
399 | ||
400 | // analysis | |
401 | //For the moment don't use CF //AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fAOD,fCFManager1,fCFManager2); | |
89f41a6a | 402 | fEvent = fEventMaker->FillTracks(fAOD); |
1c1d4332 | 403 | } |
404 | ||
46bec39c | 405 | //fListHistos->Print(); |
406 | // fOutputFile->WriteObject(fEvent,"myFlowEventSimple"); | |
1c1d4332 | 407 | PostData(0,fEvent); |
408 | if (fQA) { | |
409 | PostData(1,fQAInt); | |
410 | PostData(2,fQADiff); } | |
411 | } | |
412 | ||
413 | //________________________________________________________________________ | |
414 | void AliAnalysisTaskFlowEvent::Terminate(Option_t *) | |
415 | { | |
416 | // Called once at the end of the query -- do not call in case of CAF | |
417 | ||
418 | } | |
489fdf79 | 419 | |
420 |