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