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