]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ANALYSIS/EventMixing/AliMixInputEventHandler.cxx
Added option fDoMixExtra and fDoMixIfNotEnoughEvents - can be controled by user
[u/mrichter/AliRoot.git] / ANALYSIS / EventMixing / AliMixInputEventHandler.cxx
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    fDoMixExtra(kTRUE),
38    fDoMixIfNotEnoughEvents(kTRUE),
39    fCurrentEntry(0),
40    fCurrentEntryMain(0),
41    fCurrentEntryMix(0),
42    fCurrentBinIndex(-1),
43    fOfflineTriggerMask(0)
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 //_____________________________________________________________________________
55 void 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    }
67
68    AliDebug(AliLog::kDebug + 5, Form("->"));
69 }
70
71 //_____________________________________________________________________________
72 Bool_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    }
84
85    if (!fDoMixIfNotEnoughEvents) {
86       fDoMixExtra = kFALSE;
87       AliWarning("fDoMixIfNotEnoughEvents=kTRUE -> setting fDoMixExtra=kFALSE");
88    }
89
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    }
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
106    AliDebug(AliLog::kDebug + 5, Form("->"));
107    return kTRUE;
108 }
109 //_____________________________________________________________________________
110 Bool_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 //_____________________________________________________________________________
125 Bool_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));
131    // adds current file
132    fMixIntupHandlerInfoTmp->AddTreeToChain(path);
133    Int_t lastIndex = fMixIntupHandlerInfoTmp->GetChain()->GetListOfFiles()->GetEntries();
134    TChainElement *che = (TChainElement *)fMixIntupHandlerInfoTmp->GetChain()->GetListOfFiles()->At(lastIndex - 1);
135    AliMixInputHandlerInfo *mixIHI = 0;
136    for (Int_t i = 0; i < fInputHandlers.GetEntries(); i++) {
137       AliDebug(AliLog::kDebug + 5, Form("fInputHandlers[%d]", i));
138       mixIHI = new AliMixInputHandlerInfo(fMixIntupHandlerInfoTmp->GetName(), fMixIntupHandlerInfoTmp->GetTitle());
139       mixIHI->PrepareEntry(che, -1, (AliInputEventHandler*)InputEventHandler(i), fAnalysisType);
140       AliDebug(AliLog::kDebug + 5, Form("chain[%d]->GetEntries() = %lld", i, mixIHI->GetChain()->GetEntries()));
141       fMixTrees.Add(mixIHI);
142    }
143    AliDebug(AliLog::kDebug + 5, Form("fEntryCounter=%lld", fEntryCounter));
144    if (fEventPool && fEventPool->NeedInit())
145       fEventPool->Init();
146    if (fUseDefautProcess) {
147       AliDebug(AliLog::kDebug, Form("-> SKIPPED"));
148       return AliMultiInputEventHandler::Notify(path);
149    }
150    AliDebug(AliLog::kDebug + 5, Form("->"));
151    return kTRUE;
152 }
153
154 //_____________________________________________________________________________
155 Bool_t AliMixInputEventHandler::BeginEvent(Long64_t entry)
156 {
157    //
158    // BeginEvent(Long64_t entry) is called for all mix input handlers
159    //
160    AliDebug(AliLog::kDebug + 5, Form("-> %lld", entry));
161    if (fUseDefautProcess) {
162       AliDebug(AliLog::kDebug, Form("-> SKIPPED"));
163       AliMultiInputEventHandler::BeginEvent(entry);/* return GetEntry();*/
164    }
165    AliDebug(AliLog::kDebug + 5, Form("->"));
166    return kTRUE;
167 }
168 //_____________________________________________________________________________
169 Bool_t AliMixInputEventHandler::GetEntry()
170 {
171    //
172    // All mixed events are set
173    //
174    AliDebug(AliLog::kDebug + 5, Form("<-"));
175
176    if (!fEventPool) {
177       MixStd();
178    }
179    // if buffer size is higher then 1
180    else if (fBufferSize > 1) {
181       MixBuffer();
182    }
183    // if mix number is higher then 0 and buffer size is 1
184    else if (fMixNumber > 0) {
185       MixEventsMoreTimesWithOneEvent();
186    } else {
187       AliWarning("Not supported Mixing !!!");
188    }
189
190    AliDebug(AliLog::kDebug + 5, Form("->"));
191    return kTRUE;
192 }
193
194 //_____________________________________________________________________________
195 Bool_t AliMixInputEventHandler::MixStd()
196 {
197    //
198    // Mix std - No event pool
199    //
200    AliDebug(AliLog::kDebug + 5, Form("<-"));
201    AliDebug(AliLog::kDebug + 1, "Mix method");
202    // get correct handler
203    AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
204    AliMultiInputEventHandler *mh = dynamic_cast<AliMultiInputEventHandler *>(mgr->GetInputEventHandler());
205    AliInputEventHandler *inEvHMain = 0;
206    if (mh) inEvHMain = dynamic_cast<AliInputEventHandler *>(mh->GetFirstInputEventHandler());
207    else inEvHMain = dynamic_cast<AliInputEventHandler *>(mgr->GetInputEventHandler());
208    if (!inEvHMain) return kFALSE;
209
210    // check for PhysSelection
211    if (!IsEventCurrentSelected()) return kFALSE;
212
213    // return in case of 0 entry in full chain
214    if (!fEntryCounter) {
215       AliDebug(AliLog::kDebug + 3, Form("-> fEntryCounter == 0"));
216       // runs UserExecMix for all tasks, if needed
217       UserExecMixAllTasks(fEntryCounter, 1, fEntryCounter, -1, 0);
218       return kTRUE;
219    }
220    // pre mix evetns
221    Int_t mixNum = fMixNumber;
222    if (fDoMixExtra) {
223       if (fEntryCounter <= 2 * fMixNumber) mixNum = 2 * fMixNumber + 2;
224    }
225    // start of
226    AliDebug(AliLog::kDebug + 3, Form("++++++++++++++ BEGIN SETUP EVENT %lld +++++++++++++++++++", fEntryCounter));
227    // reset mix number
228    fNumberMixed = 0;
229    AliMixInputHandlerInfo *mihi = 0;
230    Long64_t entryMix = 0, entryMixReal = 0;
231    Int_t counter = 0;
232    for (counter = 0; counter < mixNum; counter++) {
233       entryMix = fEntryCounter - 1 - counter ;
234       AliDebug(AliLog::kDebug + 5, Form("Handler[%d] entryMix %lld ", counter, entryMix));
235       if (entryMix < 0) break;
236       entryMixReal = entryMix;
237       mihi = (AliMixInputHandlerInfo *) fMixTrees.At(0);
238       TChainElement *te = fMixIntupHandlerInfoTmp->GetEntryInTree(entryMix);
239       if (!te) {
240          AliError("te is null. this is error. tell to developer (#1)")
241       } else {
242          mihi->PrepareEntry(te, entryMix, (AliInputEventHandler*)InputEventHandler(0), fAnalysisType);
243          // runs UserExecMix for all tasks
244          fNumberMixed++;
245          UserExecMixAllTasks(fEntryCounter, 1, fEntryCounter, entryMixReal, fNumberMixed);
246          InputEventHandler(0)->FinishEvent();
247       }
248    }
249    AliDebug(AliLog::kDebug + 3, Form("fEntryCounter=%lld fMixEventNumber=%d", fEntryCounter, fNumberMixed));
250    AliDebug(AliLog::kDebug + 3, Form("++++++++++++++ END SETUP EVENT %lld +++++++++++++++++++", fEntryCounter));
251    AliDebug(AliLog::kDebug + 5, Form("->"));
252    AliDebug(AliLog::kDebug + 5, Form("->"));
253    return kTRUE;
254 }
255
256 //_____________________________________________________________________________
257 Bool_t AliMixInputEventHandler::MixBuffer()
258 {
259    //
260    // Mix in event buffer
261    //
262    AliDebug(AliLog::kDebug + 5, Form("<-"));
263    AliDebug(AliLog::kDebug + 1, "Mix method");
264    // get correct handler
265    AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
266    AliMultiInputEventHandler *mh = dynamic_cast<AliMultiInputEventHandler *>(mgr->GetInputEventHandler());
267    AliInputEventHandler *inEvHMain = 0;
268    if (mh) inEvHMain = dynamic_cast<AliInputEventHandler *>(mh->GetFirstInputEventHandler());
269    else inEvHMain = dynamic_cast<AliInputEventHandler *>(mgr->GetInputEventHandler());
270    if (!inEvHMain) return kFALSE;
271
272    // check for PhysSelection
273    if (!IsEventCurrentSelected()) return kFALSE;
274
275    // find out zero chain entries
276    Long64_t zeroChainEntries = fMixIntupHandlerInfoTmp->GetChain()->GetEntries() - inEvHMain->GetTree()->GetTree()->GetEntries();
277    // fill entry
278    Long64_t currentMainEntry = inEvHMain->GetTree()->GetTree()->GetReadEntry() + zeroChainEntries;
279    // fills entry
280    if (fEventPool && inEvHMain) fEventPool->AddEntry(currentMainEntry, inEvHMain->GetEvent());
281    // start of
282    AliDebug(AliLog::kDebug + 3, Form("++++++++++++++ BEGIN SETUP EVENT %lld +++++++++++++++++++", fEntryCounter));
283    // reset mix number
284    fNumberMixed = 0;
285    Long64_t elNum = 0;
286    TEntryList *el = 0;
287    Int_t idEntryList = -1;
288    if (fEventPool) el = fEventPool->FindEntryList(inEvHMain->GetEvent(), idEntryList);
289    // return in case of 0 entry in full chain
290    if (!fEntryCounter) {
291       AliDebug(AliLog::kDebug + 3, Form("-> fEntryCounter == 0"));
292       // runs UserExecMix for all tasks, if needed
293       if (el) UserExecMixAllTasks(fEntryCounter, idEntryList, currentMainEntry, -1, 0);
294       else UserExecMixAllTasks(fEntryCounter, -1, currentMainEntry, -1, 0);
295       return kTRUE;
296    }
297    if (!el) {
298       AliDebug(AliLog::kDebug + 3, Form("++++++++++++++ END SETUP EVENT %lld SKIPPED (el null) +++++++++++++++++++", fEntryCounter));
299       UserExecMixAllTasks(fEntryCounter, -1, fEntryCounter, -1, 0);
300       return kTRUE;
301    } else {
302       elNum = el->GetN();
303       if (elNum < fBufferSize + 1) {
304          UserExecMixAllTasks(fEntryCounter, idEntryList, currentMainEntry, -1, 0);
305          AliDebug(AliLog::kDebug + 3, Form("++++++++++++++ END SETUP EVENT %lld SKIPPED (%lld) LESS THEN BUFFER +++++++++++++++++++", fEntryCounter, elNum));
306          return kTRUE;
307       }
308    }
309    AliMixInputHandlerInfo *mihi = 0;
310    Long64_t entryMix = 0, entryMixReal = 0;
311    Int_t counter = 0;
312    AliInputEventHandler *eh = 0;
313    TObjArrayIter next(&fInputHandlers);
314    while ((eh = dynamic_cast<AliInputEventHandler *>(next()))) {
315       if (fEventPool && fEventPool->GetListOfEventCuts()->GetEntries() > 0) {
316          entryMix = -1;
317          if (elNum >= fBufferSize) {
318             Long64_t entryInEntryList =  elNum - 2 - counter;
319             if (entryInEntryList < 0) break;
320             entryMix = el->GetEntry(entryInEntryList);
321          }
322       }
323       AliDebug(AliLog::kDebug + 5, Form("Handler[%d] entryMix %lld ", counter, entryMix));
324       if (entryMix < 0) {
325          UserExecMixAllTasks(fEntryCounter, -1, currentMainEntry, -1, 0);
326          break;
327       }
328       entryMixReal = entryMix;
329       mihi = (AliMixInputHandlerInfo *) fMixTrees.At(counter);
330       TChainElement *te = fMixIntupHandlerInfoTmp->GetEntryInTree(entryMix);
331       if (!te) {
332          AliError("te is null. this is error. tell to developer (#1)")
333       } else {
334          AliDebug(AliLog::kDebug + 3, Form("Preparing InputEventHandler(%d)", counter));
335          mihi->PrepareEntry(te, entryMix, (AliInputEventHandler*)InputEventHandler(counter), fAnalysisType);
336          // runs UserExecMix for all tasks
337          UserExecMixAllTasks(fEntryCounter, idEntryList, fEntryCounter, entryMixReal, counter);
338          fNumberMixed++;
339       }
340       counter++;
341    }
342    AliDebug(AliLog::kDebug + 3, Form("fEntryCounter=%lld fMixEventNumber=%d", fEntryCounter, fNumberMixed));
343    AliDebug(AliLog::kDebug + 3, Form("++++++++++++++ END SETUP EVENT %lld +++++++++++++++++++", fEntryCounter));
344    AliDebug(AliLog::kDebug + 5, Form("->"));
345    AliDebug(AliLog::kDebug + 5, Form("->"));
346    return kTRUE;
347 }
348
349 //_____________________________________________________________________________
350 Bool_t AliMixInputEventHandler::MixEventsMoreTimesWithOneEvent()
351 {
352    //
353    // Mix in history with one event in buffer
354    //
355    AliDebug(AliLog::kDebug + 5, "<-");
356    AliDebug(AliLog::kDebug + 1, "Mix method");
357    // get correct handler
358    AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
359    AliMultiInputEventHandler *mh = dynamic_cast<AliMultiInputEventHandler *>(mgr->GetInputEventHandler());
360    AliInputEventHandler *inEvHMain = 0;
361    if (mh) inEvHMain = dynamic_cast<AliInputEventHandler *>(mh->GetFirstInputEventHandler());
362    else inEvHMain = dynamic_cast<AliInputEventHandler *>(mgr->GetInputEventHandler());
363    if (!inEvHMain) return kFALSE;
364
365    // check for PhysSelection
366    if (!IsEventCurrentSelected()) return kFALSE;
367
368    // find out zero chain entries
369    Long64_t zeroChainEntries = fMixIntupHandlerInfoTmp->GetChain()->GetEntries() - inEvHMain->GetTree()->GetTree()->GetEntries();
370    // fill entry
371    Long64_t currentMainEntry = inEvHMain->GetTree()->GetTree()->GetReadEntry() + zeroChainEntries;
372    if (fEventPool && inEvHMain) fEventPool->AddEntry(currentMainEntry, inEvHMain->GetEvent());
373    // start of
374    AliDebug(AliLog::kDebug + 3, Form("++++++++++++++ BEGIN SETUP EVENT %lld +++++++++++++++++++", fEntryCounter));
375    // reset mix number
376    fNumberMixed = 0;
377    Long64_t elNum = 0;
378    Int_t idEntryList = -1;
379    TEntryList *el = 0;
380    if (fEventPool) el = fEventPool->FindEntryList(inEvHMain->GetEvent(), idEntryList);
381    // return in case of 0 entry in full chain
382    if (!fEntryCounter) {
383       // runs UserExecMix for all tasks, if needed
384       if (el && fDoMixIfNotEnoughEvents) {
385          UserExecMixAllTasks(fEntryCounter, idEntryList, currentMainEntry, -1, 0);
386       } else {
387          idEntryList = -1;
388          UserExecMixAllTasks(fEntryCounter, idEntryList, currentMainEntry, -1, 0);
389       }
390       AliDebug(AliLog::kDebug + 3, Form("++++++++++++++ END SETUP EVENT %lld SKIPPED (fEntryCounter=0, idEntryList=%d) +++++++++++++++++++", fEntryCounter, idEntryList));
391       return kTRUE;
392    }
393    if (!el) {
394       if (fEventPool) {
395          AliDebug(AliLog::kDebug + 3, Form("++++++++++++++ END SETUP EVENT %lld SKIPPED (el null, idEntryList=%d) +++++++++++++++++++", fEntryCounter, idEntryList));
396          UserExecMixAllTasks(fEntryCounter, -1, currentMainEntry, -1, 0);
397          return kTRUE;
398       }
399    } else {
400       elNum = el->GetN();
401       if (elNum < fBufferSize + 1) {
402          if (fDoMixIfNotEnoughEvents) {
403             // include main event in to counter in this case (so idEntryList>0)
404             UserExecMixAllTasks(fEntryCounter, idEntryList, currentMainEntry, -1, 0);
405          }  else {
406             // dont include it in main event counter (idEntryList = -1)
407             idEntryList = -1;
408             UserExecMixAllTasks(fEntryCounter, idEntryList, currentMainEntry, -1, 0);
409          }
410          AliDebug(AliLog::kDebug + 3, Form("++++++++++++++ END SETUP EVENT %lld SKIPPED [FIRST ENTRY in el] (elnum=%lld, idEntryList=%d) +++++++++++++++++++", fEntryCounter, elNum, idEntryList));
411          return kTRUE;
412       }
413       if (!fDoMixIfNotEnoughEvents) {
414          if (elNum <= fMixNumber + 1) {
415             UserExecMixAllTasks(fEntryCounter, idEntryList, currentMainEntry, -1, 0);
416             AliDebug(AliLog::kDebug + 3, Form("++++++++++++++ END SETUP EVENT %lld SKIPPED (%lld) NOT ENOUGH EVENTS TO MIX => NEED=%d +++++++++++++++++++", fEntryCounter, elNum, fMixNumber + 1));
417             return kTRUE;
418          }
419       }
420    }
421    // pre mix evetns
422    Int_t mixNum = fMixNumber;
423    if (fDoMixExtra) {
424       if (elNum <= 2 * fMixNumber + 1) mixNum = elNum + 1;
425    }
426    AliMixInputHandlerInfo *mihi = 0;
427    Long64_t entryMix = 0, entryMixReal = 0;
428    Int_t counter = 0;
429    mihi = (AliMixInputHandlerInfo *) fMixTrees.At(0);
430    // fills num for main events
431    for (counter = 0; counter < mixNum; counter++) {
432       Long64_t entryInEntryList =  elNum - 2 - counter;
433       AliDebug(AliLog::kDebug + 3, Form("entryInEntryList=%lld", entryInEntryList));
434       if (entryInEntryList < 0) break;
435       entryMix = el->GetEntry(entryInEntryList);
436       AliDebug(AliLog::kDebug + 3, Form("entryMix=%lld", entryMix));
437       if (entryMix < 0) break;
438       entryMixReal = entryMix;
439       TChainElement *te = fMixIntupHandlerInfoTmp->GetEntryInTree(entryMix);
440       if (!te) {
441          AliError("te is null. this is error. tell to developer (#2)")
442       } else {
443          mihi->PrepareEntry(te, entryMix, (AliInputEventHandler*)InputEventHandler(0), fAnalysisType);
444          // runs UserExecMix for all tasks
445          fNumberMixed++;
446          UserExecMixAllTasks(fEntryCounter, idEntryList, currentMainEntry, entryMixReal, fNumberMixed);
447          InputEventHandler(0)->FinishEvent();
448       }
449    }
450    AliDebug(AliLog::kDebug + 3, Form("fEntryCounter=%lld fMixEventNumber=%d", fEntryCounter, fNumberMixed));
451    AliDebug(AliLog::kDebug + 3, Form("++++++++++++++ END SETUP EVENT %lld +++++++++++++++++++", fEntryCounter));
452    AliDebug(AliLog::kDebug + 5, Form("->"));
453    AliDebug(AliLog::kDebug + 5, Form("->"));
454    return kTRUE;
455 }
456
457 //_____________________________________________________________________________
458 Bool_t AliMixInputEventHandler::MixEventsMoreTimesWithBuffer()
459 {
460    //
461    // Mix more events in buffer with mixing with history
462    //
463    AliWarning("Not implemented");
464    return kFALSE;
465 }
466
467 //_____________________________________________________________________________
468 Bool_t AliMixInputEventHandler::FinishEvent()
469 {
470    //
471    // FinishEvent() is called for all mix input handlers
472    //
473    AliDebug(AliLog::kDebug + 5, Form("<-"));
474    AliMultiInputEventHandler::FinishEvent();
475    fEntryCounter++;
476    AliDebug(AliLog::kDebug + 5, Form("->"));
477    return kTRUE;
478 }
479
480 //_____________________________________________________________________________
481 void AliMixInputEventHandler::AddInputEventHandler(AliVEventHandler*)
482 {
483    //
484    // AddInputEventHandler will not be used
485    //
486    AliWarning("Function AddInputEventHandler is disabled for AliMixEventInputHandler !!!");
487    AliWarning("Use AliMixEventInputHandler::SetInputHandlerForMixing instead. Exiting ...");
488 }
489
490 //_____________________________________________________________________________
491 void AliMixInputEventHandler::UserExecMixAllTasks(Long64_t entryCounter, Int_t idEntryList, Long64_t entryMainReal, Long64_t entryMixReal, Int_t numMixed)
492 {
493    //
494    // Execute all task and sets mixing parameters
495    //
496    AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
497    AliAnalysisTaskSE *mixTask = 0;
498    TObjArrayIter next(mgr->GetTasks());
499    while ((mixTask = (AliAnalysisTaskSE *) next())) {
500       if (dynamic_cast<AliAnalysisTaskSE *>(mixTask)) {
501          AliDebug(AliLog::kDebug, Form("%s %lld %d [%lld,%lld] %d", mixTask->GetName(), entryCounter, numMixed, entryMainReal, entryMixReal, idEntryList));
502          fCurrentEntry = entryCounter;
503          fCurrentEntryMain = entryMainReal;
504          fCurrentEntryMix = entryMixReal;
505          fCurrentBinIndex = idEntryList;
506          if (entryMixReal >= 0) mixTask->UserExecMix("");
507       }
508    }
509 }
510
511 //_____________________________________________________________________________
512 void AliMixInputEventHandler::SetMixNumber(const Int_t mixNum)
513 {
514    //
515    // Sets mix number
516    //
517    if (fMixNumber > 1 && fBufferSize > 1) {
518       AliWarning("Sleeping 10 sec to show Warning Message ...")
519       AliWarning("=========================================================================================");
520       AliWarning(Form("BufferSize(%d) higher > 1 and fMixNumber(%d) > 1, which is not supported", fBufferSize, mixNum));
521       AliWarning("");
522       AliWarning("\tBufferSize will be set to 1");
523       AliWarning("");
524       AliWarning("Hints:");
525       AliWarning("");
526       AliWarning("\t1.If you want to use buffer do:");
527       AliWarning(Form("\t\tAliMixInputEventHandler *mixH = new AliMixInputEventHandler(%d,1)", fBufferSize));
528       AliWarning("");
529       AliWarning("\t2.If you want to use mix more time with buffer size 1, then do:");
530       AliWarning(Form("\t\tAliMixInputEventHandler *mixH = new AliMixInputEventHandler(1,%d)", mixNum));
531       AliWarning("");
532       AliWarning("=========================================================================================");
533       gSystem->Sleep(10000);
534       fBufferSize = 1;
535    }
536    fMixNumber = mixNum;
537 }
538
539 Bool_t AliMixInputEventHandler::IsEventCurrentSelected()
540 {
541    AliDebug(AliLog::kDebug + 5, Form("<-"));
542    AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
543    AliMultiInputEventHandler *mh = dynamic_cast<AliMultiInputEventHandler *>(mgr->GetInputEventHandler());
544    Bool_t isSelected = kTRUE;
545    if (mh) {
546       if (fOfflineTriggerMask && mh->GetEventSelection()) {
547          isSelected = fOfflineTriggerMask & mh->IsEventSelected();
548       }
549    }
550    AliDebug(AliLog::kDebug + 1, Form("isSelected=%d", isSelected));
551    AliDebug(AliLog::kDebug + 5, Form("-> %d", isSelected));
552    return isSelected;
553 }