]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG/EMCAL/AliEmcalPhysicsSelectionTask.cxx
Add ptr to original AliVTrack.
[u/mrichter/AliRoot.git] / PWG / EMCAL / AliEmcalPhysicsSelectionTask.cxx
CommitLineData
285664fe 1// $Id$
2//
980821ba 3// Emcal physics selection task.
285664fe 4//
cd231d42 5// Author: C.Loizides
285664fe 6
be94a07d 7#include <TFile.h>
8#include <TH1F.h>
9#include <TH2F.h>
10#include <TROOT.h>
11#include "AliAnalysisDataContainer.h"
12#include "AliAnalysisDataSlot.h"
13#include "AliAnalysisManager.h"
14#include "AliEmcalPhysicsSelection.h"
15#include "AliEmcalPhysicsSelectionTask.h"
16#include "AliESDEvent.h"
17#include "AliInputEventHandler.h"
18#include "AliLog.h"
19
20ClassImp(AliEmcalPhysicsSelectionTask)
21
22//__________________________________________________________________________________________________
23AliEmcalPhysicsSelectionTask::AliEmcalPhysicsSelectionTask() :
24 AliPhysicsSelectionTask(),
25 fDoWriteHistos(1),
26 fNCalled(0),
27 fNAccepted(0),
fb81cdb7 28 fHAcc(0),
29 fHEvtTypes(0)
be94a07d 30{
31 // Default constructor.
32}
33
34//__________________________________________________________________________________________________
35AliEmcalPhysicsSelectionTask::AliEmcalPhysicsSelectionTask(const char* opt) :
36 AliPhysicsSelectionTask(),
37 fDoWriteHistos(1),
38 fNCalled(0),
39 fNAccepted(0),
fb81cdb7 40 fHAcc(0),
41 fHEvtTypes(0)
be94a07d 42{
43 // Constructor.
44
45 fOption = opt;
46 fPhysicsSelection = new AliEmcalPhysicsSelection;
47
48 AliInputEventHandler* handler = dynamic_cast<AliInputEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
49 if (handler) {
50 handler->SetEventSelection(fPhysicsSelection);
51 AliInfo("Physics Event Selection enabled.");
52 } else {
53 AliError("No input event handler connected to analysis manager. No Physics Event Selection.");
54 }
55 // Define input and output slots here
56 DefineOutput(1, TList::Class());
e51eba5c 57 fBranchNames = "ESD:AliESDRun.,AliESDHeader.,AliMultiplicity.,AliESDVZERO.,"
58 "AliESDZDC.,SPDVertex.,PrimaryVertex.,TPCVertex.,Tracks,SPDPileupVertices";
be94a07d 59
60 AliLog::SetClassDebugLevel("AliEmcalPhysicsSelectionTask", AliLog::kWarning);
61}
62
63//__________________________________________________________________________________________________
64void AliEmcalPhysicsSelectionTask::UserCreateOutputObjects()
65{
66 // User create outputs.
67
68 AliPhysicsSelectionTask::UserCreateOutputObjects();
69 fHAcc = new TH1D("hEvCount",";0=rej/1=acc;#",2,-0.5,1.5);
70 fOutput->Add(fHAcc);
52c20ca7 71 fHEvtTypes = new TH1D("hEvtTypes",";#",12,-0.5,11.5);
6311acf7 72 fHEvtTypes->GetXaxis()->SetBinLabel(1, "All");
73 fHEvtTypes->GetXaxis()->SetBinLabel(2, "MB");
74 fHEvtTypes->GetXaxis()->SetBinLabel(3, "FO");
52c20ca7 75 fHEvtTypes->GetXaxis()->SetBinLabel(4, "SC");
76 fHEvtTypes->GetXaxis()->SetBinLabel(5, "CE");
77 fHEvtTypes->GetXaxis()->SetBinLabel(6, "EMC");
78 fHEvtTypes->GetXaxis()->SetBinLabel(7, "EJE");
79 fHEvtTypes->GetXaxis()->SetBinLabel(8, "EGA");
80 fHEvtTypes->GetXaxis()->SetBinLabel(9, "Good");
81 fHEvtTypes->GetXaxis()->SetBinLabel(10, "HC");
82 fHEvtTypes->GetXaxis()->SetBinLabel(11, "HT");
83 fHEvtTypes->GetXaxis()->SetBinLabel(12, "LED");
fb81cdb7 84 fOutput->Add(fHEvtTypes);
be94a07d 85 if (!fDoWriteHistos) {
86 fOutput->Remove(fPhysicsSelection);
87 }
88}
89
90//__________________________________________________________________________________________________
91void AliEmcalPhysicsSelectionTask::UserExec(const Option_t *opt)
92{
93 // User exec.
94
95 AliPhysicsSelectionTask::UserExec(opt);
96
97 ++fNCalled;
98
99 UInt_t res = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
100 if (res>0) {
101 ++fNAccepted;
102 fHAcc->Fill(1);
103 } else {
104 fHAcc->Fill(0);
105 }
fb81cdb7 106
107 AliEmcalPhysicsSelection *ps=static_cast<AliEmcalPhysicsSelection *>(fPhysicsSelection);
108 fHEvtTypes->Fill(0);
109 if (res&AliVEvent::kAnyINT)
110 fHEvtTypes->Fill(1);
111 if (ps->IsFastOnly())
112 fHEvtTypes->Fill(2);
52c20ca7 113 if (res&AliVEvent::kCentral)
fb81cdb7 114 fHEvtTypes->Fill(3);
52c20ca7 115 if (res&AliVEvent::kSemiCentral)
fb81cdb7 116 fHEvtTypes->Fill(4);
52c20ca7 117 if ((res&AliVEvent::kEMC1) || (res&AliVEvent::kEMC7))
fb81cdb7 118 fHEvtTypes->Fill(5);
52c20ca7 119 if (res&AliVEvent::kEMCEJE)
fb81cdb7 120 fHEvtTypes->Fill(6);
52c20ca7 121 if (res&AliVEvent::kEMCEGA)
fb81cdb7 122 fHEvtTypes->Fill(7);
52c20ca7 123 if (res&AliEmcalPhysicsSelection::kEmcalOk)
31e6d0e8 124 fHEvtTypes->Fill(8);
52c20ca7 125 if (res&AliEmcalPhysicsSelection::kEmcalHC)
31e6d0e8 126 fHEvtTypes->Fill(9);
52c20ca7 127 if (res&AliEmcalPhysicsSelection::kEmcalHT)
128 fHEvtTypes->Fill(10);
129 if (ps->IsLedEvent())
130 fHEvtTypes->Fill(11);
be94a07d 131}
132
133//__________________________________________________________________________________________________
134void AliEmcalPhysicsSelectionTask::Terminate(Option_t *)
135{
136 // The Terminate() function is the last function to be called during
137 // a query. It always runs on the client, it can be used to present
138 // the results graphically or save the results to file.
139
140 AliInfo(Form("Called %d times, accepted %d events", fNCalled, fNAccepted));
141
142 if (!fDoWriteHistos)
143 return;
144
145 fOutput = dynamic_cast<TList*> (GetOutputData(1));
146 if (!fOutput) {
147 AliError("fOutput not available");
148 return;
149 }
150
151 AliAnalysisDataSlot *oslot = GetOutputSlot(1);
152 if (!oslot)
153 return;
154
155 AliAnalysisDataContainer *ocont = oslot->GetContainer();
156 if (!ocont)
157 return;
158
159 TFile *file = OpenFile(1);
160 if (!file)
161 return;
162
163 TDirectory::TContext context(file);
164 if (AliAnalysisManager::GetAnalysisManager()->IsProofMode()) {
165 fPhysicsSelection = dynamic_cast<AliPhysicsSelection*> (fOutput->FindObject("AliPhysicsSelection"));
166 }
167 if (fPhysicsSelection) {
168 //fPhysicsSelection->Print();
169 fPhysicsSelection->SaveHistograms(Form("%sHists",ocont->GetName()));
170 AliInfo(Form("Writing result to %s",file->GetName()));
171 }
172 fOutput->Remove(fPhysicsSelection);
173}