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 "AliFlowCommonConstants.h"
66 #include "AliAnalysisTaskFlowEvent.h"
70 ClassImp(AliAnalysisTaskFlowEvent)
72 //________________________________________________________________________
73 AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent() :
99 fPhiMax(TMath::TwoPi()),
104 fAfterburnerOn(kFALSE),
105 fNonFlowNumberOfTrackClones(0),
113 cout<<"AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent()"<<endl;
116 //________________________________________________________________________
117 AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent(const char *name, TString RPtype, Bool_t on, UInt_t iseed) :
118 AliAnalysisTaskSE(name),
119 // fOutputFile(NULL),
120 fAnalysisType("ESD"),
143 fPhiMax(TMath::TwoPi()),
148 fAfterburnerOn(kFALSE),
149 fNonFlowNumberOfTrackClones(0),
157 cout<<"AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent(const char *name, Bool_t on, UInt_t iseed)"<<endl;
158 fMyTRandom3 = new TRandom3(iseed);
159 gRandom->SetSeed(fMyTRandom3->Integer(65539));
162 if (strcmp(RPtype,"FMD")==0) {
163 DefineInput(1, TList::Class());
166 // Define output slots here
167 // Define here the flow event output
168 DefineOutput(1, AliFlowEventSimple::Class());
171 DefineOutput(2, TList::Class());
172 DefineOutput(3, TList::Class());
174 // and for testing open an output file
175 // fOutputFile = new TFile("FlowEvents.root","RECREATE");
179 //________________________________________________________________________
180 AliAnalysisTaskFlowEvent::~AliAnalysisTaskFlowEvent()
185 if (fMyTRandom3) delete fMyTRandom3;
186 // objects in the output list are deleted
187 // by the TSelector dtor (I hope)
191 //________________________________________________________________________
192 void AliAnalysisTaskFlowEvent::UserCreateOutputObjects()
194 // Called at every worker node to initialize
195 cout<<"AliAnalysisTaskFlowEvent::CreateOutputObjects()"<<endl;
197 if (!(fAnalysisType == "AOD" || fAnalysisType == "ESD" || fAnalysisType == "ESDMCkineESD" || fAnalysisType == "ESDMCkineMC" || fAnalysisType == "MC"))
199 AliError("WRONG ANALYSIS TYPE! only ESD, ESDMCkineESD, ESDMCkineMC, AOD and MC are allowed.");
203 //set the common constants
204 AliFlowCommonConstants* cc = AliFlowCommonConstants::GetMaster();
205 cc->SetNbinsMult(fNbinsMult);
206 cc->SetNbinsPt(fNbinsPt);
207 cc->SetNbinsPhi(fNbinsPhi);
208 cc->SetNbinsEta(fNbinsEta);
209 cc->SetNbinsQ(fNbinsQ);
210 cc->SetMultMin(fMultMin);
211 cc->SetMultMax(fMultMax);
212 cc->SetPtMin(fPtMin);
213 cc->SetPtMax(fPtMax);
214 cc->SetPhiMin(fPhiMin);
215 cc->SetPhiMax(fPhiMax);
216 cc->SetEtaMin(fEtaMin);
217 cc->SetEtaMax(fEtaMax);
223 //________________________________________________________________________
224 void AliAnalysisTaskFlowEvent::UserExec(Option_t *)
227 // Called for each event
228 AliFlowEvent* flowEvent = NULL;
229 AliMCEvent* mcEvent = MCEvent(); // from TaskSE
230 AliESDEvent* myESD = dynamic_cast<AliESDEvent*>(InputEvent()); // from TaskSE
231 AliAODEvent* myAOD = dynamic_cast<AliAODEvent*>(InputEvent()); // from TaskSE
232 AliMultiplicity* myTracklets = NULL;
233 TH2F* histFMD = NULL;
235 if(GetNinputs()==2) {
236 TList* FMDdata = dynamic_cast<TList*>(GetInputData(1));
238 cout<<" No FMDdata "<<endl;
241 histFMD = dynamic_cast<TH2F*>(FMDdata->FindObject("dNdetadphiHistogramTrVtx"));
243 cout<< "No histFMD"<<endl;
249 // Make the FlowEvent for MC input
250 if (fAnalysisType == "MC")
252 // Process MC truth, therefore we receive the AliAnalysisManager and ask it for the AliMCEventHandler
253 // This handler can return the current MC event
254 if (!(fCFManager1&&fCFManager2))
256 AliError("ERROR: No pointer to correction framework cuts! ");
261 AliError("ERROR: Could not retrieve MC event");
265 fCFManager1->SetMCEventInfo(mcEvent);
266 fCFManager2->SetMCEventInfo(mcEvent);
268 AliInfo(Form("Number of MC particles: %d", mcEvent->GetNumberOfTracks()));
271 if (!fCFManager1->CheckEventCuts(AliCFManager::kEvtGenCuts,mcEvent))
273 AliWarning("Event does not pass multiplicity cuts"); return;
276 flowEvent = new AliFlowEvent(mcEvent,fCFManager1,fCFManager2);
279 // Make the FlowEvent for ESD input
280 else if (fAnalysisType == "ESD")
282 if (!(fCFManager1&&fCFManager2))
284 AliError("ERROR: No pointer to correction framework cuts!");
289 AliError("ERROR: ESD not available");
293 //check the offline trigger (check if the event has the correct trigger)
294 AliInfo(Form("ESD has %d tracks", fInputEvent->GetNumberOfTracks()));
297 if (!fCFManager1->CheckEventCuts(AliCFManager::kEvtRecCuts,myESD))
299 AliWarning("Event does not pass multiplicity cuts"); return;
303 if (fRPType == "Global") {
304 flowEvent = new AliFlowEvent(myESD,fCFManager1,fCFManager2);
306 else if (fRPType == "Tracklet"){
307 flowEvent = new AliFlowEvent(myESD,myTracklets,fCFManager2);
309 else if (fRPType == "FMD"){
310 flowEvent = new AliFlowEvent(myESD,histFMD,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));
319 // Make the FlowEvent for ESD input combined with MC info
320 else if (fAnalysisType == "ESDMCkineESD" || fAnalysisType == "ESDMCkineMC" )
322 if (!(fCFManager1&&fCFManager2))
324 AliError("ERROR: No pointer to correction framework cuts! ");
329 AliError("ERROR: ESD not available");
332 AliInfo(Form("There are %d tracks in this event", fInputEvent->GetNumberOfTracks()));
336 AliError("ERROR: Could not retrieve MC event");
340 fCFManager1->SetMCEventInfo(mcEvent);
341 fCFManager2->SetMCEventInfo(mcEvent);
344 if (!fCFManager1->CheckEventCuts(AliCFManager::kEvtRecCuts,myESD))
346 AliWarning("Event does not pass multiplicity cuts"); return;
350 if (fAnalysisType == "ESDMCkineESD")
352 flowEvent = new AliFlowEvent(myESD, mcEvent, AliFlowEvent::kESDkine, fCFManager1, fCFManager2 );
354 else if (fAnalysisType == "ESDMCkineMC")
356 flowEvent = new AliFlowEvent(myESD, mcEvent, AliFlowEvent::kMCkine, fCFManager1, fCFManager2 );
358 // if monte carlo event get reaction plane from monte carlo (depends on generator)
359 if (mcEvent && mcEvent->GenEventHeader()) flowEvent->SetMCReactionPlaneAngle(mcEvent);
360 //set reference multiplicity, TODO: maybe move it to the constructor?
361 flowEvent->SetReferenceMultiplicity(AliESDtrackCuts::GetReferenceMultiplicity(myESD,kTRUE));
363 // Make the FlowEventSimple for AOD input
364 else if (fAnalysisType == "AOD")
368 AliError("ERROR: AOD not available");
371 AliInfo(Form("AOD has %d tracks", myAOD->GetNumberOfTracks()));
372 flowEvent = new AliFlowEvent(myAOD);
375 //check final event cuts
376 Int_t mult = flowEvent->NumberOfTracks();
377 AliInfo(Form("FlowEvent has %i tracks",mult));
378 if (mult<fMinMult || mult>fMaxMult)
380 AliWarning("FlowEvent cut on multiplicity"); return;
383 //////////////////////////////////////////////////////////////////////////////
384 ///////////////////////////AFTERBURNER
387 //if reaction plane not set from elsewhere randomize it before adding flow
388 if (!flowEvent->IsSetMCReactionPlaneAngle())
389 flowEvent->SetMCReactionPlaneAngle(gRandom->Uniform(0.0,TMath::TwoPi()));
391 flowEvent->AddFlow(fV1,fV2,fV3,fV4); //add flow
392 flowEvent->CloneTracks(fNonFlowNumberOfTrackClones); //add nonflow by cloning tracks
394 //////////////////////////////////////////////////////////////////////////////
397 flowEvent->TagSubeventsInEta(fMinA,fMaxA,fMinB,fMaxB);
399 //fListHistos->Print();
400 //fOutputFile->WriteObject(flowEvent,"myFlowEventSimple");
401 PostData(1,flowEvent);
409 //________________________________________________________________________
410 void AliAnalysisTaskFlowEvent::Terminate(Option_t *)
412 // Called once at the end of the query -- do not call in case of CAF