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
19 #include "TFile.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 "AliCFManager.h"
37 #include "AliAnalysisTaskFlowEvent.h"
38 #include "AliFlowEventSimpleMaker.h"
40 // AliAnalysisTaskFlowEvent:
42 // analysis task for filling the flow event
43 // from MCEvent, ESD, AOD ....
44 // and put it in an output stream so it can
45 // be used by the various flow analysis methods
46 // for cuts the correction framework is used
47 // which also outputs QA histrograms to view
48 // the effects of the cuts
51 ClassImp(AliAnalysisTaskFlowEvent)
53 //________________________________________________________________________
54 AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent(const char *name, Bool_t on) :
55 AliAnalysisTask(name, ""),
67 cout<<"AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent(const char *name)"<<endl;
69 // Define input and output slots here
70 // Input slot #0 works with a TChain
71 DefineInput(0, TChain::Class());
72 // Output slot #0 writes into a TList container
73 DefineOutput(0, TObject::Class());
75 DefineOutput(1, TList::Class());
76 DefineOutput(2, TList::Class()); }
77 // Define here the flow event output
81 //________________________________________________________________________
82 AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent() :
94 cout<<"AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent()"<<endl;
97 //________________________________________________________________________
98 AliAnalysisTaskFlowEvent::~AliAnalysisTaskFlowEvent()
104 // objects in the output list are deleted
105 // by the TSelector dtor (I hope)
109 //________________________________________________________________________
110 void AliAnalysisTaskFlowEvent::ConnectInputData(Option_t *)
112 // Connect ESD or AOD here
114 cout<<"AliAnalysisTaskFlowEvent::ConnectInputData(Option_t *)"<<endl;
116 TTree* tree = dynamic_cast<TTree*> (GetInputData(0));
118 Printf("ERROR: Could not read chain from input slot 0");
120 // Disable all branches and enable only the needed ones
121 if (fAnalysisType == "MC") {
122 // we want to process only MC
123 tree->SetBranchStatus("*", kFALSE);
125 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
128 Printf("ERROR: Could not get ESDInputHandler");
130 fESD = esdH->GetEvent();
133 else if (fAnalysisType == "ESD" || fAnalysisType == "ESDMC0" || fAnalysisType == "ESDMC1") {
134 tree->SetBranchStatus("*", kFALSE);
135 tree->SetBranchStatus("Tracks.*", kTRUE);
137 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
140 Printf("ERROR: Could not get ESDInputHandler");
142 fESD = esdH->GetEvent();
144 else if (fAnalysisType == "AOD") {
145 AliAODInputHandler *aodH = dynamic_cast<AliAODInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
148 Printf("ERROR: Could not get AODInputHandler");
151 fAOD = aodH->GetEvent();
155 Printf("!!!!!Wrong analysis type: Only ESD, ESDMC0, ESDMC1, AOD and MC types are allowed!");
162 //________________________________________________________________________
163 void AliAnalysisTaskFlowEvent::CreateOutputObjects()
165 // Called at every worker node to initialize
166 cout<<"AliAnalysisTaskFlowEvent::CreateOutputObjects()"<<endl;
168 if (!(fAnalysisType == "AOD" || fAnalysisType == "ESD" || fAnalysisType == "ESDMC0" || fAnalysisType == "ESDMC1" || fAnalysisType == "MC")) {
169 cout<<"WRONG ANALYSIS TYPE! only ESD, ESDMC0, ESDMC1, AOD and MC are allowed."<<endl;
174 fEventMaker = new AliFlowEventSimpleMaker();
177 //________________________________________________________________________
178 void AliAnalysisTaskFlowEvent::Exec(Option_t *)
181 // Called for each event
182 AliFlowEventSimple* fEvent = NULL;
184 if (fAnalysisType == "MC") {
186 // Process MC truth, therefore we receive the AliAnalysisManager and ask it for the AliMCEventHandler
187 // This handler can return the current MC event
189 AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
191 Printf("ERROR: Could not retrieve MC event handler");
195 AliMCEvent* mcEvent = eventHandler->MCEvent();
197 Printf("ERROR: Could not retrieve MC event");
201 fCFManager1->SetEventInfo(mcEvent);
202 fCFManager2->SetEventInfo(mcEvent);
205 Printf("MC particles: %d", mcEvent->GetNumberOfTracks());
206 fEvent = fEventMaker->FillTracks(mcEvent,fCFManager1,fCFManager2);
207 // here we have the fEvent and want to make it available as an output stream
211 else if (fAnalysisType == "ESD") {
213 Printf("ERROR: fESD not available");
216 Printf("There are %d tracks in this event", fESD->GetNumberOfTracks());
219 fEvent = fEventMaker->FillTracks(fESD,fCFManager1,fCFManager2);
221 else if (fAnalysisType == "ESDMC0" || fAnalysisType == "ESDMC1" ) {
223 Printf("ERROR: fESD not available");
226 Printf("There are %d tracks in this event", fESD->GetNumberOfTracks());
228 AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
230 Printf("ERROR: Could not retrieve MC event handler");
234 AliMCEvent* mcEvent = eventHandler->MCEvent();
236 Printf("ERROR: Could not retrieve MC event");
240 fCFManager1->SetEventInfo(mcEvent);
241 fCFManager2->SetEventInfo(mcEvent);
244 if (fAnalysisType == "ESDMC0") {
245 fEvent = fEventMaker->FillTracks(fESD, mcEvent, fCFManager1, fCFManager2, 0); //0 = kine from ESD, 1 = kine from MC
246 } else if (fAnalysisType == "ESDMC1") {
247 fEvent = fEventMaker->FillTracks(fESD, mcEvent, fCFManager1, fCFManager2, 1); //0 = kine from ESD, 1 = kine from MC
253 else if (fAnalysisType == "AOD") {
255 Printf("ERROR: fAOD not available");
258 Printf("There are %d tracks in this event", fAOD->GetNumberOfTracks());
261 //For the moment don't use CF //AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fAOD,fCFManager1,fCFManager2);
262 fEvent = fEventMaker->FillTracks(fAOD);
265 //fListHistos->Print();
269 PostData(2,fQADiff); }
272 //________________________________________________________________________
273 void AliAnalysisTaskFlowEvent::Terminate(Option_t *)
275 // Called once at the end of the query -- do not call in case of CAF