]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ANALYSIS/EventMixing/AliMixInputEventHandler.cxx
AliMixInputHandlerInfo : BeginEvent function for each input handler after fChain...
[u/mrichter/AliRoot.git] / ANALYSIS / EventMixing / AliMixInputEventHandler.cxx
index cac0cc3ae24f21a5b59e9c780c0c899c2c82b319..34b4d9d709ace74492dd0099f58dfaa752a0508c 100644 (file)
@@ -38,7 +38,8 @@ AliMixInputEventHandler::AliMixInputEventHandler(const Int_t size, const Int_t m
    fCurrentEntry(0),
    fCurrentEntryMain(0),
    fCurrentEntryMix(0),
-   fCurrentBinIndex(-1)
+   fCurrentBinIndex(-1),
+   fOfflineTriggerMask(0)
 {
    //
    // Default constructor.
@@ -49,24 +50,6 @@ AliMixInputEventHandler::AliMixInputEventHandler(const Int_t size, const Int_t m
    AliDebug(AliLog::kDebug + 10, "->");
 }
 
-//_____________________________________________________________________________
-AliInputEventHandler *AliMixInputEventHandler::InputEventHandler(const Int_t index)
-{
-   //
-   // Returns input handler
-   //
-   AliDebug(AliLog::kDebug + 5, Form("<-"));
-   if ((index >= 0) && (index < fBufferSize)) {
-      AliMultiInputEventHandler *eh = dynamic_cast<AliMultiInputEventHandler *>(fInputHandlers.At(index));
-      if (eh)
-         return (AliInputEventHandler *) eh;
-//             return (AliInputEventHandler *) eh->InputEventHandler(0);
-      else
-         return (AliInputEventHandler *) fInputHandlers.At(index);
-   }
-   AliDebug(AliLog::kDebug + 5, Form("->"));
-   return 0;
-}
 //_____________________________________________________________________________
 void AliMixInputEventHandler::SetInputHandlerForMixing(const AliInputEventHandler *const inHandler)
 {
@@ -104,22 +87,14 @@ Bool_t AliMixInputEventHandler::Init(TTree *tree, Option_t *opt)
       tree->LoadTree(0);
       fMixIntupHandlerInfoTmp = new AliMixInputHandlerInfo(tree->GetName());
    }
-   // moved to Notify
-//     // adds current file
-//     fMixIntupHandlerInfoTmp->AddTreeToChain(tree->GetTree());
-//     Int_t lastIndex = fMixIntupHandlerInfoTmp->GetChain()->GetListOfFiles()->GetEntries();
-//     TChainElement *che = (TChainElement *)fMixIntupHandlerInfoTmp->GetChain()->GetListOfFiles()->At(lastIndex - 1);
-//     AliMixInputHandlerInfo *mixIHI = 0;
-//     for(Int_t i = 0; i < fInputHandlers.GetEntries(); i++) {
-//       AliDebug(AliLog::kDebug+5, Form("fInputHandlers[%d]", i));
-//       mixIHI = new AliMixInputHandlerInfo(fMixIntupHandlerInfoTmp->GetName(), fMixIntupHandlerInfoTmp->GetTitle());
-//       mixIHI->PrepareEntry(che, -1, InputEventHandler(i),fAnalysisType);
-//       AliDebug(AliLog::kDebug+5, Form("chain[%d]->GetEntries() = %lld", i, mixIHI->GetChain()->GetEntries()));
-//       fMixTrees.Add(mixIHI);
-//     }
-//     AliDebug(AliLog::kDebug+5, Form("fEntryCounter=%lld", fEntryCounter));
-//     if(fEventPool && fEventPool->NeedInit())
-//       fEventPool->Init();
+
+   AliInputEventHandler *ih = 0;
+   for (Int_t i = 0; i < fInputHandlers.GetEntries(); i++) {
+      ih = (AliInputEventHandler *) fInputHandlers.At(i);
+      ih->SetParentHandler(this);
+//       ih->Init(tree,opt);
+   }
+
    AliDebug(AliLog::kDebug + 5, Form("->"));
    return kTRUE;
 }
@@ -153,7 +128,7 @@ Bool_t AliMixInputEventHandler::Notify(const char *path)
    for (Int_t i = 0; i < fInputHandlers.GetEntries(); i++) {
       AliDebug(AliLog::kDebug + 5, Form("fInputHandlers[%d]", i));
       mixIHI = new AliMixInputHandlerInfo(fMixIntupHandlerInfoTmp->GetName(), fMixIntupHandlerInfoTmp->GetTitle());
-      mixIHI->PrepareEntry(che, -1, InputEventHandler(i), fAnalysisType);
+      mixIHI->PrepareEntry(che, -1, (AliInputEventHandler*)InputEventHandler(i), fAnalysisType);
       AliDebug(AliLog::kDebug + 5, Form("chain[%d]->GetEntries() = %lld", i, mixIHI->GetChain()->GetEntries()));
       fMixTrees.Add(mixIHI);
    }
@@ -189,8 +164,7 @@ Bool_t AliMixInputEventHandler::GetEntry()
    // All mixed events are set
    //
    AliDebug(AliLog::kDebug + 5, Form("<-"));
-   // if no event pool MixStd
-//     if (fEventPool && fEventPool->NeedInit()) fEventPool->Init();
+
    if (!fEventPool) {
       MixStd();
    }
@@ -204,6 +178,7 @@ Bool_t AliMixInputEventHandler::GetEntry()
    } else {
       AliWarning("Not supported Mixing !!!");
    }
+
    AliDebug(AliLog::kDebug + 5, Form("->"));
    return kTRUE;
 }
@@ -223,6 +198,10 @@ Bool_t AliMixInputEventHandler::MixStd()
    if (mh) inEvHMain = dynamic_cast<AliInputEventHandler *>(mh->GetFirstInputEventHandler());
    else inEvHMain = dynamic_cast<AliInputEventHandler *>(mgr->GetInputEventHandler());
    if (!inEvHMain) return kFALSE;
+
+   // check for PhysSelection
+   if (!IsEventCurrentSelected()) return kFALSE;
+
    // return in case of 0 entry in full chain
    if (!fEntryCounter) {
       AliDebug(AliLog::kDebug + 3, Form("-> fEntryCounter == 0"));
@@ -252,7 +231,7 @@ Bool_t AliMixInputEventHandler::MixStd()
       if (!te) {
          AliError("te is null. this is error. tell to developer (#1)")
       } else {
-         mihi->PrepareEntry(te, entryMix, InputEventHandler(0), fAnalysisType);
+         mihi->PrepareEntry(te, entryMix, (AliInputEventHandler*)InputEventHandler(0), fAnalysisType);
          // runs UserExecMix for all tasks
          fNumberMixed++;
          UserExecMixAllTasks(fEntryCounter, 1, fEntryCounter, entryMixReal, fNumberMixed);
@@ -281,6 +260,10 @@ Bool_t AliMixInputEventHandler::MixBuffer()
    if (mh) inEvHMain = dynamic_cast<AliInputEventHandler *>(mh->GetFirstInputEventHandler());
    else inEvHMain = dynamic_cast<AliInputEventHandler *>(mgr->GetInputEventHandler());
    if (!inEvHMain) return kFALSE;
+
+   // check for PhysSelection
+   if (!IsEventCurrentSelected()) return kFALSE;
+
    // find out zero chain entries
    Long64_t zeroChainEntries = fMixIntupHandlerInfoTmp->GetChain()->GetEntries() - inEvHMain->GetTree()->GetTree()->GetEntries();
    // fill entry
@@ -341,7 +324,7 @@ Bool_t AliMixInputEventHandler::MixBuffer()
          AliError("te is null. this is error. tell to developer (#1)")
       } else {
          AliDebug(AliLog::kDebug + 3, Form("Preparing InputEventHandler(%d)", counter));
-         mihi->PrepareEntry(te, entryMix, InputEventHandler(counter), fAnalysisType);
+         mihi->PrepareEntry(te, entryMix, (AliInputEventHandler*)InputEventHandler(counter), fAnalysisType);
          // runs UserExecMix for all tasks
          UserExecMixAllTasks(fEntryCounter, idEntryList, fEntryCounter, entryMixReal, counter);
          fNumberMixed++;
@@ -370,6 +353,10 @@ Bool_t AliMixInputEventHandler::MixEventsMoreTimesWithOneEvent()
    if (mh) inEvHMain = dynamic_cast<AliInputEventHandler *>(mh->GetFirstInputEventHandler());
    else inEvHMain = dynamic_cast<AliInputEventHandler *>(mgr->GetInputEventHandler());
    if (!inEvHMain) return kFALSE;
+
+   // check for PhysSelection
+   if (!IsEventCurrentSelected()) return kFALSE;
+
    // find out zero chain entries
    Long64_t zeroChainEntries = fMixIntupHandlerInfoTmp->GetChain()->GetEntries() - inEvHMain->GetTree()->GetTree()->GetEntries();
    // fill entry
@@ -427,7 +414,7 @@ Bool_t AliMixInputEventHandler::MixEventsMoreTimesWithOneEvent()
       if (!te) {
          AliError("te is null. this is error. tell to developer (#2)")
       } else {
-         mihi->PrepareEntry(te, entryMix, InputEventHandler(0), fAnalysisType);
+         mihi->PrepareEntry(te, entryMix, (AliInputEventHandler*)InputEventHandler(0), fAnalysisType);
          // runs UserExecMix for all tasks
          fNumberMixed++;
          UserExecMixAllTasks(fEntryCounter, idEntryList, currentMainEntry, entryMixReal, fNumberMixed);
@@ -522,3 +509,19 @@ void AliMixInputEventHandler::SetMixNumber(const Int_t mixNum)
    }
    fMixNumber = mixNum;
 }
+
+Bool_t AliMixInputEventHandler::IsEventCurrentSelected()
+{
+   AliDebug(AliLog::kDebug + 5, Form("<-"));
+   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+   AliMultiInputEventHandler *mh = dynamic_cast<AliMultiInputEventHandler *>(mgr->GetInputEventHandler());
+   Bool_t isSelected = kTRUE;
+   if (mh) {
+      if (fOfflineTriggerMask && mh->GetEventSelection()) {
+         isSelected = fOfflineTriggerMask & mh->IsEventSelected();
+      }
+   }
+   AliDebug(AliLog::kDebug + 1, Form("isSelected=%d", isSelected));
+   AliDebug(AliLog::kDebug + 5, Form("-> %d", isSelected));
+   return isSelected;
+}