1 /* $Id: AliEventStatsTask.cxx 35782 2009-10-22 11:54:31Z jgrosseo $ */
3 #include "AliEventStatsTask.h"
10 #include <AliESDEvent.h>
11 #include <AliHeader.h>
13 #include "AliPhysicsSelection.h"
14 //#include "AliBackgroundSelection.h"
16 ClassImp(AliEventStatsTask)
18 AliEventStatsTask::AliEventStatsTask(const char* opt) :
19 AliAnalysisTaskSE("AliEventStatsTask"),
25 // Constructor. Initialization of pointers
28 // Define input and output slots here
29 DefineOutput(1, TList::Class());
31 AliLog::SetClassDebugLevel("AliEventStatsTask", AliLog::kWarning);
34 AliEventStatsTask::~AliEventStatsTask()
40 // histograms are in the output list and deleted when the output
41 // list is deleted by the TSelector dtor
49 void AliEventStatsTask::UserCreateOutputObjects()
51 // create result objects and add to output list
53 Printf("AliEventStatsTask::CreateOutputObjects");
58 if (!fPhysicsSelection)
59 fPhysicsSelection = new AliPhysicsSelection;
61 fOutput->Add(fPhysicsSelection);
64 void AliEventStatsTask::UserExec(Option_t*)
68 // post the data already here
71 AliESDEvent* esd = dynamic_cast<AliESDEvent*> (InputEvent());
75 AliError("ESD branch not available");
79 fPhysicsSelection->IsCollisionCandidate(esd);
82 void AliEventStatsTask::Terminate(Option_t *)
84 // The Terminate() function is the last function to be called during
85 // a query. It always runs on the client, it can be used to present
86 // the results graphically or save the results to file.
88 fOutput = dynamic_cast<TList*> (GetOutputData(1));
90 Printf("ERROR: fOutput not available");
94 fPhysicsSelection = dynamic_cast<AliPhysicsSelection*> (fOutput->FindObject("AliPhysicsSelection"));
97 TFile* fout = new TFile("event_stat.root", "RECREATE");
99 if (fPhysicsSelection)
101 fPhysicsSelection->Print();
102 fPhysicsSelection->SaveHistograms("physics_selection");
108 Printf("Writting result to event_stat.root");