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