]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ANALYSIS/EventMixing/AliMixInputEventHandler.cxx
L1 monitoring code - from Nicolas A and Francesco B
[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    
132    Bool_t firstRun=(fMixIntupHandlerInfoTmp->GetChain()->GetEntries()<=0);
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       if (firstRun) mixIHI->PrepareEntry(che, -1, (AliInputEventHandler*)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("<-"));
177
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
192    AliDebug(AliLog::kDebug + 5, Form("->"));
193    return kTRUE;
194 }
195
196 //_____________________________________________________________________________
197 Bool_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;
211
212    // check for PhysSelection
213    if (!IsEventCurrentSelected()) return kFALSE;
214
215    // return in case of 0 entry in full chain
216    if (!fEntryCounter) {
217       AliDebug(AliLog::kDebug + 3, Form("-> fEntryCounter == 0"));
218       // runs UserExecMix for all tasks, if needed
219       UserExecMixAllTasks(fEntryCounter, 1, fEntryCounter, -1, 0);
220       return kTRUE;
221    }
222    // pre mix evetns
223    Int_t mixNum = fMixNumber;
224    if (fDoMixExtra) {
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) {
242         AliError("te is null. this is error. tell to developer (#1)");
243       } else {
244          mihi->PrepareEntry(te, entryMix, (AliInputEventHandler*)InputEventHandler(0), fAnalysisType);
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 //_____________________________________________________________________________
259 Bool_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;
273
274    // check for PhysSelection
275    if (!IsEventCurrentSelected()) return kFALSE;
276
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"));
294       // runs UserExecMix for all tasks, if needed
295       if (el) UserExecMixAllTasks(fEntryCounter, idEntryList, currentMainEntry, -1, 0);
296       else UserExecMixAllTasks(fEntryCounter, -1, currentMainEntry, -1, 0);
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) {
306          UserExecMixAllTasks(fEntryCounter, idEntryList, currentMainEntry, -1, 0);
307          AliDebug(AliLog::kDebug + 3, Form("++++++++++++++ END SETUP EVENT %lld SKIPPED (%lld) LESS THEN BUFFER +++++++++++++++++++", fEntryCounter, elNum));
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);
316    while ((eh = dynamic_cast<AliInputEventHandler *>(next()))) {
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) {
334         AliError("te is null. this is error. tell to developer (#1)");
335       } else {
336          AliDebug(AliLog::kDebug + 3, Form("Preparing InputEventHandler(%d)", counter));
337          mihi->PrepareEntry(te, entryMix, (AliInputEventHandler*)InputEventHandler(counter), fAnalysisType);
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 //_____________________________________________________________________________
352 Bool_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;
366
367    // check for PhysSelection
368    if (!IsEventCurrentSelected()) return kFALSE;
369
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) {
385       // runs UserExecMix for all tasks, if needed
386       if (el && fDoMixIfNotEnoughEvents) {
387          UserExecMixAllTasks(fEntryCounter, idEntryList, currentMainEntry, -1, 0);
388       } else {
389          idEntryList = -1;
390          UserExecMixAllTasks(fEntryCounter, idEntryList, currentMainEntry, -1, 0);
391       }
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) {
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          }
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       }
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       }
422    }
423    // pre mix evetns
424    Int_t mixNum = fMixNumber;
425    if (fDoMixExtra) {
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) {
443         AliError("te is null. this is error. tell to developer (#2)");
444       } else {
445          mihi->PrepareEntry(te, entryMix, (AliInputEventHandler*)InputEventHandler(0), fAnalysisType);
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 //_____________________________________________________________________________
460 Bool_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 //_____________________________________________________________________________
470 Bool_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 //_____________________________________________________________________________
483 void 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 //_____________________________________________________________________________
493 void 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));
504          fCurrentEntry = entryCounter;
505          fCurrentEntryMain = entryMainReal;
506          fCurrentEntryMix = entryMixReal;
507          fCurrentBinIndex = idEntryList;
508          if (entryMixReal >= 0) mixTask->UserExecMix("");
509       }
510    }
511 }
512
513 //_____________________________________________________________________________
514 void AliMixInputEventHandler::SetMixNumber(const Int_t mixNum)
515 {
516    //
517    // Sets mix number
518    //
519    if (fMixNumber > 1 && fBufferSize > 1) {
520      AliWarning("Sleeping 10 sec to show Warning Message ...");
521      AliWarning("=========================================================================================");
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 }
540
541 Bool_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;
547    if (mh) {
548       if (fOfflineTriggerMask && mh->GetEventSelection()) {
549          isSelected = fOfflineTriggerMask & mh->IsEventSelected();
550       }
551    }
552    AliDebug(AliLog::kDebug + 1, Form("isSelected=%d", isSelected));
553    AliDebug(AliLog::kDebug + 5, Form("-> %d", isSelected));
554    return isSelected;
555 }