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