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 cumulant method *
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 "AliAnalysisTaskCumulants.h"
54 #include "AliFlowEventSimpleMaker.h"
55 #include "AliFlowAnalysisWithCumulants.h"
56 #include "AliFlowCumuConstants.h"
57 #include "AliFlowCommonConstants.h"
58 #include "AliFlowCommonHistResults.h"
59 #include "AliCumulantsFunctions.h"
61 ClassImp(AliAnalysisTaskCumulants)
63 //================================================================================================================
65 AliAnalysisTaskCumulants::AliAnalysisTaskCumulants(const char *name):
66 AliAnalysisTask(name,""),
69 fCA(NULL),//Cumulant Analysis (CA) object
77 cout<<"AliAnalysisTaskCumulants::AliAnalysisTaskCumulants(const char *name)"<<endl;
78 //input and output slots:
79 //input slot #0 works with a TChain
80 DefineInput(0, TChain::Class());
81 //output slot #0 writes into a TList container
82 DefineOutput(0, TList::Class());
85 AliAnalysisTaskCumulants::AliAnalysisTaskCumulants():
88 fCA(NULL),//Cumulant Analysis (CA) object
96 cout<<"AliAnalysisTaskCumulants::AliAnalysisTaskCumulants()"<<endl;
99 //================================================================================================================
101 void AliAnalysisTaskCumulants::ConnectInputData(Option_t *)
103 //connect ESD or AOD (called once)
104 cout<<"AliAnalysisTaskCumulants::ConnectInputData(Option_t *)"<<endl;
106 TTree* tree = dynamic_cast<TTree*> (GetInputData(0));
109 Printf("ERROR: Could not read chain from input slot 0");
113 //disable all branches and enable only the needed ones
114 if (fAnalysisType == "MC") {
115 // we want to process only MC
116 tree->SetBranchStatus("*", kFALSE);
118 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
121 Printf("ERROR: Could not get ESDInputHandler");
123 fESD = esdH->GetEvent();
126 else if (fAnalysisType == "ESD" || fAnalysisType == "ESDMC0" || fAnalysisType == "ESDMC1" ) {
127 tree->SetBranchStatus("*", kFALSE);
128 tree->SetBranchStatus("Tracks.*", kTRUE);
130 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
133 Printf("ERROR: Could not get ESDInputHandler");
135 fESD = esdH->GetEvent();
137 else if (fAnalysisType == "AOD") {
138 AliAODInputHandler *aodH = dynamic_cast<AliAODInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
141 Printf("ERROR: Could not get AODInputHandler");
144 fAOD = aodH->GetEvent();
148 Printf("Wrong analysis type: Only ESD, ESDMC0, ESDMC1, AOD and MC types are allowed!");
154 //================================================================================================================
156 void AliAnalysisTaskCumulants::CreateOutputObjects()
158 //called at every worker node to initialize
159 cout<<"AliAnalysisTaskCumulants::CreateOutputObjects()"<<endl;
165 if(!(fAnalysisType == "AOD" || fAnalysisType == "ESD" || fAnalysisType == "ESDMC0" || fAnalysisType == "ESDMC1" || fAnalysisType == "MC"))
167 cout<<"WRONG ANALYSIS TYPE! only ESD, ESDMC0, ESDMC1, AOD and MC are allowed."<<endl;
172 fEventMaker = new AliFlowEventSimpleMaker();
175 fCA = new AliFlowAnalysisWithCumulants();
176 fCA->CreateOutputObjects();
178 if(fCA->GetHistList())
180 fListHistos = fCA->GetHistList();
181 //fListHistos->Print();
185 Printf("ERROR: Could not retrieve histogram list");
188 //PostData(0,fListHistos);
192 //================================================================================================================
194 void AliAnalysisTaskCumulants::Exec(Option_t *)
196 //main loop (called for each event)
197 if (fAnalysisType == "MC") {
198 // Process MC truth, therefore we receive the AliAnalysisManager and ask it for the AliMCEventHandler
199 // This handler can return the current MC event
201 AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
203 Printf("ERROR: Could not retrieve MC event handler");
207 AliMCEvent* mcEvent = eventHandler->MCEvent();
209 Printf("ERROR: Could not retrieve MC event");
213 Printf("MC particles: %d", mcEvent->GetNumberOfTracks());
214 fCFManager1->SetEventInfo(mcEvent);
215 fCFManager2->SetEventInfo(mcEvent);
218 AliFlowEventSimple* fEvent = fEventMaker->FillTracks(mcEvent,fCFManager1,fCFManager2);
222 else if (fAnalysisType == "ESD") {
224 Printf("ERROR: fESD not available");
227 Printf("There are %d tracks in this event", fESD->GetNumberOfTracks());
230 AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fESD);
234 else if (fAnalysisType == "ESDMC0") {
236 Printf("ERROR: fESD not available");
239 Printf("There are %d tracks in this event", fESD->GetNumberOfTracks());
241 AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
243 Printf("ERROR: Could not retrieve MC event handler");
247 AliMCEvent* mcEvent = eventHandler->MCEvent();
249 Printf("ERROR: Could not retrieve MC event");
253 fCFManager1->SetEventInfo(mcEvent);
254 fCFManager2->SetEventInfo(mcEvent);
257 AliFlowEventSimple* fEvent=NULL;
258 if (fAnalysisType == "ESDMC0") {
259 fEvent = fEventMaker->FillTracks(fESD, mcEvent, fCFManager1, fCFManager2, 0); //0 = kine from ESD, 1 = kine from MC
260 } else if (fAnalysisType == "ESDMC1") {
261 fEvent = fEventMaker->FillTracks(fESD, mcEvent, fCFManager1, fCFManager2, 1); //0 = kine from ESD, 1 = kine from MC
268 else if (fAnalysisType == "AOD") {
270 Printf("ERROR: fAOD not available");
273 Printf("There are %d tracks in this event", fAOD->GetNumberOfTracks());
276 //For the moment don't use CF //AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fAOD,fCFManager1,fCFManager2);
277 AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fAOD);
283 PostData(0,fListHistos);
286 //================================================================================================================
288 void AliAnalysisTaskCumulants::Terminate(Option_t *)
290 //accessing the output list which contains the merged 2D and 3D profiles from all worker nodes
291 fListHistos = (TList*)GetOutputData(0);
292 //fListHistos->Print();
296 //profiles with avarage values of generating functions for int. and diff. flow
297 TProfile2D *intFlowGenFun = dynamic_cast<TProfile2D*>(fListHistos->FindObject("fIntFlowGenFun"));
298 //TProfile3D *diffFlowGenFunRe=dynamic_cast<TProfile3D*>(fListHistos->FindObject("fDiffFlowGenFunRe"));
299 //TProfile3D *diffFlowGenFunIm=dynamic_cast<TProfile3D*>(fListHistos->FindObject("fDiffFlowGenFunIm"));
301 TProfile2D *diffFlowGenFunRe0 = dynamic_cast<TProfile2D*>(fListHistos->FindObject("fDiffFlowGenFunRe0"));
302 TProfile2D *diffFlowGenFunRe1 = dynamic_cast<TProfile2D*>(fListHistos->FindObject("fDiffFlowGenFunRe1"));
303 TProfile2D *diffFlowGenFunRe2 = dynamic_cast<TProfile2D*>(fListHistos->FindObject("fDiffFlowGenFunRe2"));
304 TProfile2D *diffFlowGenFunRe3 = dynamic_cast<TProfile2D*>(fListHistos->FindObject("fDiffFlowGenFunRe3"));
305 TProfile2D *diffFlowGenFunRe4 = dynamic_cast<TProfile2D*>(fListHistos->FindObject("fDiffFlowGenFunRe4"));
306 TProfile2D *diffFlowGenFunRe5 = dynamic_cast<TProfile2D*>(fListHistos->FindObject("fDiffFlowGenFunRe5"));
307 TProfile2D *diffFlowGenFunRe6 = dynamic_cast<TProfile2D*>(fListHistos->FindObject("fDiffFlowGenFunRe6"));
308 TProfile2D *diffFlowGenFunRe7 = dynamic_cast<TProfile2D*>(fListHistos->FindObject("fDiffFlowGenFunRe7"));
309 TProfile2D *diffFlowGenFunIm0 = dynamic_cast<TProfile2D*>(fListHistos->FindObject("fDiffFlowGenFunIm0"));
310 TProfile2D *diffFlowGenFunIm1 = dynamic_cast<TProfile2D*>(fListHistos->FindObject("fDiffFlowGenFunIm1"));
311 TProfile2D *diffFlowGenFunIm2 = dynamic_cast<TProfile2D*>(fListHistos->FindObject("fDiffFlowGenFunIm2"));
312 TProfile2D *diffFlowGenFunIm3 = dynamic_cast<TProfile2D*>(fListHistos->FindObject("fDiffFlowGenFunIm3"));
313 TProfile2D *diffFlowGenFunIm4 = dynamic_cast<TProfile2D*>(fListHistos->FindObject("fDiffFlowGenFunIm4"));
314 TProfile2D *diffFlowGenFunIm5 = dynamic_cast<TProfile2D*>(fListHistos->FindObject("fDiffFlowGenFunIm5"));
315 TProfile2D *diffFlowGenFunIm6 = dynamic_cast<TProfile2D*>(fListHistos->FindObject("fDiffFlowGenFunIm6"));
316 TProfile2D *diffFlowGenFunIm7 = dynamic_cast<TProfile2D*>(fListHistos->FindObject("fDiffFlowGenFunIm7"));
318 //histograms to store the final results
319 TH1D *intFlowResults = dynamic_cast<TH1D*>(fListHistos->FindObject("fIntFlowResults"));
320 TH1D *diffFlowResults2 = dynamic_cast<TH1D*>(fListHistos->FindObject("fDiffFlowResults2"));
321 TH1D *diffFlowResults4 = dynamic_cast<TH1D*>(fListHistos->FindObject("fDiffFlowResults4"));
322 TH1D *diffFlowResults6 = dynamic_cast<TH1D*>(fListHistos->FindObject("fDiffFlowResults6"));
323 TH1D *diffFlowResults8 = dynamic_cast<TH1D*>(fListHistos->FindObject("fDiffFlowResults8"));
325 //profile with avarage selected multiplicity for int. flow
326 TProfile *avMult = dynamic_cast<TProfile*>(fListHistos->FindObject("fAvMultIntFlow"));
328 //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>)
329 TProfile *QVectorComponents = dynamic_cast<TProfile*>(fListHistos->FindObject("fQVectorComponents"));
332 TH1D *qDist = dynamic_cast<TH1D*>(fListHistos->FindObject("fQDist"));
334 AliCumulantsFunctions finalResults(intFlowGenFun,NULL,NULL, intFlowResults,diffFlowResults2,diffFlowResults4,diffFlowResults6,diffFlowResults8,avMult,QVectorComponents,qDist,diffFlowGenFunRe0,diffFlowGenFunRe1,diffFlowGenFunRe2,
335 diffFlowGenFunRe3,diffFlowGenFunRe4,diffFlowGenFunRe5,diffFlowGenFunRe6,diffFlowGenFunRe7,diffFlowGenFunIm0,diffFlowGenFunIm1,
336 diffFlowGenFunIm2,diffFlowGenFunIm3,diffFlowGenFunIm4,diffFlowGenFunIm5,diffFlowGenFunIm6,diffFlowGenFunIm7);
338 finalResults.Calculate();
343 cout<<"histogram list pointer is empty"<<endl;