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"
35 #include "TProfile2D.h"
36 #include "TProfile3D.h"
38 #include "AliAnalysisTask.h"
39 #include "AliAnalysisDataSlot.h"
40 #include "AliAnalysisDataContainer.h"
41 #include "AliAnalysisManager.h"
43 #include "AliESDEvent.h"
44 #include "AliESDInputHandler.h"
46 #include "AliAODEvent.h"
47 #include "AliAODInputHandler.h"
49 #include "AliMCEventHandler.h"
50 #include "AliMCEvent.h"
52 #include "../../CORRFW/AliCFManager.h"
54 #include "AliAnalysisTaskQCumulants.h"
55 #include "AliFlowEventSimpleMaker.h"
56 #include "AliFlowAnalysisWithQCumulants.h"
57 #include "AliFlowCumuConstants.h"
58 #include "AliFlowCommonConstants.h"
59 #include "AliFlowCommonHist.h"
60 #include "AliFlowCommonHistResults.h"
61 #include "AliQCumulantsFunctions.h"
63 ClassImp(AliAnalysisTaskQCumulants)
65 //================================================================================================================
67 AliAnalysisTaskQCumulants::AliAnalysisTaskQCumulants(const char *name, Bool_t on, Bool_t useWeights):
68 AliAnalysisTask(name,""),
71 fQCA(NULL),//Q-cumulant Analysis (QCA) object
80 fUseWeights(useWeights),
81 fUsePhiWeights(kFALSE),
82 fUsePtWeights(kFALSE),
83 fUseEtaWeights(kFALSE),
87 cout<<"AliAnalysisTaskQCumulants::AliAnalysisTaskQCumulants(const char *name)"<<endl;
89 // Define input and output slots here
90 // Input slot #0 works with a TChain
91 DefineInput(0, TChain::Class());
93 // Input slot #1 is needed for the weights
96 DefineInput(1, TList::Class());
99 // Output slot #0 writes into a TList container
100 DefineOutput(0, TList::Class());
103 DefineOutput(1, TList::Class());
104 DefineOutput(2, TList::Class());
109 AliAnalysisTaskQCumulants::AliAnalysisTaskQCumulants():
112 fQCA(NULL),//Q-cumulant Analysis (QCA) object
114 fAnalysisType("ESD"),
122 fUsePhiWeights(kFALSE),
123 fUsePtWeights(kFALSE),
124 fUseEtaWeights(kFALSE),
128 cout<<"AliAnalysisTaskQCumulants::AliAnalysisTaskQCumulants()"<<endl;
131 //================================================================================================================
133 void AliAnalysisTaskQCumulants::ConnectInputData(Option_t *)
135 //connect ESD or AOD (called once)
136 cout<<"AliAnalysisTaskQCumulants::ConnectInputData(Option_t *)"<<endl;
138 TTree* tree = dynamic_cast<TTree*> (GetInputData(0));
141 Printf("ERROR: Could not read chain from input slot 0");
145 //disable all branches and enable only the needed ones
146 if (fAnalysisType == "MC") {
147 // we want to process only MC
148 tree->SetBranchStatus("*", kFALSE);
150 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
153 Printf("ERROR: Could not get ESDInputHandler");
155 fESD = esdH->GetEvent();
158 else if (fAnalysisType == "ESD" || fAnalysisType == "ESDMC0" || fAnalysisType == "ESDMC1" ) {
159 tree->SetBranchStatus("*", kFALSE);
160 tree->SetBranchStatus("Tracks.*", kTRUE);
162 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
165 Printf("ERROR: Could not get ESDInputHandler");
167 fESD = esdH->GetEvent();
169 else if (fAnalysisType == "AOD") {
170 AliAODInputHandler *aodH = dynamic_cast<AliAODInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
173 Printf("ERROR: Could not get AODInputHandler");
176 fAOD = aodH->GetEvent();
180 Printf("Wrong analysis type: Only ESD, ESDMC0, ESDMC1, AOD and MC types are allowed!");
186 //================================================================================================================
188 void AliAnalysisTaskQCumulants::CreateOutputObjects()
190 //called at every worker node to initialize
191 cout<<"AliAnalysisTaskQCumulants::CreateOutputObjects()"<<endl;
197 if(!(fAnalysisType == "AOD" || fAnalysisType == "ESD" || fAnalysisType == "ESDMC0" || fAnalysisType == "ESDMC1" || fAnalysisType == "MC"))
199 cout<<"WRONG ANALYSIS TYPE! only ESD, ESDMC0, ESDMC1, AOD and MC are allowed."<<endl;
204 fEventMaker = new AliFlowEventSimpleMaker();
207 fQCA = new AliFlowAnalysisWithQCumulants();
213 //pass the flags to class:
214 if(fUsePhiWeights) fQCA->SetUsePhiWeights(fUsePhiWeights);
215 if(fUsePtWeights) fQCA->SetUsePtWeights(fUsePtWeights);
216 if(fUseEtaWeights) fQCA->SetUseEtaWeights(fUseEtaWeights);
217 //get data from input slot #1 which is used for weights:
220 fListWeights = (TList*)GetInputData(1);
222 //pass the list with weights to class:
223 if(fListWeights) fQCA->SetWeightsList(fListWeights);
226 if(fQCA->GetHistList())
228 fListHistos = fQCA->GetHistList();
229 //fListHistos->Print();
233 Printf("ERROR: Could not retrieve histogram list");
236 //PostData(0,fListHistos);
240 //================================================================================================================
242 void AliAnalysisTaskQCumulants::Exec(Option_t *)
244 //main loop (called for each event)
245 if (fAnalysisType == "MC") {
246 // Process MC truth, therefore we receive the AliAnalysisManager and ask it for the AliMCEventHandler
247 // This handler can return the current MC event
249 AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
251 Printf("ERROR: Could not retrieve MC event handler");
255 AliMCEvent* mcEvent = eventHandler->MCEvent();
257 Printf("ERROR: Could not retrieve MC event");
261 Printf("MC particles: %d", mcEvent->GetNumberOfTracks());
262 fCFManager1->SetEventInfo(mcEvent);
263 fCFManager2->SetEventInfo(mcEvent);
265 //Q-cumulant analysis
266 AliFlowEventSimple* fEvent = fEventMaker->FillTracks(mcEvent,fCFManager1,fCFManager2);
270 else if (fAnalysisType == "ESD") {
272 Printf("ERROR: fESD not available");
275 Printf("There are %d tracks in this event", fESD->GetNumberOfTracks());
277 //Q-cumulant analysis
278 AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fESD,fCFManager1,fCFManager2);//cuts
279 //AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fESD);
285 else if (fAnalysisType == "ESDMC0") {
287 Printf("ERROR: fESD not available");
290 Printf("There are %d tracks in this event", fESD->GetNumberOfTracks());
292 AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
294 Printf("ERROR: Could not retrieve MC event handler");
298 AliMCEvent* mcEvent = eventHandler->MCEvent();
300 Printf("ERROR: Could not retrieve MC event");
304 fCFManager1->SetEventInfo(mcEvent);
305 fCFManager2->SetEventInfo(mcEvent);
307 //Q-cumulant analysis
308 AliFlowEventSimple* fEvent=NULL;
309 if (fAnalysisType == "ESDMC0") {
310 fEvent = fEventMaker->FillTracks(fESD, mcEvent, fCFManager1, fCFManager2, 0); //0 = kine from ESD, 1 = kine from MC
311 } else if (fAnalysisType == "ESDMC1") {
312 fEvent = fEventMaker->FillTracks(fESD, mcEvent, fCFManager1, fCFManager2, 1); //0 = kine from ESD, 1 = kine from MC
319 else if (fAnalysisType == "AOD") {
321 Printf("ERROR: fAOD not available");
324 Printf("There are %d tracks in this event", fAOD->GetNumberOfTracks());
327 //For the moment don't use CF //AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fAOD,fCFManager1,fCFManager2);
328 AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fAOD);
333 PostData(0,fListHistos);
341 //================================================================================================================
343 void AliAnalysisTaskQCumulants::Terminate(Option_t *)
345 //accessing the output list which contains the merged 2D and 3D profiles from all worker nodes
346 fListHistos = (TList*)GetOutputData(0);
347 //fListHistos->Print();
351 //final results (integrated flow)
352 TH1D *intFlowResults = dynamic_cast<TH1D*>(fListHistos->FindObject("fIntFlowResultsQC"));
354 //final results (differential flow)
355 TH1D *diffFlowResults2ndOrder = dynamic_cast<TH1D*>(fListHistos->FindObject("fDiffFlowResults2ndOrderQC"));
356 TH1D *diffFlowResults4thOrder = dynamic_cast<TH1D*>(fListHistos->FindObject("fDiffFlowResults4thOrderQC"));
358 //final results for covariances (1st bin <2*4>-<2>*<4>, 2nd bin <2*6>-<2>*<6>, ...)
359 TH1D *covariances = dynamic_cast<TH1D*>(fListHistos->FindObject("fCovariances"));
361 //common control histograms (taking into account only the events with 2 and more particles)
362 AliFlowCommonHist *commonHist2nd = dynamic_cast<AliFlowCommonHist*>(fListHistos->FindObject("AliFlowCommonHist2ndOrderQC"));
364 //common control histograms (taking into account only the events with 4 and more particles)
365 AliFlowCommonHist *commonHist4th = dynamic_cast<AliFlowCommonHist*>(fListHistos->FindObject("AliFlowCommonHist4thOrderQC"));
367 //common control histograms (taking into account only the events with 6 and more particles)
368 AliFlowCommonHist *commonHist6th = dynamic_cast<AliFlowCommonHist*>(fListHistos->FindObject("AliFlowCommonHist6thOrderQC"));
370 //common control histograms (taking into account only the events with 8 and more particles)
371 AliFlowCommonHist *commonHist8th = dynamic_cast<AliFlowCommonHist*>(fListHistos->FindObject("AliFlowCommonHist8thOrderQC"));
373 //common histograms to store the final results for the 2nd order integrated and differential flow
374 AliFlowCommonHistResults *commonHistRes2nd = dynamic_cast<AliFlowCommonHistResults*>(fListHistos->FindObject("AliFlowCommonHistResults2ndOrderQC"));
376 //common histograms to store the final results for the 4th order integrated and differential flow
377 AliFlowCommonHistResults *commonHistRes4th = dynamic_cast<AliFlowCommonHistResults*>(fListHistos->FindObject("AliFlowCommonHistResults4thOrderQC"));
379 //common histograms to store the final results for the 6th order integrated and differential flow
380 AliFlowCommonHistResults *commonHistRes6th = dynamic_cast<AliFlowCommonHistResults*>(fListHistos->FindObject("AliFlowCommonHistResults6thOrderQC"));
382 //common histograms to store the final results for the 8th order integrated and differential flow
383 AliFlowCommonHistResults *commonHistRes8th = dynamic_cast<AliFlowCommonHistResults*>(fListHistos->FindObject("AliFlowCommonHistResults8thOrderQC"));
385 //average selected multiplicity (for int. flow)
386 TProfile *AvMult = dynamic_cast<TProfile*>(fListHistos->FindObject("fAvMultIntFlowQC"));
388 //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
389 // !!!! to be removed !!!!
390 //profiles containing the Q-vectors from all events
391 TProfile *qvectorForEachEventX = dynamic_cast<TProfile*>(fListHistos->FindObject("fQvectorForEachEventX"));
392 TProfile *qvectorForEachEventY = dynamic_cast<TProfile*>(fListHistos->FindObject("fQvectorForEachEventY"));
393 //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
395 //multi-particle correlations calculated from Q-vectors
396 TProfile *QCorrelations = dynamic_cast<TProfile*>(fListHistos->FindObject("fQCorrelations"));
398 //average of products: 1st bin: <2*4>, 2nd bin: <2*6>, ...
399 TProfile *QProduct = dynamic_cast<TProfile*>(fListHistos->FindObject("fQProduct"));
401 //average 2-, 3- and 4-particle correlations per pt-bin
402 TProfile *binnedPt2p1n1nRP = dynamic_cast<TProfile*>(fListHistos->FindObject("f2PerPtBin1n1nRP"));
403 TProfile *binnedPt2p2n2nRP = dynamic_cast<TProfile*>(fListHistos->FindObject("f2PerPtBin2n2nRP"));
404 TProfile *binnedPt3p2n1n1nRP = dynamic_cast<TProfile*>(fListHistos->FindObject("f3PerPtBin2n1n1nRP"));
405 TProfile *binnedPt3p1n1n2nRP = dynamic_cast<TProfile*>(fListHistos->FindObject("f3PerPtBin1n1n2nRP"));
406 TProfile *binnedPt4p1n1n1n1nRP = dynamic_cast<TProfile*>(fListHistos->FindObject("f4PerPtBin1n1n1n1nRP"));
408 //average 2-, 3- and 4-particle correlations per eta-bin
409 TProfile *binnedEta2p1n1nRP = dynamic_cast<TProfile*>(fListHistos->FindObject("f2PerEtaBin1n1nRP"));
410 TProfile *binnedEta2p2n2nRP = dynamic_cast<TProfile*>(fListHistos->FindObject("f2PerEtaBin2n2nRP"));
411 TProfile *binnedEta3p2n1n1nRP = dynamic_cast<TProfile*>(fListHistos->FindObject("f3PerEtaBin2n1n1nRP"));
412 TProfile *binnedEta3p1n1n2nRP = dynamic_cast<TProfile*>(fListHistos->FindObject("f3PerEtaBin1n1n2nRP"));
413 TProfile *binnedEta4p1n1n1n1nRP = dynamic_cast<TProfile*>(fListHistos->FindObject("f4PerEtaBin1n1n1n1nRP"));
415 //average 2-, 3- and 4-particle correlations per pt-bin
416 TProfile *binnedPt2p1n1nPOI = dynamic_cast<TProfile*>(fListHistos->FindObject("f2PerPtBin1n1nPOI"));
417 TProfile *binnedPt2p2n2nPOI = dynamic_cast<TProfile*>(fListHistos->FindObject("f2PerPtBin2n2nPOI"));
418 TProfile *binnedPt3p2n1n1nPOI = dynamic_cast<TProfile*>(fListHistos->FindObject("f3PerPtBin2n1n1nPOI"));
419 TProfile *binnedPt3p1n1n2nPOI = dynamic_cast<TProfile*>(fListHistos->FindObject("f3PerPtBin1n1n2nPOI"));
420 TProfile *binnedPt4p1n1n1n1nPOI = dynamic_cast<TProfile*>(fListHistos->FindObject("f4PerPtBin1n1n1n1nPOI"));
422 //average 2-, 3- and 4-particle correlations per eta-bin
423 TProfile *binnedEta2p1n1nPOI = dynamic_cast<TProfile*>(fListHistos->FindObject("f2PerEtaBin1n1nPOI"));
424 TProfile *binnedEta2p2n2nPOI = dynamic_cast<TProfile*>(fListHistos->FindObject("f2PerEtaBin2n2nPOI"));
425 TProfile *binnedEta3p2n1n1nPOI = dynamic_cast<TProfile*>(fListHistos->FindObject("f3PerEtaBin2n1n1nPOI"));
426 TProfile *binnedEta3p1n1n2nPOI = dynamic_cast<TProfile*>(fListHistos->FindObject("f3PerEtaBin1n1n2nPOI"));
427 TProfile *binnedEta4p1n1n1n1nPOI = dynamic_cast<TProfile*>(fListHistos->FindObject("f4PerEtaBin1n1n1n1nPOI"));
429 //average values of Q-vector components (1st bin: <Q_x>, 2nd bin: <Q_y>, 3rd bin: <(Q_x)^2>, 4th bin: <(Q_y)^2>)
430 TProfile *QVectorComponents = dynamic_cast<TProfile*>(fListHistos->FindObject("fQvectorComponents"));
432 //multi-particle correlations calculated with nested loop
433 TProfile *DirectCorrelations = dynamic_cast<TProfile*>(fListHistos->FindObject("fDirectCorrelations"));
435 //----------------------------------------------------
437 fQCA = new AliFlowAnalysisWithQCumulants();
439 fQCA->SetIntFlowResults(intFlowResults);
440 fQCA->SetDiffFlowResults2nd(diffFlowResults2ndOrder);
441 fQCA->SetDiffFlowResults4th(diffFlowResults4thOrder);
442 fQCA->SetCovariances(covariances);
444 fQCA->SetCommonHists2nd(commonHist2nd);
445 fQCA->SetCommonHists4th(commonHist4th);
446 fQCA->SetCommonHists6th(commonHist6th);
447 fQCA->SetCommonHists8th(commonHist8th);
449 fQCA->SetCommonHistsResults2nd(commonHistRes2nd);
450 fQCA->SetCommonHistsResults4th(commonHistRes4th);
451 fQCA->SetCommonHistsResults6th(commonHistRes6th);
452 fQCA->SetCommonHistsResults8th(commonHistRes8th);
454 fQCA->SetAverageMultiplicity(AvMult);
455 //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
456 // !!!! to be removed !!!!
457 fQCA->SetQvectorForEachEventX(qvectorForEachEventX);
458 fQCA->SetQvectorForEachEventY(qvectorForEachEventY);
459 //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
460 fQCA->SetQCorrelations(QCorrelations);
461 fQCA->SetQProduct(QProduct);
462 fQCA->SetQVectorComponents(QVectorComponents);
464 fQCA->SetTwo1n1nPerPtBinRP(binnedPt2p1n1nRP);
465 fQCA->SetTwo2n2nPerPtBinRP(binnedPt2p2n2nRP);
466 fQCA->SetThree2n1n1nPerPtBinRP(binnedPt3p2n1n1nRP);
467 fQCA->SetThree1n1n2nPerPtBinRP(binnedPt3p1n1n2nRP);
468 fQCA->SetFour1n1n1n1nPerPtBinRP(binnedPt4p1n1n1n1nRP);
470 fQCA->SetTwo1n1nPerEtaBinRP(binnedEta2p1n1nRP);
471 fQCA->SetTwo2n2nPerEtaBinRP(binnedEta2p2n2nRP);
472 fQCA->SetThree2n1n1nPerEtaBinRP(binnedEta3p2n1n1nRP);
473 fQCA->SetThree1n1n2nPerEtaBinRP(binnedEta3p1n1n2nRP);
474 fQCA->SetFour1n1n1n1nPerEtaBinRP(binnedEta4p1n1n1n1nRP);
476 fQCA->SetTwo1n1nPerPtBinPOI(binnedPt2p1n1nPOI);
477 fQCA->SetTwo2n2nPerPtBinPOI(binnedPt2p2n2nPOI);
478 fQCA->SetThree2n1n1nPerPtBinPOI(binnedPt3p2n1n1nPOI);
479 fQCA->SetThree1n1n2nPerPtBinPOI(binnedPt3p1n1n2nPOI);
480 fQCA->SetFour1n1n1n1nPerPtBinPOI(binnedPt4p1n1n1n1nPOI);
482 fQCA->SetTwo1n1nPerEtaBinPOI(binnedEta2p1n1nPOI);
483 fQCA->SetTwo2n2nPerEtaBinPOI(binnedEta2p2n2nPOI);
484 fQCA->SetThree2n1n1nPerEtaBinPOI(binnedEta3p2n1n1nPOI);
485 fQCA->SetThree1n1n2nPerEtaBinPOI(binnedEta3p1n1n2nPOI);
486 fQCA->SetFour1n1n1n1nPerEtaBinPOI(binnedEta4p1n1n1n1nPOI);
488 fQCA->SetDirectCorrelations(DirectCorrelations);
492 //----------------------------------------------------
496 cout<<"histogram list pointer is empty"<<endl;