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
34 #include "TTimeStamp.h"
36 // ALICE Analysis Framework
37 #include "AliAnalysisManager.h"
38 #include "AliAnalysisTaskSE.h"
41 #include "AliESDEvent.h"
42 #include "AliESDInputHandler.h"
45 #include "AliAODEvent.h"
46 #include "AliAODInputHandler.h"
49 #include "AliMCEventHandler.h"
50 #include "AliMCEvent.h"
52 // ALICE Correction Framework
53 #include "AliCFManager.h"
55 // Interface to Event generators to get Reaction Plane Angle
56 #include "AliGenCocktailEventHeader.h"
57 #include "AliGenHijingEventHeader.h"
58 #include "AliGenGeVSimEventHeader.h"
59 #include "AliGenEposEventHeader.h"
61 // Interface to make the Flow Event Simple used in the flow analysis methods
62 #include "AliFlowEvent.h"
64 #include "AliAnalysisTaskFlowEvent.h"
66 ClassImp(AliAnalysisTaskFlowEvent)
68 //________________________________________________________________________
69 AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent() :
84 fMCReactionPlaneAngle(0.),
87 fEllipticFlowValue(0.),
88 fSigmaEllipticFlowValue(0.),
89 fMultiplicityOfEvent(1000000000),
90 fSigmaMultiplicityOfEvent(0),
92 fbAfterburnerOn(kFALSE)
95 cout<<"AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent()"<<endl;
98 //________________________________________________________________________
99 AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent(const char *name, Bool_t on, UInt_t iseed) :
100 AliAnalysisTaskSE(name),
101 // fOutputFile(NULL),
102 fAnalysisType("ESD"),
114 fMCReactionPlaneAngle(0.),
117 fEllipticFlowValue(0.),
118 fSigmaEllipticFlowValue(0.),
119 fMultiplicityOfEvent(1000000000),
120 fSigmaMultiplicityOfEvent(0),
122 fbAfterburnerOn(kFALSE)
125 cout<<"AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent(const char *name, Bool_t on, UInt_t iseed)"<<endl;
126 fMyTRandom3 = new TRandom3(iseed);
127 gRandom->SetSeed(fMyTRandom3->Integer(65539));
130 // Define output slots here
131 // Define here the flow event output
132 DefineOutput(1, AliFlowEventSimple::Class());
135 DefineOutput(2, TList::Class());
136 DefineOutput(3, TList::Class());
138 // and for testing open an output file
139 // fOutputFile = new TFile("FlowEvents.root","RECREATE");
143 //________________________________________________________________________
144 AliAnalysisTaskFlowEvent::~AliAnalysisTaskFlowEvent()
149 if (fMyTRandom3) delete fMyTRandom3;
150 // objects in the output list are deleted
151 // by the TSelector dtor (I hope)
155 //________________________________________________________________________
156 void AliAnalysisTaskFlowEvent::UserCreateOutputObjects()
158 // Called at every worker node to initialize
159 cout<<"AliAnalysisTaskFlowEvent::CreateOutputObjects()"<<endl;
161 if (!(fAnalysisType == "AOD" || fAnalysisType == "ESD" || fAnalysisType == "ESDMCkineESD" || fAnalysisType == "ESDMCkineMC" || fAnalysisType == "MC"))
163 cout<<"WRONG ANALYSIS TYPE! only ESD, ESDMCkineESD, ESDMCkineMC, AOD and MC are allowed."<<endl;
168 //________________________________________________________________________
169 void AliAnalysisTaskFlowEvent::UserExec(Option_t *)
172 // Called for each event
173 AliFlowEvent* flowEvent = NULL;
174 AliMCEvent* mcEvent = MCEvent(); // from TaskSE
175 AliESDEvent* myESD = dynamic_cast<AliESDEvent*>(InputEvent()); // from TaskSE
176 AliAODEvent* myAOD = dynamic_cast<AliAODEvent*>(InputEvent()); // from TaskSE
178 // Make the FlowEvent for MC input
179 if (fAnalysisType == "MC")
181 // Process MC truth, therefore we receive the AliAnalysisManager and ask it for the AliMCEventHandler
182 // This handler can return the current MC event
183 if (!(fCFManager1&&fCFManager2))
185 cout << "ERROR: No pointer to correction framework cuts! " << endl;
190 Printf("ERROR: Could not retrieve MC event");
194 fCFManager1->SetMCEventInfo(mcEvent);
195 fCFManager2->SetMCEventInfo(mcEvent);
197 Printf("Number of MC particles: %d", mcEvent->GetNumberOfTracks());
199 flowEvent = new AliFlowEvent(mcEvent,fCFManager1,fCFManager2);
201 // Make the FlowEvent for ESD input
202 else if (fAnalysisType == "ESD")
204 if (!(fCFManager1&&fCFManager2))
206 cout << "ERROR: No pointer to correction framework cuts! " << endl;
211 Printf("ERROR: ESD not available");
214 //check the offline trigger (check if the event has the correct trigger)
215 Printf("There are %d tracks in this event", fInputEvent->GetNumberOfTracks());
217 flowEvent = new AliFlowEvent(myESD,fCFManager1,fCFManager2);
219 // Make the FlowEvent for ESD input combined with MC info
220 else if (fAnalysisType == "ESDMCkineESD" || fAnalysisType == "ESDMCkineMC" )
222 if (!(fCFManager1&&fCFManager2))
224 cout << "ERROR: No pointer to correction framework cuts! " << endl;
229 Printf("ERROR: ESD not available");
232 Printf("There are %d tracks in this event", fInputEvent->GetNumberOfTracks());
236 Printf("ERROR: Could not retrieve MC event");
240 fCFManager1->SetMCEventInfo(mcEvent);
241 fCFManager2->SetMCEventInfo(mcEvent);
243 if (fAnalysisType == "ESDMCkineESD")
245 flowEvent = new AliFlowEvent(myESD, mcEvent, AliFlowEvent::kESDkine, fCFManager1, fCFManager2 );
247 else if (fAnalysisType == "ESDMCkineMC")
249 flowEvent = new AliFlowEvent(myESD, mcEvent, AliFlowEvent::kMCkine, fCFManager1, fCFManager2 );
252 // Make the FlowEventSimple for AOD input
253 else if (fAnalysisType == "AOD")
257 Printf("ERROR: AOD not available");
260 Printf("There are %d tracks in this event", myAOD->GetNumberOfTracks());
261 flowEvent = new AliFlowEvent(myAOD);
265 Int_t mult = flowEvent->NumberOfTracks();
266 if (mult<fMinMult && mult>fMaxMult) return;
269 flowEvent->TagSubeventsInEta(fMinA,fMaxA,fMinB,fMaxB);
272 //if (fbAfterburnerOn && fMyTRandom3) {
273 // // set the new value of the values using a after burner
274 // cout << "settings for afterburner in TaskFlowEvent.cxx:" << endl;
275 // cout << "fCount = " << fCount << endl;
276 // cout << "fNoOfLoops = " << fNoOfLoops << endl;
277 // cout << "fEllipticFlowValue = " << fEllipticFlowValue << endl;
278 // cout << "fSigmaEllipticFlowValue = " << fSigmaEllipticFlowValue << endl;
279 // cout << "fMultiplicityOflowEvent = " << fMultiplicityOflowEvent << endl;
280 // cout << "fSigmaMultiplicityOflowEvent = " << fSigmaMultiplicityOflowEvent << endl;
281 // Double_t xRPangle;
282 // if (!mcEvent) { xRPangle = TMath::TwoPi()*(fMyTRandom3->Rndm()); }
283 // else { xRPangle = fRP; }
284 // Double_t xNewFlowValue = fMyTRandom3->Gaus(fEllipticFlowValue,fSigmaEllipticFlowValue);
285 // Int_t nNewMultOflowEvent = TMath::Nint(fMyTRandom3->Gaus(fMultiplicityOflowEvent,fSigmaMultiplicityOflowEvent));
286 // cout << "xRPangle = " << xRPangle << endl;
287 // cout << "xNewFlowValue = " << xNewFlowValue << endl;
288 // cout << "nNewMultOflowEvent = " << nNewMultOflowEvent << endl;
289 // cout << "settings for after burner" << endl;
290 // flowEventMaker->SetMCReactionPlaneAngle(xRPangle);
291 // flowEventMaker->SetNoOfLoops(fNoOfLoops);
292 // flowEventMaker->SetEllipticFlowValue(xNewFlowValue);
293 // flowEventMaker->SetMultiplicityOflowEvent(nNewMultOflowEvent);
294 // //end settings afterburner
297 // if monte carlo event get reaction plane from monte carlo (depends on generator)
298 if (mcEvent && mcEvent->GenEventHeader()) flowEvent->SetMCReactionPlaneAngle(mcEvent);
300 //fListHistos->Print();
301 // fOutputFile->WriteObject(flowEvent,"myFlowEventSimple");
302 PostData(1,flowEvent);
310 //________________________________________________________________________
311 void AliAnalysisTaskFlowEvent::Terminate(Option_t *)
313 // Called once at the end of the query -- do not call in case of CAF