1 /* $Id: AliEventStatsTask.cxx 35782 2009-10-22 11:54:31Z jgrosseo $ */
3 #include "AliEventStatsTask.h"
13 #include <AliESDEvent.h>
14 #include <AliHeader.h>
15 #include <AliAnalysisManager.h>
16 #include <AliESDInputHandler.h>
17 #include <AliESDHeader.h>
18 #include <AliTriggerAnalysis.h>
20 #include "AliPhysicsSelection.h"
21 #include "AliBackgroundSelection.h"
23 ClassImp(AliEventStatsTask)
25 AliEventStatsTask::AliEventStatsTask(const char* opt) :
26 AliAnalysisTaskSE("AliEventStatsTask"),
32 // Constructor. Initialization of pointers
35 // Define input and output slots here
36 DefineOutput(1, TList::Class());
38 AliLog::SetClassDebugLevel("AliEventStatsTask", AliLog::kWarning);
41 AliEventStatsTask::~AliEventStatsTask()
47 // histograms are in the output list and deleted when the output
48 // list is deleted by the TSelector dtor
56 void AliEventStatsTask::UserCreateOutputObjects()
58 // create result objects and add to output list
60 Printf("AliEventStatsTask::CreateOutputObjects");
65 fPhysicsSelection = new AliPhysicsSelection;
66 AliBackgroundSelection* background = new AliBackgroundSelection("AliBackgroundSelection", "AliBackgroundSelection");
68 //fPhysicsSelection->AddBackgroundIdentification(background);
69 //AliLog::SetClassDebugLevel("AliPhysicsSelection", AliLog::kDebug);
71 fOutput->Add(fPhysicsSelection);
74 void AliEventStatsTask::UserExec(Option_t*)
78 // post the data already here
81 AliESDEvent* esd = dynamic_cast<AliESDEvent*> (InputEvent());
85 AliError("ESD branch not available");
89 fPhysicsSelection->IsCollisionCandidate(esd);
92 void AliEventStatsTask::Terminate(Option_t *)
94 // The Terminate() function is the last function to be called during
95 // a query. It always runs on the client, it can be used to present
96 // the results graphically or save the results to file.
98 fOutput = dynamic_cast<TList*> (GetOutputData(1));
100 Printf("ERROR: fOutput not available");
104 fPhysicsSelection = dynamic_cast<AliPhysicsSelection*> (fOutput->FindObject("AliPhysicsSelection"));
107 TFile* fout = new TFile("event_stat.root", "RECREATE");
109 if (fPhysicsSelection)
111 fPhysicsSelection->Print();
112 fPhysicsSelection->SaveHistograms("physics_selection");
118 Printf("Writting result to event_stat.root");