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)
60 fPhysicsSelection = new AliPhysicsSelection;
61 //AliBackgroundSelection* background = new AliBackgroundSelection("AliBackgroundSelection", "AliBackgroundSelection");
63 //fPhysicsSelection->AddBackgroundIdentification(background);
64 //AliLog::SetClassDebugLevel("AliPhysicsSelection", AliLog::kDebug);
67 fOutput->Add(fPhysicsSelection);
70 void AliEventStatsTask::UserExec(Option_t*)
74 // post the data already here
77 AliESDEvent* esd = dynamic_cast<AliESDEvent*> (InputEvent());
81 AliError("ESD branch not available");
85 fPhysicsSelection->IsCollisionCandidate(esd);
88 void AliEventStatsTask::Terminate(Option_t *)
90 // The Terminate() function is the last function to be called during
91 // a query. It always runs on the client, it can be used to present
92 // the results graphically or save the results to file.
94 fOutput = dynamic_cast<TList*> (GetOutputData(1));
96 Printf("ERROR: fOutput not available");
100 fPhysicsSelection = dynamic_cast<AliPhysicsSelection*> (fOutput->FindObject("AliPhysicsSelection"));
103 TFile* fout = new TFile("event_stat.root", "RECREATE");
105 if (fPhysicsSelection)
107 fPhysicsSelection->Print();
108 fPhysicsSelection->SaveHistograms("physics_selection");
114 Printf("Writting result to event_stat.root");