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"
66 #include "AliAnalysisTaskFlowEvent.h"
70 ClassImp(AliAnalysisTaskFlowEvent)
72 //________________________________________________________________________
73 AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent() :
89 fMCReactionPlaneAngle(0.),
92 fEllipticFlowValue(0.),
93 fSigmaEllipticFlowValue(0.),
94 fMultiplicityOfEvent(1000000000),
95 fSigmaMultiplicityOfEvent(0),
97 fbAfterburnerOn(kFALSE)
100 cout<<"AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent()"<<endl;
103 //________________________________________________________________________
104 AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent(const char *name, TString RPtype, Bool_t on, UInt_t iseed) :
105 AliAnalysisTaskSE(name),
106 // fOutputFile(NULL),
107 fAnalysisType("ESD"),
120 fMCReactionPlaneAngle(0.),
123 fEllipticFlowValue(0.),
124 fSigmaEllipticFlowValue(0.),
125 fMultiplicityOfEvent(1000000000),
126 fSigmaMultiplicityOfEvent(0),
128 fbAfterburnerOn(kFALSE)
131 cout<<"AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent(const char *name, Bool_t on, UInt_t iseed)"<<endl;
132 fMyTRandom3 = new TRandom3(iseed);
133 gRandom->SetSeed(fMyTRandom3->Integer(65539));
136 if (strcmp(RPtype,"FMD")==0) {
137 DefineInput(1, TList::Class());
140 // Define output slots here
141 // Define here the flow event output
142 DefineOutput(1, AliFlowEventSimple::Class());
145 DefineOutput(2, TList::Class());
146 DefineOutput(3, TList::Class());
148 // and for testing open an output file
149 // fOutputFile = new TFile("FlowEvents.root","RECREATE");
153 //________________________________________________________________________
154 AliAnalysisTaskFlowEvent::~AliAnalysisTaskFlowEvent()
159 if (fMyTRandom3) delete fMyTRandom3;
160 // objects in the output list are deleted
161 // by the TSelector dtor (I hope)
165 //________________________________________________________________________
166 void AliAnalysisTaskFlowEvent::UserCreateOutputObjects()
168 // Called at every worker node to initialize
169 cout<<"AliAnalysisTaskFlowEvent::CreateOutputObjects()"<<endl;
171 if (!(fAnalysisType == "AOD" || fAnalysisType == "ESD" || fAnalysisType == "ESDMCkineESD" || fAnalysisType == "ESDMCkineMC" || fAnalysisType == "MC"))
173 AliError("WRONG ANALYSIS TYPE! only ESD, ESDMCkineESD, ESDMCkineMC, AOD and MC are allowed.");
178 //________________________________________________________________________
179 void AliAnalysisTaskFlowEvent::UserExec(Option_t *)
182 // Called for each event
183 AliFlowEvent* flowEvent = NULL;
184 AliMCEvent* mcEvent = MCEvent(); // from TaskSE
185 AliESDEvent* myESD = dynamic_cast<AliESDEvent*>(InputEvent()); // from TaskSE
186 AliAODEvent* myAOD = dynamic_cast<AliAODEvent*>(InputEvent()); // from TaskSE
187 AliMultiplicity* myTracklets = NULL;
188 TH2F* histFMD = NULL;
190 if(GetNinputs()==2) {
191 TList* FMDdata = dynamic_cast<TList*>(GetInputData(1));
193 cout<<" No FMDdata "<<endl;
196 histFMD = dynamic_cast<TH2F*>(FMDdata->FindObject("dNdetadphiHistogramTrVtx"));
198 cout<< "No histFMD"<<endl;
204 // Make the FlowEvent for MC input
205 if (fAnalysisType == "MC")
207 // Process MC truth, therefore we receive the AliAnalysisManager and ask it for the AliMCEventHandler
208 // This handler can return the current MC event
209 if (!(fCFManager1&&fCFManager2))
211 AliError("ERROR: No pointer to correction framework cuts! ");
216 AliError("ERROR: Could not retrieve MC event");
220 fCFManager1->SetMCEventInfo(mcEvent);
221 fCFManager2->SetMCEventInfo(mcEvent);
223 AliInfo(Form("Number of MC particles: %d", mcEvent->GetNumberOfTracks()));
226 if (!fCFManager1->CheckEventCuts(AliCFManager::kEvtGenCuts,mcEvent))
228 AliWarning("Event does not pass multiplicity cuts"); return;
231 flowEvent = new AliFlowEvent(mcEvent,fCFManager1,fCFManager2);
234 // Make the FlowEvent for ESD input
235 else if (fAnalysisType == "ESD")
237 if (!(fCFManager1&&fCFManager2))
239 AliError("ERROR: No pointer to correction framework cuts!");
244 AliError("ERROR: ESD not available");
248 //check the offline trigger (check if the event has the correct trigger)
249 AliInfo(Form("ESD has %d tracks", fInputEvent->GetNumberOfTracks()));
252 if (!fCFManager1->CheckEventCuts(AliCFManager::kEvtRecCuts,myESD))
254 AliWarning("Event does not pass multiplicity cuts"); return;
258 if (fRPType == "Global") {
259 flowEvent = new AliFlowEvent(myESD,fCFManager1,fCFManager2);
261 else if (fRPType == "Tracklet"){
262 flowEvent = new AliFlowEvent(myESD,myTracklets,fCFManager2);
264 else if (fRPType == "FMD"){
265 flowEvent = new AliFlowEvent(myESD,histFMD,fCFManager2);
268 // if monte carlo event get reaction plane from monte carlo (depends on generator)
269 if (mcEvent && mcEvent->GenEventHeader()) flowEvent->SetMCReactionPlaneAngle(mcEvent);
270 //set reference multiplicity, TODO: maybe move it to the constructor?
271 flowEvent->SetReferenceMultiplicity(AliESDtrackCuts::GetReferenceMultiplicity(myESD,kTRUE));
274 // Make the FlowEvent for ESD input combined with MC info
275 else if (fAnalysisType == "ESDMCkineESD" || fAnalysisType == "ESDMCkineMC" )
277 if (!(fCFManager1&&fCFManager2))
279 AliError("ERROR: No pointer to correction framework cuts! ");
284 AliError("ERROR: ESD not available");
287 AliInfo(Form("There are %d tracks in this event", fInputEvent->GetNumberOfTracks()));
291 AliError("ERROR: Could not retrieve MC event");
295 fCFManager1->SetMCEventInfo(mcEvent);
296 fCFManager2->SetMCEventInfo(mcEvent);
299 if (!fCFManager1->CheckEventCuts(AliCFManager::kEvtRecCuts,myESD))
301 AliWarning("Event does not pass multiplicity cuts"); return;
305 if (fAnalysisType == "ESDMCkineESD")
307 flowEvent = new AliFlowEvent(myESD, mcEvent, AliFlowEvent::kESDkine, fCFManager1, fCFManager2 );
309 else if (fAnalysisType == "ESDMCkineMC")
311 flowEvent = new AliFlowEvent(myESD, mcEvent, AliFlowEvent::kMCkine, fCFManager1, fCFManager2 );
313 // if monte carlo event get reaction plane from monte carlo (depends on generator)
314 if (mcEvent && mcEvent->GenEventHeader()) flowEvent->SetMCReactionPlaneAngle(mcEvent);
315 //set reference multiplicity, TODO: maybe move it to the constructor?
316 flowEvent->SetReferenceMultiplicity(AliESDtrackCuts::GetReferenceMultiplicity(myESD,kTRUE));
318 // Make the FlowEventSimple for AOD input
319 else if (fAnalysisType == "AOD")
323 AliError("ERROR: AOD not available");
326 AliInfo(Form("AOD has %d tracks", myAOD->GetNumberOfTracks()));
327 flowEvent = new AliFlowEvent(myAOD);
330 //check final event cuts
331 Int_t mult = flowEvent->NumberOfTracks();
332 AliInfo(Form("FlowEvent has %i tracks",mult));
333 if (mult<fMinMult || mult>fMaxMult)
335 AliWarning("FlowEvent cut on multiplicity"); return;
339 flowEvent->TagSubeventsInEta(fMinA,fMaxA,fMinB,fMaxB);
341 //fListHistos->Print();
342 //fOutputFile->WriteObject(flowEvent,"myFlowEventSimple");
343 PostData(1,flowEvent);
351 //________________________________________________________________________
352 void AliAnalysisTaskFlowEvent::Terminate(Option_t *)
354 // Called once at the end of the query -- do not call in case of CAF