1 //------------------------------------------------------
\r
2 // AliAnalysisTaskFemto - A task for the analysis framework
\r
3 // from the FEMTOSCOPY analysis of PWG2. Creates the necessary
\r
4 // connection between the ESD or AOD input and the femtoscopic
\r
6 // Author: Adam Kisiel, OSU; Adam.Kisiel@cern.ch
\r
7 //------------------------------------------------------
\r
11 #include "TCanvas.h"
\r
12 #include "TSystem.h"
\r
15 #include "AliAnalysisTask.h"
\r
17 #include "AliESDEvent.h"
\r
19 #include "AliFemtoAnalysis.h"
\r
20 #include "AliAnalysisTaskFemto.h"
\r
21 #include "AliVHeader.h"
\r
22 #include "AliGenEventHeader.h"
\r
23 #include "AliGenHijingEventHeader.h"
\r
24 #include "AliGenCocktailEventHeader.h"
\r
26 ClassImp(AliAnalysisTaskFemto)
\r
28 // Default name for the setup macro of femto analysis
\r
29 // This function MUST be defined in the separate file !!!
\r
30 extern AliFemtoManager *ConfigFemtoAnalysis();
\r
32 //________________________________________________________________________
\r
33 AliAnalysisTaskFemto::AliAnalysisTaskFemto(const char *name):
\r
34 AliAnalysisTask(name,""),
\r
43 // Input slot #0 works with an Ntuple
\r
44 DefineInput(0, TChain::Class());
\r
45 // Output slot #0 writes into a TH1 container
\r
46 DefineOutput(0, TList::Class());
\r
49 //________________________________________________________________________
\r
50 void AliAnalysisTaskFemto::ConnectInputData(Option_t *) {
\r
51 printf(" ConnectInputData %s\n", GetName());
\r
57 TTree* tree = dynamic_cast<TTree*> (GetInputData(0));
\r
59 Printf("ERROR: Could not read chain from input slot 0");
\r
62 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
\r
65 cout << "Selected ESD analysis" << endl;
\r
69 Printf("ERROR: Could not get ESDInputHandler");
\r
72 fESD = esdH->GetEvent();
\r
76 AliAODInputHandler *aodH = dynamic_cast<AliAODInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
\r
79 Printf("ERROR: Could not get AODInputHandler");
\r
82 cout << "Selected AOD analysis" << endl;
\r
85 fAOD = aodH->GetEvent();
\r
88 if ((!fAOD) && (!fESD)) {
\r
89 Printf("Wrong analysis type: Only ESD and AOD types are allowed!");
\r
96 //________________________________________________________________________
\r
97 void AliAnalysisTaskFemto::CreateOutputObjects() {
\r
98 printf("Creating Femto Analysis objects\n");
\r
100 SetFemtoManager(ConfigFemtoAnalysis());
\r
103 //________________________________________________________________________
\r
104 void AliAnalysisTaskFemto::Exec(Option_t *) {
\r
105 // Task making a femtoscopic analysis.
\r
107 if (fAnalysisType==1) {
\r
109 Printf("ERROR: fESD not available");
\r
114 AliMCEventHandler* mctruth = (AliMCEventHandler*)
\r
115 ((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler());
\r
117 AliGenHijingEventHeader *hdh;
\r
119 fStack = mctruth->MCEvent()->Stack();
\r
121 AliGenCocktailEventHeader *hd = dynamic_cast<AliGenCocktailEventHeader *> (mctruth->MCEvent()->GenEventHeader());
\r
125 printf ("Got MC cocktail event header %p\n", (void *) hd);
\r
126 TList *lhd = hd->GetHeaders();
\r
127 printf ("Got list of headers %d\n", lhd->GetEntries());
\r
129 for (int iterh=0; iterh<lhd->GetEntries(); iterh++)
\r
131 hdh = dynamic_cast<AliGenHijingEventHeader *> (lhd->At(iterh));
\r
132 printf ("HIJING header at %i is %p\n", iterh, (void *) hdh);
\r
137 printf("Tracks in ESD: %d \n",fESD->GetNumberOfTracks());
\r
139 if (fESD->GetNumberOfTracks() >= 0) {
\r
142 printf("ERROR: No ESD reader for ESD analysis !\n");
\r
145 AliFemtoEventReaderESDChain* fesdc = dynamic_cast<AliFemtoEventReaderESDChain *> (fReader);
\r
148 // Process the event with no Kine information
\r
149 fesdc->SetESDSource(fESD);
\r
150 fManager->ProcessEvent();
\r
152 AliFemtoEventReaderESDChainKine* fesdck = dynamic_cast<AliFemtoEventReaderESDChainKine *> (fReader);
\r
155 // Process the event with Kine information
\r
156 fesdck->SetESDSource(fESD);
\r
157 fesdck->SetStackSource(fStack);
\r
159 fesdck->SetGenEventHeader(hdh);
\r
160 fManager->ProcessEvent();
\r
163 // Post the output histogram list
\r
164 fOutputList = fManager->Analysis(0)->GetOutputList();
\r
165 PostData(0, fOutputList);
\r
168 if (fAnalysisType==2) {
\r
170 Printf("ERROR: fAOD not available");
\r
173 printf("Tracks in AOD: %d \n",fAOD->GetNumberOfTracks());
\r
175 if (fAOD->GetNumberOfTracks() > 0) {
\r
177 printf("ERROR: No AOD reader for AOD analysis! \n");
\r
180 AliFemtoEventReaderAODChain* faodc = dynamic_cast<AliFemtoEventReaderAODChain *> (fReader);
\r
183 // Process the event
\r
184 faodc->SetAODSource(fAOD);
\r
185 fManager->ProcessEvent();
\r
189 fOutputList = fManager->Analysis(0)->GetOutputList();
\r
190 PostData(0, fOutputList);
\r
194 //________________________________________________________________________
\r
195 void AliAnalysisTaskFemto::Terminate(Option_t *) {
\r
196 // Do the final processing
\r
198 //________________________________________________________________________
\r
199 void AliAnalysisTaskFemto::SetFemtoReaderESD(AliFemtoEventReaderESDChain *aReader)
\r
201 printf("Selectring Femto reader for ESD\n");
\r
204 //________________________________________________________________________
\r
205 void AliAnalysisTaskFemto::SetFemtoReaderESDKine(AliFemtoEventReaderESDChainKine *aReader)
\r
207 printf("Selectring Femto reader for ESD with Kinematics information\n");
\r
210 //________________________________________________________________________
\r
211 void AliAnalysisTaskFemto::SetFemtoReaderAOD(AliFemtoEventReaderAODChain *aReader)
\r
213 printf("Selectring Femto reader for AOD\n");
\r
216 //________________________________________________________________________
\r
217 void AliAnalysisTaskFemto::SetFemtoManager(AliFemtoManager *aManager)
\r
219 fManager = aManager;
\r
220 printf("Got reader %p\n", (void *) aManager->EventReader());
\r
221 AliFemtoEventReaderESDChain *tReaderESDChain = dynamic_cast<AliFemtoEventReaderESDChain *> (aManager->EventReader());
\r
222 AliFemtoEventReaderESDChainKine *tReaderESDChainKine = dynamic_cast<AliFemtoEventReaderESDChainKine *> (aManager->EventReader());
\r
223 AliFemtoEventReaderAODChain *tReaderAODChain = dynamic_cast<AliFemtoEventReaderAODChain *> (aManager->EventReader());
\r
225 if ((!tReaderESDChain) && (!tReaderESDChainKine) && (!tReaderAODChain)) {
\r
226 printf("No AliFemto event reader created. Will not run femto analysis.\n");
\r
229 if (tReaderESDChain) SetFemtoReaderESD(tReaderESDChain);
\r
230 if (tReaderESDChainKine) SetFemtoReaderESDKine(tReaderESDChainKine);
\r
231 if (tReaderAODChain) SetFemtoReaderAOD(tReaderAODChain);
\r