]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/FLOW/AliAnalysisTaskCumulants.cxx
In AliMUONReconstructor:
[u/mrichter/AliRoot.git] / PWG2 / FLOW / AliAnalysisTaskCumulants.cxx
CommitLineData
924fafb7 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
2188af53 16/**************************************
17 * analysis task for cumulant method *
18 * *
19 * authors: Naomi van der Kolk *
20 * (kolk@nikhef.nl) *
21 * Raimond Snellings *
22 * (snelling@nikhef.nl) *
23 * Ante Bilandzic *
24 * (anteb@nikhef.nl) *
25 * ***********************************/
26
27#include "Riostream.h"
924fafb7 28#include "TChain.h"
29#include "TTree.h"
30#include "TFile.h"
aaebd73d 31#include "TList.h"
32#include "TH1.h"
aaebd73d 33#include "TProfile.h"
34#include "TProfile2D.h"
35#include "TProfile3D.h"
924fafb7 36
aaebd73d 37#include "AliAnalysisTask.h"
38#include "AliAnalysisDataSlot.h"
39#include "AliAnalysisDataContainer.h"
924fafb7 40#include "AliAnalysisManager.h"
41
42#include "AliESDEvent.h"
43#include "AliESDInputHandler.h"
44
45#include "AliAODEvent.h"
46#include "AliAODInputHandler.h"
47
48#include "AliMCEventHandler.h"
49#include "AliMCEvent.h"
50
aaebd73d 51#include "../../CORRFW/AliCFManager.h"
52
924fafb7 53#include "AliAnalysisTaskCumulants.h"
54#include "AliFlowEventSimpleMaker.h"
55#include "AliFlowAnalysisWithCumulants.h"
aaebd73d 56#include "AliFlowCumuConstants.h"
57#include "AliFlowCommonConstants.h"
58#include "AliFlowCommonHistResults.h"
aaebd73d 59#include "AliCumulantsFunctions.h"
924fafb7 60
924fafb7 61ClassImp(AliAnalysisTaskCumulants)
62
2188af53 63//================================================================================================================
64
6d4fa5d3 65AliAnalysisTaskCumulants::AliAnalysisTaskCumulants(const char *name, Bool_t on):
2188af53 66 AliAnalysisTask(name,""),
67 fESD(NULL),
68 fAOD(NULL),
52021ae2 69 fGFC(NULL),//Generating Function Cumulant (GFC) analysis object
2188af53 70 fEventMaker(NULL),
71 fAnalysisType("ESD"),
72 fCFManager1(NULL),
73 fCFManager2(NULL),
6d4fa5d3 74 fListHistos(NULL),
75 fQAInt(NULL),
76 fQADiff(NULL),
77 fQA(on)
924fafb7 78{
fe488c8a 79//constructor
52021ae2 80 cout<<"AliAnalysisTaskCumulants::AliAnalysisTaskCumulants(const char *name)"<<endl;
fe488c8a 81
82 // Define input and output slots here
83 // Input slot #0 works with a TChain
2188af53 84 DefineInput(0, TChain::Class());
fe488c8a 85
86 // Output slot #0 writes into a TList container
2188af53 87 DefineOutput(0, TList::Class());
fe488c8a 88 if(on)
89 {
90 DefineOutput(1, TList::Class());
91 DefineOutput(2, TList::Class());
92 }
924fafb7 93}
2188af53 94
95AliAnalysisTaskCumulants::AliAnalysisTaskCumulants():
96 fESD(NULL),
97 fAOD(NULL),
52021ae2 98 fGFC(NULL),//Generating Function Cumulant (GFC) analysis object
2188af53 99 fEventMaker(NULL),
100 fAnalysisType("ESD"),
101 fCFManager1(NULL),
102 fCFManager2(NULL),
6d4fa5d3 103 fListHistos(NULL),
104 fQAInt(NULL),
105 fQADiff(NULL),
106 fQA(kFALSE)
aaebd73d 107{
2188af53 108 //dummy constructor
109 cout<<"AliAnalysisTaskCumulants::AliAnalysisTaskCumulants()"<<endl;
110}
111
112//================================================================================================================
924fafb7 113
924fafb7 114void AliAnalysisTaskCumulants::ConnectInputData(Option_t *)
115{
2188af53 116 //connect ESD or AOD (called once)
117 cout<<"AliAnalysisTaskCumulants::ConnectInputData(Option_t *)"<<endl;
118
119 TTree* tree = dynamic_cast<TTree*> (GetInputData(0));
120 if (!tree)
121 {
122 Printf("ERROR: Could not read chain from input slot 0");
123 }
124 else
125 {
126 //disable all branches and enable only the needed ones
127 if (fAnalysisType == "MC") {
128 // we want to process only MC
924fafb7 129 tree->SetBranchStatus("*", kFALSE);
130
131 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
132
133 if (!esdH) {
134 Printf("ERROR: Could not get ESDInputHandler");
135 } else {
136 fESD = esdH->GetEvent();
137 }
138 }
139 else if (fAnalysisType == "ESD" || fAnalysisType == "ESDMC0" || fAnalysisType == "ESDMC1" ) {
140 tree->SetBranchStatus("*", kFALSE);
141 tree->SetBranchStatus("Tracks.*", kTRUE);
142
143 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
144
145 if (!esdH) {
146 Printf("ERROR: Could not get ESDInputHandler");
147 } else
148 fESD = esdH->GetEvent();
149 }
150 else if (fAnalysisType == "AOD") {
151 AliAODInputHandler *aodH = dynamic_cast<AliAODInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
152
153 if (!aodH) {
154 Printf("ERROR: Could not get AODInputHandler");
155 }
156 else {
157 fAOD = aodH->GetEvent();
158 }
159 }
160 else {
161 Printf("Wrong analysis type: Only ESD, ESDMC0, ESDMC1, AOD and MC types are allowed!");
162
163 }
164 }
165}
166
2188af53 167//================================================================================================================
168
924fafb7 169void AliAnalysisTaskCumulants::CreateOutputObjects()
170{
2188af53 171 //called at every worker node to initialize
172 cout<<"AliAnalysisTaskCumulants::CreateOutputObjects()"<<endl;
924fafb7 173
aaebd73d 174
2188af53 175 //OpenFile(0);
176
177
178 if(!(fAnalysisType == "AOD" || fAnalysisType == "ESD" || fAnalysisType == "ESDMC0" || fAnalysisType == "ESDMC1" || fAnalysisType == "MC"))
179 {
180 cout<<"WRONG ANALYSIS TYPE! only ESD, ESDMC0, ESDMC1, AOD and MC are allowed."<<endl;
181 exit(1);
182 }
183
184 //event maker
185 fEventMaker = new AliFlowEventSimpleMaker();
186
187 //analyser
52021ae2 188 fGFC = new AliFlowAnalysisWithCumulants();
189 fGFC->CreateOutputObjects();
2188af53 190
52021ae2 191 if(fGFC->GetHistList())
2188af53 192 {
52021ae2 193 fListHistos = fGFC->GetHistList();
2188af53 194 //fListHistos->Print();
aaebd73d 195 }
2188af53 196 else
197 {
198 Printf("ERROR: Could not retrieve histogram list");
199 }
2188af53 200}
201
202//================================================================================================================
924fafb7 203
924fafb7 204void AliAnalysisTaskCumulants::Exec(Option_t *)
205{
2188af53 206 //main loop (called for each event)
207 if (fAnalysisType == "MC") {
924fafb7 208 // Process MC truth, therefore we receive the AliAnalysisManager and ask it for the AliMCEventHandler
209 // This handler can return the current MC event
210
211 AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
212 if (!eventHandler) {
213 Printf("ERROR: Could not retrieve MC event handler");
214 return;
215 }
216
217 AliMCEvent* mcEvent = eventHandler->MCEvent();
218 if (!mcEvent) {
219 Printf("ERROR: Could not retrieve MC event");
220 return;
221 }
222
a58fb92e 223
aaebd73d 224 fCFManager1->SetEventInfo(mcEvent);
225 fCFManager2->SetEventInfo(mcEvent);
924fafb7 226
a58fb92e 227 Printf("MC particles: %d", mcEvent->GetNumberOfTracks());
228
aaebd73d 229 //cumulant analysis
230 AliFlowEventSimple* fEvent = fEventMaker->FillTracks(mcEvent,fCFManager1,fCFManager2);
52021ae2 231 fGFC->Make(fEvent);
924fafb7 232 delete fEvent;
233 }
234 else if (fAnalysisType == "ESD") {
235 if (!fESD) {
236 Printf("ERROR: fESD not available");
237 return;
238 }
239 Printf("There are %d tracks in this event", fESD->GetNumberOfTracks());
240
2188af53 241 //cumulant analysis
fe488c8a 242 AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fESD,fCFManager1,fCFManager2);
52021ae2 243 fGFC->Make(fEvent);
924fafb7 244 delete fEvent;
245 }
246 else if (fAnalysisType == "ESDMC0") {
247 if (!fESD) {
248 Printf("ERROR: fESD not available");
249 return;
250 }
251 Printf("There are %d tracks in this event", fESD->GetNumberOfTracks());
252
253 AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
254 if (!eventHandler) {
255 Printf("ERROR: Could not retrieve MC event handler");
256 return;
257 }
258
259 AliMCEvent* mcEvent = eventHandler->MCEvent();
260 if (!mcEvent) {
261 Printf("ERROR: Could not retrieve MC event");
262 return;
263 }
264
aaebd73d 265 fCFManager1->SetEventInfo(mcEvent);
266 fCFManager2->SetEventInfo(mcEvent);
924fafb7 267
2188af53 268 //cumulant analysis
aaebd73d 269 AliFlowEventSimple* fEvent=NULL;
270 if (fAnalysisType == "ESDMC0") {
271 fEvent = fEventMaker->FillTracks(fESD, mcEvent, fCFManager1, fCFManager2, 0); //0 = kine from ESD, 1 = kine from MC
272 } else if (fAnalysisType == "ESDMC1") {
273 fEvent = fEventMaker->FillTracks(fESD, mcEvent, fCFManager1, fCFManager2, 1); //0 = kine from ESD, 1 = kine from MC
274 }
52021ae2 275 fGFC->Make(fEvent);
924fafb7 276 delete fEvent;
277 //delete mcEvent;
278 }
aaebd73d 279
924fafb7 280 else if (fAnalysisType == "AOD") {
281 if (!fAOD) {
282 Printf("ERROR: fAOD not available");
283 return;
284 }
285 Printf("There are %d tracks in this event", fAOD->GetNumberOfTracks());
286
aaebd73d 287 // analysis
288 //For the moment don't use CF //AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fAOD,fCFManager1,fCFManager2);
924fafb7 289 AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fAOD);
52021ae2 290 fGFC->Make(fEvent);
924fafb7 291 delete fEvent;
292 }
aaebd73d 293
294
295 PostData(0,fListHistos);
6d4fa5d3 296 if(fQA)
297 {
298 PostData(1,fQAInt);
299 PostData(2,fQADiff);
300 }
924fafb7 301}
302
2188af53 303//================================================================================================================
304
924fafb7 305void AliAnalysisTaskCumulants::Terminate(Option_t *)
aaebd73d 306{
2188af53 307 //accessing the output list which contains the merged 2D and 3D profiles from all worker nodes
308 fListHistos = (TList*)GetOutputData(0);
309 //fListHistos->Print();
310
311 if(fListHistos)
52021ae2 312 {
313 //histograms to store the final results
314 TH1D *intFlowResults = dynamic_cast<TH1D*>(fListHistos->FindObject("fIntFlowResultsGFC"));
315 TH1D *diffFlowResults2 = dynamic_cast<TH1D*>(fListHistos->FindObject("fDiffFlowResults2ndOrderGFC"));
316 TH1D *diffFlowResults4 = dynamic_cast<TH1D*>(fListHistos->FindObject("fDiffFlowResults4thOrderGFC"));
317 TH1D *diffFlowResults6 = dynamic_cast<TH1D*>(fListHistos->FindObject("fDiffFlowResults6thOrderGFC"));
318 TH1D *diffFlowResults8 = dynamic_cast<TH1D*>(fListHistos->FindObject("fDiffFlowResults8thOrderGFC"));
319
320 //common histograms to store the final results the integrated and differential flow
321 AliFlowCommonHistResults *commonHistRes2nd = dynamic_cast<AliFlowCommonHistResults*>(fListHistos->FindObject("AliFlowCommonHistResults2ndOrderGFC"));
322 AliFlowCommonHistResults *commonHistRes4th = dynamic_cast<AliFlowCommonHistResults*>(fListHistos->FindObject("AliFlowCommonHistResults4thOrderGFC"));
323 AliFlowCommonHistResults *commonHistRes6th = dynamic_cast<AliFlowCommonHistResults*>(fListHistos->FindObject("AliFlowCommonHistResults6thOrderGFC"));
324 AliFlowCommonHistResults *commonHistRes8th = dynamic_cast<AliFlowCommonHistResults*>(fListHistos->FindObject("AliFlowCommonHistResults8thOrderGFC"));
325
326 //profiles with average values of generating functions for int. and diff. flow
327 TProfile2D *intFlowGenFun = dynamic_cast<TProfile2D*>(fListHistos->FindObject("fIntFlowGenFun"));
328 TProfile3D *diffFlowGenFunRe = dynamic_cast<TProfile3D*>(fListHistos->FindObject("fDiffFlowGenFunRe"));
329 TProfile3D *diffFlowGenFunIm = dynamic_cast<TProfile3D*>(fListHistos->FindObject("fDiffFlowGenFunIm"));
330
331 //number of particles per pt bin
332 TProfile *BinNoOfParticles = dynamic_cast<TProfile*>(fListHistos->FindObject("fBinNoOfParticles"));
333
334 //average selected multiplicity (for int. flow)
335 TProfile *AvMult = dynamic_cast<TProfile*>(fListHistos->FindObject("fAvMultIntFlowGFC"));
336
337 //average values of Q-vector components (1st bin: <Q_x>, 2nd bin: <Q_y>, 3rd bin: <(Q_x)^2>, 4th bin: <(Q_y)^2>)
338 TProfile *QVectorComponents = dynamic_cast<TProfile*>(fListHistos->FindObject("fQVectorComponentsGFC"));
aaebd73d 339
52021ae2 340 /*
2188af53 341 TProfile2D *diffFlowGenFunRe0 = dynamic_cast<TProfile2D*>(fListHistos->FindObject("fDiffFlowGenFunRe0"));
342 TProfile2D *diffFlowGenFunRe1 = dynamic_cast<TProfile2D*>(fListHistos->FindObject("fDiffFlowGenFunRe1"));
343 TProfile2D *diffFlowGenFunRe2 = dynamic_cast<TProfile2D*>(fListHistos->FindObject("fDiffFlowGenFunRe2"));
344 TProfile2D *diffFlowGenFunRe3 = dynamic_cast<TProfile2D*>(fListHistos->FindObject("fDiffFlowGenFunRe3"));
345 TProfile2D *diffFlowGenFunRe4 = dynamic_cast<TProfile2D*>(fListHistos->FindObject("fDiffFlowGenFunRe4"));
346 TProfile2D *diffFlowGenFunRe5 = dynamic_cast<TProfile2D*>(fListHistos->FindObject("fDiffFlowGenFunRe5"));
347 TProfile2D *diffFlowGenFunRe6 = dynamic_cast<TProfile2D*>(fListHistos->FindObject("fDiffFlowGenFunRe6"));
348 TProfile2D *diffFlowGenFunRe7 = dynamic_cast<TProfile2D*>(fListHistos->FindObject("fDiffFlowGenFunRe7"));
349 TProfile2D *diffFlowGenFunIm0 = dynamic_cast<TProfile2D*>(fListHistos->FindObject("fDiffFlowGenFunIm0"));
350 TProfile2D *diffFlowGenFunIm1 = dynamic_cast<TProfile2D*>(fListHistos->FindObject("fDiffFlowGenFunIm1"));
351 TProfile2D *diffFlowGenFunIm2 = dynamic_cast<TProfile2D*>(fListHistos->FindObject("fDiffFlowGenFunIm2"));
352 TProfile2D *diffFlowGenFunIm3 = dynamic_cast<TProfile2D*>(fListHistos->FindObject("fDiffFlowGenFunIm3"));
353 TProfile2D *diffFlowGenFunIm4 = dynamic_cast<TProfile2D*>(fListHistos->FindObject("fDiffFlowGenFunIm4"));
354 TProfile2D *diffFlowGenFunIm5 = dynamic_cast<TProfile2D*>(fListHistos->FindObject("fDiffFlowGenFunIm5"));
355 TProfile2D *diffFlowGenFunIm6 = dynamic_cast<TProfile2D*>(fListHistos->FindObject("fDiffFlowGenFunIm6"));
356 TProfile2D *diffFlowGenFunIm7 = dynamic_cast<TProfile2D*>(fListHistos->FindObject("fDiffFlowGenFunIm7"));
52021ae2 357 */
2188af53 358
359 //profile with avarage selected multiplicity for int. flow
52021ae2 360 //TProfile *avMult = dynamic_cast<TProfile*>(fListHistos->FindObject("fAvMultIntFlow"));
2188af53 361
362 //profile with avarage values of Q-vector components (1st bin: <Q_x>, 2nd bin: <Q_y>, 3rd bin: <(Q_x)^2>, 4th bin: <(Q_y)^2>)
52021ae2 363 //TProfile *QVectorComponents = dynamic_cast<TProfile*>(fListHistos->FindObject("fQVectorComponents"));
2188af53 364
365 //q-distribution
52021ae2 366 //TH1D *qDist = dynamic_cast<TH1D*>(fListHistos->FindObject("fQDist"));
2188af53 367
52021ae2 368 //AliCumulantsFunctions finalResults(intFlowGenFun,NULL,NULL, intFlowResults,diffFlowResults2,diffFlowResults4,diffFlowResults6,diffFlowResults8,avMult,QVectorComponents,qDist,diffFlowGenFunRe0,diffFlowGenFunRe1,diffFlowGenFunRe2, diffFlowGenFunRe3,diffFlowGenFunRe4,diffFlowGenFunRe5,diffFlowGenFunRe6,diffFlowGenFunRe7,diffFlowGenFunIm0,diffFlowGenFunIm1, diffFlowGenFunIm2,diffFlowGenFunIm3,diffFlowGenFunIm4,diffFlowGenFunIm5,diffFlowGenFunIm6,diffFlowGenFunIm7);
369
370 //AliCumulantsFunctions finalResults(intFlowGenFun,diffFlowGenFunRe,diffFlowGenFunIm, intFlowResults,diffFlowResults2,diffFlowResults4,diffFlowResults6,diffFlowResults8,avMult,QVectorComponents,qDist);
2188af53 371
52021ae2 372 //finalResults.Calculate();
373
374
375
376 //----------------------------------------------------
377
378 fGFC = new AliFlowAnalysisWithCumulants();
2188af53 379
52021ae2 380 fGFC->SetIntFlowResults(intFlowResults);
381 fGFC->SetDiffFlowResults2nd(diffFlowResults2);
382 fGFC->SetDiffFlowResults4th(diffFlowResults4);
383 fGFC->SetDiffFlowResults6th(diffFlowResults6);
384 fGFC->SetDiffFlowResults8th(diffFlowResults8);
385
386 fGFC->SetCommonHistsResults2nd(commonHistRes2nd);
387 fGFC->SetCommonHistsResults4th(commonHistRes4th);
388 fGFC->SetCommonHistsResults6th(commonHistRes6th);
389 fGFC->SetCommonHistsResults8th(commonHistRes8th);
390
391 fGFC->SetIntFlowGenFun(intFlowGenFun);
392 fGFC->SetDiffFlowGenFunRe(diffFlowGenFunRe);
393 fGFC->SetDiffFlowGenFunIm(diffFlowGenFunIm);
394
395 fGFC->SetNumberOfParticlesPerPtBin(BinNoOfParticles);
396
397 fGFC->SetAverageMultiplicity(AvMult);
398 fGFC->SetQVectorComponents(QVectorComponents);
399
400 fGFC->Finish();
401
402 //----------------------------------------------------
2188af53 403 }
404 else
405 {
406 cout<<"histogram list pointer is empty"<<endl;
407 }
aaebd73d 408}
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
924fafb7 425
924fafb7 426
924fafb7 427
924fafb7 428
c75fdbdc 429