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