X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=PWGUD%2Fselectors%2FeventStats%2FAliEventStatsTask.cxx;fp=PWGUD%2Fselectors%2FeventStats%2FAliEventStatsTask.cxx;h=d624126be36f898fb3b86ce79266f0e23bc42855;hb=d056f832bf1084d2e5a2eb61f91bb4d22b59e84b;hp=0000000000000000000000000000000000000000;hpb=9c5d274f9584c61bddd022c700317e6e377245e2;p=u%2Fmrichter%2FAliRoot.git diff --git a/PWGUD/selectors/eventStats/AliEventStatsTask.cxx b/PWGUD/selectors/eventStats/AliEventStatsTask.cxx new file mode 100644 index 00000000000..d624126be36 --- /dev/null +++ b/PWGUD/selectors/eventStats/AliEventStatsTask.cxx @@ -0,0 +1,109 @@ +/* $Id: AliEventStatsTask.cxx 35782 2009-10-22 11:54:31Z jgrosseo $ */ + +#include "AliEventStatsTask.h" + +#include +#include +#include + +#include +#include +#include + +#include "AliPhysicsSelection.h" +//#include "AliBackgroundSelection.h" + +ClassImp(AliEventStatsTask) + +AliEventStatsTask::AliEventStatsTask(const char* opt) : + AliAnalysisTaskSE("AliEventStatsTask"), + fOutput(0), + fOption(opt), + fPhysicsSelection(0) +{ + // + // Constructor. Initialization of pointers + // + + // Define input and output slots here + DefineOutput(1, TList::Class()); + + AliLog::SetClassDebugLevel("AliEventStatsTask", AliLog::kWarning); +} + +AliEventStatsTask::~AliEventStatsTask() +{ + // + // Destructor + // + + // histograms are in the output list and deleted when the output + // list is deleted by the TSelector dtor + + if (fOutput) { + delete fOutput; + fOutput = 0; + } +} + +void AliEventStatsTask::UserCreateOutputObjects() +{ + // create result objects and add to output list + + Printf("AliEventStatsTask::CreateOutputObjects"); + + fOutput = new TList; + fOutput->SetOwner(); + + if (!fPhysicsSelection) + fPhysicsSelection = new AliPhysicsSelection; + + fOutput->Add(fPhysicsSelection); +} + +void AliEventStatsTask::UserExec(Option_t*) +{ + // process the event + + // post the data already here + PostData(1, fOutput); + + AliESDEvent* esd = dynamic_cast (InputEvent()); + + if (!esd) + { + AliError("ESD branch not available"); + return; + } + + fPhysicsSelection->IsCollisionCandidate(esd); +} + +void AliEventStatsTask::Terminate(Option_t *) +{ + // The Terminate() function is the last function to be called during + // a query. It always runs on the client, it can be used to present + // the results graphically or save the results to file. + + fOutput = dynamic_cast (GetOutputData(1)); + if (!fOutput) + Printf("ERROR: fOutput not available"); + + if (fOutput) + { + fPhysicsSelection = dynamic_cast (fOutput->FindObject("AliPhysicsSelection")); + } + + TFile* fout = new TFile("event_stat.root", "RECREATE"); + + if (fPhysicsSelection) + { + fPhysicsSelection->Print(); + fPhysicsSelection->SaveHistograms("physics_selection"); + } + + fout->Write(); + fout->Close(); + + Printf("Writting result to event_stat.root"); +}