]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/FLOW/AliFlowTasks/AliAnalysisTaskFlowEventforRP.cxx
fixes coding violations
[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
fbdb53fa 38#include "AliAnalysisTaskSE.h"
0692a009 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
fbdb53fa 63#include "AliFlowEventSimple.h"
0692a009 64#include "AliFlowEventSimpleMaker.h"
0692a009 65#include "AliFlowVector.h"
713d0676 66#include "AliAnalysisTaskFlowEventforRP.h"
0692a009 67
0692a009 68
69ClassImp(AliAnalysisTaskFlowEventforRP)
70
71//________________________________________________________________________
713d0676 72AliAnalysisTaskFlowEventforRP::AliAnalysisTaskFlowEventforRP(const char *name) :
0692a009 73 AliAnalysisTaskSE(name),
74// fOutputFile(NULL),
75 //fESD(NULL),
76 //fAOD(NULL),
77 fEventMaker(NULL),
78 fAnalysisType("ESD"),
79 fCFManager1(NULL),
80 fCFManager2(NULL),
0692a009 81 fMinMult(0),
82 fMaxMult(10000000),
713d0676 83 fMCReactionPlaneAngle(0.)
84
85
0692a009 86{
87 // Constructor
88 cout<<"AliAnalysisTaskFlowEventforRP::AliAnalysisTaskFlowEventforRP(const char *name)"<<endl;
89
90 // Define input and output slots here
91 // Input slot #0 works with a TChain
92 DefineInput(0, TChain::Class());
93 // Define here the flow event output
94 DefineOutput(0, AliFlowEventSimple::Class());
713d0676 95
0692a009 96}
97
98//________________________________________________________________________
99AliAnalysisTaskFlowEventforRP::AliAnalysisTaskFlowEventforRP() :
100 // fOutputFile(NULL),
101 //fESD(NULL),
102 //fAOD(NULL),
103 fEventMaker(NULL),
104 fAnalysisType("ESD"),
105 fCFManager1(NULL),
106 fCFManager2(NULL),
0692a009 107 fMinMult(0),
108 fMaxMult(10000000),
713d0676 109 fMCReactionPlaneAngle(0.)
0692a009 110{
111 // Constructor
112 cout<<"AliAnalysisTaskFlowEventforRP::AliAnalysisTaskFlowEventforRP()"<<endl;
113}
114
0692a009 115
116//________________________________________________________________________
117AliAnalysisTaskFlowEventforRP::~AliAnalysisTaskFlowEventforRP()
118{
119 //
120 // Destructor
121 //
713d0676 122
0692a009 123}
124
125
126//________________________________________________________________________
127void AliAnalysisTaskFlowEventforRP::UserCreateOutputObjects()
128{
129 // Called at every worker node to initialize
130 cout<<"AliAnalysisTaskFlowEventforRP::UserCreateOutputObjects()"<<endl;
131
713d0676 132 if (!(fAnalysisType == "ESD")) {
133 cout<<"WRONG ANALYSIS TYPE! only ESD for this method."<<endl;
0692a009 134 exit(1);
135 }
136
137 // Flow Event maker
138 fEventMaker = new AliFlowEventSimpleMaker();
713d0676 139
0692a009 140}
141
142//________________________________________________________________________
143void AliAnalysisTaskFlowEventforRP::UserExec(Option_t *)
144{
145 // Main loop
146
147 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(InputEvent());
148 //AliESD* old = esd->GetAliESDOld();
149
0692a009 150 // Called for each event
151 AliFlowEventSimple* fEvent = NULL;
152 Double_t fRP = 0.; // the monte carlo reaction plane angle
713d0676 153
154 AliMCEvent* mcEvent = NULL;
0692a009 155 // See if we can get Monte Carlo Information and if so get the reaction plane
713d0676 156 AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
157 if (eventHandler) {
158 mcEvent = eventHandler->MCEvent();
159 if (mcEvent) {
160 //COCKTAIL with HIJING
161 if (!strcmp(mcEvent-> GenEventHeader()->GetName(),"Cocktail Header")) { //returns 0 if matches
162 AliGenCocktailEventHeader *headerC = dynamic_cast<AliGenCocktailEventHeader *> (mcEvent-> GenEventHeader());
163 if (headerC) {
164 TList *lhd = headerC->GetHeaders();
165 if (lhd) {
166 AliGenHijingEventHeader *hdh = dynamic_cast<AliGenHijingEventHeader *> (lhd->At(0));
167 if (hdh) {
168 fRP = hdh->ReactionPlaneAngle();
169 //cout<<"The reactionPlane from Hijing (Cocktail) is: "<< fRP <<endl;
170 }
171 }
172 }
173 //else { cout<<"headerC is NULL"<<endl; }
174 }
175 //GEVSIM
176 else if (!strcmp(mcEvent-> GenEventHeader()->GetName(),"GeVSim header")) { //returns 0 if matches
177 AliGenGeVSimEventHeader* headerG = (AliGenGeVSimEventHeader*)(mcEvent->GenEventHeader());
178 if (headerG) {
179 fRP = headerG->GetEventPlane();
180 //cout<<"The reactionPlane from GeVSim is: "<< fRP <<endl;
181 }
182 //else { cout<<"headerG is NULL"<<endl; }
183 }
184 //HIJING
185 else if (!strcmp(mcEvent-> GenEventHeader()->GetName(),"Hijing")) { //returns 0 if matches
186 AliGenHijingEventHeader* headerH = (AliGenHijingEventHeader*)(mcEvent->GenEventHeader());
187 if (headerH) {
188 fRP = headerH->ReactionPlaneAngle();
189 //cout<<"The reactionPlane from Hijing is: "<< fRP <<endl;
190 }
191 //else { cout<<"headerH is NULL"<<endl; }
192 }
193 }
194 else {cout<<"No MC event!"<<endl; }
195 }
196 else {cout<<"No eventHandler!"<<endl; }
0692a009 197
713d0676 198 fEventMaker->SetMCReactionPlaneAngle(fRP);
199
0692a009 200 //setting event cuts
201 fEventMaker->SetMinMult(fMinMult);
202 fEventMaker->SetMaxMult(fMaxMult);
203
0692a009 204 // Fill the FlowEventSimple for ESD input
205 //else if (fAnalysisType == "ESD") {
206 if (fAnalysisType == "ESD") {
207 if (!fCFManager1) {cout << "ERROR: No pointer to correction framework cuts! " << endl; return; }
208 if (!fCFManager2) {cout << "ERROR: No pointer to correction framework cuts! " << endl; return; }
209
210 if (!esd) { Printf("ERROR: esd not available"); return;}
211 Printf("There are %d tracks in this event", esd->GetNumberOfTracks());
212
213 // analysis
214 fEvent = fEventMaker->FillTracks(esd,fCFManager1,fCFManager2);
713d0676 215
216 AliFlowVector vQ = fEvent->GetQ();
217 Double_t dRP[1] = {0.0}; // Phi is een Double_t, maar SetQTheta heeft een Double_t* nodig, dus een double in array vorm.
218 dRP[0] = vQ.Phi()/2;
0692a009 219
713d0676 220 cout<<"The reaction plane from MC is "<<fRP<<endl;
0692a009 221 cout<<"The calculated reaction plane is "<<dRP[0]<<endl;
713d0676 222
0692a009 223
224 // Update the header
0692a009 225 AliAODHeader* header = AODEvent()->GetHeader();
0692a009 226 header->SetRunNumber(esd->GetRunNumber());
0692a009 227 header->SetQTheta(dRP,1);
713d0676 228
0692a009 229 }
0692a009 230
0692a009 231 PostData(0,fEvent);
713d0676 232
0692a009 233}
234
235//________________________________________________________________________
236void AliAnalysisTaskFlowEventforRP::Terminate(Option_t *)
237{
238 // Called once at the end of the query -- do not call in case of CAF
713d0676 239
0692a009 240}
241
242