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 // AliAnalysisTaskFlowEventforRP:
19 // analysis task for filling the flow event
21 // and put it in an output stream so the calculated
22 // Reaction Plane can be stored in the AODHeader
23 // when the AOD is made from the ESD
24 // for cuts the correction framework is used
25 // which also outputs QA histograms to view
26 // the effects of the cuts
27 ////////////////////////////////////////////////////
29 #include "Riostream.h" //needed as include
32 #include "TFile.h" //needed as include
35 #include "TTimeStamp.h"
37 // ALICE Analysis Framework
38 #include "AliAnalysisTaskSE.h"
39 #include "AliAnalysisManager.h"
42 #include "AliESDEvent.h"
43 #include "AliESDInputHandler.h"
46 #include "AliAODEvent.h"
47 #include "AliAODInputHandler.h"
50 #include "AliAODHandler.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 "AliFlowVector.h"
66 #include "AliAnalysisTaskFlowEventforRP.h"
70 ClassImp(AliAnalysisTaskFlowEventforRP)
72 //________________________________________________________________________
73 AliAnalysisTaskFlowEventforRP::AliAnalysisTaskFlowEventforRP(const char *name) :
74 AliAnalysisTaskSE(name),
80 fMCReactionPlaneAngle(0.)
84 cout<<"AliAnalysisTaskFlowEventforRP::AliAnalysisTaskFlowEventforRP(const char *name)"<<endl;
86 // Define input and output slots here
87 // Input slot #0 works with a TChain
88 DefineInput(0, TChain::Class());
89 // Define here the flow event output
90 DefineOutput(0, AliFlowEventSimple::Class());
94 //________________________________________________________________________
95 AliAnalysisTaskFlowEventforRP::AliAnalysisTaskFlowEventforRP() :
101 fMCReactionPlaneAngle(0.)
104 cout<<"AliAnalysisTaskFlowEventforRP::AliAnalysisTaskFlowEventforRP()"<<endl;
108 //________________________________________________________________________
109 AliAnalysisTaskFlowEventforRP::~AliAnalysisTaskFlowEventforRP()
118 //________________________________________________________________________
119 void AliAnalysisTaskFlowEventforRP::UserCreateOutputObjects()
121 // Called at every worker node to initialize
122 cout<<"AliAnalysisTaskFlowEventforRP::UserCreateOutputObjects()"<<endl;
124 if (!(fAnalysisType == "ESD")) {
125 cout<<"WRONG ANALYSIS TYPE! only ESD for this method."<<endl;
131 //________________________________________________________________________
132 void AliAnalysisTaskFlowEventforRP::UserExec(Option_t *)
136 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(InputEvent());
137 AliFlowEvent* fEvent = NULL;
138 AliMCEvent* mcEvent = MCEvent();
139 Double_t fRP = 0.; // the monte carlo reaction plane angle
141 // Fill the FlowEventSimple for ESD input
142 if (fAnalysisType == "ESD") {
143 if (!(fCFManager1&&fCFManager2))
145 cout << "ERROR: No pointer to correction framework cuts! " << endl;
150 AliError("ERROR: ESD not available");
154 //check the offline trigger (check if the event has the correct trigger)
155 //AliInfo(Form("ESD has %d tracks", fInputEvent->GetNumberOfTracks()));
158 if (!fCFManager1->CheckEventCuts(AliCFManager::kEvtRecCuts,esd))
160 cout << "Event does not pass multiplicity cuts" << endl;
164 // make the flowevent
165 fEvent = new AliFlowEvent(esd,fCFManager1,fCFManager2);
167 if (mcEvent && mcEvent->GenEventHeader())
169 fEvent->SetMCReactionPlaneAngle(mcEvent);
170 fRP = fEvent->GetMCReactionPlaneAngle();
173 //check final event cuts
174 Int_t mult = fEvent->NumberOfTracks();
175 cout << "FlowEvent has "<<mult<<" tracks"<<endl;
176 if (mult<fMinMult || mult>fMaxMult)
178 cout << "FlowEvent cut on multiplicity" << endl;
183 // get the flow vector
184 AliFlowVector vQ = fEvent->GetQ();
185 Double_t dRP[1] = {0.0};
186 // Phi is a Double_t, but SetQTheta() needs as input Double_t*,
187 // an array of doubles.
190 cout<<"The reaction plane from MC is "<<fRP<<endl;
191 cout<<"The calculated reaction plane is "<<dRP[0]<<endl;
195 AliAODHeader* header = dynamic_cast<AliAODHeader*>(AODEvent()->GetHeader());
196 if(!header) AliFatal("Not a standard AOD");
197 header->SetRunNumber(esd->GetRunNumber());
198 header->SetQTheta(dRP,1);
207 //________________________________________________________________________
208 void AliAnalysisTaskFlowEventforRP::Terminate(Option_t *)
210 // Called once at the end of the query -- do not call in case of CAF