1 //------------------------------------------------------
2 // AliAnalysisTaskFemto - A task for the analysis framework
3 // from the FEMTOSCOPY analysis of PWG2. Creates the necessary
4 // connection between the ESD or AOD input and the femtoscopic
6 // Author: Adam Kisiel, OSU; Adam.Kisiel@cern.ch
7 //------------------------------------------------------
14 #include "TInterpreter.h"
16 //#include "AliAnalysisTask.h"
17 #include "AliAnalysisTaskSE.h"
19 #include "AliESDEvent.h"
21 #include "AliFemtoAnalysis.h"
22 #include "AliAnalysisTaskFemto.h"
23 #include "AliVHeader.h"
24 #include "AliGenEventHeader.h"
25 #include "AliGenHijingEventHeader.h"
26 #include "AliGenCocktailEventHeader.h"
28 ClassImp(AliAnalysisTaskFemto)
30 // Default name for the setup macro of femto analysis
31 // This function MUST be defined in the separate file !!!
32 // extern AliFemtoManager *ConfigFemtoAnalysis();
34 //________________________________________________________________________
35 AliAnalysisTaskFemto::AliAnalysisTaskFemto(TString name, TString aConfigMacro, TString aConfigParams, Bool_t aVerbose):
36 AliAnalysisTaskSE(name), //AliAnalysisTask(name,""),
47 fConfigMacro(aConfigMacro),
48 fConfigParams(aConfigParams),
52 // Input slot #0 works with an Ntuple
53 //DefineInput(0, TChain::Class());
54 // Output slot #0 writes into a TH1 container
55 DefineOutput(0, TList::Class());
58 //________________________________________________________________________
59 AliAnalysisTaskFemto::AliAnalysisTaskFemto(TString name, TString aConfigMacro="ConfigFemtoAnalysis.C", Bool_t aVerbose):
60 AliAnalysisTaskSE(name), //AliAnalysisTask(name,""),
71 fConfigMacro(aConfigMacro),
76 // Input slot #0 works with an Ntuple
77 //DefineInput(0, TChain::Class());
78 // Output slot #0 writes into a TH1 container
79 DefineOutput(0, TList::Class());
83 AliAnalysisTaskFemto::AliAnalysisTaskFemto(const AliAnalysisTaskFemto& aFemtoTask):
84 AliAnalysisTaskSE(aFemtoTask), //AliAnalysisTask(aFemtoTask),
100 fESD = aFemtoTask.fESD;
101 fESDpid = aFemtoTask.fESDpid;
102 fAOD = aFemtoTask.fAOD;
103 fAODpidUtil = aFemtoTask.fAODpidUtil;
104 fAODheader = aFemtoTask.fAODheader;
105 fStack = aFemtoTask.fStack;
106 fOutputList = aFemtoTask.fOutputList;
107 fReader = aFemtoTask.fReader;
108 fManager = aFemtoTask.fManager;
109 fAnalysisType = aFemtoTask.fAnalysisType;
111 fConfigMacro = aFemtoTask.fConfigMacro;
112 fConfigParams = aFemtoTask.fConfigParams;
114 fVerbose = aFemtoTask.fVerbose;
118 AliAnalysisTaskFemto& AliAnalysisTaskFemto::operator=(const AliAnalysisTaskFemto& aFemtoTask){
119 // assignment operator
120 if (this == &aFemtoTask)
123 fESD = aFemtoTask.fESD;
124 fESDpid = aFemtoTask.fESDpid;
125 fAOD = aFemtoTask.fAOD;
126 fAODpidUtil = aFemtoTask.fAODpidUtil;
127 fAODheader = aFemtoTask.fAODheader;
128 fStack = aFemtoTask.fStack;
129 fOutputList = aFemtoTask.fOutputList;
130 fReader = aFemtoTask.fReader;
131 fManager = aFemtoTask.fManager;
132 fAnalysisType = aFemtoTask.fAnalysisType;
134 fConfigMacro = aFemtoTask.fConfigMacro;
135 fConfigParams = aFemtoTask.fConfigParams;
136 fVerbose = aFemtoTask.fVerbose;
142 AliAnalysisTaskFemto::~AliAnalysisTaskFemto()
147 //________________________________________________________________________
148 void AliAnalysisTaskFemto::ConnectInputData(Option_t *) {
149 AliInfo(Form(" ConnectInputData %s\n", GetName()));
158 TTree* tree = dynamic_cast<TTree*> (GetInputData(0));
160 AliWarning("Could not read chain from input slot 0");
164 AliFemtoEventReaderESDChain *femtoReader = dynamic_cast<AliFemtoEventReaderESDChain *> (fReader);
165 if ((dynamic_cast<AliFemtoEventReaderESDChain *> (fReader))) {
166 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
170 AliInfo("Selected ESD analysis");
173 fESD = esdH->GetEvent();
174 fESDpid = esdH->GetESDpid();
175 femtoReader->SetESDPid(fESDpid);
178 else if ((dynamic_cast<AliFemtoEventReaderKinematicsChain *> (fReader))) {
179 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
183 AliInfo("Selected ESD analysis");
185 fESD = esdH->GetEvent();
188 else if ((dynamic_cast<AliFemtoEventReaderKinematicsChainESD *> (fReader))) {
189 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
192 AliInfo("Selected ESD analysis");
194 fESD = esdH->GetEvent();
198 AliFemtoEventReaderESDChainKine *femtoReaderESDKine = dynamic_cast<AliFemtoEventReaderESDChainKine *> (fReader);
199 if ((dynamic_cast<AliFemtoEventReaderESDChainKine *> (fReader))) {
200 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
204 AliInfo("Selected ESD analysis");
206 fESD = esdH->GetEvent();
207 fESDpid = esdH->GetESDpid();
208 femtoReaderESDKine->SetESDPid(fESDpid);
213 // AliFemtoEventReaderKinematicsChain *femtoReaderKine = dynamic_cast<AliFemtoEventReaderKinematicsChain *> (fReader);
214 if ((dynamic_cast<AliFemtoEventReaderKinematicsChain *> (fReader))) {
215 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
219 AliInfo("Selected ESD analysis");
223 // AliWarning("Could not get ESDInputHandler");
226 fESD = esdH->GetEvent();
227 //fESDpid = esdH->GetESDpid();
228 //femtoReader->SetESDPid(fESDpid);
234 AliFemtoEventReaderAODChain *femtoReaderAOD = dynamic_cast<AliFemtoEventReaderAODChain *> (fReader);
235 if (dynamic_cast<AliFemtoEventReaderAODChain *> (fReader)) {
236 AliAODInputHandler *aodH = dynamic_cast<AliAODInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
239 TObject *handler = AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler();
241 AliInfo("Has output handler ");
242 if( handler && handler->InheritsFrom("AliAODHandler") ) {
244 AliInfo("Selected AOD analysis");
246 fAOD = ((AliAODHandler*)handler)->GetAOD();
251 AliWarning("Selected AOD reader but no AOD handler found");
256 AliInfo("Selected AOD analysis");
259 fAOD = aodH->GetEvent();
261 fAODpidUtil = aodH->GetAODpidUtil(); //correct way
262 //fAODpidUtil = new AliAODpidUtil(); //not correct way
263 // printf("aodH->GetAODpidUtil(): %x",aodH->GetAODpidUtil());
265 cout<<"AliAnalysisTaskFemto::AodpidUtil:"<<fAODpidUtil<<endl;
266 femtoReaderAOD->SetAODpidUtil(fAODpidUtil);
268 fAODheader = dynamic_cast<AliAODHeader*>(fAOD->GetHeader());
269 if(!fAODheader) AliFatal("Not a standard AOD");
270 femtoReaderAOD->SetAODheader(fAODheader);
275 if ((!fAOD) && (!fESD)) {
277 AliWarning("Wrong analysis type: Only ESD and AOD types are allowed!");
281 //________________________________________________________________________
282 void AliAnalysisTaskFemto::CreateOutputObjects() {
284 AliInfo("Creating Femto Analysis objects\n");
286 gSystem->SetIncludePath("-I$ROOTSYS/include -I./STEERBase/ -I./ESD/ -I./AOD/ -I./ANALYSIS/ -I./ANALYSISalice/ -I./PWG2AOD/AOD -I./PWG2femtoscopy/FEMTOSCOPY/AliFemto -I./PWG2femtoscopyUser/FEMTOSCOPY/AliFemtoUser");
288 // sprintf(fcm, "%s++", fConfigMacro);
289 // gROOT->LoadMacro(fcm);
290 gROOT->LoadMacro(fConfigMacro);
291 // fJetFinder = (AliJetFinder*) gInterpreter->ProcessLine("ConfigJetAnalysis()");
293 SetFemtoManager((AliFemtoManager *) gInterpreter->ProcessLine("ConfigFemtoAnalysis()"));
295 SetFemtoManager((AliFemtoManager *) gInterpreter->ProcessLine(Form("ConfigFemtoAnalysis(%s)", fConfigParams.Data())));
298 fOutputList = fManager->Analysis(0)->GetOutputList();
300 for (unsigned int ian = 1; ian<fManager->AnalysisCollection()->size(); ian++) {
301 tOL = fManager->Analysis(ian)->GetOutputList();
303 TIter nextListCf(tOL);
304 while (TObject *obj = nextListCf()) {
305 fOutputList->Add(obj);
311 PostData(0, fOutputList);
314 //________________________________________________________________________
315 void AliAnalysisTaskFemto::Exec(Option_t *) {
316 // Task making a femtoscopic analysis.
317 if(fOfflineTriggerMask){
318 Bool_t isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & fOfflineTriggerMask);
321 cout << "AliAnalysisTaskFemto: is not selected" << endl;
325 if (fAnalysisType==1) {
328 AliWarning("fESD not available");
332 AliMCEventHandler* mctruth = (AliMCEventHandler*)
333 ((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler());
335 AliGenHijingEventHeader *hdh = 0;
337 fStack = mctruth->MCEvent()->Stack();
339 AliGenCocktailEventHeader *hd = dynamic_cast<AliGenCocktailEventHeader *> (mctruth->MCEvent()->GenEventHeader());
343 // AliInfo ("Got MC cocktail event header %p\n", (void *) hd);
344 TList *lhd = hd->GetHeaders();
345 // AliInfo ("Got list of headers %d\n", lhd->GetEntries());
347 for (int iterh=0; iterh<lhd->GetEntries(); iterh++)
349 hdh = dynamic_cast<AliGenHijingEventHeader *> (lhd->At(iterh));
350 // AliInfo ("HIJING header at %i is %p\n", iterh, (void *) hdh);
356 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
360 AliWarning("Could not get ESDInputHandler");
364 fESD = esdH->GetEvent();
365 fESDpid = esdH->GetESDpid();
369 AliInfo(Form("Tracks in ESD: %d \n",fESD->GetNumberOfTracks()));
371 if (fESD->GetNumberOfTracks() >= 0) {
375 AliWarning("No ESD reader for ESD analysis !\n");
378 AliFemtoEventReaderESDChain* fesdc = dynamic_cast<AliFemtoEventReaderESDChain *> (fReader);
381 // Process the event with no Kine information
382 fesdc->SetESDSource(fESD);
383 fManager->ProcessEvent();
386 AliFemtoEventReaderKinematicsChain* fkinec = dynamic_cast<AliFemtoEventReaderKinematicsChain *> (fReader);
389 // Process the event with Kine information only
390 fkinec->SetStackSource(fStack);
391 fManager->ProcessEvent();
395 AliFemtoEventReaderESDChainKine* fesdck = dynamic_cast<AliFemtoEventReaderESDChainKine *> (fReader);
398 // Process the event with Kine information
399 fesdck->SetESDSource(fESD);
400 fesdck->SetStackSource(fStack);
401 cout<<"Set Stack:"<<fStack<<endl;
402 fesdck->SetGenEventHeader(hdh);
403 fManager->ProcessEvent();
407 AliFemtoEventReaderKinematicsChainESD* fkcesd = dynamic_cast<AliFemtoEventReaderKinematicsChainESD *> (fReader);
410 // Process the event with Kine information
411 fkcesd->SetESDSource(fESD);
412 fkcesd->SetStackSource(fStack);
413 fkcesd->SetGenEventHeader(hdh);
414 fManager->ProcessEvent();
417 AliFemtoEventReaderStandard* fstd = dynamic_cast<AliFemtoEventReaderStandard *> (fReader);
420 // Process the event with Kine information
421 fstd->SetESDSource(fESD);
423 fstd->SetStackSource(fStack);
424 fstd->SetGenEventHeader(hdh);
425 fstd->SetInputType(AliFemtoEventReaderStandard::kESDKine);
428 fstd->SetInputType(AliFemtoEventReaderStandard::kESD);
429 fManager->ProcessEvent();
433 // Post the output histogram list
434 PostData(0, fOutputList);
437 if (fAnalysisType==2) {
440 AliWarning("fAOD not available");
445 // AliAODInputHandler *aodH = dynamic_cast<AliAODInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
448 // AliWarning("Could not get AODInputHandler");
453 // fAOD = aodH->GetEvent();
460 AliInfo(Form("Tracks in AOD: %d \n",fAOD->GetNumberOfTracks()));
462 if (fAOD->GetNumberOfTracks() > 0) {
465 AliWarning("No AOD reader for AOD analysis! \n");
468 AliFemtoEventReaderAODChain* faodc = dynamic_cast<AliFemtoEventReaderAODChain *> (fReader);
472 faodc->SetAODSource(fAOD);
473 fManager->ProcessEvent();
475 AliFemtoEventReaderStandard* fstd = dynamic_cast<AliFemtoEventReaderStandard *> (fReader);
479 fstd->SetAODSource(fAOD);
480 fstd->SetInputType(AliFemtoEventReaderStandard::kAOD);
481 fManager->ProcessEvent();
486 // Post the output histogram list
487 PostData(0, fOutputList);
491 //________________________________________________________________________
492 void AliAnalysisTaskFemto::Terminate(Option_t *) {
493 // Do the final processing
498 //________________________________________________________________________
499 void AliAnalysisTaskFemto:: FinishTaskOutput() {
500 // Do the final processing
505 //________________________________________________________________________
506 void AliAnalysisTaskFemto::SetFemtoReaderESD(AliFemtoEventReaderESDChain *aReader)
509 AliInfo("Selecting Femto reader for ESD\n");
512 //________________________________________________________________________
513 void AliAnalysisTaskFemto::SetFemtoReaderESDKine(AliFemtoEventReaderESDChainKine *aReader)
516 AliInfo("Selecting Femto reader for ESD with Kinematics information\n");
519 //________________________________________________________________________
520 void AliAnalysisTaskFemto::SetFemtoReaderAOD(AliFemtoEventReaderAODChain *aReader)
523 AliInfo("Selecting Femto reader for AOD\n");
526 void AliAnalysisTaskFemto::SetFemtoReaderStandard(AliFemtoEventReaderStandard *aReader)
529 AliInfo("Selecting Standard all-purpose Femto reader\n");
532 void AliAnalysisTaskFemto::SetFemtoReaderKinematics(AliFemtoEventReaderKinematicsChain *aReader)
535 printf("Selecting Femto reader for Kinematics (Monte Carlo) information\n");
538 void AliAnalysisTaskFemto::SetFemtoReaderKinematicsESD(AliFemtoEventReaderKinematicsChainESD *aReader)
541 printf("Selecting Femto reader for Kinematics (Monte Carlo) information + ESD\n");
544 //________________________________________________________________________
545 void AliAnalysisTaskFemto::SetFemtoManager(AliFemtoManager *aManager)
549 AliInfo(Form("Got reader %p\n", (void *) aManager->EventReader()));
550 AliFemtoEventReaderESDChain *tReaderESDChain = dynamic_cast<AliFemtoEventReaderESDChain *> (aManager->EventReader());
551 AliFemtoEventReaderESDChainKine *tReaderESDChainKine = dynamic_cast<AliFemtoEventReaderESDChainKine *> (aManager->EventReader());
552 AliFemtoEventReaderAODChain *tReaderAODChain = dynamic_cast<AliFemtoEventReaderAODChain *> (aManager->EventReader());
553 AliFemtoEventReaderStandard *tReaderStandard = dynamic_cast<AliFemtoEventReaderStandard *> (aManager->EventReader());
554 AliFemtoEventReaderKinematicsChain *tReaderKineChain = dynamic_cast<AliFemtoEventReaderKinematicsChain *> (aManager->EventReader());
555 AliFemtoEventReaderKinematicsChainESD *tReaderKineChainESD = dynamic_cast<AliFemtoEventReaderKinematicsChainESD *> (aManager->EventReader());
557 if ((!tReaderESDChain) && (!tReaderESDChainKine) && (!tReaderAODChain) && (!tReaderStandard) && (!tReaderKineChain) && (!tReaderKineChainESD)) {
559 AliWarning("No AliFemto event reader created. Will not run femto analysis.\n");
562 if (tReaderESDChain) SetFemtoReaderESD(tReaderESDChain);
563 if (tReaderESDChainKine) SetFemtoReaderESDKine(tReaderESDChainKine);
564 if (tReaderAODChain) SetFemtoReaderAOD(tReaderAODChain);
565 if (tReaderStandard) SetFemtoReaderStandard(tReaderStandard);
566 if (tReaderKineChain) SetFemtoReaderKinematics(tReaderKineChain);
567 if (tReaderKineChainESD) SetFemtoReaderKinematicsESD(tReaderKineChainESD);