]>
Commit | Line | Data |
---|---|---|
1c1d4332 | 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 | #include "Riostream.h" //needed as include | |
17 | #include "TChain.h" | |
18 | #include "TTree.h" | |
19 | #include "TFile.h" //needed as include | |
20 | #include "TList.h" | |
21 | ||
7183fe85 | 22 | // ALICE Analysis Framework |
1c1d4332 | 23 | class AliAnalysisTask; |
24 | #include "AliAnalysisManager.h" | |
25 | ||
7183fe85 | 26 | // ESD interface |
1c1d4332 | 27 | #include "AliESDEvent.h" |
28 | #include "AliESDInputHandler.h" | |
29 | ||
7183fe85 | 30 | // AOD interface |
1c1d4332 | 31 | #include "AliAODEvent.h" |
32 | #include "AliAODInputHandler.h" | |
33 | ||
7183fe85 | 34 | // Monte Carlo Event |
1c1d4332 | 35 | #include "AliMCEventHandler.h" |
36 | #include "AliMCEvent.h" | |
37 | ||
7183fe85 | 38 | // ALICE Correction Framework |
1c1d4332 | 39 | #include "AliCFManager.h" |
40 | ||
7183fe85 | 41 | // Interface to Event generators to get Reaction Plane Angle |
42 | #include "AliGenCocktailEventHeader.h" | |
43 | #include "AliGenHijingEventHeader.h" | |
c9f92d16 | 44 | #include "../EVGEN/AliGenGeVSimEventHeader.h" |
7183fe85 | 45 | |
46 | // Interface to make the Flow Event Simple used in the flow analysis methods | |
1c1d4332 | 47 | #include "AliFlowEventSimpleMaker.h" |
48 | ||
7183fe85 | 49 | #include "AliAnalysisTaskFlowEvent.h" |
50 | ||
1c1d4332 | 51 | // AliAnalysisTaskFlowEvent: |
52 | // | |
53 | // analysis task for filling the flow event | |
54 | // from MCEvent, ESD, AOD .... | |
55 | // and put it in an output stream so it can | |
56 | // be used by the various flow analysis methods | |
57 | // for cuts the correction framework is used | |
58 | // which also outputs QA histrograms to view | |
59 | // the effects of the cuts | |
60 | ||
61 | ||
62 | ClassImp(AliAnalysisTaskFlowEvent) | |
c9f92d16 | 63 | //extern void ConfigFlowAnalysis(AliAnalysisTaskFlowEvent*); |
1c1d4332 | 64 | |
65 | //________________________________________________________________________ | |
66 | AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent(const char *name, Bool_t on) : | |
67 | AliAnalysisTask(name, ""), | |
46bec39c | 68 | // fOutputFile(NULL), |
1c1d4332 | 69 | fESD(NULL), |
70 | fAOD(NULL), | |
71 | fEventMaker(NULL), | |
72 | fAnalysisType("ESD"), | |
73 | fCFManager1(NULL), | |
74 | fCFManager2(NULL), | |
75 | fQAInt(NULL), | |
76 | fQADiff(NULL), | |
77 | fQA(on) | |
78 | { | |
79 | // Constructor | |
80 | cout<<"AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent(const char *name)"<<endl; | |
81 | ||
82 | // Define input and output slots here | |
83 | // Input slot #0 works with a TChain | |
84 | DefineInput(0, TChain::Class()); | |
46bec39c | 85 | // Define here the flow event output |
86 | DefineOutput(0, AliFlowEventSimple::Class()); | |
1c1d4332 | 87 | if(on) { |
88 | DefineOutput(1, TList::Class()); | |
89 | DefineOutput(2, TList::Class()); } | |
46bec39c | 90 | // and for testing open an output file |
91 | // fOutputFile = new TFile("FlowEvents.root","RECREATE"); | |
1c1d4332 | 92 | |
93 | } | |
94 | ||
95 | //________________________________________________________________________ | |
96 | AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent() : | |
46bec39c | 97 | // fOutputFile(NULL), |
1c1d4332 | 98 | fESD(NULL), |
99 | fAOD(NULL), | |
100 | fEventMaker(NULL), | |
101 | fAnalysisType("ESD"), | |
102 | fCFManager1(NULL), | |
103 | fCFManager2(NULL), | |
104 | fQAInt(NULL), | |
105 | fQADiff(NULL), | |
106 | fQA(kFALSE) | |
107 | { | |
108 | // Constructor | |
109 | cout<<"AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent()"<<endl; | |
110 | } | |
111 | ||
112 | //________________________________________________________________________ | |
113 | AliAnalysisTaskFlowEvent::~AliAnalysisTaskFlowEvent() | |
114 | { | |
115 | // | |
116 | // Destructor | |
117 | // | |
118 | ||
119 | // objects in the output list are deleted | |
120 | // by the TSelector dtor (I hope) | |
121 | ||
122 | } | |
123 | ||
124 | //________________________________________________________________________ | |
125 | void AliAnalysisTaskFlowEvent::ConnectInputData(Option_t *) | |
126 | { | |
127 | // Connect ESD or AOD here | |
128 | // Called once | |
129 | cout<<"AliAnalysisTaskFlowEvent::ConnectInputData(Option_t *)"<<endl; | |
130 | ||
131 | TTree* tree = dynamic_cast<TTree*> (GetInputData(0)); | |
132 | if (!tree) { | |
133 | Printf("ERROR: Could not read chain from input slot 0"); | |
134 | } else { | |
135 | // Disable all branches and enable only the needed ones | |
136 | if (fAnalysisType == "MC") { | |
137 | // we want to process only MC | |
138 | tree->SetBranchStatus("*", kFALSE); | |
139 | ||
140 | AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()); | |
141 | ||
142 | if (!esdH) { | |
143 | Printf("ERROR: Could not get ESDInputHandler"); | |
144 | } else { | |
145 | fESD = esdH->GetEvent(); | |
146 | } | |
147 | } | |
148 | else if (fAnalysisType == "ESD" || fAnalysisType == "ESDMC0" || fAnalysisType == "ESDMC1") { | |
149 | tree->SetBranchStatus("*", kFALSE); | |
150 | tree->SetBranchStatus("Tracks.*", kTRUE); | |
151 | ||
152 | AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()); | |
153 | ||
154 | if (!esdH) { | |
155 | Printf("ERROR: Could not get ESDInputHandler"); | |
156 | } else | |
157 | fESD = esdH->GetEvent(); | |
158 | } | |
159 | else if (fAnalysisType == "AOD") { | |
160 | AliAODInputHandler *aodH = dynamic_cast<AliAODInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()); | |
161 | ||
162 | if (!aodH) { | |
163 | Printf("ERROR: Could not get AODInputHandler"); | |
164 | } | |
165 | else { | |
166 | fAOD = aodH->GetEvent(); | |
167 | } | |
168 | } | |
169 | else { | |
170 | Printf("!!!!!Wrong analysis type: Only ESD, ESDMC0, ESDMC1, AOD and MC types are allowed!"); | |
171 | exit(1); | |
172 | ||
173 | } | |
174 | } | |
175 | } | |
176 | ||
177 | //________________________________________________________________________ | |
178 | void AliAnalysisTaskFlowEvent::CreateOutputObjects() | |
179 | { | |
180 | // Called at every worker node to initialize | |
181 | cout<<"AliAnalysisTaskFlowEvent::CreateOutputObjects()"<<endl; | |
182 | ||
183 | if (!(fAnalysisType == "AOD" || fAnalysisType == "ESD" || fAnalysisType == "ESDMC0" || fAnalysisType == "ESDMC1" || fAnalysisType == "MC")) { | |
184 | cout<<"WRONG ANALYSIS TYPE! only ESD, ESDMC0, ESDMC1, AOD and MC are allowed."<<endl; | |
185 | exit(1); | |
186 | } | |
187 | ||
c9f92d16 | 188 | //ConfigFlowAnalysis(this); |
189 | ||
1c1d4332 | 190 | // Flow Event maker |
191 | fEventMaker = new AliFlowEventSimpleMaker(); | |
192 | } | |
193 | ||
194 | //________________________________________________________________________ | |
195 | void AliAnalysisTaskFlowEvent::Exec(Option_t *) | |
196 | { | |
197 | // Main loop | |
198 | // Called for each event | |
89f41a6a | 199 | AliFlowEventSimple* fEvent = NULL; |
7183fe85 | 200 | Double_t fRP = 0.; // the monte carlo reaction plane angle |
201 | AliMCEvent* mcEvent = NULL; | |
202 | // See if we can get Monte Carlo Information and if so get the reaction plane | |
203 | ||
204 | AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()); | |
205 | if (eventHandler) { | |
206 | mcEvent = eventHandler->MCEvent(); | |
207 | if (mcEvent) { | |
c9f92d16 | 208 | if (!strcmp(mcEvent-> GenEventHeader()->GetName(),"Cocktail Header")) { //returns 0 if matches |
209 | AliGenCocktailEventHeader *headerC = dynamic_cast<AliGenCocktailEventHeader *> (mcEvent-> GenEventHeader()); | |
210 | if (headerC) { | |
211 | TList *lhd = headerC->GetHeaders(); | |
212 | if (lhd) { | |
213 | AliGenHijingEventHeader *hdh = dynamic_cast<AliGenHijingEventHeader *> (lhd->At(0)); | |
214 | if (hdh) { | |
215 | fRP = hdh->ReactionPlaneAngle(); | |
216 | //cout<<"The reactionPlane from Hijing is: "<< fRP <<endl; | |
217 | } | |
7183fe85 | 218 | } |
219 | } | |
c9f92d16 | 220 | //else { cout<<"headerC is NULL"<<endl; } |
221 | } | |
222 | else if (!strcmp(mcEvent-> GenEventHeader()->GetName(),"GeVSim header")) { //returns 0 if matches | |
223 | AliGenGeVSimEventHeader* headerG = (AliGenGeVSimEventHeader*)(mcEvent->GenEventHeader()); | |
224 | if (headerG) { | |
225 | fRP = headerG->GetEventPlane(); | |
226 | //cout<<"The reactionPlane from GeVSim is: "<< fRP <<endl; | |
227 | } | |
228 | //else { cout<<"headerG is NULL"<<endl; } | |
7183fe85 | 229 | } |
230 | } | |
c9f92d16 | 231 | //else {cout<<"No MC event!"<<endl; } |
7183fe85 | 232 | } |
c9f92d16 | 233 | //else {cout<<"No eventHandler!"<<endl; } |
62726ef0 | 234 | |
235 | // set the value of the monte carlo event plane for the flow event | |
236 | fEventMaker->SetMCReactionPlaneAngle(fRP); | |
237 | ||
238 | // Fill the FlowEventSimple for MC input | |
1c1d4332 | 239 | if (fAnalysisType == "MC") { |
587b0a35 | 240 | if (!fCFManager1) {cout << "ERROR: No pointer to correction framework cuts! " << endl; return; } |
241 | if (!fCFManager2) {cout << "ERROR: No pointer to correction framework cuts! " << endl; return; } | |
1c1d4332 | 242 | |
243 | // Process MC truth, therefore we receive the AliAnalysisManager and ask it for the AliMCEventHandler | |
244 | // This handler can return the current MC event | |
587b0a35 | 245 | if (!mcEvent) { Printf("ERROR: Could not retrieve MC event"); return;} |
1c1d4332 | 246 | |
247 | fCFManager1->SetEventInfo(mcEvent); | |
248 | fCFManager2->SetEventInfo(mcEvent); | |
587b0a35 | 249 | |
1c1d4332 | 250 | // analysis |
7183fe85 | 251 | Printf("Number of MC particles: %d", mcEvent->GetNumberOfTracks()); |
89f41a6a | 252 | fEvent = fEventMaker->FillTracks(mcEvent,fCFManager1,fCFManager2); |
1c1d4332 | 253 | // here we have the fEvent and want to make it available as an output stream |
7183fe85 | 254 | // so no delete fEvent; |
1c1d4332 | 255 | } |
62726ef0 | 256 | // Fill the FlowEventSimple for ESD input |
1c1d4332 | 257 | else if (fAnalysisType == "ESD") { |
587b0a35 | 258 | if (!fCFManager1) {cout << "ERROR: No pointer to correction framework cuts! " << endl; return; } |
259 | if (!fCFManager2) {cout << "ERROR: No pointer to correction framework cuts! " << endl; return; } | |
260 | ||
261 | if (!fESD) { Printf("ERROR: fESD not available"); return;} | |
1c1d4332 | 262 | Printf("There are %d tracks in this event", fESD->GetNumberOfTracks()); |
263 | ||
264 | // analysis | |
89f41a6a | 265 | fEvent = fEventMaker->FillTracks(fESD,fCFManager1,fCFManager2); |
1c1d4332 | 266 | } |
62726ef0 | 267 | // Fill the FlowEventSimple for ESD input combined with MC info |
1c1d4332 | 268 | else if (fAnalysisType == "ESDMC0" || fAnalysisType == "ESDMC1" ) { |
587b0a35 | 269 | if (!fCFManager1) {cout << "ERROR: No pointer to correction framework cuts! " << endl; return; } |
270 | if (!fCFManager2) {cout << "ERROR: No pointer to correction framework cuts! " << endl; return; } | |
271 | if (!fESD) { Printf("ERROR: fESD not available"); return;} | |
1c1d4332 | 272 | Printf("There are %d tracks in this event", fESD->GetNumberOfTracks()); |
273 | ||
587b0a35 | 274 | if (!mcEvent) {Printf("ERROR: Could not retrieve MC event"); return;} |
1c1d4332 | 275 | |
276 | fCFManager1->SetEventInfo(mcEvent); | |
277 | fCFManager2->SetEventInfo(mcEvent); | |
278 | ||
89f41a6a | 279 | |
1c1d4332 | 280 | if (fAnalysisType == "ESDMC0") { |
281 | fEvent = fEventMaker->FillTracks(fESD, mcEvent, fCFManager1, fCFManager2, 0); //0 = kine from ESD, 1 = kine from MC | |
282 | } else if (fAnalysisType == "ESDMC1") { | |
283 | fEvent = fEventMaker->FillTracks(fESD, mcEvent, fCFManager1, fCFManager2, 1); //0 = kine from ESD, 1 = kine from MC | |
284 | } | |
1c1d4332 | 285 | } |
62726ef0 | 286 | // Fill the FlowEventSimple for AOD input |
1c1d4332 | 287 | else if (fAnalysisType == "AOD") { |
587b0a35 | 288 | if (!fAOD) {Printf("ERROR: fAOD not available"); return;} |
1c1d4332 | 289 | Printf("There are %d tracks in this event", fAOD->GetNumberOfTracks()); |
290 | ||
291 | // analysis | |
292 | //For the moment don't use CF //AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fAOD,fCFManager1,fCFManager2); | |
89f41a6a | 293 | fEvent = fEventMaker->FillTracks(fAOD); |
1c1d4332 | 294 | } |
295 | ||
46bec39c | 296 | //fListHistos->Print(); |
297 | // fOutputFile->WriteObject(fEvent,"myFlowEventSimple"); | |
1c1d4332 | 298 | PostData(0,fEvent); |
299 | if (fQA) { | |
300 | PostData(1,fQAInt); | |
301 | PostData(2,fQADiff); } | |
302 | } | |
303 | ||
304 | //________________________________________________________________________ | |
305 | void AliAnalysisTaskFlowEvent::Terminate(Option_t *) | |
306 | { | |
307 | // Called once at the end of the query -- do not call in case of CAF | |
308 | ||
309 | } |