]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/FLOW/AliAnalysisTaskQCumulants.cxx
Corrected analysis configuration and execution files after changes in PartCorr frame...
[u/mrichter/AliRoot.git] / PWG2 / FLOW / AliAnalysisTaskQCumulants.cxx
CommitLineData
bc92c0cb 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 *f
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 * analysis task for Q-cumulants *
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"
28#include "TChain.h"
29#include "TTree.h"
30#include "TFile.h"
31#include "TList.h"
32#include "TH1.h"
33#include "TProfile.h"
34#include "TProfile2D.h"
35#include "TProfile3D.h"
36
37#include "AliAnalysisTask.h"
38#include "AliAnalysisDataSlot.h"
39#include "AliAnalysisDataContainer.h"
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
51#include "../../CORRFW/AliCFManager.h"
52
53#include "AliAnalysisTaskQCumulants.h"
54#include "AliFlowEventSimpleMaker.h"
55#include "AliFlowAnalysisWithQCumulants.h"
56#include "AliFlowCumuConstants.h"
57#include "AliFlowCommonConstants.h"
58#include "AliFlowCommonHistResults.h"
59#include "AliQCumulantsFunctions.h"
60
61ClassImp(AliAnalysisTaskQCumulants)
62
63//================================================================================================================
64
65AliAnalysisTaskQCumulants::AliAnalysisTaskQCumulants(const char *name, Bool_t on):
66 AliAnalysisTask(name,""),
67 fESD(NULL),
68 fAOD(NULL),
69 fQCA(NULL),//Q-cumulant Analysis (QCA) object
70 fEventMaker(NULL),
71 fAnalysisType("ESD"),
72 fCFManager1(NULL),
73 fCFManager2(NULL),
74 fListHistos(NULL),
75 fQAInt(NULL),
76 fQADiff(NULL),
77 fQA(on)
78{
79 //constructor
80 cout<<"AliAnalysisTaskQCumulants::AliAnalysisTaskQCumulants(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());
85
86 // Output slot #0 writes into a TList container
87 DefineOutput(0, TList::Class());
88 if(on)
89 {
90 DefineOutput(1, TList::Class());
91 DefineOutput(2, TList::Class());
92 }
93}
94
95AliAnalysisTaskQCumulants::AliAnalysisTaskQCumulants():
96 fESD(NULL),
97 fAOD(NULL),
98 fQCA(NULL),//Q-cumulant Analysis (QCA) object
99 fEventMaker(NULL),
100 fAnalysisType("ESD"),
101 fCFManager1(NULL),
102 fCFManager2(NULL),
103 fListHistos(NULL),
104 fQAInt(NULL),
105 fQADiff(NULL),
106 fQA(kFALSE)
107{
108 //dummy constructor
109 cout<<"AliAnalysisTaskQCumulants::AliAnalysisTaskQCumulants()"<<endl;
110}
111
112//================================================================================================================
113
114void AliAnalysisTaskQCumulants::ConnectInputData(Option_t *)
115{
116 //connect ESD or AOD (called once)
117 cout<<"AliAnalysisTaskQCumulants::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
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
167//================================================================================================================
168
169void AliAnalysisTaskQCumulants::CreateOutputObjects()
170{
171 //called at every worker node to initialize
172 cout<<"AliAnalysisTaskQCumulants::CreateOutputObjects()"<<endl;
173
174
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
188 fQCA = new AliFlowAnalysisWithQCumulants();
189 fQCA->CreateOutputObjects();
190
191 if(fQCA->GetHistList())
192 {
193 fListHistos = fQCA->GetHistList();
194 //fListHistos->Print();
195 }
196 else
197 {
198 Printf("ERROR: Could not retrieve histogram list");
199 }
200
201 //PostData(0,fListHistos);
202
203}
204
205//================================================================================================================
206
207void AliAnalysisTaskQCumulants::Exec(Option_t *)
208{
209 //main loop (called for each event)
210 if (fAnalysisType == "MC") {
211 // Process MC truth, therefore we receive the AliAnalysisManager and ask it for the AliMCEventHandler
212 // This handler can return the current MC event
213
214 AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
215 if (!eventHandler) {
216 Printf("ERROR: Could not retrieve MC event handler");
217 return;
218 }
219
220 AliMCEvent* mcEvent = eventHandler->MCEvent();
221 if (!mcEvent) {
222 Printf("ERROR: Could not retrieve MC event");
223 return;
224 }
225
226 Printf("MC particles: %d", mcEvent->GetNumberOfTracks());
227 fCFManager1->SetEventInfo(mcEvent);
228 fCFManager2->SetEventInfo(mcEvent);
229
230 //Q-cumulant analysis
231 AliFlowEventSimple* fEvent = fEventMaker->FillTracks(mcEvent,fCFManager1,fCFManager2);
232 fQCA->Make(fEvent);
233 delete fEvent;
234 }
235 else if (fAnalysisType == "ESD") {
236 if (!fESD) {
237 Printf("ERROR: fESD not available");
238 return;
239 }
240 Printf("There are %d tracks in this event", fESD->GetNumberOfTracks());
241
1315fe58 242 //Q-cumulant analysis
fe488c8a 243 AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fESD,fCFManager1,fCFManager2);
1315fe58 244 //AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fESD);
245 fQCA->Make(fEvent);
bc92c0cb 246 delete fEvent;
247 }
248 else if (fAnalysisType == "ESDMC0") {
249 if (!fESD) {
250 Printf("ERROR: fESD not available");
251 return;
252 }
253 Printf("There are %d tracks in this event", fESD->GetNumberOfTracks());
254
255 AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
256 if (!eventHandler) {
257 Printf("ERROR: Could not retrieve MC event handler");
258 return;
259 }
260
261 AliMCEvent* mcEvent = eventHandler->MCEvent();
262 if (!mcEvent) {
263 Printf("ERROR: Could not retrieve MC event");
264 return;
265 }
266
267 fCFManager1->SetEventInfo(mcEvent);
268 fCFManager2->SetEventInfo(mcEvent);
269
270 //Q-cumulant analysis
271 AliFlowEventSimple* fEvent=NULL;
272 if (fAnalysisType == "ESDMC0") {
273 fEvent = fEventMaker->FillTracks(fESD, mcEvent, fCFManager1, fCFManager2, 0); //0 = kine from ESD, 1 = kine from MC
274 } else if (fAnalysisType == "ESDMC1") {
275 fEvent = fEventMaker->FillTracks(fESD, mcEvent, fCFManager1, fCFManager2, 1); //0 = kine from ESD, 1 = kine from MC
276 }
277 fQCA->Make(fEvent);
278 delete fEvent;
279 //delete mcEvent;
280 }
281
282 else if (fAnalysisType == "AOD") {
283 if (!fAOD) {
284 Printf("ERROR: fAOD not available");
285 return;
286 }
287 Printf("There are %d tracks in this event", fAOD->GetNumberOfTracks());
288
289 // analysis
290 //For the moment don't use CF //AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fAOD,fCFManager1,fCFManager2);
291 AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fAOD);
292 fQCA->Make(fEvent);
293 delete fEvent;
294 }
295
296 PostData(0,fListHistos);
297 if(fQA)
298 {
299 PostData(1,fQAInt);
300 PostData(2,fQADiff);
301 }
302}
303
304//================================================================================================================
305
306void AliAnalysisTaskQCumulants::Terminate(Option_t *)
307{
308 //accessing the output list which contains the merged 2D and 3D profiles from all worker nodes
309 fListHistos = (TList*)GetOutputData(0);
310 //fListHistos->Print();
311
312 if(fListHistos)
313 {
314 //histograms to store the final results (integrated flow)
1315fe58 315 TH1D *intFlowResults = dynamic_cast<TH1D*>(fListHistos->FindObject("fIntFlowResultsQC"));
bc92c0cb 316
317 //histograms to store the final results (differential flow)
1315fe58 318 TH1D *diffFlowResults2ndOrder = dynamic_cast<TH1D*>(fListHistos->FindObject("fDiffFlowResults2ndOrderQC"));
319 TH1D *diffFlowResults4thOrder = dynamic_cast<TH1D*>(fListHistos->FindObject("fDiffFlowResults4thOrderQC"));
bc92c0cb 320
1315fe58 321 //histogram to store the final results for covariances (1st bin <2*4>-<2>*<4>, 2nd bin <2*6>-<2>*<6>, ...)
322 TH1D *covariances = dynamic_cast<TH1D*>(fListHistos->FindObject("fCovariances"));
bc92c0cb 323
324 //profile with avarage selected multiplicity for int. flow
1315fe58 325 TProfile *AvMultHere = dynamic_cast<TProfile*>(fListHistos->FindObject("fAvMultIntFlowQC"));
bc92c0cb 326
327 //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>)
328 TProfile *QvectorComponentsHere = dynamic_cast<TProfile*>(fListHistos->FindObject("fQvectorComponents"));
329
330 TProfile *QCorrelations = dynamic_cast<TProfile*>(fListHistos->FindObject("fQCorrelations"));
331 TProfile *QCovariance = dynamic_cast<TProfile*>(fListHistos->FindObject("fQCovariance"));
332
333 TProfile *QCorrelationsPerBin = dynamic_cast<TProfile*>(fListHistos->FindObject("fQCorrelationsPerBin"));
334
335
336
337 TProfile *DirectHere = dynamic_cast<TProfile*>(fListHistos->FindObject("fDirectCorrelations"));
338
339
340 TProfile *binned2p_1n1n = dynamic_cast<TProfile*>(fListHistos->FindObject("f2_1n1n"));
341 TProfile *binned2p_2n2n = dynamic_cast<TProfile*>(fListHistos->FindObject("f2_2n2n"));
342 TProfile *binned3p_2n1n1n = dynamic_cast<TProfile*>(fListHistos->FindObject("f3_2n1n1n"));
343 TProfile *binned3p_1n1n2n = dynamic_cast<TProfile*>(fListHistos->FindObject("f3_1n1n2n"));
344 TProfile *binned4p_1n1n1n1n = dynamic_cast<TProfile*>(fListHistos->FindObject("f4_1n1n1n1n"));
1315fe58 345
346 /*
347 AliFlowCommonHistResults *commonHR2nd = dynamic_cast<AliFlowCommonHistResults*>(fListHistos->FindObject("fCommonHistsResults2nd"));
348 AliFlowCommonHistResults *commonHR4th = dynamic_cast<AliFlowCommonHistResults*>(fListHistos->FindObject("fCommonHistsResults4th"));
349 AliFlowCommonHistResults *commonHR6th = dynamic_cast<AliFlowCommonHistResults*>(fListHistos->FindObject("fCommonHistsResults6th"));
350 AliFlowCommonHistResults *commonHR8th = dynamic_cast<AliFlowCommonHistResults*>(fListHistos->FindObject("fCommonHistsResults8th"));
351 */
bc92c0cb 352
353
1315fe58 354 /*
355 AliQCumulantsFunctions finalResults(intFlowResults,diffFlowResults2ndOrder,diffFlowResults4thOrder,covariances,AvMultHere,QvectorComponentsHere,QCorrelations,QCovariance,QCorrelationsPerBin,DirectHere,binned2p_1n1n,binned2p_2n2n, binned3p_2n1n1n,binned3p_1n1n2n, binned4p_1n1n1n1n, commonHR2nd, commonHR4th, commonHR6th, commonHR8th);
356 */
bc92c0cb 357
1315fe58 358 AliQCumulantsFunctions finalResults(intFlowResults,diffFlowResults2ndOrder,diffFlowResults4thOrder,covariances,AvMultHere,QvectorComponentsHere,QCorrelations,QCovariance,QCorrelationsPerBin,DirectHere,binned2p_1n1n,binned2p_2n2n, binned3p_2n1n1n,binned3p_1n1n2n, binned4p_1n1n1n1n);
359
360
bc92c0cb 361 finalResults.Calculate();
362
363
364
365 }
366 else
367 {
368 cout<<"histogram list pointer is empty"<<endl;
369 }
370}
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391