]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/FLOW/AliFlowTasks/AliAnalysisTaskFlowEvent.cxx
remove static from variables which are initialized
[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),
1c1d4332 78 fAnalysisType("ESD"),
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),
489fdf79 129 fAnalysisType("ESD"),
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
59dab33a 213 if (!(fAnalysisType == "AOD" || fAnalysisType == "ESD" || fAnalysisType == "ESDMCkineESD" || fAnalysisType == "ESDMCkineMC" || fAnalysisType == "MC" || fAnalysisType == "MK"))
940a5ed1 214 {
77111ee6 215 AliError("WRONG ANALYSIS TYPE! only ESD, ESDMCkineESD, ESDMCkineMC, AOD and MC 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;
44e060e0 249 TH2F* histFMD = NULL;
ef4799a7 250
44e060e0 251 if(GetNinputs()==2) {
252 TList* FMDdata = dynamic_cast<TList*>(GetInputData(1));
253 if(!FMDdata) {
254 cout<<" No FMDdata "<<endl;
255 exit(2);
256 }
257 histFMD = dynamic_cast<TH2F*>(FMDdata->FindObject("dNdetadphiHistogramTrVtx"));
258 if (!histFMD) {
259 cout<< "No histFMD"<<endl;
260 exit(2);
261 }
262 }
263
daf66719 264 //use the new and temporarily inclomplete way of doing things
265 if (fAnalysisType == "MK")
266 {
267 if (!(fCutsRP&&fCutsPOI))
268 {
269 AliError("cuts not set");
270 return;
271 }
59dab33a 272 if (fCutsEvent)
273 {
274 if (!fCutsEvent->IsSelected(InputEvent())) return;
275 }
276
daf66719 277 fCutsRP->SetMCevent( MCEvent() );
278 fCutsPOI->SetMCevent( MCEvent() );
279 flowEvent = new AliFlowEvent( InputEvent(), fCutsRP, fCutsPOI );
280 if (myESD)
281 flowEvent->SetReferenceMultiplicity(AliESDtrackCuts::GetReferenceMultiplicity(myESD,kTRUE));
282 }
940a5ed1 283
284 // Make the FlowEvent for MC input
285 if (fAnalysisType == "MC")
286 {
1c1d4332 287 // Process MC truth, therefore we receive the AliAnalysisManager and ask it for the AliMCEventHandler
288 // This handler can return the current MC event
940a5ed1 289 if (!(fCFManager1&&fCFManager2))
290 {
77111ee6 291 AliError("ERROR: No pointer to correction framework cuts! ");
940a5ed1 292 return;
293 }
294 if (!mcEvent)
295 {
77111ee6 296 AliError("ERROR: Could not retrieve MC event");
940a5ed1 297 return;
298 }
1c1d4332 299
6d7734d2 300 fCFManager1->SetMCEventInfo(mcEvent);
301 fCFManager2->SetMCEventInfo(mcEvent);
940a5ed1 302
77111ee6 303 AliInfo(Form("Number of MC particles: %d", mcEvent->GetNumberOfTracks()));
304
305 //check multiplicity
306 if (!fCFManager1->CheckEventCuts(AliCFManager::kEvtGenCuts,mcEvent))
307 {
308 AliWarning("Event does not pass multiplicity cuts"); return;
309 }
310 //make event
940a5ed1 311 flowEvent = new AliFlowEvent(mcEvent,fCFManager1,fCFManager2);
1c1d4332 312 }
ef4799a7 313
940a5ed1 314 // Make the FlowEvent for ESD input
315 else if (fAnalysisType == "ESD")
316 {
317 if (!(fCFManager1&&fCFManager2))
318 {
77111ee6 319 AliError("ERROR: No pointer to correction framework cuts!");
940a5ed1 320 return;
321 }
322 if (!myESD)
323 {
77111ee6 324 AliError("ERROR: ESD not available");
940a5ed1 325 return;
326 }
77111ee6 327
b0569f96 328 //check the offline trigger (check if the event has the correct trigger)
ade93aa4 329 AliInfo(Form("ESD has %d tracks", fInputEvent->GetNumberOfTracks()));
77111ee6 330
331 //check multiplicity
332 if (!fCFManager1->CheckEventCuts(AliCFManager::kEvtRecCuts,myESD))
333 {
334 AliWarning("Event does not pass multiplicity cuts"); return;
335 }
336
337 //make event
ef4799a7 338 if (fRPType == "Global") {
339 flowEvent = new AliFlowEvent(myESD,fCFManager1,fCFManager2);
340 }
cd755f77 341 if (fRPType == "TPCOnly") {
342 flowEvent = new AliFlowEvent(myESD,fCFManager2,kFALSE);
343 }
344 if (fRPType == "TPCHybrid") {
345 flowEvent = new AliFlowEvent(myESD,fCFManager2,kTRUE);
346 }
ef4799a7 347 else if (fRPType == "Tracklet"){
348 flowEvent = new AliFlowEvent(myESD,myTracklets,fCFManager2);
349 }
44e060e0 350 else if (fRPType == "FMD"){
351 flowEvent = new AliFlowEvent(myESD,histFMD,fCFManager2);
352 }
353
ef4799a7 354 // if monte carlo event get reaction plane from monte carlo (depends on generator)
355 if (mcEvent && mcEvent->GenEventHeader()) flowEvent->SetMCReactionPlaneAngle(mcEvent);
85d2ee8d 356 //set reference multiplicity, TODO: maybe move it to the constructor?
357 flowEvent->SetReferenceMultiplicity(AliESDtrackCuts::GetReferenceMultiplicity(myESD,kTRUE));
1c1d4332 358 }
ef4799a7 359
940a5ed1 360 // Make the FlowEvent for ESD input combined with MC info
361 else if (fAnalysisType == "ESDMCkineESD" || fAnalysisType == "ESDMCkineMC" )
362 {
363 if (!(fCFManager1&&fCFManager2))
364 {
77111ee6 365 AliError("ERROR: No pointer to correction framework cuts! ");
940a5ed1 366 return;
367 }
368 if (!myESD)
369 {
77111ee6 370 AliError("ERROR: ESD not available");
940a5ed1 371 return;
372 }
77111ee6 373 AliInfo(Form("There are %d tracks in this event", fInputEvent->GetNumberOfTracks()));
940a5ed1 374
375 if (!mcEvent)
376 {
77111ee6 377 AliError("ERROR: Could not retrieve MC event");
940a5ed1 378 return;
379 }
1c1d4332 380
6d7734d2 381 fCFManager1->SetMCEventInfo(mcEvent);
382 fCFManager2->SetMCEventInfo(mcEvent);
1c1d4332 383
77111ee6 384 //check multiplicity
385 if (!fCFManager1->CheckEventCuts(AliCFManager::kEvtRecCuts,myESD))
386 {
387 AliWarning("Event does not pass multiplicity cuts"); return;
388 }
389
390 //make event
940a5ed1 391 if (fAnalysisType == "ESDMCkineESD")
392 {
393 flowEvent = new AliFlowEvent(myESD, mcEvent, AliFlowEvent::kESDkine, fCFManager1, fCFManager2 );
394 }
395 else if (fAnalysisType == "ESDMCkineMC")
396 {
397 flowEvent = new AliFlowEvent(myESD, mcEvent, AliFlowEvent::kMCkine, fCFManager1, fCFManager2 );
1c1d4332 398 }
85d2ee8d 399 // if monte carlo event get reaction plane from monte carlo (depends on generator)
400 if (mcEvent && mcEvent->GenEventHeader()) flowEvent->SetMCReactionPlaneAngle(mcEvent);
401 //set reference multiplicity, TODO: maybe move it to the constructor?
402 flowEvent->SetReferenceMultiplicity(AliESDtrackCuts::GetReferenceMultiplicity(myESD,kTRUE));
1c1d4332 403 }
940a5ed1 404 // Make the FlowEventSimple for AOD input
405 else if (fAnalysisType == "AOD")
406 {
407 if (!myAOD)
408 {
77111ee6 409 AliError("ERROR: AOD not available");
940a5ed1 410 return;
411 }
ade93aa4 412 AliInfo(Form("AOD has %d tracks", myAOD->GetNumberOfTracks()));
940a5ed1 413 flowEvent = new AliFlowEvent(myAOD);
1c1d4332 414 }
415
77111ee6 416 //check final event cuts
940a5ed1 417 Int_t mult = flowEvent->NumberOfTracks();
ade93aa4 418 AliInfo(Form("FlowEvent has %i tracks",mult));
419 if (mult<fMinMult || mult>fMaxMult)
77111ee6 420 {
421 AliWarning("FlowEvent cut on multiplicity"); return;
422 }
940a5ed1 423
f6f8c3fc 424 //define dead zone
425 flowEvent->DefineDeadZone(fExcludedEtaMin, fExcludedEtaMax, fExcludedPhiMin, fExcludedPhiMax );
426
427
54089829 428 //////////////////////////////////////////////////////////////////////////////
429 ///////////////////////////AFTERBURNER
430 if (fAfterburnerOn)
431 {
432 //if reaction plane not set from elsewhere randomize it before adding flow
433 if (!flowEvent->IsSetMCReactionPlaneAngle())
434 flowEvent->SetMCReactionPlaneAngle(gRandom->Uniform(0.0,TMath::TwoPi()));
435
436 flowEvent->AddFlow(fV1,fV2,fV3,fV4); //add flow
437 flowEvent->CloneTracks(fNonFlowNumberOfTrackClones); //add nonflow by cloning tracks
438 }
439 //////////////////////////////////////////////////////////////////////////////
440
ef4799a7 441 //tag subEvents
940a5ed1 442 flowEvent->TagSubeventsInEta(fMinA,fMaxA,fMinB,fMaxB);
443
46bec39c 444 //fListHistos->Print();
ef4799a7 445 //fOutputFile->WriteObject(flowEvent,"myFlowEventSimple");
940a5ed1 446 PostData(1,flowEvent);
447 if (fQA)
448 {
65201059 449 PostData(2,fQAInt);
940a5ed1 450 PostData(3,fQADiff);
451 }
452}
1c1d4332 453
454//________________________________________________________________________
940a5ed1 455void AliAnalysisTaskFlowEvent::Terminate(Option_t *)
1c1d4332 456{
457 // Called once at the end of the query -- do not call in case of CAF
1c1d4332 458}
489fdf79 459
460