1 /*************************************************************************
2 * Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 /**************************************
17 * analysis task for Q-cumulants *
19 * authors: Naomi van der Kolk *
22 * (snelling@nikhef.nl) *
25 * ***********************************/
27 #include "Riostream.h"
34 #include "TProfile2D.h"
35 #include "TProfile3D.h"
37 #include "AliAnalysisTask.h"
38 #include "AliAnalysisDataSlot.h"
39 #include "AliAnalysisDataContainer.h"
40 #include "AliAnalysisManager.h"
42 #include "AliESDEvent.h"
43 #include "AliESDInputHandler.h"
45 #include "AliAODEvent.h"
46 #include "AliAODInputHandler.h"
48 #include "AliMCEventHandler.h"
49 #include "AliMCEvent.h"
51 #include "../../CORRFW/AliCFManager.h"
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"
61 ClassImp(AliAnalysisTaskQCumulants)
63 //================================================================================================================
65 AliAnalysisTaskQCumulants::AliAnalysisTaskQCumulants(const char *name, Bool_t on):
66 AliAnalysisTask(name,""),
69 fQCA(NULL),//Q-cumulant Analysis (QCA) object
80 cout<<"AliAnalysisTaskQCumulants::AliAnalysisTaskQCumulants(const char *name)"<<endl;
82 // Define input and output slots here
83 // Input slot #0 works with a TChain
84 DefineInput(0, TChain::Class());
86 // Output slot #0 writes into a TList container
87 DefineOutput(0, TList::Class());
90 DefineOutput(1, TList::Class());
91 DefineOutput(2, TList::Class());
95 AliAnalysisTaskQCumulants::AliAnalysisTaskQCumulants():
98 fQCA(NULL),//Q-cumulant Analysis (QCA) object
100 fAnalysisType("ESD"),
109 cout<<"AliAnalysisTaskQCumulants::AliAnalysisTaskQCumulants()"<<endl;
112 //================================================================================================================
114 void AliAnalysisTaskQCumulants::ConnectInputData(Option_t *)
116 //connect ESD or AOD (called once)
117 cout<<"AliAnalysisTaskQCumulants::ConnectInputData(Option_t *)"<<endl;
119 TTree* tree = dynamic_cast<TTree*> (GetInputData(0));
122 Printf("ERROR: Could not read chain from input slot 0");
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);
131 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
134 Printf("ERROR: Could not get ESDInputHandler");
136 fESD = esdH->GetEvent();
139 else if (fAnalysisType == "ESD" || fAnalysisType == "ESDMC0" || fAnalysisType == "ESDMC1" ) {
140 tree->SetBranchStatus("*", kFALSE);
141 tree->SetBranchStatus("Tracks.*", kTRUE);
143 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
146 Printf("ERROR: Could not get ESDInputHandler");
148 fESD = esdH->GetEvent();
150 else if (fAnalysisType == "AOD") {
151 AliAODInputHandler *aodH = dynamic_cast<AliAODInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
154 Printf("ERROR: Could not get AODInputHandler");
157 fAOD = aodH->GetEvent();
161 Printf("Wrong analysis type: Only ESD, ESDMC0, ESDMC1, AOD and MC types are allowed!");
167 //================================================================================================================
169 void AliAnalysisTaskQCumulants::CreateOutputObjects()
171 //called at every worker node to initialize
172 cout<<"AliAnalysisTaskQCumulants::CreateOutputObjects()"<<endl;
178 if(!(fAnalysisType == "AOD" || fAnalysisType == "ESD" || fAnalysisType == "ESDMC0" || fAnalysisType == "ESDMC1" || fAnalysisType == "MC"))
180 cout<<"WRONG ANALYSIS TYPE! only ESD, ESDMC0, ESDMC1, AOD and MC are allowed."<<endl;
185 fEventMaker = new AliFlowEventSimpleMaker();
188 fQCA = new AliFlowAnalysisWithQCumulants();
189 fQCA->CreateOutputObjects();
191 if(fQCA->GetHistList())
193 fListHistos = fQCA->GetHistList();
194 //fListHistos->Print();
198 Printf("ERROR: Could not retrieve histogram list");
201 //PostData(0,fListHistos);
205 //================================================================================================================
207 void AliAnalysisTaskQCumulants::Exec(Option_t *)
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
214 AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
216 Printf("ERROR: Could not retrieve MC event handler");
220 AliMCEvent* mcEvent = eventHandler->MCEvent();
222 Printf("ERROR: Could not retrieve MC event");
226 Printf("MC particles: %d", mcEvent->GetNumberOfTracks());
227 fCFManager1->SetEventInfo(mcEvent);
228 fCFManager2->SetEventInfo(mcEvent);
230 //Q-cumulant analysis
231 AliFlowEventSimple* fEvent = fEventMaker->FillTracks(mcEvent,fCFManager1,fCFManager2);
235 else if (fAnalysisType == "ESD") {
237 Printf("ERROR: fESD not available");
240 Printf("There are %d tracks in this event", fESD->GetNumberOfTracks());
242 //Q-cumulant analysis
243 AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fESD,fCFManager1,fCFManager2);//cuts
244 //AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fESD);
250 else if (fAnalysisType == "ESDMC0") {
252 Printf("ERROR: fESD not available");
255 Printf("There are %d tracks in this event", fESD->GetNumberOfTracks());
257 AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
259 Printf("ERROR: Could not retrieve MC event handler");
263 AliMCEvent* mcEvent = eventHandler->MCEvent();
265 Printf("ERROR: Could not retrieve MC event");
269 fCFManager1->SetEventInfo(mcEvent);
270 fCFManager2->SetEventInfo(mcEvent);
272 //Q-cumulant analysis
273 AliFlowEventSimple* fEvent=NULL;
274 if (fAnalysisType == "ESDMC0") {
275 fEvent = fEventMaker->FillTracks(fESD, mcEvent, fCFManager1, fCFManager2, 0); //0 = kine from ESD, 1 = kine from MC
276 } else if (fAnalysisType == "ESDMC1") {
277 fEvent = fEventMaker->FillTracks(fESD, mcEvent, fCFManager1, fCFManager2, 1); //0 = kine from ESD, 1 = kine from MC
284 else if (fAnalysisType == "AOD") {
286 Printf("ERROR: fAOD not available");
289 Printf("There are %d tracks in this event", fAOD->GetNumberOfTracks());
292 //For the moment don't use CF //AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fAOD,fCFManager1,fCFManager2);
293 AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fAOD);
298 PostData(0,fListHistos);
306 //================================================================================================================
308 void AliAnalysisTaskQCumulants::Terminate(Option_t *)
310 //accessing the output list which contains the merged 2D and 3D profiles from all worker nodes
311 fListHistos = (TList*)GetOutputData(0);
312 //fListHistos->Print();
316 //final results (integrated flow)
317 TH1D *intFlowResults = dynamic_cast<TH1D*>(fListHistos->FindObject("fIntFlowResultsQC"));
319 //final results (differential flow)
320 TH1D *diffFlowResults2ndOrder = dynamic_cast<TH1D*>(fListHistos->FindObject("fDiffFlowResults2ndOrderQC"));
321 TH1D *diffFlowResults4thOrder = dynamic_cast<TH1D*>(fListHistos->FindObject("fDiffFlowResults4thOrderQC"));
323 //final results for covariances (1st bin <2*4>-<2>*<4>, 2nd bin <2*6>-<2>*<6>, ...)
324 TH1D *covariances = dynamic_cast<TH1D*>(fListHistos->FindObject("fCovariances"));
326 //common histograms to store the final results for the 2nd order integrated and differential flow
327 AliFlowCommonHistResults *commonHistRes2nd = dynamic_cast<AliFlowCommonHistResults*>(fListHistos->FindObject("AliFlowCommonHistResults2ndOrderQC"));
329 //common histograms to store the final results for the 4th order integrated and differential flow
330 AliFlowCommonHistResults *commonHistRes4th = dynamic_cast<AliFlowCommonHistResults*>(fListHistos->FindObject("AliFlowCommonHistResults4thOrderQC"));
332 //common histograms to store the final results for the 6th order integrated and differential flow
333 AliFlowCommonHistResults *commonHistRes6th = dynamic_cast<AliFlowCommonHistResults*>(fListHistos->FindObject("AliFlowCommonHistResults6thOrderQC"));
335 //common histograms to store the final results for the 8th order integrated and differential flow
336 AliFlowCommonHistResults *commonHistRes8th = dynamic_cast<AliFlowCommonHistResults*>(fListHistos->FindObject("AliFlowCommonHistResults8thOrderQC"));
338 //average selected multiplicity (for int. flow)
339 TProfile *AvMult = dynamic_cast<TProfile*>(fListHistos->FindObject("fAvMultIntFlowQC"));
341 //multi-particle correlations calculated from Q-vectors
342 TProfile *QCorrelations = dynamic_cast<TProfile*>(fListHistos->FindObject("fQCorrelations"));
344 //average of products: 1st bin: <2*4>, 2nd bin: <2*6>, ...
345 TProfile *QProduct = dynamic_cast<TProfile*>(fListHistos->FindObject("fQProduct"));
347 //average 2-, 3- and 4-particle correlations per pt-bin
348 TProfile *binnedPt2p1n1nRP = dynamic_cast<TProfile*>(fListHistos->FindObject("f2PerPtBin1n1nRP"));
349 TProfile *binnedPt2p2n2nRP = dynamic_cast<TProfile*>(fListHistos->FindObject("f2PerPtBin2n2nRP"));
350 TProfile *binnedPt3p2n1n1nRP = dynamic_cast<TProfile*>(fListHistos->FindObject("f3PerPtBin2n1n1nRP"));
351 TProfile *binnedPt3p1n1n2nRP = dynamic_cast<TProfile*>(fListHistos->FindObject("f3PerPtBin1n1n2nRP"));
352 TProfile *binnedPt4p1n1n1n1nRP = dynamic_cast<TProfile*>(fListHistos->FindObject("f4PerPtBin1n1n1n1nRP"));
354 //average 2-, 3- and 4-particle correlations per eta-bin
355 TProfile *binnedEta2p1n1nRP = dynamic_cast<TProfile*>(fListHistos->FindObject("f2PerEtaBin1n1nRP"));
356 TProfile *binnedEta2p2n2nRP = dynamic_cast<TProfile*>(fListHistos->FindObject("f2PerEtaBin2n2nRP"));
357 TProfile *binnedEta3p2n1n1nRP = dynamic_cast<TProfile*>(fListHistos->FindObject("f3PerEtaBin2n1n1nRP"));
358 TProfile *binnedEta3p1n1n2nRP = dynamic_cast<TProfile*>(fListHistos->FindObject("f3PerEtaBin1n1n2nRP"));
359 TProfile *binnedEta4p1n1n1n1nRP = dynamic_cast<TProfile*>(fListHistos->FindObject("f4PerEtaBin1n1n1n1nRP"));
361 //average 2-, 3- and 4-particle correlations per pt-bin
362 TProfile *binnedPt2p1n1nPOI = dynamic_cast<TProfile*>(fListHistos->FindObject("f2PerPtBin1n1nPOI"));
363 TProfile *binnedPt2p2n2nPOI = dynamic_cast<TProfile*>(fListHistos->FindObject("f2PerPtBin2n2nPOI"));
364 TProfile *binnedPt3p2n1n1nPOI = dynamic_cast<TProfile*>(fListHistos->FindObject("f3PerPtBin2n1n1nPOI"));
365 TProfile *binnedPt3p1n1n2nPOI = dynamic_cast<TProfile*>(fListHistos->FindObject("f3PerPtBin1n1n2nPOI"));
366 TProfile *binnedPt4p1n1n1n1nPOI = dynamic_cast<TProfile*>(fListHistos->FindObject("f4PerPtBin1n1n1n1nPOI"));
368 //average 2-, 3- and 4-particle correlations per eta-bin
369 TProfile *binnedEta2p1n1nPOI = dynamic_cast<TProfile*>(fListHistos->FindObject("f2PerEtaBin1n1nPOI"));
370 TProfile *binnedEta2p2n2nPOI = dynamic_cast<TProfile*>(fListHistos->FindObject("f2PerEtaBin2n2nPOI"));
371 TProfile *binnedEta3p2n1n1nPOI = dynamic_cast<TProfile*>(fListHistos->FindObject("f3PerEtaBin2n1n1nPOI"));
372 TProfile *binnedEta3p1n1n2nPOI = dynamic_cast<TProfile*>(fListHistos->FindObject("f3PerEtaBin1n1n2nPOI"));
373 TProfile *binnedEta4p1n1n1n1nPOI = dynamic_cast<TProfile*>(fListHistos->FindObject("f4PerEtaBin1n1n1n1nPOI"));
376 //average values of Q-vector components (1st bin: <Q_x>, 2nd bin: <Q_y>, 3rd bin: <(Q_x)^2>, 4th bin: <(Q_y)^2>)
377 TProfile *QVectorComponents = dynamic_cast<TProfile*>(fListHistos->FindObject("fQvectorComponents"));
379 //multi-particle correlations calculated with nested loop
380 TProfile *DirectCorrelations = dynamic_cast<TProfile*>(fListHistos->FindObject("fDirectCorrelations"));
382 //----------------------------------------------------
384 fQCA = new AliFlowAnalysisWithQCumulants();
386 fQCA->SetIntFlowResults(intFlowResults);
387 fQCA->SetDiffFlowResults2nd(diffFlowResults2ndOrder);
388 fQCA->SetDiffFlowResults4th(diffFlowResults4thOrder);
389 fQCA->SetCovariances(covariances);
391 fQCA->SetCommonHistsResults2nd(commonHistRes2nd);
392 fQCA->SetCommonHistsResults4th(commonHistRes4th);
393 fQCA->SetCommonHistsResults6th(commonHistRes6th);
394 fQCA->SetCommonHistsResults8th(commonHistRes8th);
396 fQCA->SetAverageMultiplicity(AvMult);
397 fQCA->SetQCorrelations(QCorrelations);
398 fQCA->SetQProduct(QProduct);
399 fQCA->SetQVectorComponents(QVectorComponents);
401 fQCA->SetTwo1n1nPerPtBinRP(binnedPt2p1n1nRP);
402 fQCA->SetTwo2n2nPerPtBinRP(binnedPt2p2n2nRP);
403 fQCA->SetThree2n1n1nPerPtBinRP(binnedPt3p2n1n1nRP);
404 fQCA->SetThree1n1n2nPerPtBinRP(binnedPt3p1n1n2nRP);
405 fQCA->SetFour1n1n1n1nPerPtBinRP(binnedPt4p1n1n1n1nRP);
407 fQCA->SetTwo1n1nPerEtaBinRP(binnedEta2p1n1nRP);
408 fQCA->SetTwo2n2nPerEtaBinRP(binnedEta2p2n2nRP);
409 fQCA->SetThree2n1n1nPerEtaBinRP(binnedEta3p2n1n1nRP);
410 fQCA->SetThree1n1n2nPerEtaBinRP(binnedEta3p1n1n2nRP);
411 fQCA->SetFour1n1n1n1nPerEtaBinRP(binnedEta4p1n1n1n1nRP);
413 fQCA->SetTwo1n1nPerPtBinPOI(binnedPt2p1n1nPOI);
414 fQCA->SetTwo2n2nPerPtBinPOI(binnedPt2p2n2nPOI);
415 fQCA->SetThree2n1n1nPerPtBinPOI(binnedPt3p2n1n1nPOI);
416 fQCA->SetThree1n1n2nPerPtBinPOI(binnedPt3p1n1n2nPOI);
417 fQCA->SetFour1n1n1n1nPerPtBinPOI(binnedPt4p1n1n1n1nPOI);
419 fQCA->SetTwo1n1nPerEtaBinPOI(binnedEta2p1n1nPOI);
420 fQCA->SetTwo2n2nPerEtaBinPOI(binnedEta2p2n2nPOI);
421 fQCA->SetThree2n1n1nPerEtaBinPOI(binnedEta3p2n1n1nPOI);
422 fQCA->SetThree1n1n2nPerEtaBinPOI(binnedEta3p1n1n2nPOI);
423 fQCA->SetFour1n1n1n1nPerEtaBinPOI(binnedEta4p1n1n1n1nPOI);
425 fQCA->SetDirectCorrelations(DirectCorrelations);
429 //----------------------------------------------------
433 cout<<"histogram list pointer is empty"<<endl;