]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ANALYSIS/EventMixing/AliMixInputEventHandler.cxx
Coverity Fix 16220
[u/mrichter/AliRoot.git] / ANALYSIS / EventMixing / AliMixInputEventHandler.cxx
index cac0cc3ae24f21a5b59e9c780c0c899c2c82b319..fd9bab82f30476227be7354ee1beac821102afb6 100644 (file)
@@ -38,7 +38,8 @@ AliMixInputEventHandler::AliMixInputEventHandler(const Int_t size, const Int_t m
    fCurrentEntry(0),
    fCurrentEntryMain(0),
    fCurrentEntryMix(0),
    fCurrentEntry(0),
    fCurrentEntryMain(0),
    fCurrentEntryMix(0),
-   fCurrentBinIndex(-1)
+   fCurrentBinIndex(-1),
+   fOfflineTriggerMask(0)
 {
    //
    // Default constructor.
 {
    //
    // Default constructor.
@@ -104,22 +105,6 @@ Bool_t AliMixInputEventHandler::Init(TTree *tree, Option_t *opt)
       tree->LoadTree(0);
       fMixIntupHandlerInfoTmp = new AliMixInputHandlerInfo(tree->GetName());
    }
       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();
    AliDebug(AliLog::kDebug + 5, Form("->"));
    return kTRUE;
 }
    AliDebug(AliLog::kDebug + 5, Form("->"));
    return kTRUE;
 }
@@ -189,8 +174,7 @@ Bool_t AliMixInputEventHandler::GetEntry()
    // All mixed events are set
    //
    AliDebug(AliLog::kDebug + 5, Form("<-"));
    // All mixed events are set
    //
    AliDebug(AliLog::kDebug + 5, Form("<-"));
-   // if no event pool MixStd
-//     if (fEventPool && fEventPool->NeedInit()) fEventPool->Init();
+
    if (!fEventPool) {
       MixStd();
    }
    if (!fEventPool) {
       MixStd();
    }
@@ -223,6 +207,10 @@ Bool_t AliMixInputEventHandler::MixStd()
    if (mh) inEvHMain = dynamic_cast<AliInputEventHandler *>(mh->GetFirstInputEventHandler());
    else inEvHMain = dynamic_cast<AliInputEventHandler *>(mgr->GetInputEventHandler());
    if (!inEvHMain) return kFALSE;
    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"));
    // return in case of 0 entry in full chain
    if (!fEntryCounter) {
       AliDebug(AliLog::kDebug + 3, Form("-> fEntryCounter == 0"));
@@ -281,6 +269,10 @@ Bool_t AliMixInputEventHandler::MixBuffer()
    if (mh) inEvHMain = dynamic_cast<AliInputEventHandler *>(mh->GetFirstInputEventHandler());
    else inEvHMain = dynamic_cast<AliInputEventHandler *>(mgr->GetInputEventHandler());
    if (!inEvHMain) return kFALSE;
    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
    // find out zero chain entries
    Long64_t zeroChainEntries = fMixIntupHandlerInfoTmp->GetChain()->GetEntries() - inEvHMain->GetTree()->GetTree()->GetEntries();
    // fill entry
@@ -370,6 +362,10 @@ Bool_t AliMixInputEventHandler::MixEventsMoreTimesWithOneEvent()
    if (mh) inEvHMain = dynamic_cast<AliInputEventHandler *>(mh->GetFirstInputEventHandler());
    else inEvHMain = dynamic_cast<AliInputEventHandler *>(mgr->GetInputEventHandler());
    if (!inEvHMain) return kFALSE;
    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
    // find out zero chain entries
    Long64_t zeroChainEntries = fMixIntupHandlerInfoTmp->GetChain()->GetEntries() - inEvHMain->GetTree()->GetTree()->GetEntries();
    // fill entry
@@ -522,3 +518,19 @@ void AliMixInputEventHandler::SetMixNumber(const Int_t mixNum)
    }
    fMixNumber = 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;
+}