1 /*************************************************************************
2 * Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 ////////////////////////////////////////////////////
17 // AliAnalysisTaskFlowEvent:
19 // analysis task for filling the flow event
20 // from MCEvent, ESD, AOD ....
21 // and put it in an output stream so it can
22 // be used by the various flow analysis methods
23 // for cuts the correction framework is used
24 // which also outputs QA histograms to view
25 // the effects of the cuts
26 ////////////////////////////////////////////////////
28 #include "Riostream.h" //needed as include
31 #include "TFile.h" //needed as include
35 #include "TTimeStamp.h"
37 // ALICE Analysis Framework
38 #include "AliAnalysisManager.h"
39 #include "AliAnalysisTaskSE.h"
40 #include "AliESDtrackCuts.h"
43 #include "AliESDEvent.h"
44 #include "AliESDInputHandler.h"
47 #include "AliAODEvent.h"
48 #include "AliAODInputHandler.h"
51 #include "AliMCEventHandler.h"
52 #include "AliMCEvent.h"
54 // ALICE Correction Framework
55 #include "AliCFManager.h"
57 // Interface to Event generators to get Reaction Plane Angle
58 #include "AliGenCocktailEventHeader.h"
59 #include "AliGenHijingEventHeader.h"
60 #include "AliGenGeVSimEventHeader.h"
61 #include "AliGenEposEventHeader.h"
63 // Interface to make the Flow Event Simple used in the flow analysis methods
64 #include "AliFlowEvent.h"
65 #include "AliFlowTrackCuts.h"
66 #include "AliFlowEventCuts.h"
67 #include "AliFlowCommonConstants.h"
68 #include "AliAnalysisTaskFlowEvent.h"
72 ClassImp(AliAnalysisTaskFlowEvent)
74 //________________________________________________________________________
75 AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent() :
104 fPhiMax(TMath::TwoPi()),
113 fAfterburnerOn(kFALSE),
114 fNonFlowNumberOfTrackClones(0),
122 cout<<"AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent()"<<endl;
125 //________________________________________________________________________
126 AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent(const char *name, TString RPtype, Bool_t on, UInt_t iseed) :
127 AliAnalysisTaskSE(name),
128 // fOutputFile(NULL),
129 fAnalysisType("ESD"),
155 fPhiMax(TMath::TwoPi()),
164 fAfterburnerOn(kFALSE),
165 fNonFlowNumberOfTrackClones(0),
173 cout<<"AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent(const char *name, Bool_t on, UInt_t iseed)"<<endl;
174 fMyTRandom3 = new TRandom3(iseed);
175 gRandom->SetSeed(fMyTRandom3->Integer(65539));
178 if (strcmp(RPtype,"FMD")==0) {
179 DefineInput(1, TList::Class());
182 // Define output slots here
183 // Define here the flow event output
184 DefineOutput(1, AliFlowEventSimple::Class());
187 DefineOutput(2, TList::Class());
188 DefineOutput(3, TList::Class());
190 // and for testing open an output file
191 // fOutputFile = new TFile("FlowEvents.root","RECREATE");
195 //________________________________________________________________________
196 AliAnalysisTaskFlowEvent::~AliAnalysisTaskFlowEvent()
201 if (fMyTRandom3) delete fMyTRandom3;
202 // objects in the output list are deleted
203 // by the TSelector dtor (I hope)
207 //________________________________________________________________________
208 void AliAnalysisTaskFlowEvent::UserCreateOutputObjects()
210 // Called at every worker node to initialize
211 cout<<"AliAnalysisTaskFlowEvent::CreateOutputObjects()"<<endl;
213 if (!(fAnalysisType == "AOD" || fAnalysisType == "ESD" || fAnalysisType == "ESDMCkineESD" || fAnalysisType == "ESDMCkineMC" || fAnalysisType == "MC" || fAnalysisType == "MK"))
215 AliError("WRONG ANALYSIS TYPE! only ESD, ESDMCkineESD, ESDMCkineMC, AOD and MC are allowed.");
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);
239 //________________________________________________________________________
240 void AliAnalysisTaskFlowEvent::UserExec(Option_t *)
243 // Called for each event
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
248 AliMultiplicity* myTracklets = NULL;
249 TH2F* histFMD = NULL;
251 if(GetNinputs()==2) {
252 TList* FMDdata = dynamic_cast<TList*>(GetInputData(1));
254 cout<<" No FMDdata "<<endl;
257 histFMD = dynamic_cast<TH2F*>(FMDdata->FindObject("dNdetadphiHistogramTrVtx"));
259 cout<< "No histFMD"<<endl;
264 //use the new and temporarily inclomplete way of doing things
265 if (fAnalysisType == "MK")
267 if (!(fCutsRP&&fCutsPOI))
269 AliError("cuts not set");
274 if (!fCutsEvent->IsSelected(InputEvent())) return;
277 fCutsRP->SetMCevent( MCEvent() );
278 fCutsPOI->SetMCevent( MCEvent() );
279 flowEvent = new AliFlowEvent( InputEvent(), fCutsRP, fCutsPOI );
281 flowEvent->SetReferenceMultiplicity(AliESDtrackCuts::GetReferenceMultiplicity(myESD,kTRUE));
284 // Make the FlowEvent for MC input
285 if (fAnalysisType == "MC")
287 // Process MC truth, therefore we receive the AliAnalysisManager and ask it for the AliMCEventHandler
288 // This handler can return the current MC event
289 if (!(fCFManager1&&fCFManager2))
291 AliError("ERROR: No pointer to correction framework cuts! ");
296 AliError("ERROR: Could not retrieve MC event");
300 fCFManager1->SetMCEventInfo(mcEvent);
301 fCFManager2->SetMCEventInfo(mcEvent);
303 AliInfo(Form("Number of MC particles: %d", mcEvent->GetNumberOfTracks()));
306 if (!fCFManager1->CheckEventCuts(AliCFManager::kEvtGenCuts,mcEvent))
308 AliWarning("Event does not pass multiplicity cuts"); return;
311 flowEvent = new AliFlowEvent(mcEvent,fCFManager1,fCFManager2);
314 // Make the FlowEvent for ESD input
315 else if (fAnalysisType == "ESD")
317 if (!(fCFManager1&&fCFManager2))
319 AliError("ERROR: No pointer to correction framework cuts!");
324 AliError("ERROR: ESD not available");
328 //check the offline trigger (check if the event has the correct trigger)
329 AliInfo(Form("ESD has %d tracks", fInputEvent->GetNumberOfTracks()));
332 if (!fCFManager1->CheckEventCuts(AliCFManager::kEvtRecCuts,myESD))
334 AliWarning("Event does not pass multiplicity cuts"); return;
338 if (fRPType == "Global") {
339 flowEvent = new AliFlowEvent(myESD,fCFManager1,fCFManager2);
341 if (fRPType == "TPCOnly") {
342 flowEvent = new AliFlowEvent(myESD,fCFManager2,kFALSE);
344 if (fRPType == "TPCHybrid") {
345 flowEvent = new AliFlowEvent(myESD,fCFManager2,kTRUE);
347 else if (fRPType == "Tracklet"){
348 flowEvent = new AliFlowEvent(myESD,myTracklets,fCFManager2);
350 else if (fRPType == "FMD"){
351 flowEvent = new AliFlowEvent(myESD,histFMD,fCFManager2);
354 // if monte carlo event get reaction plane from monte carlo (depends on generator)
355 if (mcEvent && mcEvent->GenEventHeader()) flowEvent->SetMCReactionPlaneAngle(mcEvent);
356 //set reference multiplicity, TODO: maybe move it to the constructor?
357 flowEvent->SetReferenceMultiplicity(AliESDtrackCuts::GetReferenceMultiplicity(myESD,kTRUE));
360 // Make the FlowEvent for ESD input combined with MC info
361 else if (fAnalysisType == "ESDMCkineESD" || fAnalysisType == "ESDMCkineMC" )
363 if (!(fCFManager1&&fCFManager2))
365 AliError("ERROR: No pointer to correction framework cuts! ");
370 AliError("ERROR: ESD not available");
373 AliInfo(Form("There are %d tracks in this event", fInputEvent->GetNumberOfTracks()));
377 AliError("ERROR: Could not retrieve MC event");
381 fCFManager1->SetMCEventInfo(mcEvent);
382 fCFManager2->SetMCEventInfo(mcEvent);
385 if (!fCFManager1->CheckEventCuts(AliCFManager::kEvtRecCuts,myESD))
387 AliWarning("Event does not pass multiplicity cuts"); return;
391 if (fAnalysisType == "ESDMCkineESD")
393 flowEvent = new AliFlowEvent(myESD, mcEvent, AliFlowEvent::kESDkine, fCFManager1, fCFManager2 );
395 else if (fAnalysisType == "ESDMCkineMC")
397 flowEvent = new AliFlowEvent(myESD, mcEvent, AliFlowEvent::kMCkine, fCFManager1, fCFManager2 );
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));
404 // Make the FlowEventSimple for AOD input
405 else if (fAnalysisType == "AOD")
409 AliError("ERROR: AOD not available");
412 AliInfo(Form("AOD has %d tracks", myAOD->GetNumberOfTracks()));
413 flowEvent = new AliFlowEvent(myAOD);
416 //check final event cuts
417 Int_t mult = flowEvent->NumberOfTracks();
418 AliInfo(Form("FlowEvent has %i tracks",mult));
419 if (mult<fMinMult || mult>fMaxMult)
421 AliWarning("FlowEvent cut on multiplicity"); return;
425 flowEvent->DefineDeadZone(fExcludedEtaMin, fExcludedEtaMax, fExcludedPhiMin, fExcludedPhiMax );
428 //////////////////////////////////////////////////////////////////////////////
429 ///////////////////////////AFTERBURNER
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()));
436 flowEvent->AddFlow(fV1,fV2,fV3,fV4); //add flow
437 flowEvent->CloneTracks(fNonFlowNumberOfTrackClones); //add nonflow by cloning tracks
439 //////////////////////////////////////////////////////////////////////////////
442 flowEvent->TagSubeventsInEta(fMinA,fMaxA,fMinB,fMaxB);
444 //fListHistos->Print();
445 //fOutputFile->WriteObject(flowEvent,"myFlowEventSimple");
446 PostData(1,flowEvent);
454 //________________________________________________________________________
455 void AliAnalysisTaskFlowEvent::Terminate(Option_t *)
457 // Called once at the end of the query -- do not call in case of CAF