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