]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/FLOW/AliFlowTasks/AliAnalysisTaskFlowEvent.cxx
mean pt cut
[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
63// Interface to make the Flow Event Simple used in the flow analysis methods
940a5ed1 64#include "AliFlowEvent.h"
daf66719 65#include "AliFlowTrackCuts.h"
66#include "AliFlowEventCuts.h"
d459546b 67#include "AliFlowCommonConstants.h"
7183fe85 68#include "AliAnalysisTaskFlowEvent.h"
69
77111ee6 70#include "AliLog.h"
71
1c1d4332 72ClassImp(AliAnalysisTaskFlowEvent)
940a5ed1 73
1c1d4332 74//________________________________________________________________________
940a5ed1 75AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent() :
76 AliAnalysisTaskSE(),
46bec39c 77 // fOutputFile(NULL),
12b2b8bc 78 fAnalysisType("AUTOMATIC"),
ef4799a7 79 fRPType("Global"),
1c1d4332 80 fCFManager1(NULL),
81 fCFManager2(NULL),
daf66719 82 fCutsEvent(NULL),
83 fCutsRP(NULL),
84 fCutsPOI(NULL),
1c1d4332 85 fQAInt(NULL),
86 fQADiff(NULL),
fdff44c8 87 fMinMult(0),
88 fMaxMult(10000000),
7a01f4a7 89 fMinA(-1.0),
90 fMaxA(-0.01),
91 fMinB(0.01),
92 fMaxB(1.0),
489fdf79 93 fQA(kFALSE),
d459546b 94 fNbinsMult(10000),
95 fNbinsPt(100),
96 fNbinsPhi(100),
97 fNbinsEta(200),
98 fNbinsQ(500),
99 fMultMin(0.),
100 fMultMax(10000.),
101 fPtMin(0.),
102 fPtMax(10.),
103 fPhiMin(0.),
104 fPhiMax(TMath::TwoPi()),
105 fEtaMin(-5.),
106 fEtaMax(5.),
107 fQMin(0.),
108 fQMax(3.),
f6f8c3fc 109 fExcludedEtaMin(0.),
110 fExcludedEtaMax(0.),
111 fExcludedPhiMin(0.),
112 fExcludedPhiMax(0.),
54089829 113 fAfterburnerOn(kFALSE),
114 fNonFlowNumberOfTrackClones(0),
115 fV1(0.),
116 fV2(0.),
117 fV3(0.),
118 fV4(0.),
119 fMyTRandom3(NULL)
1c1d4332 120{
121 // Constructor
122 cout<<"AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent()"<<endl;
123}
124
489fdf79 125//________________________________________________________________________
44e060e0 126AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent(const char *name, TString RPtype, Bool_t on, UInt_t iseed) :
940a5ed1 127 AliAnalysisTaskSE(name),
128 // fOutputFile(NULL),
12b2b8bc 129 fAnalysisType("AUTOMATIC"),
44e060e0 130 fRPType(RPtype),
489fdf79 131 fCFManager1(NULL),
132 fCFManager2(NULL),
daf66719 133 fCutsEvent(NULL),
134 fCutsRP(NULL),
135 fCutsPOI(NULL),
489fdf79 136 fQAInt(NULL),
137 fQADiff(NULL),
fdff44c8 138 fMinMult(0),
139 fMaxMult(10000000),
7a01f4a7 140 fMinA(-1.0),
141 fMaxA(-0.01),
142 fMinB(0.01),
143 fMaxB(1.0),
489fdf79 144 fQA(on),
d459546b 145 fNbinsMult(10000),
146 fNbinsPt(100),
147 fNbinsPhi(100),
148 fNbinsEta(200),
149 fNbinsQ(500),
150 fMultMin(0.),
151 fMultMax(10000.),
152 fPtMin(0.),
153 fPtMax(10.),
154 fPhiMin(0.),
155 fPhiMax(TMath::TwoPi()),
156 fEtaMin(-5.),
157 fEtaMax(5.),
158 fQMin(0.),
159 fQMax(3.),
f6f8c3fc 160 fExcludedEtaMin(0.),
161 fExcludedEtaMax(0.),
162 fExcludedPhiMin(0.),
163 fExcludedPhiMax(0.),
54089829 164 fAfterburnerOn(kFALSE),
165 fNonFlowNumberOfTrackClones(0),
166 fV1(0.),
167 fV2(0.),
168 fV3(0.),
169 fV4(0.),
170 fMyTRandom3(NULL)
489fdf79 171{
172 // Constructor
173 cout<<"AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent(const char *name, Bool_t on, UInt_t iseed)"<<endl;
940a5ed1 174 fMyTRandom3 = new TRandom3(iseed);
489fdf79 175 gRandom->SetSeed(fMyTRandom3->Integer(65539));
65201059 176
44e060e0 177 //FMD input slot
178 if (strcmp(RPtype,"FMD")==0) {
179 DefineInput(1, TList::Class());
180 }
65201059 181
182 // Define output slots here
489fdf79 183 // Define here the flow event output
940a5ed1 184 DefineOutput(1, AliFlowEventSimple::Class());
185 if(on)
186 {
65201059 187 DefineOutput(2, TList::Class());
940a5ed1 188 DefineOutput(3, TList::Class());
189 }
489fdf79 190 // and for testing open an output file
191 // fOutputFile = new TFile("FlowEvents.root","RECREATE");
192
193}
194
1c1d4332 195//________________________________________________________________________
196AliAnalysisTaskFlowEvent::~AliAnalysisTaskFlowEvent()
197{
198 //
199 // Destructor
200 //
489fdf79 201 if (fMyTRandom3) delete fMyTRandom3;
940a5ed1 202 // objects in the output list are deleted
1c1d4332 203 // by the TSelector dtor (I hope)
204
205}
206
207//________________________________________________________________________
940a5ed1 208void AliAnalysisTaskFlowEvent::UserCreateOutputObjects()
1c1d4332 209{
210 // Called at every worker node to initialize
211 cout<<"AliAnalysisTaskFlowEvent::CreateOutputObjects()"<<endl;
212
12b2b8bc 213 if (!(fAnalysisType == "AOD" || fAnalysisType == "ESD" || fAnalysisType == "ESDMCkineESD" || fAnalysisType == "ESDMCkineMC" || fAnalysisType == "MC" || fAnalysisType == "AUTOMATIC"))
940a5ed1 214 {
12b2b8bc 215 AliError("WRONG ANALYSIS TYPE! only ESD, ESDMCkineESD, ESDMCkineMC, AOD, MC and AUTOMATIC are allowed.");
1c1d4332 216 exit(1);
217 }
d459546b 218
219 //set the common constants
220 AliFlowCommonConstants* cc = AliFlowCommonConstants::GetMaster();
221 cc->SetNbinsMult(fNbinsMult);
222 cc->SetNbinsPt(fNbinsPt);
223 cc->SetNbinsPhi(fNbinsPhi);
224 cc->SetNbinsEta(fNbinsEta);
225 cc->SetNbinsQ(fNbinsQ);
226 cc->SetMultMin(fMultMin);
227 cc->SetMultMax(fMultMax);
228 cc->SetPtMin(fPtMin);
229 cc->SetPtMax(fPtMax);
230 cc->SetPhiMin(fPhiMin);
231 cc->SetPhiMax(fPhiMax);
232 cc->SetEtaMin(fEtaMin);
233 cc->SetEtaMax(fEtaMax);
234 cc->SetQMin(fQMin);
235 cc->SetQMax(fQMax);
236
1c1d4332 237}
238
239//________________________________________________________________________
940a5ed1 240void AliAnalysisTaskFlowEvent::UserExec(Option_t *)
1c1d4332 241{
242 // Main loop
243 // Called for each event
940a5ed1 244 AliFlowEvent* flowEvent = NULL;
245 AliMCEvent* mcEvent = MCEvent(); // from TaskSE
246 AliESDEvent* myESD = dynamic_cast<AliESDEvent*>(InputEvent()); // from TaskSE
247 AliAODEvent* myAOD = dynamic_cast<AliAODEvent*>(InputEvent()); // from TaskSE
ef4799a7 248 AliMultiplicity* myTracklets = NULL;
333ce021 249 AliESDPmdTrack* pmdtracks = NULL;//pmd
44e060e0 250 TH2F* histFMD = NULL;
ef4799a7 251
44e060e0 252 if(GetNinputs()==2) {
253 TList* FMDdata = dynamic_cast<TList*>(GetInputData(1));
254 if(!FMDdata) {
255 cout<<" No FMDdata "<<endl;
256 exit(2);
257 }
258 histFMD = dynamic_cast<TH2F*>(FMDdata->FindObject("dNdetadphiHistogramTrVtx"));
259 if (!histFMD) {
260 cout<< "No histFMD"<<endl;
261 exit(2);
262 }
263 }
264
daf66719 265 //use the new and temporarily inclomplete way of doing things
12b2b8bc 266 if (fAnalysisType == "AUTOMATIC")
daf66719 267 {
268 if (!(fCutsRP&&fCutsPOI))
269 {
270 AliError("cuts not set");
271 return;
272 }
59dab33a 273 if (fCutsEvent)
274 {
275 if (!fCutsEvent->IsSelected(InputEvent())) return;
276 }
277
03d364db 278 //first attach all possible information to the cuts
279 fCutsRP->SetEvent( InputEvent() ); //attach event
280 fCutsRP->SetMCevent( MCEvent() ); //attach mc truth
281 fCutsPOI->SetEvent( InputEvent() );
daf66719 282 fCutsPOI->SetMCevent( MCEvent() );
03d364db 283 //then make the event
284 flowEvent = new AliFlowEvent( fCutsRP, fCutsPOI );
daf66719 285 if (myESD)
9a0783cc 286 flowEvent->SetReferenceMultiplicity(fCutsEvent->GetReferenceMultiplicity(InputEvent()));
333ce021 287 if (mcEvent && mcEvent->GenEventHeader()) flowEvent->SetMCReactionPlaneAngle(mcEvent);
daf66719 288 }
940a5ed1 289
290 // Make the FlowEvent for MC input
291 if (fAnalysisType == "MC")
292 {
1c1d4332 293 // Process MC truth, therefore we receive the AliAnalysisManager and ask it for the AliMCEventHandler
294 // This handler can return the current MC event
940a5ed1 295 if (!(fCFManager1&&fCFManager2))
296 {
77111ee6 297 AliError("ERROR: No pointer to correction framework cuts! ");
940a5ed1 298 return;
299 }
300 if (!mcEvent)
301 {
77111ee6 302 AliError("ERROR: Could not retrieve MC event");
940a5ed1 303 return;
304 }
1c1d4332 305
6d7734d2 306 fCFManager1->SetMCEventInfo(mcEvent);
307 fCFManager2->SetMCEventInfo(mcEvent);
940a5ed1 308
77111ee6 309 AliInfo(Form("Number of MC particles: %d", mcEvent->GetNumberOfTracks()));
310
311 //check multiplicity
312 if (!fCFManager1->CheckEventCuts(AliCFManager::kEvtGenCuts,mcEvent))
313 {
314 AliWarning("Event does not pass multiplicity cuts"); return;
315 }
316 //make event
940a5ed1 317 flowEvent = new AliFlowEvent(mcEvent,fCFManager1,fCFManager2);
1c1d4332 318 }
ef4799a7 319
940a5ed1 320 // Make the FlowEvent for ESD input
321 else if (fAnalysisType == "ESD")
322 {
323 if (!(fCFManager1&&fCFManager2))
324 {
77111ee6 325 AliError("ERROR: No pointer to correction framework cuts!");
940a5ed1 326 return;
327 }
328 if (!myESD)
329 {
77111ee6 330 AliError("ERROR: ESD not available");
940a5ed1 331 return;
332 }
77111ee6 333
b0569f96 334 //check the offline trigger (check if the event has the correct trigger)
ade93aa4 335 AliInfo(Form("ESD has %d tracks", fInputEvent->GetNumberOfTracks()));
77111ee6 336
337 //check multiplicity
338 if (!fCFManager1->CheckEventCuts(AliCFManager::kEvtRecCuts,myESD))
339 {
340 AliWarning("Event does not pass multiplicity cuts"); return;
341 }
342
343 //make event
ef4799a7 344 if (fRPType == "Global") {
345 flowEvent = new AliFlowEvent(myESD,fCFManager1,fCFManager2);
346 }
cd755f77 347 if (fRPType == "TPCOnly") {
348 flowEvent = new AliFlowEvent(myESD,fCFManager2,kFALSE);
349 }
350 if (fRPType == "TPCHybrid") {
351 flowEvent = new AliFlowEvent(myESD,fCFManager2,kTRUE);
352 }
ef4799a7 353 else if (fRPType == "Tracklet"){
354 flowEvent = new AliFlowEvent(myESD,myTracklets,fCFManager2);
355 }
44e060e0 356 else if (fRPType == "FMD"){
357 flowEvent = new AliFlowEvent(myESD,histFMD,fCFManager2);
358 }
333ce021 359 //pmd
360 else if (fRPType == "PMD"){
361 flowEvent = new AliFlowEvent(myESD,pmdtracks,fCFManager2);
362 }
363 //pmd
44e060e0 364
ef4799a7 365 // if monte carlo event get reaction plane from monte carlo (depends on generator)
366 if (mcEvent && mcEvent->GenEventHeader()) flowEvent->SetMCReactionPlaneAngle(mcEvent);
85d2ee8d 367 //set reference multiplicity, TODO: maybe move it to the constructor?
368 flowEvent->SetReferenceMultiplicity(AliESDtrackCuts::GetReferenceMultiplicity(myESD,kTRUE));
1c1d4332 369 }
ef4799a7 370
940a5ed1 371 // Make the FlowEvent for ESD input combined with MC info
372 else if (fAnalysisType == "ESDMCkineESD" || fAnalysisType == "ESDMCkineMC" )
373 {
374 if (!(fCFManager1&&fCFManager2))
375 {
77111ee6 376 AliError("ERROR: No pointer to correction framework cuts! ");
940a5ed1 377 return;
378 }
379 if (!myESD)
380 {
77111ee6 381 AliError("ERROR: ESD not available");
940a5ed1 382 return;
383 }
77111ee6 384 AliInfo(Form("There are %d tracks in this event", fInputEvent->GetNumberOfTracks()));
940a5ed1 385
386 if (!mcEvent)
387 {
77111ee6 388 AliError("ERROR: Could not retrieve MC event");
940a5ed1 389 return;
390 }
1c1d4332 391
6d7734d2 392 fCFManager1->SetMCEventInfo(mcEvent);
393 fCFManager2->SetMCEventInfo(mcEvent);
1c1d4332 394
77111ee6 395 //check multiplicity
396 if (!fCFManager1->CheckEventCuts(AliCFManager::kEvtRecCuts,myESD))
397 {
398 AliWarning("Event does not pass multiplicity cuts"); return;
399 }
400
401 //make event
940a5ed1 402 if (fAnalysisType == "ESDMCkineESD")
403 {
404 flowEvent = new AliFlowEvent(myESD, mcEvent, AliFlowEvent::kESDkine, fCFManager1, fCFManager2 );
405 }
406 else if (fAnalysisType == "ESDMCkineMC")
407 {
408 flowEvent = new AliFlowEvent(myESD, mcEvent, AliFlowEvent::kMCkine, fCFManager1, fCFManager2 );
1c1d4332 409 }
85d2ee8d 410 // if monte carlo event get reaction plane from monte carlo (depends on generator)
411 if (mcEvent && mcEvent->GenEventHeader()) flowEvent->SetMCReactionPlaneAngle(mcEvent);
412 //set reference multiplicity, TODO: maybe move it to the constructor?
413 flowEvent->SetReferenceMultiplicity(AliESDtrackCuts::GetReferenceMultiplicity(myESD,kTRUE));
1c1d4332 414 }
940a5ed1 415 // Make the FlowEventSimple for AOD input
416 else if (fAnalysisType == "AOD")
417 {
418 if (!myAOD)
419 {
77111ee6 420 AliError("ERROR: AOD not available");
940a5ed1 421 return;
422 }
ade93aa4 423 AliInfo(Form("AOD has %d tracks", myAOD->GetNumberOfTracks()));
940a5ed1 424 flowEvent = new AliFlowEvent(myAOD);
1c1d4332 425 }
426
77111ee6 427 //check final event cuts
940a5ed1 428 Int_t mult = flowEvent->NumberOfTracks();
ade93aa4 429 AliInfo(Form("FlowEvent has %i tracks",mult));
430 if (mult<fMinMult || mult>fMaxMult)
77111ee6 431 {
432 AliWarning("FlowEvent cut on multiplicity"); return;
433 }
940a5ed1 434
f6f8c3fc 435 //define dead zone
436 flowEvent->DefineDeadZone(fExcludedEtaMin, fExcludedEtaMax, fExcludedPhiMin, fExcludedPhiMax );
437
438
54089829 439 //////////////////////////////////////////////////////////////////////////////
440 ///////////////////////////AFTERBURNER
441 if (fAfterburnerOn)
442 {
443 //if reaction plane not set from elsewhere randomize it before adding flow
444 if (!flowEvent->IsSetMCReactionPlaneAngle())
445 flowEvent->SetMCReactionPlaneAngle(gRandom->Uniform(0.0,TMath::TwoPi()));
446
447 flowEvent->AddFlow(fV1,fV2,fV3,fV4); //add flow
448 flowEvent->CloneTracks(fNonFlowNumberOfTrackClones); //add nonflow by cloning tracks
449 }
450 //////////////////////////////////////////////////////////////////////////////
451
ef4799a7 452 //tag subEvents
940a5ed1 453 flowEvent->TagSubeventsInEta(fMinA,fMaxA,fMinB,fMaxB);
454
46bec39c 455 //fListHistos->Print();
ef4799a7 456 //fOutputFile->WriteObject(flowEvent,"myFlowEventSimple");
940a5ed1 457 PostData(1,flowEvent);
458 if (fQA)
459 {
65201059 460 PostData(2,fQAInt);
940a5ed1 461 PostData(3,fQADiff);
462 }
463}
1c1d4332 464
465//________________________________________________________________________
940a5ed1 466void AliAnalysisTaskFlowEvent::Terminate(Option_t *)
1c1d4332 467{
468 // Called once at the end of the query -- do not call in case of CAF
1c1d4332 469}
489fdf79 470
471