]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGLF/RESONANCES/AliRsnAnalysisTask.cxx
Update for centrality patch flag
[u/mrichter/AliRoot.git] / PWGLF / RESONANCES / AliRsnAnalysisTask.cxx
CommitLineData
c865cb1d 1#include <TEntryList.h>
1c7bc43c 2
c865cb1d 3#include "AliLog.h"
4#include "AliAnalysisManager.h"
5#include "AliMultiInputEventHandler.h"
6#include "AliMixInputEventHandler.h"
7#include "AliMCEventHandler.h"
d7712d44 8
c865cb1d 9#include "AliRsnEvent.h"
10#include "AliRsnLoop.h"
11#include "AliRsnInputHandler.h"
1c7bc43c 12
1c7bc43c 13#include "AliRsnAnalysisTask.h"
14
15ClassImp(AliRsnAnalysisTask)
16
c865cb1d 17//__________________________________________________________________________________________________
18AliRsnAnalysisTask::AliRsnAnalysisTask() :
19 AliAnalysisTaskSE(),
20 fOutput(0),
21 fRsnObjects(0),
22 fInputEHMain(0),
781ffe72 23 fInputEHMix(0),
24 fBigOutput(kFALSE)
c865cb1d 25{
26//
27// Dummy constructor ALWAYS needed for I/O.
28//
29}
30
31//__________________________________________________________________________________________________
32AliRsnAnalysisTask::AliRsnAnalysisTask(const char *name) :
33 AliAnalysisTaskSE(name),
34 fOutput(0),
35 fRsnObjects(0),
36 fInputEHMain(0),
781ffe72 37 fInputEHMix(0),
38 fBigOutput(kFALSE)
1c7bc43c 39{
40//
41// Default constructor.
c865cb1d 42// Define input and output slots here (never in the dummy constructor)
43// Input slot #0 works with a TChain - it is connected to the default input container
44// Output slot #1 writes into a TH1 container
1c7bc43c 45//
46
c865cb1d 47 DefineOutput(1, TList::Class());
1c7bc43c 48}
49
c865cb1d 50//__________________________________________________________________________________________________
61f275d1 51AliRsnAnalysisTask::AliRsnAnalysisTask(const AliRsnAnalysisTask &copy) :
c865cb1d 52 AliAnalysisTaskSE(copy),
53 fOutput(0),
54 fRsnObjects(copy.fRsnObjects),
55 fInputEHMain(copy.fInputEHMain),
781ffe72 56 fInputEHMix(copy.fInputEHMix),
57 fBigOutput(copy.fBigOutput)
1c7bc43c 58{
59//
60// Copy constructor.
c865cb1d 61// Implemented as requested by C++ standards.
62// Can be used in PROOF and by plugins.
1c7bc43c 63//
64}
65
c865cb1d 66//__________________________________________________________________________________________________
61f275d1 67AliRsnAnalysisTask &AliRsnAnalysisTask::operator=(const AliRsnAnalysisTask &copy)
1c7bc43c 68{
69//
c865cb1d 70// Assignment operator.
71// Implemented as requested by C++ standards.
72// Can be used in PROOF and by plugins.
1c7bc43c 73//
c865cb1d 74 AliAnalysisTaskSE::operator=(copy);
e6f3a909 75 if (this == &copy)
61f275d1 76 return *this;
c865cb1d 77 fRsnObjects = copy.fRsnObjects;
78 fInputEHMain = copy.fInputEHMain;
79 fInputEHMix = copy.fInputEHMix;
781ffe72 80 fBigOutput = copy.fBigOutput;
61f275d1 81
2a1c7696 82 return (*this);
1c7bc43c 83}
84
c865cb1d 85//__________________________________________________________________________________________________
86AliRsnAnalysisTask::~AliRsnAnalysisTask()
1c7bc43c 87{
88//
61f275d1 89// Destructor.
c865cb1d 90// Clean-up the output list, but not the histograms that are put inside
91// (the list is owner and will clean-up these histograms). Protect in PROOF case.
1c7bc43c 92//
93
c865cb1d 94 if (fOutput && !AliAnalysisManager::GetAnalysisManager()->IsProofMode()) {
95 delete fOutput;
96 }
1c7bc43c 97}
98
c865cb1d 99//__________________________________________________________________________________________________
e187bd70 100void AliRsnAnalysisTask::AddLoop(AliRsnLoop *obj)
1c7bc43c 101{
102//
c865cb1d 103// Add new computation object
1c7bc43c 104//
7356f978 105
c865cb1d 106 fRsnObjects.Add(obj);
1c7bc43c 107}
108
c865cb1d 109//__________________________________________________________________________________________________
110void AliRsnAnalysisTask::UserCreateOutputObjects()
1c7bc43c 111{
7356f978 112//
c865cb1d 113// Initialization of outputs.
114// This is called once per worker node.
7356f978 115//
116
c865cb1d 117 // sets all Inuput Handler pointers
118 InitInputHandlers();
2a1c7696 119
c865cb1d 120 // create list and set it as owner of its content (MANDATORY)
781ffe72 121 if (fBigOutput) OpenFile(1);
c865cb1d 122 fOutput = new TList();
123 fOutput->SetOwner();
61f275d1 124
c865cb1d 125 // loop on computators and initialize all their outputs
126 TObjArrayIter next(&fRsnObjects);
61f275d1 127 AliRsnLoop *objLoop = 0x0;
128 while ( (objLoop = (AliRsnLoop *)next()) ) {
129 objLoop->Init(GetName(), fOutput);
c865cb1d 130 }
131
61f275d1 132 if (fInputEHMain) {
133 TObjArrayIter nextIH(fInputEHMain->InputEventHandlers());
134 TObject *obj = 0x0;
b63dbf69 135 AliRsnInputHandler *rsnIH;
136 AliRsnDaughterSelector *s;
137 TClonesArray *c;
138 AliRsnCutSet *cuts;
61f275d1 139 while ( (obj = nextIH()) ) {
140 if (obj->IsA() == AliRsnInputHandler::Class()) {
b63dbf69 141 rsnIH = (AliRsnInputHandler *) obj;
142 s = rsnIH->GetSelector();
143 s->InitActions(fOutput);
144 c = s->GetCutSetC();
61f275d1 145 for (Int_t is = 0; is < c->GetEntries(); is++) {
b63dbf69 146 cuts = (AliRsnCutSet *)c->At(is);
61f275d1 147 cuts->Init(fOutput);
148 }
149 }
150 }
151 }
152
153
c865cb1d 154 // post data for ALL output slots >0 here, to get at least an empty histogram
155 PostData(1, fOutput);
1c7bc43c 156}
157
c865cb1d 158//__________________________________________________________________________________________________
159void AliRsnAnalysisTask::UserExec(Option_t *)
1c7bc43c 160{
161//
c865cb1d 162// Main loop for single-event computations.
163// It is called for each event and executes the 'DoLoop'
164// function of all AliRsnLoop instances stored here.
1c7bc43c 165//
c865cb1d 166
167 AliRsnEvent *evMain = 0x0;
168 AliRsnInputHandler *rsnIH = 0x0;
169
170 if (fInputEHMain) {
171 TObjArrayIter next(fInputEHMain->InputEventHandlers());
172 TObject *obj = 0x0;
173 while ( (obj = next()) ) {
174 if (obj->IsA() == AliRsnInputHandler::Class()) {
61f275d1 175 rsnIH = (AliRsnInputHandler *)obj;
c865cb1d 176 //AliInfo(Form("Found object '%s' which is RSN input handler", obj->GetName()));
177 evMain = rsnIH->GetRsnEvent();
178 break;
179 }
180 }
181 }
61f275d1 182
c865cb1d 183 if (!evMain) return;
184
185 TObjArrayIter next(&fRsnObjects);
186 AliRsnLoop *obj = 0x0;
61f275d1 187 while ( (obj = (AliRsnLoop *)next()) ) {
c865cb1d 188 if (obj->IsMixed()) continue;
189 obj->DoLoop(evMain, rsnIH->GetSelector());
190 }
61f275d1 191
c865cb1d 192 PostData(1, fOutput);
1c7bc43c 193}
194
c865cb1d 195//__________________________________________________________________________________________________
61f275d1 196void AliRsnAnalysisTask::UserExecMix(Option_t *)
1c7bc43c 197{
198//
c865cb1d 199// Main loop for event-mixing computations
200// It is called for each pair of matched events
201// and executes the 'DoLoop' function of all AliRsnLoop instances stored here.
202//
203
204 AliRsnEvent *evMain = 0x0;
205 AliRsnEvent *evMix = 0x0;
206 Int_t id = -1;
207 AliRsnInputHandler *rsnIH = 0x0, *rsnMixIH = 0x0;
208
209 if (fInputEHMain) {
210 TObjArrayIter next(fInputEHMain->InputEventHandlers());
211 TObject *obj = 0x0;
212 while ( (obj = next()) ) {
213 if (obj->IsA() == AliRsnInputHandler::Class()) {
61f275d1 214 rsnIH = (AliRsnInputHandler *)obj;
c865cb1d 215 //AliInfo(Form("Found object '%s' which is RSN input handler", obj->GetName()));
216 evMain = rsnIH->GetRsnEvent();
217 id = fInputEHMain->InputEventHandlers()->IndexOf(obj);
218 break;
2a1c7696 219 }
1c7bc43c 220 }
2a1c7696 221 }
61f275d1 222
c865cb1d 223 if (!evMain) return;
224
225 // gets first input handler form mixing buffer
61f275d1 226 AliMultiInputEventHandler *ihMultiMix = dynamic_cast<AliMultiInputEventHandler *>(fInputEHMix->InputEventHandler(0));
e187bd70 227 if (ihMultiMix) {
61f275d1 228 rsnMixIH = dynamic_cast<AliRsnInputHandler *>(ihMultiMix->InputEventHandler(id));
e187bd70 229 if (rsnMixIH) {
230 evMix = rsnMixIH->GetRsnEvent();
231 if (!evMix) return;
232
233 TObjArrayIter next(&fRsnObjects);
234 AliRsnLoop *obj = 0x0;
61f275d1 235 while ( (obj = (AliRsnLoop *)next()) ) {
e187bd70 236 if (!obj->IsMixed()) continue;
237 obj->DoLoop(evMain, rsnIH->GetSelector(), evMix, rsnMixIH->GetSelector());
238 }
239 }
2a1c7696 240 }
61f275d1 241
c865cb1d 242 PostData(1, fOutput);
243}
244
245//________________________________________________________________________
246void AliRsnAnalysisTask::Terminate(Option_t *)
247{
248//
249// Draw result to screen, or perform fitting, normalizations
250// Called once at the end of the query
251//
2a1c7696 252
61f275d1 253 fOutput = dynamic_cast<TList *>(GetOutputData(1));
c865cb1d 254 if (!fOutput) { AliError("Could not retrieve TList fOutput"); return; }
255}
2a1c7696 256
c865cb1d 257//_____________________________________________________________________________
258void AliRsnAnalysisTask::InitInputHandlers()
259{
260//
261// Sets needed input handlers
262//
263 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
264 fInputEHMain = dynamic_cast<AliMultiInputEventHandler *>(mgr->GetInputEventHandler());
265 if (fInputEHMain) {
266 fInputEHMix = dynamic_cast<AliMixInputEventHandler *>(fInputEHMain->GetFirstMultiInputHandler());
267 }
1c7bc43c 268}
781ffe72 269