]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ANALYSIS/EventMixing/AliMixInputEventHandler.cxx
cac0cc3ae24f21a5b59e9c780c0c899c2c82b319
[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, if needed
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, if needed
302       if (el) UserExecMixAllTasks(fEntryCounter, idEntryList, currentMainEntry, -1, 0);
303       else UserExecMixAllTasks(fEntryCounter, -1, currentMainEntry, -1, 0);
304       return kTRUE;
305    }
306    if (!el) {
307       AliDebug(AliLog::kDebug + 3, Form("++++++++++++++ END SETUP EVENT %lld SKIPPED (el null) +++++++++++++++++++", fEntryCounter));
308       UserExecMixAllTasks(fEntryCounter, -1, fEntryCounter, -1, 0);
309       return kTRUE;
310    } else {
311       elNum = el->GetN();
312       if (elNum < fBufferSize + 1) {
313          UserExecMixAllTasks(fEntryCounter, idEntryList, currentMainEntry, -1, 0);
314          AliDebug(AliLog::kDebug + 3, Form("++++++++++++++ END SETUP EVENT %lld SKIPPED (%lld) +++++++++++++++++++", fEntryCounter, elNum));
315          return kTRUE;
316       }
317    }
318    AliMixInputHandlerInfo *mihi = 0;
319    Long64_t entryMix = 0, entryMixReal = 0;
320    Int_t counter = 0;
321    AliInputEventHandler *eh = 0;
322    TObjArrayIter next(&fInputHandlers);
323    while ((eh = dynamic_cast<AliInputEventHandler *>(next()))) {
324       if (fEventPool && fEventPool->GetListOfEventCuts()->GetEntries() > 0) {
325          entryMix = -1;
326          if (elNum >= fBufferSize) {
327             Long64_t entryInEntryList =  elNum - 2 - counter;
328             if (entryInEntryList < 0) break;
329             entryMix = el->GetEntry(entryInEntryList);
330          }
331       }
332       AliDebug(AliLog::kDebug + 5, Form("Handler[%d] entryMix %lld ", counter, entryMix));
333       if (entryMix < 0) {
334          UserExecMixAllTasks(fEntryCounter, -1, currentMainEntry, -1, 0);
335          break;
336       }
337       entryMixReal = entryMix;
338       mihi = (AliMixInputHandlerInfo *) fMixTrees.At(counter);
339       TChainElement *te = fMixIntupHandlerInfoTmp->GetEntryInTree(entryMix);
340       if (!te) {
341          AliError("te is null. this is error. tell to developer (#1)")
342       } else {
343          AliDebug(AliLog::kDebug + 3, Form("Preparing InputEventHandler(%d)", counter));
344          mihi->PrepareEntry(te, entryMix, InputEventHandler(counter), fAnalysisType);
345          // runs UserExecMix for all tasks
346          UserExecMixAllTasks(fEntryCounter, idEntryList, fEntryCounter, entryMixReal, counter);
347          fNumberMixed++;
348       }
349       counter++;
350    }
351    AliDebug(AliLog::kDebug + 3, Form("fEntryCounter=%lld fMixEventNumber=%d", fEntryCounter, fNumberMixed));
352    AliDebug(AliLog::kDebug + 3, Form("++++++++++++++ END SETUP EVENT %lld +++++++++++++++++++", fEntryCounter));
353    AliDebug(AliLog::kDebug + 5, Form("->"));
354    AliDebug(AliLog::kDebug + 5, Form("->"));
355    return kTRUE;
356 }
357
358 //_____________________________________________________________________________
359 Bool_t AliMixInputEventHandler::MixEventsMoreTimesWithOneEvent()
360 {
361    //
362    // Mix in history with one event in buffer
363    //
364    AliDebug(AliLog::kDebug + 5, "<-");
365    AliDebug(AliLog::kDebug + 1, "Mix method");
366    // get correct handler
367    AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
368    AliMultiInputEventHandler *mh = dynamic_cast<AliMultiInputEventHandler *>(mgr->GetInputEventHandler());
369    AliInputEventHandler *inEvHMain = 0;
370    if (mh) inEvHMain = dynamic_cast<AliInputEventHandler *>(mh->GetFirstInputEventHandler());
371    else inEvHMain = dynamic_cast<AliInputEventHandler *>(mgr->GetInputEventHandler());
372    if (!inEvHMain) return kFALSE;
373    // find out zero chain entries
374    Long64_t zeroChainEntries = fMixIntupHandlerInfoTmp->GetChain()->GetEntries() - inEvHMain->GetTree()->GetTree()->GetEntries();
375    // fill entry
376    Long64_t currentMainEntry = inEvHMain->GetTree()->GetTree()->GetReadEntry() + zeroChainEntries;
377    if (fEventPool && inEvHMain) fEventPool->AddEntry(currentMainEntry, inEvHMain->GetEvent());
378    // start of
379    AliDebug(AliLog::kDebug + 3, Form("++++++++++++++ BEGIN SETUP EVENT %lld +++++++++++++++++++", fEntryCounter));
380    // reset mix number
381    fNumberMixed = 0;
382    Long64_t elNum = 0;
383    Int_t idEntryList = -1;
384    TEntryList *el = 0;
385    if (fEventPool) el = fEventPool->FindEntryList(inEvHMain->GetEvent(), idEntryList);
386    // return in case of 0 entry in full chain
387    if (!fEntryCounter) {
388       // runs UserExecMix for all tasks, if needed
389       if (el) UserExecMixAllTasks(fEntryCounter, idEntryList, currentMainEntry, -1, 0);
390       else UserExecMixAllTasks(fEntryCounter, -1, currentMainEntry, -1, 0);
391       AliDebug(AliLog::kDebug + 3, Form("++++++++++++++ END SETUP EVENT %lld SKIPPED (fEntryCounter=0, idEntryList=%d) +++++++++++++++++++", fEntryCounter, idEntryList));
392       return kTRUE;
393    }
394    if (!el) {
395       if (fEventPool) {
396          AliDebug(AliLog::kDebug + 3, Form("++++++++++++++ END SETUP EVENT %lld SKIPPED (el null, idEntryList=%d) +++++++++++++++++++", fEntryCounter, idEntryList));
397          UserExecMixAllTasks(fEntryCounter, -1, currentMainEntry, -1, 0);
398          return kTRUE;
399       }
400    } else {
401       elNum = el->GetN();
402       if (elNum < fBufferSize + 1) {
403          UserExecMixAllTasks(fEntryCounter, idEntryList, currentMainEntry, -1, 0);
404          AliDebug(AliLog::kDebug + 3, Form("++++++++++++++ END SETUP EVENT %lld SKIPPED [FIRST ENTRY in el] (elnum=%lld, idEntryList=%d) +++++++++++++++++++", fEntryCounter, elNum, idEntryList));
405          return kTRUE;
406       }
407    }
408    // pre mix evetns
409    Int_t mixNum = fMixNumber;
410    if (fUsePreMixEvents) {
411       if (elNum <= 2 * fMixNumber + 1) mixNum = elNum + 1;
412    }
413    AliMixInputHandlerInfo *mihi = 0;
414    Long64_t entryMix = 0, entryMixReal = 0;
415    Int_t counter = 0;
416    mihi = (AliMixInputHandlerInfo *) fMixTrees.At(0);
417    // fills num for main events
418    for (counter = 0; counter < mixNum; counter++) {
419       Long64_t entryInEntryList =  elNum - 2 - counter;
420       AliDebug(AliLog::kDebug + 3, Form("entryInEntryList=%lld", entryInEntryList));
421       if (entryInEntryList < 0) break;
422       entryMix = el->GetEntry(entryInEntryList);
423       AliDebug(AliLog::kDebug + 3, Form("entryMix=%lld", entryMix));
424       if (entryMix < 0) break;
425       entryMixReal = entryMix;
426       TChainElement *te = fMixIntupHandlerInfoTmp->GetEntryInTree(entryMix);
427       if (!te) {
428          AliError("te is null. this is error. tell to developer (#2)")
429       } else {
430          mihi->PrepareEntry(te, entryMix, InputEventHandler(0), fAnalysisType);
431          // runs UserExecMix for all tasks
432          fNumberMixed++;
433          UserExecMixAllTasks(fEntryCounter, idEntryList, currentMainEntry, entryMixReal, fNumberMixed);
434          InputEventHandler(0)->FinishEvent();
435       }
436    }
437    AliDebug(AliLog::kDebug + 3, Form("fEntryCounter=%lld fMixEventNumber=%d", fEntryCounter, fNumberMixed));
438    AliDebug(AliLog::kDebug + 3, Form("++++++++++++++ END SETUP EVENT %lld +++++++++++++++++++", fEntryCounter));
439    AliDebug(AliLog::kDebug + 5, Form("->"));
440    AliDebug(AliLog::kDebug + 5, Form("->"));
441    return kTRUE;
442 }
443
444 //_____________________________________________________________________________
445 Bool_t AliMixInputEventHandler::MixEventsMoreTimesWithBuffer()
446 {
447    //
448    // Mix more events in buffer with mixing with history
449    //
450    AliWarning("Not implemented");
451    return kFALSE;
452 }
453
454 //_____________________________________________________________________________
455 Bool_t AliMixInputEventHandler::FinishEvent()
456 {
457    //
458    // FinishEvent() is called for all mix input handlers
459    //
460    AliDebug(AliLog::kDebug + 5, Form("<-"));
461    AliMultiInputEventHandler::FinishEvent();
462    fEntryCounter++;
463    AliDebug(AliLog::kDebug + 5, Form("->"));
464    return kTRUE;
465 }
466
467 //_____________________________________________________________________________
468 void AliMixInputEventHandler::AddInputEventHandler(AliVEventHandler*)
469 {
470    //
471    // AddInputEventHandler will not be used
472    //
473    AliWarning("Function AddInputEventHandler is disabled for AliMixEventInputHandler !!!");
474    AliWarning("Use AliMixEventInputHandler::SetInputHandlerForMixing instead. Exiting ...");
475 }
476
477 //_____________________________________________________________________________
478 void AliMixInputEventHandler::UserExecMixAllTasks(Long64_t entryCounter, Int_t idEntryList, Long64_t entryMainReal, Long64_t entryMixReal, Int_t numMixed)
479 {
480    //
481    // Execute all task and sets mixing parameters
482    //
483    AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
484    AliAnalysisTaskSE *mixTask = 0;
485    TObjArrayIter next(mgr->GetTasks());
486    while ((mixTask = (AliAnalysisTaskSE *) next())) {
487       if (dynamic_cast<AliAnalysisTaskSE *>(mixTask)) {
488          AliDebug(AliLog::kDebug, Form("%s %lld %d [%lld,%lld] %d", mixTask->GetName(), entryCounter, numMixed, entryMainReal, entryMixReal, idEntryList));
489          fCurrentEntry = entryCounter;
490          fCurrentEntryMain = entryMainReal;
491          fCurrentEntryMix = entryMixReal;
492          fCurrentBinIndex = idEntryList;
493          if (entryMixReal >= 0) mixTask->UserExecMix("");
494       }
495    }
496 }
497
498 //_____________________________________________________________________________
499 void AliMixInputEventHandler::SetMixNumber(const Int_t mixNum)
500 {
501    //
502    // Sets mix number
503    //
504    if (fMixNumber > 1 && fBufferSize > 1) {
505       AliWarning("Sleeping 10 sec to show Warning Message ...")
506       AliWarning("=========================================================================================");
507       AliWarning(Form("BufferSize(%d) higher > 1 and fMixNumber(%d) > 1, which is not supported", fBufferSize, mixNum));
508       AliWarning("");
509       AliWarning("\tBufferSize will be set to 1");
510       AliWarning("");
511       AliWarning("Hints:");
512       AliWarning("");
513       AliWarning("\t1.If you want to use buffer do:");
514       AliWarning(Form("\t\tAliMixInputEventHandler *mixH = new AliMixInputEventHandler(%d,1)", fBufferSize));
515       AliWarning("");
516       AliWarning("\t2.If you want to use mix more time with buffer size 1, then do:");
517       AliWarning(Form("\t\tAliMixInputEventHandler *mixH = new AliMixInputEventHandler(1,%d)", mixNum));
518       AliWarning("");
519       AliWarning("=========================================================================================");
520       gSystem->Sleep(10000);
521       fBufferSize = 1;
522    }
523    fMixNumber = mixNum;
524 }