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
23 class AliAnalysisTask;
24 #include "AliAnalysisManager.h"
26 #include "AliESDEvent.h"
27 #include "AliESDInputHandler.h"
29 #include "AliAODEvent.h"
30 #include "AliAODInputHandler.h"
32 #include "AliMCEventHandler.h"
33 #include "AliMCEvent.h"
35 #include "../../CORRFW/AliCFManager.h"
37 #include "AliAnalysisTaskLeeYangZeros.h"
38 #include "AliFlowEventSimpleMaker.h"
39 #include "AliFlowAnalysisWithLeeYangZeros.h"
41 // AliAnalysisTaskLeeYangZeros:
42 // analysis task for Lee Yang Zeros method
43 // Author: Naomi van der Kolk (kolk@nikhef.nl)
45 ClassImp(AliAnalysisTaskLeeYangZeros)
47 //________________________________________________________________________
48 AliAnalysisTaskLeeYangZeros::AliAnalysisTaskLeeYangZeros(const char *name, Bool_t firstrun) :
49 AliAnalysisTask(name, ""),
59 fFirstRunLYZ(firstrun), //set boolean for firstrun to initial value
60 fUseSumLYZ(kTRUE) //set boolean for use sum to initial value
63 cout<<"AliAnalysisTaskLeeYangZeros::AliAnalysisTaskLeeYangZeros(const char *name)"<<endl;
65 // Define input and output slots here
66 // Input slot #0 works with a TChain
67 DefineInput(0, TChain::Class());
68 if (!firstrun) DefineInput(1, TList::Class()); //for second loop
69 // Output slot #0 writes into a TList container
70 DefineOutput(0, TList::Class());
75 //________________________________________________________________________
76 AliAnalysisTaskLeeYangZeros::AliAnalysisTaskLeeYangZeros() :
86 fFirstRunLYZ(kTRUE), //set boolean for firstrun to initial value
87 fUseSumLYZ(kTRUE) //set boolean for use sum to initial value
90 cout<<"AliAnalysisTaskLeeYangZeros::AliAnalysisTaskLeeYangZeros(const char *name)"<<endl;
96 //________________________________________________________________________
97 AliAnalysisTaskLeeYangZeros::~AliAnalysisTaskLeeYangZeros()
106 //________________________________________________________________________
107 void AliAnalysisTaskLeeYangZeros::ConnectInputData(Option_t *)
109 // Connect ESD or AOD here
111 cout<<"AliAnalysisTaskLeeYangZeros::ConnectInputData(Option_t *)"<<endl;
113 TTree* tree = dynamic_cast<TTree*> (GetInputData(0));
115 Printf("ERROR: Could not read chain from input slot 0");
118 // Disable all branches and enable only the needed ones
119 if (fAnalysisType == "MC") {
120 // we want to process only MC
121 tree->SetBranchStatus("*", kFALSE);
123 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
126 Printf("ERROR: Could not get ESDInputHandler");
128 fESD = esdH->GetEvent();
131 else if (fAnalysisType == "ESD" || fAnalysisType == "ESDMC0" || fAnalysisType == "ESDMC1" ) {
132 tree->SetBranchStatus("*", kFALSE);
133 tree->SetBranchStatus("Tracks.*", kTRUE);
135 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
138 Printf("ERROR: Could not get ESDInputHandler");
140 fESD = esdH->GetEvent();
142 else if (fAnalysisType == "AOD") {
143 AliAODInputHandler *aodH = dynamic_cast<AliAODInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
146 Printf("ERROR: Could not get AODInputHandler");
149 fAOD = aodH->GetEvent();
153 Printf("Wrong analysis type: Only ESD, ESDMC0, ESDMC1, AOD and MC types are allowed!");
159 //________________________________________________________________________
160 void AliAnalysisTaskLeeYangZeros::CreateOutputObjects()
163 cout<<"AliAnalysisTaskLeeYangZeros::CreateOutputObjects()"<<endl;
165 if (!(fAnalysisType == "AOD" || fAnalysisType == "ESD" || fAnalysisType == "ESDMC0" || fAnalysisType == "ESDMC1" || fAnalysisType == "MC")) {
166 cout<<"WRONG ANALYSIS TYPE! only ESD, ESDMC0, ESDMC1, AOD and MC are allowed."<<endl;
171 fEventMaker = new AliFlowEventSimpleMaker();
173 fLyz = new AliFlowAnalysisWithLeeYangZeros() ;
175 fLyz -> SetFirstRun(GetFirstRunLYZ()); //set first run true or false
176 fLyz -> SetUseSum(GetUseSumLYZ()); //set use sum true or false
178 // Get data from input slot 1
179 if (GetNinputs() == 2) { //if there are two input slots
180 fFirstRunFile = (TFile*)GetInputData(1);
181 cerr<<"fFirstRunFile ("<<fFirstRunFile<<")"<<endl;
182 if (fFirstRunFile) { cerr<<"fFirstRunFile -> IsOpen() = "<<fFirstRunFile -> IsOpen()<<endl;}
183 else { cerr<<"fFirstRunFile has a NULL pointer!!"<<endl; exit(0);}
184 fLyz -> SetFirstRunFile(fFirstRunFile);
189 if (fLyz->GetHistList()) {
190 fLyz->GetHistList()->Print();
191 fListHistos = fLyz->GetHistList();
192 fListHistos->Print();
194 else {Printf("ERROR: Could not retrieve histogram list"); }
198 //________________________________________________________________________
199 void AliAnalysisTaskLeeYangZeros::Exec(Option_t *)
202 // Called for each event
203 if (fAnalysisType == "MC") {
204 // Process MC truth, therefore we receive the AliAnalysisManager and ask it for the AliMCEventHandler
205 // This handler can return the current MC event
207 AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
209 Printf("ERROR: Could not retrieve MC event handler");
213 AliMCEvent* mcEvent = eventHandler->MCEvent();
215 Printf("ERROR: Could not retrieve MC event");
219 fCFManager1->SetEventInfo(mcEvent);
220 fCFManager2->SetEventInfo(mcEvent);
222 Printf("MC particles: %d", mcEvent->GetNumberOfTracks());
224 //lee yang zeros analysis
225 //AliFlowEventSimple* fEvent = fEventMaker->FillTracks(mcEvent);
226 AliFlowEventSimple* fEvent = fEventMaker->FillTracks(mcEvent,fCFManager1,fCFManager2);
230 else if (fAnalysisType == "ESD") {
232 Printf("ERROR: fESD not available");
235 Printf("There are %d tracks in this event", fESD->GetNumberOfTracks());
237 //lee yang zeros analysis
238 //AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fESD);
239 AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fESD,fCFManager1,fCFManager2);
243 else if (fAnalysisType == "ESDMC0" || fAnalysisType == "ESDMC1") {
245 Printf("ERROR: fESD not available");
248 Printf("There are %d tracks in this event", fESD->GetNumberOfTracks());
250 AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
252 Printf("ERROR: Could not retrieve MC event handler");
256 AliMCEvent* mcEvent = eventHandler->MCEvent();
258 Printf("ERROR: Could not retrieve MC event");
262 fCFManager1->SetEventInfo(mcEvent);
263 fCFManager2->SetEventInfo(mcEvent);
265 //lee yang zeros analysis
266 //AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fESD,mcEvent,0); //0 = kine from ESD, 1 = kine from MC
267 AliFlowEventSimple* fEvent=NULL;
268 if (fAnalysisType == "ESDMC0") {
269 fEvent = fEventMaker->FillTracks(fESD, mcEvent, fCFManager1, fCFManager2, 0); //0 = kine from ESD, 1 = kine from MC
270 } else if (fAnalysisType == "ESDMC1") {
271 fEvent = fEventMaker->FillTracks(fESD, mcEvent, fCFManager1, fCFManager2, 1); //0 = kine from ESD, 1 = kine from MC
278 else if (fAnalysisType == "AOD") {
280 Printf("ERROR: fAOD not available");
283 Printf("There are %d tracks in this event", fAOD->GetNumberOfTracks());
285 //lee yang zeros analysis
286 AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fAOD); //no CF yet!
291 //PostData(0,fListHistos); //here for CAF
295 //________________________________________________________________________
296 void AliAnalysisTaskLeeYangZeros::Terminate(Option_t *)
298 // Called once at the end of the query
299 if (GetNinputs() == 2) {
300 cerr<<"fFirstRunFile -> IsOpen() = "<<fFirstRunFile -> IsOpen()<<endl;
303 fLyz->Finish(); //remove for CAF
304 PostData(0,fListHistos); //remove for CAF
307 //print histogram list:
308 TList* fOutListHistos = (TList*)GetOutputData(0);
309 cout << "histogram list in Terminate" << endl;
310 if (fOutListHistos) {
311 //fOutListHistos->Print(); //gives error for secondrun??
314 cout << "histgram list pointer is empty" << endl;}
317 //delete fEventMaker;
319 cout<<".....finished"<<endl;