]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG0/eventStats/AliEventStatsTask.cxx
bug fix
[u/mrichter/AliRoot.git] / PWG0 / eventStats / AliEventStatsTask.cxx
CommitLineData
296dd262 1/* $Id: AliEventStatsTask.cxx 35782 2009-10-22 11:54:31Z jgrosseo $ */
2
3#include "AliEventStatsTask.h"
4
296dd262 5#include <TFile.h>
296dd262 6#include <TH1F.h>
7#include <TH2F.h>
296dd262 8
9#include <AliLog.h>
10#include <AliESDEvent.h>
11#include <AliHeader.h>
296dd262 12
13#include "AliPhysicsSelection.h"
b43e01ed 14//#include "AliBackgroundSelection.h"
296dd262 15
16ClassImp(AliEventStatsTask)
17
18AliEventStatsTask::AliEventStatsTask(const char* opt) :
19 AliAnalysisTaskSE("AliEventStatsTask"),
20 fOutput(0),
21 fOption(opt),
22 fPhysicsSelection(0)
23{
24 //
25 // Constructor. Initialization of pointers
26 //
27
28 // Define input and output slots here
29 DefineOutput(1, TList::Class());
30
31 AliLog::SetClassDebugLevel("AliEventStatsTask", AliLog::kWarning);
32}
33
34AliEventStatsTask::~AliEventStatsTask()
35{
36 //
37 // Destructor
38 //
39
40 // histograms are in the output list and deleted when the output
41 // list is deleted by the TSelector dtor
42
43 if (fOutput) {
44 delete fOutput;
45 fOutput = 0;
46 }
47}
48
49void AliEventStatsTask::UserCreateOutputObjects()
50{
51 // create result objects and add to output list
52
53 Printf("AliEventStatsTask::CreateOutputObjects");
54
55 fOutput = new TList;
56 fOutput->SetOwner();
57
b43e01ed 58 if (!fPhysicsSelection)
59 {
60 fPhysicsSelection = new AliPhysicsSelection;
61 //AliBackgroundSelection* background = new AliBackgroundSelection("AliBackgroundSelection", "AliBackgroundSelection");
62 //background->Init();
63 //fPhysicsSelection->AddBackgroundIdentification(background);
64 //AliLog::SetClassDebugLevel("AliPhysicsSelection", AliLog::kDebug);
65 }
66
296dd262 67 fOutput->Add(fPhysicsSelection);
68}
69
70void AliEventStatsTask::UserExec(Option_t*)
71{
72 // process the event
73
74 // post the data already here
75 PostData(1, fOutput);
76
77 AliESDEvent* esd = dynamic_cast<AliESDEvent*> (InputEvent());
78
79 if (!esd)
80 {
81 AliError("ESD branch not available");
82 return;
83 }
84
85 fPhysicsSelection->IsCollisionCandidate(esd);
86}
87
88void AliEventStatsTask::Terminate(Option_t *)
89{
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.
93
94 fOutput = dynamic_cast<TList*> (GetOutputData(1));
95 if (!fOutput)
96 Printf("ERROR: fOutput not available");
97
98 if (fOutput)
99 {
100 fPhysicsSelection = dynamic_cast<AliPhysicsSelection*> (fOutput->FindObject("AliPhysicsSelection"));
101 }
102
103 TFile* fout = new TFile("event_stat.root", "RECREATE");
104
105 if (fPhysicsSelection)
106 {
107 fPhysicsSelection->Print();
108 fPhysicsSelection->SaveHistograms("physics_selection");
109 }
110
111 fout->Write();
112 fout->Close();
113
114 Printf("Writting result to event_stat.root");
115}