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