]>
Commit | Line | Data |
---|---|---|
f1d945a1 | 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" | |
88e00a8a | 20 | #include "TList.h" |
9d062fe3 | 21 | #include "TProfile.h" |
f1d945a1 | 22 | |
f1d945a1 | 23 | class AliAnalysisTask; |
24 | #include "AliAnalysisManager.h" | |
25 | ||
26 | #include "AliESDEvent.h" | |
27 | #include "AliESDInputHandler.h" | |
28 | ||
29 | #include "AliAODEvent.h" | |
30 | #include "AliAODInputHandler.h" | |
31 | ||
32 | #include "AliMCEventHandler.h" | |
33 | #include "AliMCEvent.h" | |
34 | ||
88e00a8a | 35 | #include "../../CORRFW/AliCFManager.h" |
36 | ||
bc92c0cb | 37 | #include "AliFlowLYZConstants.h" |
f1d945a1 | 38 | #include "AliAnalysisTaskLeeYangZeros.h" |
39 | #include "AliFlowEventSimpleMaker.h" | |
9d062fe3 | 40 | #include "AliFlowCommonHist.h" |
41 | #include "AliFlowCommonHistResults.h" | |
42 | #include "AliFlowLYZHist1.h" | |
43 | #include "AliFlowLYZHist2.h" | |
f1d945a1 | 44 | #include "AliFlowAnalysisWithLeeYangZeros.h" |
45 | ||
46 | // AliAnalysisTaskLeeYangZeros: | |
47 | // analysis task for Lee Yang Zeros method | |
48 | // Author: Naomi van der Kolk (kolk@nikhef.nl) | |
49 | ||
50 | ClassImp(AliAnalysisTaskLeeYangZeros) | |
51 | ||
52 | //________________________________________________________________________ | |
9d062fe3 | 53 | AliAnalysisTaskLeeYangZeros::AliAnalysisTaskLeeYangZeros(const char *name, Bool_t firstrun, Bool_t on) : |
f1d945a1 | 54 | AliAnalysisTask(name, ""), |
55 | fESD(0), | |
56 | fAOD(0), | |
57 | fAnalysisType("ESD"), | |
88e00a8a | 58 | fCFManager1(NULL), |
59 | fCFManager2(NULL), | |
f1d945a1 | 60 | fLyz(0), |
61 | fEventMaker(0), | |
62 | fFirstRunFile(0), | |
88e00a8a | 63 | fListHistos(NULL), |
9d062fe3 | 64 | fQAInt(NULL), |
65 | fQADiff(NULL), | |
66 | fFirstRunLYZ(firstrun), //set boolean for firstrun to initial value | |
67 | fUseSumLYZ(kTRUE), //set boolean for use sum to initial value | |
68 | fQA(on) | |
f1d945a1 | 69 | { |
70 | // Constructor | |
71 | cout<<"AliAnalysisTaskLeeYangZeros::AliAnalysisTaskLeeYangZeros(const char *name)"<<endl; | |
72 | ||
73 | // Define input and output slots here | |
74 | // Input slot #0 works with a TChain | |
75 | DefineInput(0, TChain::Class()); | |
76 | if (!firstrun) DefineInput(1, TList::Class()); //for second loop | |
77 | // Output slot #0 writes into a TList container | |
78 | DefineOutput(0, TList::Class()); | |
9d062fe3 | 79 | if(on) { |
80 | DefineOutput(1, TList::Class()); | |
81 | DefineOutput(2, TList::Class()); } | |
82 | } | |
83 | ||
f1d945a1 | 84 | |
88e00a8a | 85 | |
88e00a8a | 86 | //________________________________________________________________________ |
87 | AliAnalysisTaskLeeYangZeros::AliAnalysisTaskLeeYangZeros() : | |
88 | fESD(0), | |
89 | fAOD(0), | |
90 | fAnalysisType("ESD"), | |
91 | fCFManager1(NULL), | |
92 | fCFManager2(NULL), | |
93 | fLyz(0), | |
94 | fEventMaker(0), | |
95 | fFirstRunFile(0), | |
96 | fListHistos(NULL), | |
9d062fe3 | 97 | fQAInt(NULL), |
98 | fQADiff(NULL), | |
88e00a8a | 99 | fFirstRunLYZ(kTRUE), //set boolean for firstrun to initial value |
9d062fe3 | 100 | fUseSumLYZ(kTRUE), //set boolean for use sum to initial value |
101 | fQA(kFALSE) | |
88e00a8a | 102 | { |
103 | // Constructor | |
9d062fe3 | 104 | cout<<"AliAnalysisTaskLeeYangZeros::AliAnalysisTaskLeeYangZeros()"<<endl; |
88e00a8a | 105 | |
106 | } | |
107 | ||
88e00a8a | 108 | //________________________________________________________________________ |
109 | AliAnalysisTaskLeeYangZeros::~AliAnalysisTaskLeeYangZeros() | |
110 | { | |
111 | ||
112 | //destructor | |
113 | ||
114 | } | |
115 | ||
f1d945a1 | 116 | //________________________________________________________________________ |
117 | void AliAnalysisTaskLeeYangZeros::ConnectInputData(Option_t *) | |
118 | { | |
119 | // Connect ESD or AOD here | |
120 | // Called once | |
121 | cout<<"AliAnalysisTaskLeeYangZeros::ConnectInputData(Option_t *)"<<endl; | |
122 | ||
123 | TTree* tree = dynamic_cast<TTree*> (GetInputData(0)); | |
124 | if (!tree) { | |
125 | Printf("ERROR: Could not read chain from input slot 0"); | |
126 | } | |
127 | else { | |
128 | // Disable all branches and enable only the needed ones | |
129 | if (fAnalysisType == "MC") { | |
130 | // we want to process only MC | |
131 | tree->SetBranchStatus("*", kFALSE); | |
132 | ||
133 | AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()); | |
134 | ||
135 | if (!esdH) { | |
136 | Printf("ERROR: Could not get ESDInputHandler"); | |
137 | } else { | |
138 | fESD = esdH->GetEvent(); | |
139 | } | |
140 | } | |
0b7f49e9 | 141 | else if (fAnalysisType == "ESD" || fAnalysisType == "ESDMC0" || fAnalysisType == "ESDMC1" ) { |
f1d945a1 | 142 | tree->SetBranchStatus("*", kFALSE); |
143 | tree->SetBranchStatus("Tracks.*", kTRUE); | |
144 | ||
145 | AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()); | |
146 | ||
147 | if (!esdH) { | |
148 | Printf("ERROR: Could not get ESDInputHandler"); | |
149 | } else | |
150 | fESD = esdH->GetEvent(); | |
151 | } | |
152 | else if (fAnalysisType == "AOD") { | |
153 | AliAODInputHandler *aodH = dynamic_cast<AliAODInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()); | |
154 | ||
155 | if (!aodH) { | |
156 | Printf("ERROR: Could not get AODInputHandler"); | |
157 | } | |
158 | else { | |
159 | fAOD = aodH->GetEvent(); | |
160 | } | |
161 | } | |
162 | else { | |
0b7f49e9 | 163 | Printf("Wrong analysis type: Only ESD, ESDMC0, ESDMC1, AOD and MC types are allowed!"); |
f1d945a1 | 164 | |
165 | } | |
166 | } | |
167 | } | |
168 | ||
169 | //________________________________________________________________________ | |
170 | void AliAnalysisTaskLeeYangZeros::CreateOutputObjects() | |
171 | { | |
172 | // Called once | |
173 | cout<<"AliAnalysisTaskLeeYangZeros::CreateOutputObjects()"<<endl; | |
174 | ||
0b7f49e9 | 175 | if (!(fAnalysisType == "AOD" || fAnalysisType == "ESD" || fAnalysisType == "ESDMC0" || fAnalysisType == "ESDMC1" || fAnalysisType == "MC")) { |
176 | cout<<"WRONG ANALYSIS TYPE! only ESD, ESDMC0, ESDMC1, AOD and MC are allowed."<<endl; | |
f1d945a1 | 177 | exit(1); |
178 | } | |
179 | ||
180 | //event maker | |
181 | fEventMaker = new AliFlowEventSimpleMaker(); | |
182 | //Analyser | |
183 | fLyz = new AliFlowAnalysisWithLeeYangZeros() ; | |
184 | ||
185 | fLyz -> SetFirstRun(GetFirstRunLYZ()); //set first run true or false | |
186 | fLyz -> SetUseSum(GetUseSumLYZ()); //set use sum true or false | |
187 | ||
f1d945a1 | 188 | // Get data from input slot 1 |
189 | if (GetNinputs() == 2) { //if there are two input slots | |
9d062fe3 | 190 | TList* pFirstRunList = (TList*)GetInputData(1); |
191 | if (pFirstRunList) { | |
192 | fLyz -> SetFirstRunList(pFirstRunList); | |
193 | } else { cout<<"No first run List!"<<endl; exit(0); } | |
f1d945a1 | 194 | } |
195 | ||
9d062fe3 | 196 | fLyz -> Init(); |
f1d945a1 | 197 | |
88e00a8a | 198 | if (fLyz->GetHistList()) { |
9d062fe3 | 199 | fListHistos = fLyz->GetHistList(); |
200 | fListHistos->Print(); | |
88e00a8a | 201 | } |
202 | else {Printf("ERROR: Could not retrieve histogram list"); } | |
203 | ||
f1d945a1 | 204 | } |
205 | ||
206 | //________________________________________________________________________ | |
207 | void AliAnalysisTaskLeeYangZeros::Exec(Option_t *) | |
208 | { | |
209 | // Main loop | |
210 | // Called for each event | |
211 | if (fAnalysisType == "MC") { | |
212 | // Process MC truth, therefore we receive the AliAnalysisManager and ask it for the AliMCEventHandler | |
213 | // This handler can return the current MC event | |
214 | ||
215 | AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()); | |
216 | if (!eventHandler) { | |
217 | Printf("ERROR: Could not retrieve MC event handler"); | |
218 | return; | |
219 | } | |
220 | ||
221 | AliMCEvent* mcEvent = eventHandler->MCEvent(); | |
222 | if (!mcEvent) { | |
223 | Printf("ERROR: Could not retrieve MC event"); | |
224 | return; | |
225 | } | |
226 | ||
88e00a8a | 227 | fCFManager1->SetEventInfo(mcEvent); |
228 | fCFManager2->SetEventInfo(mcEvent); | |
229 | ||
f1d945a1 | 230 | Printf("MC particles: %d", mcEvent->GetNumberOfTracks()); |
231 | ||
232 | //lee yang zeros analysis | |
88e00a8a | 233 | //AliFlowEventSimple* fEvent = fEventMaker->FillTracks(mcEvent); |
234 | AliFlowEventSimple* fEvent = fEventMaker->FillTracks(mcEvent,fCFManager1,fCFManager2); | |
f1d945a1 | 235 | fLyz->Make(fEvent); |
236 | delete fEvent; | |
237 | } | |
238 | else if (fAnalysisType == "ESD") { | |
239 | if (!fESD) { | |
240 | Printf("ERROR: fESD not available"); | |
241 | return; | |
242 | } | |
243 | Printf("There are %d tracks in this event", fESD->GetNumberOfTracks()); | |
244 | ||
245 | //lee yang zeros analysis | |
88e00a8a | 246 | //AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fESD); |
247 | AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fESD,fCFManager1,fCFManager2); | |
f1d945a1 | 248 | fLyz->Make(fEvent); |
249 | delete fEvent; | |
250 | } | |
88e00a8a | 251 | else if (fAnalysisType == "ESDMC0" || fAnalysisType == "ESDMC1") { |
0b7f49e9 | 252 | if (!fESD) { |
253 | Printf("ERROR: fESD not available"); | |
254 | return; | |
255 | } | |
256 | Printf("There are %d tracks in this event", fESD->GetNumberOfTracks()); | |
257 | ||
258 | AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()); | |
259 | if (!eventHandler) { | |
260 | Printf("ERROR: Could not retrieve MC event handler"); | |
261 | return; | |
262 | } | |
263 | ||
264 | AliMCEvent* mcEvent = eventHandler->MCEvent(); | |
265 | if (!mcEvent) { | |
266 | Printf("ERROR: Could not retrieve MC event"); | |
267 | return; | |
268 | } | |
269 | ||
88e00a8a | 270 | fCFManager1->SetEventInfo(mcEvent); |
271 | fCFManager2->SetEventInfo(mcEvent); | |
0b7f49e9 | 272 | |
273 | //lee yang zeros analysis | |
88e00a8a | 274 | //AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fESD,mcEvent,0); //0 = kine from ESD, 1 = kine from MC |
275 | AliFlowEventSimple* fEvent=NULL; | |
276 | if (fAnalysisType == "ESDMC0") { | |
277 | fEvent = fEventMaker->FillTracks(fESD, mcEvent, fCFManager1, fCFManager2, 0); //0 = kine from ESD, 1 = kine from MC | |
278 | } else if (fAnalysisType == "ESDMC1") { | |
279 | fEvent = fEventMaker->FillTracks(fESD, mcEvent, fCFManager1, fCFManager2, 1); //0 = kine from ESD, 1 = kine from MC | |
280 | } | |
0b7f49e9 | 281 | fLyz->Make(fEvent); |
282 | delete fEvent; | |
283 | //delete mcEvent; | |
284 | } | |
88e00a8a | 285 | |
f1d945a1 | 286 | else if (fAnalysisType == "AOD") { |
287 | if (!fAOD) { | |
288 | Printf("ERROR: fAOD not available"); | |
289 | return; | |
290 | } | |
291 | Printf("There are %d tracks in this event", fAOD->GetNumberOfTracks()); | |
292 | ||
293 | //lee yang zeros analysis | |
88e00a8a | 294 | AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fAOD); //no CF yet! |
f1d945a1 | 295 | fLyz->Make(fEvent); |
296 | delete fEvent; | |
297 | } | |
298 | ||
9d062fe3 | 299 | PostData(0,fListHistos); //here for CAF |
300 | if (fQA) { | |
301 | PostData(1,fQAInt); | |
302 | PostData(2,fQADiff); } | |
f1d945a1 | 303 | } |
304 | ||
305 | //________________________________________________________________________ | |
306 | void AliAnalysisTaskLeeYangZeros::Terminate(Option_t *) | |
307 | { | |
308 | // Called once at the end of the query | |
f1d945a1 | 309 | |
bc92c0cb | 310 | const Int_t iNtheta = AliFlowLYZConstants::kTheta; |
311 | ||
9d062fe3 | 312 | AliFlowAnalysisWithLeeYangZeros* fLyzTerm = new AliFlowAnalysisWithLeeYangZeros() ; |
313 | fLyzTerm -> SetFirstRun(GetFirstRunLYZ()); //set first run true or false | |
314 | fLyzTerm -> SetUseSum(GetUseSumLYZ()); //set use sum true or false | |
315 | ||
316 | fListHistos = (TList*)GetOutputData(0); | |
88e00a8a | 317 | cout << "histogram list in Terminate" << endl; |
9d062fe3 | 318 | if (fListHistos) { |
319 | //Get the common histograms from the output list | |
320 | AliFlowCommonHist *pCommonHist = dynamic_cast<AliFlowCommonHist*> | |
321 | (fListHistos->FindObject("AliFlowCommonHistLYZ")); | |
322 | ||
323 | AliFlowCommonHistResults *pCommonHistResults = dynamic_cast<AliFlowCommonHistResults*> | |
324 | (fListHistos->FindObject("AliFlowCommonHistResultsLYZ")); | |
325 | ||
326 | TProfile* pHistProR0theta = dynamic_cast<TProfile*> | |
327 | (fListHistos->FindObject("First_FlowPro_r0theta_LYZ")); | |
328 | ||
329 | TH1F* pHistQsumforChi = dynamic_cast<TH1F*> | |
330 | (fListHistos->FindObject("Flow_QsumforChi_LYZEP")); | |
331 | ||
332 | //define histograms for first and second run | |
ba37f85c | 333 | TProfile* pHistProVtheta = NULL; |
334 | TProfile* pHistProReDenom = NULL; | |
335 | TProfile* pHistProImDenom = NULL; | |
336 | TProfile* pHistProReDtheta = NULL; | |
337 | TProfile* pHistProImDtheta = NULL; | |
338 | TProfile* pHistProVeta = NULL; | |
339 | TProfile* pHistProVPt = NULL; | |
340 | ||
bc92c0cb | 341 | AliFlowLYZHist1 *pLYZHist1[iNtheta] = {NULL}; //array of pointers to AliFlowLYZHist1 |
342 | AliFlowLYZHist2 *pLYZHist2[iNtheta] = {NULL}; //array of pointers to AliFlowLYZHist2 | |
9d062fe3 | 343 | |
344 | if (GetFirstRunLYZ()) { //for firstrun | |
345 | //Get the histograms from the output list | |
bc92c0cb | 346 | for(Int_t theta = 0;theta<iNtheta;theta++){ |
9d062fe3 | 347 | TString name = "AliFlowLYZHist1_"; |
348 | name += theta; | |
349 | pLYZHist1[theta] = dynamic_cast<AliFlowLYZHist1*> | |
350 | (fListHistos->FindObject(name)); | |
351 | } | |
352 | pHistProVtheta = dynamic_cast<TProfile*> | |
353 | (fListHistos->FindObject("First_FlowPro_Vtheta_LYZ")); | |
354 | ||
355 | //Set the histogram pointers and call Finish() | |
ba37f85c | 356 | if (pCommonHist && pCommonHistResults && pLYZHist1[0] && |
9d062fe3 | 357 | pHistProVtheta && pHistProR0theta && pHistQsumforChi ) { |
358 | fLyzTerm->SetCommonHists(pCommonHist); | |
359 | fLyzTerm->SetCommonHistsRes(pCommonHistResults); | |
360 | fLyzTerm->SetHist1(pLYZHist1); | |
361 | fLyzTerm->SetHistProVtheta(pHistProVtheta); | |
362 | fLyzTerm->SetHistProR0theta(pHistProR0theta); | |
363 | fLyzTerm->SetHistQsumforChi(pHistQsumforChi); | |
364 | fLyzTerm->Finish(); | |
365 | PostData(0,fListHistos); | |
366 | } else { | |
367 | cout<<"WARNING: Histograms needed to run Finish() firstrun are not accessable!"<<endl; | |
368 | } | |
369 | } else { //for second run | |
370 | //Get the histograms from the output list | |
bc92c0cb | 371 | for(Int_t theta = 0;theta<iNtheta;theta++){ |
9d062fe3 | 372 | TString name = "AliFlowLYZHist2_"; |
373 | name += theta; | |
374 | pLYZHist2[theta] = dynamic_cast<AliFlowLYZHist2*> | |
375 | (fListHistos->FindObject(name)); | |
376 | } | |
377 | ||
378 | pHistProReDenom = dynamic_cast<TProfile*> | |
379 | (fListHistos->FindObject("Second_FlowPro_ReDenom_LYZ")); | |
380 | pHistProImDenom = dynamic_cast<TProfile*> | |
381 | (fListHistos->FindObject("Second_FlowPro_ImDenom_LYZ")); | |
382 | ||
383 | pHistProReDtheta = dynamic_cast<TProfile*> | |
384 | (fListHistos->FindObject("Second_FlowPro_ReDtheta_LYZ")); | |
385 | pHistProImDtheta = dynamic_cast<TProfile*> | |
386 | (fListHistos->FindObject("Second_FlowPro_ImDtheta_LYZ")); | |
387 | ||
388 | pHistProVeta = dynamic_cast<TProfile*> | |
389 | (fListHistos->FindObject("Second_FlowPro_Veta_LYZ")); | |
390 | pHistProVPt = dynamic_cast<TProfile*> | |
391 | (fListHistos->FindObject("Second_FlowPro_VPt_LYZ")); | |
392 | ||
393 | //Set the histogram pointers and call Finish() | |
ba37f85c | 394 | if (pCommonHist && pCommonHistResults && pLYZHist2[0] && pHistProR0theta && |
9d062fe3 | 395 | pHistProReDenom && pHistProImDenom && pHistProVeta && pHistProVPt) { |
396 | fLyzTerm->SetCommonHists(pCommonHist); | |
397 | fLyzTerm->SetCommonHistsRes(pCommonHistResults); | |
398 | fLyzTerm->SetHist2(pLYZHist2); | |
399 | fLyzTerm->SetHistProR0theta(pHistProR0theta); | |
400 | fLyzTerm->SetHistProReDenom(pHistProReDenom); | |
401 | fLyzTerm->SetHistProImDenom(pHistProImDenom); | |
402 | fLyzTerm->SetHistProReDtheta(pHistProReDtheta); | |
403 | fLyzTerm->SetHistProImDtheta(pHistProImDtheta); | |
404 | fLyzTerm->SetHistProVeta(pHistProVeta); | |
405 | fLyzTerm->SetHistProVPt(pHistProVPt); | |
406 | fLyzTerm->SetHistQsumforChi(pHistQsumforChi); | |
407 | fLyzTerm->Finish(); | |
408 | PostData(0,fListHistos); | |
409 | } else { | |
410 | cout<<"WARNING: Histograms needed to run Finish() secondrun are not accessable!"<<endl; | |
411 | } | |
412 | } | |
413 | ||
414 | fListHistos->Print(); | |
88e00a8a | 415 | } |
9d062fe3 | 416 | else { cout << "histogram list pointer is empty" << endl;} |
f1d945a1 | 417 | |
418 | cout<<".....finished"<<endl; | |
419 | } |