]>
Commit | Line | Data |
---|---|---|
b425275c | 1 | // |
2 | // Class AliMixEventInputHandler | |
3 | // | |
4 | // Mixing input handler prepare N events before UserExec | |
5 | // TODO example | |
6 | // author: | |
7 | // Martin Vala (martin.vala@cern.ch) | |
8 | // | |
9 | ||
10 | #include <TFile.h> | |
11 | #include <TChain.h> | |
12 | #include <TEntryList.h> | |
13 | #include <TChainElement.h> | |
14 | #include <TSystem.h> | |
15 | ||
16 | #include "AliLog.h" | |
17 | #include "AliAnalysisManager.h" | |
18 | #include "AliInputEventHandler.h" | |
19 | ||
20 | #include "AliMixEventPool.h" | |
21 | #include "AliMixInputEventHandler.h" | |
22 | #include "AliMixInputHandlerInfo.h" | |
23 | ||
24 | #include "AliAnalysisTaskSE.h" | |
25 | ||
26 | ClassImp(AliMixInputEventHandler) | |
27 | ||
28 | AliMixInputEventHandler::AliMixInputEventHandler(const Int_t size, const Int_t mixNum): AliMultiInputEventHandler(size), | |
29 | fMixTrees(), | |
30 | fTreeMap(size > 0 ? size : 1), | |
31 | fMixIntupHandlerInfoTmp(0), | |
32 | fEntryCounter(0), | |
33 | fEventPool(0), | |
34 | fNumberMixed(0), | |
35 | fMixNumber(mixNum), | |
36 | fUseDefautProcess(kFALSE), | |
37 | fUsePreMixEvents(kTRUE), | |
38 | fCurrentEntry(0), | |
39 | fCurrentEntryMain(0), | |
40 | fCurrentEntryMix(0), | |
522016cc | 41 | fCurrentBinIndex(-1), |
42 | fOfflineTriggerMask(0) | |
b425275c | 43 | { |
44 | // | |
45 | // Default constructor. | |
46 | // | |
47 | AliDebug(AliLog::kDebug + 10, "<-"); | |
48 | fMixTrees.SetOwner(kTRUE); | |
49 | SetMixNumber(mixNum); | |
50 | AliDebug(AliLog::kDebug + 10, "->"); | |
51 | } | |
52 | ||
53 | //_____________________________________________________________________________ | |
54 | AliInputEventHandler *AliMixInputEventHandler::InputEventHandler(const Int_t index) | |
55 | { | |
56 | // | |
57 | // Returns input handler | |
58 | // | |
59 | AliDebug(AliLog::kDebug + 5, Form("<-")); | |
60 | if ((index >= 0) && (index < fBufferSize)) { | |
61 | AliMultiInputEventHandler *eh = dynamic_cast<AliMultiInputEventHandler *>(fInputHandlers.At(index)); | |
62 | if (eh) | |
63 | return (AliInputEventHandler *) eh; | |
64 | // return (AliInputEventHandler *) eh->InputEventHandler(0); | |
65 | else | |
66 | return (AliInputEventHandler *) fInputHandlers.At(index); | |
67 | } | |
68 | AliDebug(AliLog::kDebug + 5, Form("->")); | |
69 | return 0; | |
70 | } | |
71 | //_____________________________________________________________________________ | |
72 | void AliMixInputEventHandler::SetInputHandlerForMixing(const AliInputEventHandler *const inHandler) | |
73 | { | |
74 | // | |
75 | // Create N (fBufferSize) copies of input handler | |
76 | // | |
77 | AliDebug(AliLog::kDebug + 5, Form("<-")); | |
78 | fInputHandlers.Clear(); | |
79 | AliDebug(AliLog::kDebug + 5, Form("Creating %d input event handlers ...", fBufferSize)); | |
80 | for (Int_t i = 0; i < fBufferSize; i++) { | |
81 | AliDebug(AliLog::kDebug + 5, Form("Adding %d ...", i)); | |
82 | fInputHandlers.Add((AliInputEventHandler *) inHandler->Clone()); | |
83 | } | |
84 | AliDebug(AliLog::kDebug + 5, Form("->")); | |
85 | } | |
86 | ||
87 | //_____________________________________________________________________________ | |
88 | Bool_t AliMixInputEventHandler::Init(TTree *tree, Option_t *opt) | |
89 | { | |
90 | // | |
91 | // Init(const char*path) is called for all mix input handlers. | |
92 | // Create event pool if needed | |
93 | // | |
94 | AliDebug(AliLog::kDebug + 5, Form("<- %p %s", (void *)tree, opt)); | |
95 | fAnalysisType = opt; | |
96 | if (!tree) { | |
97 | AliDebug(AliLog::kDebug + 5, Form("->")); | |
98 | return kFALSE; | |
99 | } | |
100 | // clears array of input handlers | |
101 | fMixTrees.Clear(); | |
102 | // create AliMixInputHandlerInfo | |
103 | if (!fMixIntupHandlerInfoTmp) { | |
104 | // loads first file TChain (tree) | |
105 | tree->LoadTree(0); | |
106 | fMixIntupHandlerInfoTmp = new AliMixInputHandlerInfo(tree->GetName()); | |
107 | } | |
b425275c | 108 | AliDebug(AliLog::kDebug + 5, Form("->")); |
109 | return kTRUE; | |
110 | } | |
111 | //_____________________________________________________________________________ | |
112 | Bool_t AliMixInputEventHandler::Notify() | |
113 | { | |
114 | // | |
115 | // Notify() is called for all mix input handlers | |
116 | // | |
117 | AliDebug(AliLog::kDebug + 5, Form("<-")); | |
118 | if (fUseDefautProcess) { | |
119 | AliDebug(AliLog::kDebug, Form("-> SKIPPED")); | |
120 | return AliMultiInputEventHandler::Notify(); | |
121 | } | |
122 | AliDebug(AliLog::kDebug + 5, Form("->")); | |
123 | return kTRUE; | |
124 | } | |
125 | ||
126 | //_____________________________________________________________________________ | |
127 | Bool_t AliMixInputEventHandler::Notify(const char *path) | |
128 | { | |
129 | // | |
130 | // Notify(const char*path) is called for all mix input handlers | |
131 | // | |
132 | AliDebug(AliLog::kDebug + 5, Form("<- %s", path)); | |
133 | // adds current file | |
134 | fMixIntupHandlerInfoTmp->AddTreeToChain(path); | |
135 | Int_t lastIndex = fMixIntupHandlerInfoTmp->GetChain()->GetListOfFiles()->GetEntries(); | |
136 | TChainElement *che = (TChainElement *)fMixIntupHandlerInfoTmp->GetChain()->GetListOfFiles()->At(lastIndex - 1); | |
137 | AliMixInputHandlerInfo *mixIHI = 0; | |
138 | for (Int_t i = 0; i < fInputHandlers.GetEntries(); i++) { | |
139 | AliDebug(AliLog::kDebug + 5, Form("fInputHandlers[%d]", i)); | |
140 | mixIHI = new AliMixInputHandlerInfo(fMixIntupHandlerInfoTmp->GetName(), fMixIntupHandlerInfoTmp->GetTitle()); | |
141 | mixIHI->PrepareEntry(che, -1, InputEventHandler(i), fAnalysisType); | |
142 | AliDebug(AliLog::kDebug + 5, Form("chain[%d]->GetEntries() = %lld", i, mixIHI->GetChain()->GetEntries())); | |
143 | fMixTrees.Add(mixIHI); | |
144 | } | |
145 | AliDebug(AliLog::kDebug + 5, Form("fEntryCounter=%lld", fEntryCounter)); | |
146 | if (fEventPool && fEventPool->NeedInit()) | |
147 | fEventPool->Init(); | |
148 | if (fUseDefautProcess) { | |
149 | AliDebug(AliLog::kDebug, Form("-> SKIPPED")); | |
150 | return AliMultiInputEventHandler::Notify(path); | |
151 | } | |
152 | AliDebug(AliLog::kDebug + 5, Form("->")); | |
153 | return kTRUE; | |
154 | } | |
155 | ||
156 | //_____________________________________________________________________________ | |
157 | Bool_t AliMixInputEventHandler::BeginEvent(Long64_t entry) | |
158 | { | |
159 | // | |
160 | // BeginEvent(Long64_t entry) is called for all mix input handlers | |
161 | // | |
162 | AliDebug(AliLog::kDebug + 5, Form("-> %lld", entry)); | |
163 | if (fUseDefautProcess) { | |
164 | AliDebug(AliLog::kDebug, Form("-> SKIPPED")); | |
165 | AliMultiInputEventHandler::BeginEvent(entry);/* return GetEntry();*/ | |
166 | } | |
167 | AliDebug(AliLog::kDebug + 5, Form("->")); | |
168 | return kTRUE; | |
169 | } | |
170 | //_____________________________________________________________________________ | |
171 | Bool_t AliMixInputEventHandler::GetEntry() | |
172 | { | |
173 | // | |
174 | // All mixed events are set | |
175 | // | |
176 | AliDebug(AliLog::kDebug + 5, Form("<-")); | |
62e756a5 | 177 | |
b425275c | 178 | if (!fEventPool) { |
179 | MixStd(); | |
180 | } | |
181 | // if buffer size is higher then 1 | |
182 | else if (fBufferSize > 1) { | |
183 | MixBuffer(); | |
184 | } | |
185 | // if mix number is higher then 0 and buffer size is 1 | |
186 | else if (fMixNumber > 0) { | |
187 | MixEventsMoreTimesWithOneEvent(); | |
188 | } else { | |
189 | AliWarning("Not supported Mixing !!!"); | |
190 | } | |
191 | AliDebug(AliLog::kDebug + 5, Form("->")); | |
192 | return kTRUE; | |
193 | } | |
194 | ||
195 | //_____________________________________________________________________________ | |
196 | Bool_t AliMixInputEventHandler::MixStd() | |
197 | { | |
198 | // | |
199 | // Mix std - No event pool | |
200 | // | |
201 | AliDebug(AliLog::kDebug + 5, Form("<-")); | |
202 | AliDebug(AliLog::kDebug + 1, "Mix method"); | |
203 | // get correct handler | |
204 | AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); | |
205 | AliMultiInputEventHandler *mh = dynamic_cast<AliMultiInputEventHandler *>(mgr->GetInputEventHandler()); | |
206 | AliInputEventHandler *inEvHMain = 0; | |
207 | if (mh) inEvHMain = dynamic_cast<AliInputEventHandler *>(mh->GetFirstInputEventHandler()); | |
208 | else inEvHMain = dynamic_cast<AliInputEventHandler *>(mgr->GetInputEventHandler()); | |
209 | if (!inEvHMain) return kFALSE; | |
62e756a5 | 210 | |
211 | // check for PhysSelection | |
212 | if (!IsEventCurrentSelected()) return kFALSE; | |
213 | ||
b425275c | 214 | // return in case of 0 entry in full chain |
215 | if (!fEntryCounter) { | |
216 | AliDebug(AliLog::kDebug + 3, Form("-> fEntryCounter == 0")); | |
06aad8b5 | 217 | // runs UserExecMix for all tasks, if needed |
b425275c | 218 | UserExecMixAllTasks(fEntryCounter, 1, fEntryCounter, -1, 0); |
219 | return kTRUE; | |
220 | } | |
221 | // pre mix evetns | |
222 | Int_t mixNum = fMixNumber; | |
223 | if (fUsePreMixEvents) { | |
224 | if (fEntryCounter <= 2 * fMixNumber) mixNum = 2 * fMixNumber + 2; | |
225 | } | |
226 | // start of | |
227 | AliDebug(AliLog::kDebug + 3, Form("++++++++++++++ BEGIN SETUP EVENT %lld +++++++++++++++++++", fEntryCounter)); | |
228 | // reset mix number | |
229 | fNumberMixed = 0; | |
230 | AliMixInputHandlerInfo *mihi = 0; | |
231 | Long64_t entryMix = 0, entryMixReal = 0; | |
232 | Int_t counter = 0; | |
233 | for (counter = 0; counter < mixNum; counter++) { | |
234 | entryMix = fEntryCounter - 1 - counter ; | |
235 | AliDebug(AliLog::kDebug + 5, Form("Handler[%d] entryMix %lld ", counter, entryMix)); | |
236 | if (entryMix < 0) break; | |
237 | entryMixReal = entryMix; | |
238 | mihi = (AliMixInputHandlerInfo *) fMixTrees.At(0); | |
239 | TChainElement *te = fMixIntupHandlerInfoTmp->GetEntryInTree(entryMix); | |
240 | if (!te) { | |
241 | AliError("te is null. this is error. tell to developer (#1)") | |
242 | } else { | |
243 | mihi->PrepareEntry(te, entryMix, InputEventHandler(0), fAnalysisType); | |
244 | // runs UserExecMix for all tasks | |
245 | fNumberMixed++; | |
246 | UserExecMixAllTasks(fEntryCounter, 1, fEntryCounter, entryMixReal, fNumberMixed); | |
247 | InputEventHandler(0)->FinishEvent(); | |
248 | } | |
249 | } | |
250 | AliDebug(AliLog::kDebug + 3, Form("fEntryCounter=%lld fMixEventNumber=%d", fEntryCounter, fNumberMixed)); | |
251 | AliDebug(AliLog::kDebug + 3, Form("++++++++++++++ END SETUP EVENT %lld +++++++++++++++++++", fEntryCounter)); | |
252 | AliDebug(AliLog::kDebug + 5, Form("->")); | |
253 | AliDebug(AliLog::kDebug + 5, Form("->")); | |
254 | return kTRUE; | |
255 | } | |
256 | ||
257 | //_____________________________________________________________________________ | |
258 | Bool_t AliMixInputEventHandler::MixBuffer() | |
259 | { | |
260 | // | |
261 | // Mix in event buffer | |
262 | // | |
263 | AliDebug(AliLog::kDebug + 5, Form("<-")); | |
264 | AliDebug(AliLog::kDebug + 1, "Mix method"); | |
265 | // get correct handler | |
266 | AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); | |
267 | AliMultiInputEventHandler *mh = dynamic_cast<AliMultiInputEventHandler *>(mgr->GetInputEventHandler()); | |
268 | AliInputEventHandler *inEvHMain = 0; | |
269 | if (mh) inEvHMain = dynamic_cast<AliInputEventHandler *>(mh->GetFirstInputEventHandler()); | |
270 | else inEvHMain = dynamic_cast<AliInputEventHandler *>(mgr->GetInputEventHandler()); | |
271 | if (!inEvHMain) return kFALSE; | |
62e756a5 | 272 | |
273 | // check for PhysSelection | |
274 | if (!IsEventCurrentSelected()) return kFALSE; | |
275 | ||
b425275c | 276 | // find out zero chain entries |
277 | Long64_t zeroChainEntries = fMixIntupHandlerInfoTmp->GetChain()->GetEntries() - inEvHMain->GetTree()->GetTree()->GetEntries(); | |
278 | // fill entry | |
279 | Long64_t currentMainEntry = inEvHMain->GetTree()->GetTree()->GetReadEntry() + zeroChainEntries; | |
280 | // fills entry | |
281 | if (fEventPool && inEvHMain) fEventPool->AddEntry(currentMainEntry, inEvHMain->GetEvent()); | |
282 | // start of | |
283 | AliDebug(AliLog::kDebug + 3, Form("++++++++++++++ BEGIN SETUP EVENT %lld +++++++++++++++++++", fEntryCounter)); | |
284 | // reset mix number | |
285 | fNumberMixed = 0; | |
286 | Long64_t elNum = 0; | |
287 | TEntryList *el = 0; | |
288 | Int_t idEntryList = -1; | |
289 | if (fEventPool) el = fEventPool->FindEntryList(inEvHMain->GetEvent(), idEntryList); | |
290 | // return in case of 0 entry in full chain | |
291 | if (!fEntryCounter) { | |
292 | AliDebug(AliLog::kDebug + 3, Form("-> fEntryCounter == 0")); | |
06aad8b5 | 293 | // runs UserExecMix for all tasks, if needed |
a86b14f8 | 294 | if (el) UserExecMixAllTasks(fEntryCounter, idEntryList, currentMainEntry, -1, 0); |
295 | else UserExecMixAllTasks(fEntryCounter, -1, currentMainEntry, -1, 0); | |
b425275c | 296 | return kTRUE; |
297 | } | |
298 | if (!el) { | |
299 | AliDebug(AliLog::kDebug + 3, Form("++++++++++++++ END SETUP EVENT %lld SKIPPED (el null) +++++++++++++++++++", fEntryCounter)); | |
300 | UserExecMixAllTasks(fEntryCounter, -1, fEntryCounter, -1, 0); | |
301 | return kTRUE; | |
302 | } else { | |
303 | elNum = el->GetN(); | |
304 | if (elNum < fBufferSize + 1) { | |
a86b14f8 | 305 | UserExecMixAllTasks(fEntryCounter, idEntryList, currentMainEntry, -1, 0); |
b425275c | 306 | AliDebug(AliLog::kDebug + 3, Form("++++++++++++++ END SETUP EVENT %lld SKIPPED (%lld) +++++++++++++++++++", fEntryCounter, elNum)); |
307 | return kTRUE; | |
308 | } | |
309 | } | |
310 | AliMixInputHandlerInfo *mihi = 0; | |
311 | Long64_t entryMix = 0, entryMixReal = 0; | |
312 | Int_t counter = 0; | |
313 | AliInputEventHandler *eh = 0; | |
314 | TObjArrayIter next(&fInputHandlers); | |
a86b14f8 | 315 | while ((eh = dynamic_cast<AliInputEventHandler *>(next()))) { |
b425275c | 316 | if (fEventPool && fEventPool->GetListOfEventCuts()->GetEntries() > 0) { |
317 | entryMix = -1; | |
318 | if (elNum >= fBufferSize) { | |
319 | Long64_t entryInEntryList = elNum - 2 - counter; | |
320 | if (entryInEntryList < 0) break; | |
321 | entryMix = el->GetEntry(entryInEntryList); | |
322 | } | |
323 | } | |
324 | AliDebug(AliLog::kDebug + 5, Form("Handler[%d] entryMix %lld ", counter, entryMix)); | |
325 | if (entryMix < 0) { | |
326 | UserExecMixAllTasks(fEntryCounter, -1, currentMainEntry, -1, 0); | |
327 | break; | |
328 | } | |
329 | entryMixReal = entryMix; | |
330 | mihi = (AliMixInputHandlerInfo *) fMixTrees.At(counter); | |
331 | TChainElement *te = fMixIntupHandlerInfoTmp->GetEntryInTree(entryMix); | |
332 | if (!te) { | |
333 | AliError("te is null. this is error. tell to developer (#1)") | |
334 | } else { | |
335 | AliDebug(AliLog::kDebug + 3, Form("Preparing InputEventHandler(%d)", counter)); | |
336 | mihi->PrepareEntry(te, entryMix, InputEventHandler(counter), fAnalysisType); | |
337 | // runs UserExecMix for all tasks | |
338 | UserExecMixAllTasks(fEntryCounter, idEntryList, fEntryCounter, entryMixReal, counter); | |
339 | fNumberMixed++; | |
340 | } | |
341 | counter++; | |
342 | } | |
343 | AliDebug(AliLog::kDebug + 3, Form("fEntryCounter=%lld fMixEventNumber=%d", fEntryCounter, fNumberMixed)); | |
344 | AliDebug(AliLog::kDebug + 3, Form("++++++++++++++ END SETUP EVENT %lld +++++++++++++++++++", fEntryCounter)); | |
345 | AliDebug(AliLog::kDebug + 5, Form("->")); | |
346 | AliDebug(AliLog::kDebug + 5, Form("->")); | |
347 | return kTRUE; | |
348 | } | |
349 | ||
350 | //_____________________________________________________________________________ | |
351 | Bool_t AliMixInputEventHandler::MixEventsMoreTimesWithOneEvent() | |
352 | { | |
353 | // | |
354 | // Mix in history with one event in buffer | |
355 | // | |
356 | AliDebug(AliLog::kDebug + 5, "<-"); | |
357 | AliDebug(AliLog::kDebug + 1, "Mix method"); | |
358 | // get correct handler | |
359 | AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); | |
360 | AliMultiInputEventHandler *mh = dynamic_cast<AliMultiInputEventHandler *>(mgr->GetInputEventHandler()); | |
361 | AliInputEventHandler *inEvHMain = 0; | |
362 | if (mh) inEvHMain = dynamic_cast<AliInputEventHandler *>(mh->GetFirstInputEventHandler()); | |
363 | else inEvHMain = dynamic_cast<AliInputEventHandler *>(mgr->GetInputEventHandler()); | |
364 | if (!inEvHMain) return kFALSE; | |
62e756a5 | 365 | |
366 | // check for PhysSelection | |
367 | if (!IsEventCurrentSelected()) return kFALSE; | |
368 | ||
b425275c | 369 | // find out zero chain entries |
370 | Long64_t zeroChainEntries = fMixIntupHandlerInfoTmp->GetChain()->GetEntries() - inEvHMain->GetTree()->GetTree()->GetEntries(); | |
371 | // fill entry | |
372 | Long64_t currentMainEntry = inEvHMain->GetTree()->GetTree()->GetReadEntry() + zeroChainEntries; | |
373 | if (fEventPool && inEvHMain) fEventPool->AddEntry(currentMainEntry, inEvHMain->GetEvent()); | |
374 | // start of | |
375 | AliDebug(AliLog::kDebug + 3, Form("++++++++++++++ BEGIN SETUP EVENT %lld +++++++++++++++++++", fEntryCounter)); | |
376 | // reset mix number | |
377 | fNumberMixed = 0; | |
378 | Long64_t elNum = 0; | |
379 | Int_t idEntryList = -1; | |
380 | TEntryList *el = 0; | |
381 | if (fEventPool) el = fEventPool->FindEntryList(inEvHMain->GetEvent(), idEntryList); | |
382 | // return in case of 0 entry in full chain | |
383 | if (!fEntryCounter) { | |
06aad8b5 | 384 | // runs UserExecMix for all tasks, if needed |
385 | if (el) UserExecMixAllTasks(fEntryCounter, idEntryList, currentMainEntry, -1, 0); | |
a86b14f8 | 386 | else UserExecMixAllTasks(fEntryCounter, -1, currentMainEntry, -1, 0); |
b425275c | 387 | AliDebug(AliLog::kDebug + 3, Form("++++++++++++++ END SETUP EVENT %lld SKIPPED (fEntryCounter=0, idEntryList=%d) +++++++++++++++++++", fEntryCounter, idEntryList)); |
388 | return kTRUE; | |
389 | } | |
390 | if (!el) { | |
391 | if (fEventPool) { | |
392 | AliDebug(AliLog::kDebug + 3, Form("++++++++++++++ END SETUP EVENT %lld SKIPPED (el null, idEntryList=%d) +++++++++++++++++++", fEntryCounter, idEntryList)); | |
393 | UserExecMixAllTasks(fEntryCounter, -1, currentMainEntry, -1, 0); | |
394 | return kTRUE; | |
395 | } | |
396 | } else { | |
397 | elNum = el->GetN(); | |
398 | if (elNum < fBufferSize + 1) { | |
399 | UserExecMixAllTasks(fEntryCounter, idEntryList, currentMainEntry, -1, 0); | |
400 | AliDebug(AliLog::kDebug + 3, Form("++++++++++++++ END SETUP EVENT %lld SKIPPED [FIRST ENTRY in el] (elnum=%lld, idEntryList=%d) +++++++++++++++++++", fEntryCounter, elNum, idEntryList)); | |
401 | return kTRUE; | |
402 | } | |
403 | } | |
404 | // pre mix evetns | |
405 | Int_t mixNum = fMixNumber; | |
406 | if (fUsePreMixEvents) { | |
407 | if (elNum <= 2 * fMixNumber + 1) mixNum = elNum + 1; | |
408 | } | |
409 | AliMixInputHandlerInfo *mihi = 0; | |
410 | Long64_t entryMix = 0, entryMixReal = 0; | |
411 | Int_t counter = 0; | |
412 | mihi = (AliMixInputHandlerInfo *) fMixTrees.At(0); | |
413 | // fills num for main events | |
414 | for (counter = 0; counter < mixNum; counter++) { | |
415 | Long64_t entryInEntryList = elNum - 2 - counter; | |
416 | AliDebug(AliLog::kDebug + 3, Form("entryInEntryList=%lld", entryInEntryList)); | |
417 | if (entryInEntryList < 0) break; | |
418 | entryMix = el->GetEntry(entryInEntryList); | |
419 | AliDebug(AliLog::kDebug + 3, Form("entryMix=%lld", entryMix)); | |
420 | if (entryMix < 0) break; | |
421 | entryMixReal = entryMix; | |
422 | TChainElement *te = fMixIntupHandlerInfoTmp->GetEntryInTree(entryMix); | |
423 | if (!te) { | |
424 | AliError("te is null. this is error. tell to developer (#2)") | |
425 | } else { | |
426 | mihi->PrepareEntry(te, entryMix, InputEventHandler(0), fAnalysisType); | |
427 | // runs UserExecMix for all tasks | |
428 | fNumberMixed++; | |
429 | UserExecMixAllTasks(fEntryCounter, idEntryList, currentMainEntry, entryMixReal, fNumberMixed); | |
430 | InputEventHandler(0)->FinishEvent(); | |
431 | } | |
432 | } | |
433 | AliDebug(AliLog::kDebug + 3, Form("fEntryCounter=%lld fMixEventNumber=%d", fEntryCounter, fNumberMixed)); | |
434 | AliDebug(AliLog::kDebug + 3, Form("++++++++++++++ END SETUP EVENT %lld +++++++++++++++++++", fEntryCounter)); | |
435 | AliDebug(AliLog::kDebug + 5, Form("->")); | |
436 | AliDebug(AliLog::kDebug + 5, Form("->")); | |
437 | return kTRUE; | |
438 | } | |
439 | ||
440 | //_____________________________________________________________________________ | |
441 | Bool_t AliMixInputEventHandler::MixEventsMoreTimesWithBuffer() | |
442 | { | |
443 | // | |
444 | // Mix more events in buffer with mixing with history | |
445 | // | |
446 | AliWarning("Not implemented"); | |
447 | return kFALSE; | |
448 | } | |
449 | ||
450 | //_____________________________________________________________________________ | |
451 | Bool_t AliMixInputEventHandler::FinishEvent() | |
452 | { | |
453 | // | |
454 | // FinishEvent() is called for all mix input handlers | |
455 | // | |
456 | AliDebug(AliLog::kDebug + 5, Form("<-")); | |
457 | AliMultiInputEventHandler::FinishEvent(); | |
458 | fEntryCounter++; | |
459 | AliDebug(AliLog::kDebug + 5, Form("->")); | |
460 | return kTRUE; | |
461 | } | |
462 | ||
463 | //_____________________________________________________________________________ | |
464 | void AliMixInputEventHandler::AddInputEventHandler(AliVEventHandler*) | |
465 | { | |
466 | // | |
467 | // AddInputEventHandler will not be used | |
468 | // | |
469 | AliWarning("Function AddInputEventHandler is disabled for AliMixEventInputHandler !!!"); | |
470 | AliWarning("Use AliMixEventInputHandler::SetInputHandlerForMixing instead. Exiting ..."); | |
471 | } | |
472 | ||
473 | //_____________________________________________________________________________ | |
474 | void AliMixInputEventHandler::UserExecMixAllTasks(Long64_t entryCounter, Int_t idEntryList, Long64_t entryMainReal, Long64_t entryMixReal, Int_t numMixed) | |
475 | { | |
476 | // | |
477 | // Execute all task and sets mixing parameters | |
478 | // | |
479 | AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); | |
480 | AliAnalysisTaskSE *mixTask = 0; | |
481 | TObjArrayIter next(mgr->GetTasks()); | |
482 | while ((mixTask = (AliAnalysisTaskSE *) next())) { | |
483 | if (dynamic_cast<AliAnalysisTaskSE *>(mixTask)) { | |
484 | AliDebug(AliLog::kDebug, Form("%s %lld %d [%lld,%lld] %d", mixTask->GetName(), entryCounter, numMixed, entryMainReal, entryMixReal, idEntryList)); | |
a86b14f8 | 485 | fCurrentEntry = entryCounter; |
486 | fCurrentEntryMain = entryMainReal; | |
487 | fCurrentEntryMix = entryMixReal; | |
488 | fCurrentBinIndex = idEntryList; | |
489 | if (entryMixReal >= 0) mixTask->UserExecMix(""); | |
b425275c | 490 | } |
491 | } | |
492 | } | |
493 | ||
494 | //_____________________________________________________________________________ | |
495 | void AliMixInputEventHandler::SetMixNumber(const Int_t mixNum) | |
496 | { | |
497 | // | |
498 | // Sets mix number | |
499 | // | |
500 | if (fMixNumber > 1 && fBufferSize > 1) { | |
501 | AliWarning("Sleeping 10 sec to show Warning Message ...") | |
502 | AliWarning("========================================================================================="); | |
503 | AliWarning(Form("BufferSize(%d) higher > 1 and fMixNumber(%d) > 1, which is not supported", fBufferSize, mixNum)); | |
504 | AliWarning(""); | |
505 | AliWarning("\tBufferSize will be set to 1"); | |
506 | AliWarning(""); | |
507 | AliWarning("Hints:"); | |
508 | AliWarning(""); | |
509 | AliWarning("\t1.If you want to use buffer do:"); | |
510 | AliWarning(Form("\t\tAliMixInputEventHandler *mixH = new AliMixInputEventHandler(%d,1)", fBufferSize)); | |
511 | AliWarning(""); | |
512 | AliWarning("\t2.If you want to use mix more time with buffer size 1, then do:"); | |
513 | AliWarning(Form("\t\tAliMixInputEventHandler *mixH = new AliMixInputEventHandler(1,%d)", mixNum)); | |
514 | AliWarning(""); | |
515 | AliWarning("========================================================================================="); | |
516 | gSystem->Sleep(10000); | |
517 | fBufferSize = 1; | |
518 | } | |
519 | fMixNumber = mixNum; | |
520 | } | |
62e756a5 | 521 | |
522 | Bool_t AliMixInputEventHandler::IsEventCurrentSelected() | |
523 | { | |
524 | AliDebug(AliLog::kDebug + 5, Form("<-")); | |
525 | AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); | |
526 | AliMultiInputEventHandler *mh = dynamic_cast<AliMultiInputEventHandler *>(mgr->GetInputEventHandler()); | |
527 | Bool_t isSelected = kTRUE; | |
ddec4399 | 528 | if (mh) { |
529 | if (fOfflineTriggerMask && mh->GetEventSelection()) { | |
530 | isSelected = fOfflineTriggerMask & mh->IsEventSelected(); | |
531 | } | |
62e756a5 | 532 | } |
533 | AliDebug(AliLog::kDebug + 1, Form("isSelected=%d", isSelected)); | |
534 | AliDebug(AliLog::kDebug + 5, Form("-> %d", isSelected)); | |
535 | return isSelected; | |
536 | } |