]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/FLOW/AliFlowTasks/AliAnalysisTaskFlowEvent.cxx
Generation of Lambda(1520) in Pythia 6.4
[u/mrichter/AliRoot.git] / PWG2 / FLOW / AliFlowTasks / AliAnalysisTaskFlowEvent.cxx
CommitLineData
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 *
940a5ed1 13* provided "as is" without express or implied warranty. *
1c1d4332 14**************************************************************************/
15
fdff44c8 16////////////////////////////////////////////////////
17// AliAnalysisTaskFlowEvent:
18//
19// analysis task for filling the flow event
20// from MCEvent, ESD, AOD ....
940a5ed1 21// and put it in an output stream so it can
22// be used by the various flow analysis methods
fdff44c8 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"
44e060e0 33#include "TH2F.h"
489fdf79 34#include "TRandom3.h"
35#include "TTimeStamp.h"
1c1d4332 36
7183fe85 37// ALICE Analysis Framework
1c1d4332 38#include "AliAnalysisManager.h"
fbdb53fa 39#include "AliAnalysisTaskSE.h"
85d2ee8d 40#include "AliESDtrackCuts.h"
1c1d4332 41
7183fe85 42// ESD interface
1c1d4332 43#include "AliESDEvent.h"
44#include "AliESDInputHandler.h"
45
7183fe85 46// AOD interface
1c1d4332 47#include "AliAODEvent.h"
48#include "AliAODInputHandler.h"
49
7183fe85 50// Monte Carlo Event
1c1d4332 51#include "AliMCEventHandler.h"
52#include "AliMCEvent.h"
53
7183fe85 54// ALICE Correction Framework
1c1d4332 55#include "AliCFManager.h"
56
7183fe85 57// Interface to Event generators to get Reaction Plane Angle
58#include "AliGenCocktailEventHeader.h"
59#include "AliGenHijingEventHeader.h"
48ad51a1 60#include "AliGenGeVSimEventHeader.h"
26f120fa 61#include "AliGenEposEventHeader.h"
7183fe85 62
6e214c87 63// Interface to Load short life particles
64#include "TObjArray.h"
65#include "AliFlowCandidateTrack.h"
66
7183fe85 67// Interface to make the Flow Event Simple used in the flow analysis methods
940a5ed1 68#include "AliFlowEvent.h"
daf66719 69#include "AliFlowTrackCuts.h"
70#include "AliFlowEventCuts.h"
d459546b 71#include "AliFlowCommonConstants.h"
7183fe85 72#include "AliAnalysisTaskFlowEvent.h"
73
77111ee6 74#include "AliLog.h"
75
1c1d4332 76ClassImp(AliAnalysisTaskFlowEvent)
940a5ed1 77
1c1d4332 78//________________________________________________________________________
940a5ed1 79AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent() :
80 AliAnalysisTaskSE(),
46bec39c 81 // fOutputFile(NULL),
12b2b8bc 82 fAnalysisType("AUTOMATIC"),
ef4799a7 83 fRPType("Global"),
1c1d4332 84 fCFManager1(NULL),
85 fCFManager2(NULL),
daf66719 86 fCutsEvent(NULL),
87 fCutsRP(NULL),
88 fCutsPOI(NULL),
1c1d4332 89 fQAInt(NULL),
90 fQADiff(NULL),
fdff44c8 91 fMinMult(0),
92 fMaxMult(10000000),
7a01f4a7 93 fMinA(-1.0),
94 fMaxA(-0.01),
95 fMinB(0.01),
96 fMaxB(1.0),
489fdf79 97 fQA(kFALSE),
6e214c87 98 fLoadCandidates(kFALSE),
d459546b 99 fNbinsMult(10000),
100 fNbinsPt(100),
101 fNbinsPhi(100),
102 fNbinsEta(200),
103 fNbinsQ(500),
104 fMultMin(0.),
105 fMultMax(10000.),
106 fPtMin(0.),
107 fPtMax(10.),
108 fPhiMin(0.),
109 fPhiMax(TMath::TwoPi()),
110 fEtaMin(-5.),
111 fEtaMax(5.),
112 fQMin(0.),
113 fQMax(3.),
f6f8c3fc 114 fExcludedEtaMin(0.),
115 fExcludedEtaMax(0.),
116 fExcludedPhiMin(0.),
117 fExcludedPhiMax(0.),
54089829 118 fAfterburnerOn(kFALSE),
119 fNonFlowNumberOfTrackClones(0),
120 fV1(0.),
121 fV2(0.),
122 fV3(0.),
123 fV4(0.),
aab6527a 124 fMyTRandom3(NULL)
1c1d4332 125{
126 // Constructor
127 cout<<"AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent()"<<endl;
128}
129
489fdf79 130//________________________________________________________________________
6e214c87 131AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent(const char *name, TString RPtype, Bool_t on, UInt_t iseed, Bool_t bCandidates) :
940a5ed1 132 AliAnalysisTaskSE(name),
133 // fOutputFile(NULL),
12b2b8bc 134 fAnalysisType("AUTOMATIC"),
44e060e0 135 fRPType(RPtype),
489fdf79 136 fCFManager1(NULL),
137 fCFManager2(NULL),
daf66719 138 fCutsEvent(NULL),
139 fCutsRP(NULL),
140 fCutsPOI(NULL),
489fdf79 141 fQAInt(NULL),
142 fQADiff(NULL),
fdff44c8 143 fMinMult(0),
144 fMaxMult(10000000),
7a01f4a7 145 fMinA(-1.0),
146 fMaxA(-0.01),
147 fMinB(0.01),
148 fMaxB(1.0),
489fdf79 149 fQA(on),
6e214c87 150 fLoadCandidates(bCandidates),
d459546b 151 fNbinsMult(10000),
152 fNbinsPt(100),
153 fNbinsPhi(100),
154 fNbinsEta(200),
155 fNbinsQ(500),
156 fMultMin(0.),
157 fMultMax(10000.),
158 fPtMin(0.),
159 fPtMax(10.),
160 fPhiMin(0.),
161 fPhiMax(TMath::TwoPi()),
162 fEtaMin(-5.),
163 fEtaMax(5.),
164 fQMin(0.),
165 fQMax(3.),
f6f8c3fc 166 fExcludedEtaMin(0.),
167 fExcludedEtaMax(0.),
168 fExcludedPhiMin(0.),
169 fExcludedPhiMax(0.),
54089829 170 fAfterburnerOn(kFALSE),
171 fNonFlowNumberOfTrackClones(0),
172 fV1(0.),
173 fV2(0.),
174 fV3(0.),
175 fV4(0.),
aab6527a 176 fMyTRandom3(NULL)
489fdf79 177{
178 // Constructor
179 cout<<"AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent(const char *name, Bool_t on, UInt_t iseed)"<<endl;
940a5ed1 180 fMyTRandom3 = new TRandom3(iseed);
489fdf79 181 gRandom->SetSeed(fMyTRandom3->Integer(65539));
65201059 182
6e214c87 183 int availableINslot=1;
44e060e0 184 //FMD input slot
185 if (strcmp(RPtype,"FMD")==0) {
6e214c87 186 DefineInput(availableINslot++, TList::Class());
44e060e0 187 }
6e214c87 188 //Candidates input slot
189 if( fLoadCandidates )
190 DefineInput(availableINslot, TObjArray::Class());
65201059 191
192 // Define output slots here
489fdf79 193 // Define here the flow event output
940a5ed1 194 DefineOutput(1, AliFlowEventSimple::Class());
195 if(on)
196 {
65201059 197 DefineOutput(2, TList::Class());
940a5ed1 198 DefineOutput(3, TList::Class());
199 }
6e214c87 200
489fdf79 201 // and for testing open an output file
202 // fOutputFile = new TFile("FlowEvents.root","RECREATE");
203
204}
205
1c1d4332 206//________________________________________________________________________
207AliAnalysisTaskFlowEvent::~AliAnalysisTaskFlowEvent()
208{
209 //
210 // Destructor
211 //
32b846cd 212 delete fMyTRandom3;
940a5ed1 213 // objects in the output list are deleted
1c1d4332 214 // by the TSelector dtor (I hope)
215
216}
217
32b846cd 218//________________________________________________________________________
219void AliAnalysisTaskFlowEvent::NotifyRun()
220{
221 //at the beginning of each new run
222 AliESDEvent* fESD = dynamic_cast<AliESDEvent*> (InputEvent());
2a745a5f 223 if (!fESD) return;
3abf7ecc 224
225 Int_t run = fESD->GetRunNumber();
226 AliInfo(Form("Stariting run #%i",run));
32b846cd 227}
228
1c1d4332 229//________________________________________________________________________
940a5ed1 230void AliAnalysisTaskFlowEvent::UserCreateOutputObjects()
1c1d4332 231{
232 // Called at every worker node to initialize
233 cout<<"AliAnalysisTaskFlowEvent::CreateOutputObjects()"<<endl;
234
12b2b8bc 235 if (!(fAnalysisType == "AOD" || fAnalysisType == "ESD" || fAnalysisType == "ESDMCkineESD" || fAnalysisType == "ESDMCkineMC" || fAnalysisType == "MC" || fAnalysisType == "AUTOMATIC"))
940a5ed1 236 {
12b2b8bc 237 AliError("WRONG ANALYSIS TYPE! only ESD, ESDMCkineESD, ESDMCkineMC, AOD, MC and AUTOMATIC are allowed.");
1c1d4332 238 exit(1);
239 }
d459546b 240
241 //set the common constants
242 AliFlowCommonConstants* cc = AliFlowCommonConstants::GetMaster();
243 cc->SetNbinsMult(fNbinsMult);
244 cc->SetNbinsPt(fNbinsPt);
245 cc->SetNbinsPhi(fNbinsPhi);
246 cc->SetNbinsEta(fNbinsEta);
247 cc->SetNbinsQ(fNbinsQ);
248 cc->SetMultMin(fMultMin);
249 cc->SetMultMax(fMultMax);
250 cc->SetPtMin(fPtMin);
251 cc->SetPtMax(fPtMax);
252 cc->SetPhiMin(fPhiMin);
253 cc->SetPhiMax(fPhiMax);
254 cc->SetEtaMin(fEtaMin);
255 cc->SetEtaMax(fEtaMax);
256 cc->SetQMin(fQMin);
257 cc->SetQMax(fQMax);
258
1c1d4332 259}
260
261//________________________________________________________________________
940a5ed1 262void AliAnalysisTaskFlowEvent::UserExec(Option_t *)
1c1d4332 263{
264 // Main loop
265 // Called for each event
940a5ed1 266 AliFlowEvent* flowEvent = NULL;
267 AliMCEvent* mcEvent = MCEvent(); // from TaskSE
268 AliESDEvent* myESD = dynamic_cast<AliESDEvent*>(InputEvent()); // from TaskSE
269 AliAODEvent* myAOD = dynamic_cast<AliAODEvent*>(InputEvent()); // from TaskSE
ef4799a7 270 AliMultiplicity* myTracklets = NULL;
333ce021 271 AliESDPmdTrack* pmdtracks = NULL;//pmd
ef4799a7 272
6e214c87 273 int availableINslot=1;
3ca4688a 274
2a745a5f 275 if (!(fCutsRP&&fCutsPOI&&fCutsEvent))
276 {
277 AliError("cuts not set");
278 return;
279 }
280
3abf7ecc 281 //use the new and temporarily incomplete way of doing things
12b2b8bc 282 if (fAnalysisType == "AUTOMATIC")
daf66719 283 {
7d9ab4fb 284 //check event cuts
2a745a5f 285 if (!fCutsEvent->IsSelected(InputEvent())) return;
7d9ab4fb 286
03d364db 287 //first attach all possible information to the cuts
441ea1cf 288 fCutsRP->SetEvent( InputEvent(), MCEvent() ); //attach event
289 fCutsPOI->SetEvent( InputEvent(), MCEvent() );
32b846cd 290
03d364db 291 //then make the event
292 flowEvent = new AliFlowEvent( fCutsRP, fCutsPOI );
daf66719 293 if (myESD)
9a0783cc 294 flowEvent->SetReferenceMultiplicity(fCutsEvent->GetReferenceMultiplicity(InputEvent()));
333ce021 295 if (mcEvent && mcEvent->GenEventHeader()) flowEvent->SetMCReactionPlaneAngle(mcEvent);
daf66719 296 }
940a5ed1 297
298 // Make the FlowEvent for MC input
a0241c3a 299 else if (fAnalysisType == "MC")
940a5ed1 300 {
1c1d4332 301 // Process MC truth, therefore we receive the AliAnalysisManager and ask it for the AliMCEventHandler
302 // This handler can return the current MC event
940a5ed1 303 if (!(fCFManager1&&fCFManager2))
304 {
77111ee6 305 AliError("ERROR: No pointer to correction framework cuts! ");
940a5ed1 306 return;
307 }
308 if (!mcEvent)
309 {
77111ee6 310 AliError("ERROR: Could not retrieve MC event");
940a5ed1 311 return;
312 }
1c1d4332 313
6d7734d2 314 fCFManager1->SetMCEventInfo(mcEvent);
315 fCFManager2->SetMCEventInfo(mcEvent);
940a5ed1 316
77111ee6 317 AliInfo(Form("Number of MC particles: %d", mcEvent->GetNumberOfTracks()));
318
319 //check multiplicity
320 if (!fCFManager1->CheckEventCuts(AliCFManager::kEvtGenCuts,mcEvent))
321 {
322 AliWarning("Event does not pass multiplicity cuts"); return;
323 }
324 //make event
940a5ed1 325 flowEvent = new AliFlowEvent(mcEvent,fCFManager1,fCFManager2);
1c1d4332 326 }
ef4799a7 327
940a5ed1 328 // Make the FlowEvent for ESD input
329 else if (fAnalysisType == "ESD")
330 {
331 if (!(fCFManager1&&fCFManager2))
332 {
77111ee6 333 AliError("ERROR: No pointer to correction framework cuts!");
940a5ed1 334 return;
335 }
336 if (!myESD)
337 {
77111ee6 338 AliError("ERROR: ESD not available");
940a5ed1 339 return;
340 }
77111ee6 341
b0569f96 342 //check the offline trigger (check if the event has the correct trigger)
ade93aa4 343 AliInfo(Form("ESD has %d tracks", fInputEvent->GetNumberOfTracks()));
77111ee6 344
345 //check multiplicity
346 if (!fCFManager1->CheckEventCuts(AliCFManager::kEvtRecCuts,myESD))
347 {
348 AliWarning("Event does not pass multiplicity cuts"); return;
349 }
350
351 //make event
ef4799a7 352 if (fRPType == "Global") {
353 flowEvent = new AliFlowEvent(myESD,fCFManager1,fCFManager2);
354 }
a0241c3a 355 else if (fRPType == "TPCOnly") {
cd755f77 356 flowEvent = new AliFlowEvent(myESD,fCFManager2,kFALSE);
357 }
a0241c3a 358 else if (fRPType == "TPCHybrid") {
cd755f77 359 flowEvent = new AliFlowEvent(myESD,fCFManager2,kTRUE);
360 }
ef4799a7 361 else if (fRPType == "Tracklet"){
362 flowEvent = new AliFlowEvent(myESD,myTracklets,fCFManager2);
363 }
44e060e0 364 else if (fRPType == "FMD"){
dd60b476 365 TList* FMDdata = dynamic_cast<TList*>(GetInputData(availableINslot++));
366 if(!FMDdata) {
367 cout<<" No FMDdata "<<endl;
368 return;
369 }
370 TH2F* histFMD = dynamic_cast<TH2F*>(FMDdata->FindObject("dNdetadphiHistogramTrVtx"));
371 if (!histFMD) {
372 cout<< "No histFMD"<<endl;
373 return;
374 }
44e060e0 375 flowEvent = new AliFlowEvent(myESD,histFMD,fCFManager2);
376 }
333ce021 377 else if (fRPType == "PMD"){
378 flowEvent = new AliFlowEvent(myESD,pmdtracks,fCFManager2);
379 }
5104aa35 380 else return;
44e060e0 381
ef4799a7 382 // if monte carlo event get reaction plane from monte carlo (depends on generator)
5104aa35 383 if (mcEvent && mcEvent->GenEventHeader()) flowEvent->SetMCReactionPlaneAngle(mcEvent);
384 //set reference multiplicity, TODO: maybe move it to the constructor?
385 flowEvent->SetReferenceMultiplicity(AliESDtrackCuts::GetReferenceMultiplicity(myESD,kTRUE));
1c1d4332 386 }
ef4799a7 387
940a5ed1 388 // Make the FlowEvent for ESD input combined with MC info
389 else if (fAnalysisType == "ESDMCkineESD" || fAnalysisType == "ESDMCkineMC" )
390 {
391 if (!(fCFManager1&&fCFManager2))
392 {
77111ee6 393 AliError("ERROR: No pointer to correction framework cuts! ");
940a5ed1 394 return;
395 }
396 if (!myESD)
397 {
77111ee6 398 AliError("ERROR: ESD not available");
940a5ed1 399 return;
400 }
77111ee6 401 AliInfo(Form("There are %d tracks in this event", fInputEvent->GetNumberOfTracks()));
940a5ed1 402
403 if (!mcEvent)
404 {
77111ee6 405 AliError("ERROR: Could not retrieve MC event");
940a5ed1 406 return;
407 }
1c1d4332 408
6d7734d2 409 fCFManager1->SetMCEventInfo(mcEvent);
410 fCFManager2->SetMCEventInfo(mcEvent);
1c1d4332 411
77111ee6 412 //check multiplicity
413 if (!fCFManager1->CheckEventCuts(AliCFManager::kEvtRecCuts,myESD))
414 {
415 AliWarning("Event does not pass multiplicity cuts"); return;
416 }
417
418 //make event
940a5ed1 419 if (fAnalysisType == "ESDMCkineESD")
420 {
421 flowEvent = new AliFlowEvent(myESD, mcEvent, AliFlowEvent::kESDkine, fCFManager1, fCFManager2 );
422 }
423 else if (fAnalysisType == "ESDMCkineMC")
424 {
425 flowEvent = new AliFlowEvent(myESD, mcEvent, AliFlowEvent::kMCkine, fCFManager1, fCFManager2 );
1c1d4332 426 }
a0241c3a 427 if (!flowEvent) return;
85d2ee8d 428 // if monte carlo event get reaction plane from monte carlo (depends on generator)
429 if (mcEvent && mcEvent->GenEventHeader()) flowEvent->SetMCReactionPlaneAngle(mcEvent);
430 //set reference multiplicity, TODO: maybe move it to the constructor?
431 flowEvent->SetReferenceMultiplicity(AliESDtrackCuts::GetReferenceMultiplicity(myESD,kTRUE));
1c1d4332 432 }
940a5ed1 433 // Make the FlowEventSimple for AOD input
434 else if (fAnalysisType == "AOD")
435 {
436 if (!myAOD)
437 {
77111ee6 438 AliError("ERROR: AOD not available");
940a5ed1 439 return;
440 }
ade93aa4 441 AliInfo(Form("AOD has %d tracks", myAOD->GetNumberOfTracks()));
940a5ed1 442 flowEvent = new AliFlowEvent(myAOD);
1c1d4332 443 }
444
6e214c87 445 //inject candidates
446 if(fLoadCandidates) {
447 TObjArray* Candidates = dynamic_cast<TObjArray*>(GetInputData(availableINslot++));
41dc4195 448 //if(Candidates->GetEntriesFast())
449 //printf("I received %d candidates\n",Candidates->GetEntriesFast());
422c61c7 450 if (Candidates)
451 {
41dc4195 452 for(int iCand=0; iCand!=Candidates->GetEntriesFast(); ++iCand ) {
453 AliFlowCandidateTrack *cand = dynamic_cast<AliFlowCandidateTrack*>(Candidates->At(iCand));
422c61c7 454 if (!cand) continue;
41dc4195 455 cand->SetForPOISelection(kTRUE);
456 cand->SetForRPSelection(kFALSE);
457 //printf(" Ⱶ Checking at candidate %d with %d daughters\n",iCand,cand->GetNDaughters());
458 for(int iDau=0; iDau!=cand->GetNDaughters(); ++iDau) {
459 //printf(" Ⱶ Daughter %d with fID %d", iDau, cand->GetIDDaughter(iDau) );
460 for(int iRPs=0; iRPs!=flowEvent->NumberOfTracks(); ++iRPs ) {
461 AliFlowTrack *iRP = dynamic_cast<AliFlowTrack*>(flowEvent->GetTrack( iRPs ));
462 if (!iRP) continue;
463 if( !iRP->InRPSelection() )
464 continue;
465 if( cand->GetIDDaughter(iDau) == iRP->GetID() ) {
466 //printf(" was in RP set");
467 cand->SetDaughter( iDau, iRP );
468 //temporarily untagging all daugters
469 iRP->SetForRPSelection(kFALSE);
470 }
471 }
472 //printf("\n");
473 }
422c61c7 474 flowEvent->AddTrack(cand);
475 }
6e214c87 476 }
477 }
478
a0241c3a 479 if (!flowEvent) return; //shuts up coverity
480
77111ee6 481 //check final event cuts
940a5ed1 482 Int_t mult = flowEvent->NumberOfTracks();
ade93aa4 483 AliInfo(Form("FlowEvent has %i tracks",mult));
484 if (mult<fMinMult || mult>fMaxMult)
77111ee6 485 {
486 AliWarning("FlowEvent cut on multiplicity"); return;
487 }
940a5ed1 488
f6f8c3fc 489 //define dead zone
490 flowEvent->DefineDeadZone(fExcludedEtaMin, fExcludedEtaMax, fExcludedPhiMin, fExcludedPhiMax );
491
492
54089829 493 //////////////////////////////////////////////////////////////////////////////
494 ///////////////////////////AFTERBURNER
495 if (fAfterburnerOn)
496 {
497 //if reaction plane not set from elsewhere randomize it before adding flow
498 if (!flowEvent->IsSetMCReactionPlaneAngle())
499 flowEvent->SetMCReactionPlaneAngle(gRandom->Uniform(0.0,TMath::TwoPi()));
500
32104217 501 flowEvent->AddFlow(fV1,fV2,fV3,fV4); //add flow
54089829 502 flowEvent->CloneTracks(fNonFlowNumberOfTrackClones); //add nonflow by cloning tracks
503 }
504 //////////////////////////////////////////////////////////////////////////////
505
ef4799a7 506 //tag subEvents
940a5ed1 507 flowEvent->TagSubeventsInEta(fMinA,fMaxA,fMinB,fMaxB);
508
46bec39c 509 //fListHistos->Print();
ef4799a7 510 //fOutputFile->WriteObject(flowEvent,"myFlowEventSimple");
940a5ed1 511 PostData(1,flowEvent);
512 if (fQA)
513 {
65201059 514 PostData(2,fQAInt);
940a5ed1 515 PostData(3,fQADiff);
516 }
517}
1c1d4332 518
519//________________________________________________________________________
940a5ed1 520void AliAnalysisTaskFlowEvent::Terminate(Option_t *)
1c1d4332 521{
522 // Called once at the end of the query -- do not call in case of CAF
1c1d4332 523}
489fdf79 524