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 #include "Riostream.h" //needed as include
22 class AliAnalysisTask;
23 #include "AliAnalysisManager.h"
25 #include "AliESDEvent.h"
26 #include "AliESDInputHandler.h"
28 #include "AliAODEvent.h"
29 #include "AliAODInputHandler.h"
31 #include "AliMCEventHandler.h"
32 #include "AliMCEvent.h"
34 #include "AliAnalysisTaskCumulants.h"
35 #include "AliFlowEventSimpleMaker.h"
36 #include "AliFlowAnalysisWithCumulants.h"
38 // AliAnalysisTaskCumulants:
39 // analysis task for Lee Yang Zeros method
40 // Author: Naomi van der Kolk (kolk@nikhef.nl)
42 ClassImp(AliAnalysisTaskCumulants)
44 //________________________________________________________________________
45 AliAnalysisTaskCumulants::AliAnalysisTaskCumulants(const char *name) :
46 AliAnalysisTask(name, ""),
50 fMyCumuAnalysis(NULL),
54 cout<<"AliAnalysisTaskCumulants::AliAnalysisTaskCumulants(const char *name)"<<endl;
56 // Define input and output slots here
57 // Input slot #0 works with a TChain
58 DefineInput(0, TChain::Class());
60 // Output slot #0 writes into a TList container
61 DefineOutput(0, TList::Class());
64 //________________________________________________________________________
65 void AliAnalysisTaskCumulants::ConnectInputData(Option_t *)
67 // Connect ESD or AOD here
69 cout<<"AliAnalysisTaskCumulants::ConnectInputData(Option_t *)"<<endl;
71 TTree* tree = dynamic_cast<TTree*> (GetInputData(0));
73 Printf("ERROR: Could not read chain from input slot 0");
76 // Disable all branches and enable only the needed ones
77 if (fAnalysisType == "MC") {
78 // we want to process only MC
79 tree->SetBranchStatus("*", kFALSE);
81 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
84 Printf("ERROR: Could not get ESDInputHandler");
86 fESD = esdH->GetEvent();
89 else if (fAnalysisType == "ESD" || fAnalysisType == "ESDMC0" || fAnalysisType == "ESDMC1" ) {
90 tree->SetBranchStatus("*", kFALSE);
91 tree->SetBranchStatus("Tracks.*", kTRUE);
93 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
96 Printf("ERROR: Could not get ESDInputHandler");
98 fESD = esdH->GetEvent();
100 else if (fAnalysisType == "AOD") {
101 AliAODInputHandler *aodH = dynamic_cast<AliAODInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
104 Printf("ERROR: Could not get AODInputHandler");
107 fAOD = aodH->GetEvent();
111 Printf("Wrong analysis type: Only ESD, ESDMC0, ESDMC1, AOD and MC types are allowed!");
117 //________________________________________________________________________
118 void AliAnalysisTaskCumulants::CreateOutputObjects()
121 cout<<"AliAnalysisTaskCumulants::CreateOutputObjects()"<<endl;
123 if (!(fAnalysisType == "AOD" || fAnalysisType == "ESD" || fAnalysisType == "ESDMC0" || fAnalysisType == "ESDMC1" || fAnalysisType == "MC")) {
124 cout<<"WRONG ANALYSIS TYPE! only ESD, ESDMC0, ESDMC1, AOD and MC are allowed."<<endl;
129 fEventMaker = new AliFlowEventSimpleMaker();
131 fMyCumuAnalysis = new AliFlowAnalysisWithCumulants() ;
135 TString outputName = "outputFromCumulantsAnalysis" ;
136 outputName += fAnalysisType.Data();
137 outputName += ".root";
138 fMyCumuAnalysis->SetHistFileName( outputName.Data() ); //Ante please implement
141 fMyCumuAnalysis->CreateOutputObjects();
145 //________________________________________________________________________
146 void AliAnalysisTaskCumulants::Exec(Option_t *)
149 // Called for each event
150 if (fAnalysisType == "MC") {
151 // Process MC truth, therefore we receive the AliAnalysisManager and ask it for the AliMCEventHandler
152 // This handler can return the current MC event
154 AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
156 Printf("ERROR: Could not retrieve MC event handler");
160 AliMCEvent* mcEvent = eventHandler->MCEvent();
162 Printf("ERROR: Could not retrieve MC event");
166 Printf("MC particles: %d", mcEvent->GetNumberOfTracks());
169 AliFlowEventSimple* fEvent = fEventMaker->FillTracks(mcEvent);
170 fMyCumuAnalysis->Make(fEvent);
173 else if (fAnalysisType == "ESD") {
175 Printf("ERROR: fESD not available");
178 Printf("There are %d tracks in this event", fESD->GetNumberOfTracks());
181 AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fESD);
182 fMyCumuAnalysis->Make(fEvent);
185 else if (fAnalysisType == "ESDMC0") {
187 Printf("ERROR: fESD not available");
190 Printf("There are %d tracks in this event", fESD->GetNumberOfTracks());
192 AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
194 Printf("ERROR: Could not retrieve MC event handler");
198 AliMCEvent* mcEvent = eventHandler->MCEvent();
200 Printf("ERROR: Could not retrieve MC event");
205 AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fESD,mcEvent,0); //0 = kine from ESD, 1 = kine from MC
206 fMyCumuAnalysis->Make(fEvent);
210 else if (fAnalysisType == "ESDMC1") {
212 Printf("ERROR: fESD not available");
215 Printf("There are %d tracks in this event", fESD->GetNumberOfTracks());
217 AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
219 Printf("ERROR: Could not retrieve MC event handler");
223 AliMCEvent* mcEvent = eventHandler->MCEvent();
225 Printf("ERROR: Could not retrieve MC event");
230 AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fESD,mcEvent,1); //0 = kine from ESD, 1 = kine from MC
231 fMyCumuAnalysis->Make(fEvent);
235 else if (fAnalysisType == "AOD") {
237 Printf("ERROR: fAOD not available");
240 Printf("There are %d tracks in this event", fAOD->GetNumberOfTracks());
243 AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fAOD);
244 fMyCumuAnalysis->Make(fEvent);
250 //________________________________________________________________________
251 void AliAnalysisTaskCumulants::Terminate(Option_t *)
253 // Called once at the end of the query
254 cerr<<"fMyCumuAnalysis->GetHistFile() -> IsOpen() = "<<fMyCumuAnalysis->GetHistFile() -> IsOpen()<<endl;
256 fMyCumuAnalysis->Finish();
258 PostData(0,fMyCumuAnalysis->GetHistFile());
260 delete fMyCumuAnalysis;
263 cout<<".....finished"<<endl;