]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/FLOW/AliFlowTasks/AliAnalysisTaskFlowEventforRP.cxx
changed the order of call of endofcycle so that images are produced
[u/mrichter/AliRoot.git] / PWG2 / FLOW / AliFlowTasks / AliAnalysisTaskFlowEventforRP.cxx
CommitLineData
0692a009 1/*************************************************************************
2* Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. *
3* *
4* Author: The ALICE Off-line Project. *
5* Contributors are mentioned in the code where appropriate. *
6* *
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**************************************************************************/
15
16////////////////////////////////////////////////////
17// AliAnalysisTaskFlowEventforRP:
18//
19// analysis task for filling the flow event
20// from MCEvent, ESD
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////////////////////////////////////////////////////
28
29#include "Riostream.h" //needed as include
30#include "TChain.h"
31#include "TTree.h"
32#include "TFile.h" //needed as include
33#include "TList.h"
34#include "TRandom3.h"
35#include "TTimeStamp.h"
36
37// ALICE Analysis Framework
38class AliAnalysisTaskSE;
39#include "AliAnalysisManager.h"
40
41// ESD interface
42#include "AliESDEvent.h"
43#include "AliESDInputHandler.h"
44
45// AOD interface
46#include "AliAODEvent.h"
47#include "AliAODInputHandler.h"
48
49// Monte Carlo Eventp
713d0676 50#include "AliAODHandler.h"
0692a009 51#include "AliMCEventHandler.h"
52#include "AliMCEvent.h"
53
54// ALICE Correction Framework
55#include "AliCFManager.h"
56
57// Interface to Event generators to get Reaction Plane Angle
58#include "AliGenCocktailEventHeader.h"
59#include "AliGenHijingEventHeader.h"
60#include "AliGenGeVSimEventHeader.h"
61
62// Interface to make the Flow Event Simple used in the flow analysis methods
63#include "AliFlowEventSimpleMaker.h"
0692a009 64#include "AliFlowVector.h"
713d0676 65#include "AliAnalysisTaskFlowEventforRP.h"
0692a009 66
0692a009 67
68ClassImp(AliAnalysisTaskFlowEventforRP)
69
70//________________________________________________________________________
713d0676 71AliAnalysisTaskFlowEventforRP::AliAnalysisTaskFlowEventforRP(const char *name) :
0692a009 72 AliAnalysisTaskSE(name),
73// fOutputFile(NULL),
74 //fESD(NULL),
75 //fAOD(NULL),
76 fEventMaker(NULL),
77 fAnalysisType("ESD"),
78 fCFManager1(NULL),
79 fCFManager2(NULL),
0692a009 80 fMinMult(0),
81 fMaxMult(10000000),
713d0676 82 fMCReactionPlaneAngle(0.)
83
84
0692a009 85{
86 // Constructor
87 cout<<"AliAnalysisTaskFlowEventforRP::AliAnalysisTaskFlowEventforRP(const char *name)"<<endl;
88
89 // Define input and output slots here
90 // Input slot #0 works with a TChain
91 DefineInput(0, TChain::Class());
92 // Define here the flow event output
93 DefineOutput(0, AliFlowEventSimple::Class());
713d0676 94
0692a009 95}
96
97//________________________________________________________________________
98AliAnalysisTaskFlowEventforRP::AliAnalysisTaskFlowEventforRP() :
99 // fOutputFile(NULL),
100 //fESD(NULL),
101 //fAOD(NULL),
102 fEventMaker(NULL),
103 fAnalysisType("ESD"),
104 fCFManager1(NULL),
105 fCFManager2(NULL),
0692a009 106 fMinMult(0),
107 fMaxMult(10000000),
713d0676 108 fMCReactionPlaneAngle(0.)
0692a009 109{
110 // Constructor
111 cout<<"AliAnalysisTaskFlowEventforRP::AliAnalysisTaskFlowEventforRP()"<<endl;
112}
113
0692a009 114
115//________________________________________________________________________
116AliAnalysisTaskFlowEventforRP::~AliAnalysisTaskFlowEventforRP()
117{
118 //
119 // Destructor
120 //
713d0676 121
0692a009 122}
123
124
125//________________________________________________________________________
126void AliAnalysisTaskFlowEventforRP::UserCreateOutputObjects()
127{
128 // Called at every worker node to initialize
129 cout<<"AliAnalysisTaskFlowEventforRP::UserCreateOutputObjects()"<<endl;
130
713d0676 131 if (!(fAnalysisType == "ESD")) {
132 cout<<"WRONG ANALYSIS TYPE! only ESD for this method."<<endl;
0692a009 133 exit(1);
134 }
135
136 // Flow Event maker
137 fEventMaker = new AliFlowEventSimpleMaker();
713d0676 138
0692a009 139}
140
141//________________________________________________________________________
142void AliAnalysisTaskFlowEventforRP::UserExec(Option_t *)
143{
144 // Main loop
145
146 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(InputEvent());
147 //AliESD* old = esd->GetAliESDOld();
148
0692a009 149 // Called for each event
150 AliFlowEventSimple* fEvent = NULL;
151 Double_t fRP = 0.; // the monte carlo reaction plane angle
713d0676 152
153 AliMCEvent* mcEvent = NULL;
0692a009 154 // See if we can get Monte Carlo Information and if so get the reaction plane
713d0676 155 AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
156 if (eventHandler) {
157 mcEvent = eventHandler->MCEvent();
158 if (mcEvent) {
159 //COCKTAIL with HIJING
160 if (!strcmp(mcEvent-> GenEventHeader()->GetName(),"Cocktail Header")) { //returns 0 if matches
161 AliGenCocktailEventHeader *headerC = dynamic_cast<AliGenCocktailEventHeader *> (mcEvent-> GenEventHeader());
162 if (headerC) {
163 TList *lhd = headerC->GetHeaders();
164 if (lhd) {
165 AliGenHijingEventHeader *hdh = dynamic_cast<AliGenHijingEventHeader *> (lhd->At(0));
166 if (hdh) {
167 fRP = hdh->ReactionPlaneAngle();
168 //cout<<"The reactionPlane from Hijing (Cocktail) is: "<< fRP <<endl;
169 }
170 }
171 }
172 //else { cout<<"headerC is NULL"<<endl; }
173 }
174 //GEVSIM
175 else if (!strcmp(mcEvent-> GenEventHeader()->GetName(),"GeVSim header")) { //returns 0 if matches
176 AliGenGeVSimEventHeader* headerG = (AliGenGeVSimEventHeader*)(mcEvent->GenEventHeader());
177 if (headerG) {
178 fRP = headerG->GetEventPlane();
179 //cout<<"The reactionPlane from GeVSim is: "<< fRP <<endl;
180 }
181 //else { cout<<"headerG is NULL"<<endl; }
182 }
183 //HIJING
184 else if (!strcmp(mcEvent-> GenEventHeader()->GetName(),"Hijing")) { //returns 0 if matches
185 AliGenHijingEventHeader* headerH = (AliGenHijingEventHeader*)(mcEvent->GenEventHeader());
186 if (headerH) {
187 fRP = headerH->ReactionPlaneAngle();
188 //cout<<"The reactionPlane from Hijing is: "<< fRP <<endl;
189 }
190 //else { cout<<"headerH is NULL"<<endl; }
191 }
192 }
193 else {cout<<"No MC event!"<<endl; }
194 }
195 else {cout<<"No eventHandler!"<<endl; }
0692a009 196
713d0676 197 fEventMaker->SetMCReactionPlaneAngle(fRP);
198
0692a009 199 //setting event cuts
200 fEventMaker->SetMinMult(fMinMult);
201 fEventMaker->SetMaxMult(fMaxMult);
202
0692a009 203 // Fill the FlowEventSimple for ESD input
204 //else if (fAnalysisType == "ESD") {
205 if (fAnalysisType == "ESD") {
206 if (!fCFManager1) {cout << "ERROR: No pointer to correction framework cuts! " << endl; return; }
207 if (!fCFManager2) {cout << "ERROR: No pointer to correction framework cuts! " << endl; return; }
208
209 if (!esd) { Printf("ERROR: esd not available"); return;}
210 Printf("There are %d tracks in this event", esd->GetNumberOfTracks());
211
212 // analysis
213 fEvent = fEventMaker->FillTracks(esd,fCFManager1,fCFManager2);
713d0676 214
215 AliFlowVector vQ = fEvent->GetQ();
216 Double_t dRP[1] = {0.0}; // Phi is een Double_t, maar SetQTheta heeft een Double_t* nodig, dus een double in array vorm.
217 dRP[0] = vQ.Phi()/2;
0692a009 218
713d0676 219 cout<<"The reaction plane from MC is "<<fRP<<endl;
0692a009 220 cout<<"The calculated reaction plane is "<<dRP[0]<<endl;
713d0676 221
0692a009 222
223 // Update the header
0692a009 224 AliAODHeader* header = AODEvent()->GetHeader();
0692a009 225 header->SetRunNumber(esd->GetRunNumber());
0692a009 226 header->SetQTheta(dRP,1);
713d0676 227
0692a009 228 }
0692a009 229
0692a009 230 PostData(0,fEvent);
713d0676 231
0692a009 232}
233
234//________________________________________________________________________
235void AliAnalysisTaskFlowEventforRP::Terminate(Option_t *)
236{
237 // Called once at the end of the query -- do not call in case of CAF
713d0676 238
0692a009 239}
240
241