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