2 // This class is the task for connecting together
3 // MC information and the RC information
5 // The task is a wrapper over two components
7 // AliESDRecInfoMaker.h
14 #include <AliAnalysisManager.h>
15 #include <AliESDInputHandler.h>
17 #include "AliMCEvent.h"
18 #include "AliMCEventHandler.h"
21 #include "AliGenInfoTask.h"
22 #include "AliGenInfoMaker.h"
30 ClassImp(AliGenInfoTask)
32 //________________________________________________________________________
33 AliGenInfoTask::AliGenInfoTask() :
40 fMaxTracks(0), // Max tracks in histogram
41 hESDTracks(0) , //! N ESD tracks
42 hGoodTracks(0) //! GOOD tracks
45 // Default constructor (should not be used)
51 AliGenInfoTask::AliGenInfoTask(const AliGenInfoTask& /*info*/) :
58 fMaxTracks(0), // Max tracks in histogram
59 hESDTracks(0) , //! N ESD tracks
60 hGoodTracks(0) //! GOOD tracks
63 // Default constructor
71 //________________________________________________________________________
72 AliGenInfoTask::AliGenInfoTask(const char *name) :
73 AliAnalysisTask(name, "AliGenInfoTask"),
79 fMaxTracks(0), // Max tracks in histogram
80 hESDTracks(0) , //! N ESD tracks
81 hGoodTracks(0) //! GOOD tracks
86 fGenMaker = new AliGenInfoMaker;
88 // Input slot #0 works with a TChain
89 DefineInput(0, TChain::Class());
90 // Output slot #0 writes into a TList
91 DefineOutput(0, TList::Class());
97 //________________________________________________________________________
98 void AliGenInfoTask::ConnectInputData(Option_t *)
101 // Connect the input data
104 cout << "AnalysisTaskTPCCluster::ConnectInputData()" << endl;
106 AliESDInputHandler* esdH = (AliESDInputHandler*)
107 ((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
108 fESD = esdH->GetEvent();
112 cout << endl << "WARNING: NO ESD event found" << endl << endl;
116 (AliESDfriend*)fESD->FindListObject("AliESDfriend");
120 cout << endl << "WARNING: NO ESD friend found" << endl << endl;
125 //________________________________________________________________________
126 void AliGenInfoTask::CreateOutputObjects()
129 // Connect the output objects
132 cout << "AnalysisTaskTPCCluster::CreateOutputObjects()" << endl;
135 // fListOfHists = new TList();
138 // new TH1F("hESDTracks",
139 // "Number of ESD tracks per event; N ESD tracks; Counts",
140 // TMath::Min(fMaxTracks, 100), 0, fMaxTracks);
141 // fListOfHists->Add(hESDTracks);
144 // new TH1F("hGoodTracks",
145 // "Number of Good tracks per event; N good tracks; Counts",
146 // TMath::Min(fMaxTracks, 100), 0, fMaxTracks);
147 // fListOfHists->Add(hGoodTracks);
151 //________________________________________________________________________
152 void AliGenInfoTask::Exec(Option_t *) {
154 // Execute analysis for current event
155 // For the moment I require that mcTruth is there! I am afraid to
156 // get out of sync if it is missing for some events since I use the
157 // number of MC events for normalisation
161 cout << "AliGenInfoTask::Exec()" << endl;
164 // AliHelix::SetBz(fESD->GetMagneticField()); // Enable after commit of AliHelix
168 AliMCEventHandler* mcinfo = (AliMCEventHandler*) (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
169 // If MC has been connected
172 cout << "Not MC info\n" << endl;
174 fGenMaker->ProcessEvent(mcinfo);
178 if(fESD==0 || fESDfriend==0) {
180 cout << "AliGenInfoTask::Exec(): WARNING: fESD=" << fESD
181 << ", fESDfriend=" << fESDfriend << endl;
182 // Post final data. It will be written to a file with option "RECREATE"
183 PostData(0, fListOfHists);
187 fESD->SetESDfriend(fESDfriend);
188 const Int_t nESDTracks = fESD->GetNumberOfTracks();
191 cout << " AliGenIfoTask::Exec() Number of ESD tracks: " << nESDTracks << endl;
193 if ( nESDTracks != fESDfriend->GetNumberOfTracks() ) {
194 AliWarning("Number of Tracks differs from Number of Friend-Tracks!");
195 printf("Number of tracks: %i, number of friend tracks: %i \n", nESDTracks, fESDfriend->GetNumberOfTracks());
198 // // Post final data. It will be written to a file with option "RECREATE"
199 PostData(0, fListOfHists);
202 //________________________________________________________________________
203 Int_t AliGenInfoTask::FillTrackHistograms(Int_t nTracks, AliESDtrack* track, AliESDfriendTrack* friendTrack, AliTPCseed* seed) {
205 // This method should be overloaded and used to make cuts on tracks
206 // and fill histograms.
207 // return 0 if track was rejected, 1 if accepted
210 if(nTracks && track && friendTrack && seed)
216 //________________________________________________________________________
217 void AliGenInfoTask::Terminate(Option_t *) {
222 printf("AliGenInfoTask: Terminate() \n");
223 fGenMaker->CloseOutputFile();