From dbaf06ad8498ef2471049281ef7dfe6dba4279a6 Mon Sep 17 00:00:00 2001
From: Rafal Bielski <rafal.bielski@cern.ch>
Date: Fri, 6 Nov 2020 23:42:53 +0100
Subject: [PATCH] Partial Event Building: use previous RoI instead of initial

except for streamers, where there is no previous RoI.
---
 .../src/PEBInfoWriterAlg.cxx                      |  3 +--
 .../CommonSequences/EventBuildingSequenceSetup.py | 15 ++++++++++-----
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/Trigger/TrigAlgorithms/TrigPartialEventBuilding/src/PEBInfoWriterAlg.cxx b/Trigger/TrigAlgorithms/TrigPartialEventBuilding/src/PEBInfoWriterAlg.cxx
index b556667b4d81..0af90d9b69d1 100644
--- a/Trigger/TrigAlgorithms/TrigPartialEventBuilding/src/PEBInfoWriterAlg.cxx
+++ b/Trigger/TrigAlgorithms/TrigPartialEventBuilding/src/PEBInfoWriterAlg.cxx
@@ -18,7 +18,6 @@ using TrigCompositeUtils::createAndStore;
 using TrigCompositeUtils::decisionIDs;
 using TrigCompositeUtils::linkToPrevious;
 using TrigCompositeUtils::newDecisionIn;
-using TrigCompositeUtils::initialRoIString;
 using TrigCompositeUtils::featureString;
 using TrigCompositeUtils::roiString;
 using TrigCompositeUtils::findLink;
@@ -74,7 +73,7 @@ StatusCode PEBInfoWriterAlg::execute(const EventContext& eventContext) const {
   size_t counter = 0;
   for (const Decision* previousDecision: *previousDecisionsHandle) {
     // Get RoI
-    auto roiELInfo = findLink<TrigRoiDescriptorCollection>(previousDecision, initialRoIString());
+    auto roiELInfo = findLink<TrigRoiDescriptorCollection>(previousDecision, roiString());
     auto roiEL = roiELInfo.link;
     ATH_CHECK(roiEL.isValid());
 
diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/CommonSequences/EventBuildingSequenceSetup.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/CommonSequences/EventBuildingSequenceSetup.py
index c9223001f7be..e3cdd1e78233 100644
--- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/CommonSequences/EventBuildingSequenceSetup.py
+++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/CommonSequences/EventBuildingSequenceSetup.py
@@ -7,7 +7,7 @@ from TriggerMenuMT.HLTMenuConfig.Menu import EventBuildingInfo
 from TriggerMenuMT.HLTMenuConfig.Menu.MenuComponents import ChainStep, MenuSequence
 from TrigPartialEventBuilding.TrigPartialEventBuildingConf import PEBInfoWriterAlg
 from TrigPartialEventBuilding.TrigPartialEventBuildingConfig import StaticPEBInfoWriterToolCfg, RoIPEBInfoWriterToolCfg
-from DecisionHandling.DecisionHandlingConf import InputMakerForRoI, ViewCreatorInitialROITool
+from DecisionHandling import DecisionHandlingConf
 from libpyeformat_helper import SubDetector
 from AthenaCommon.CFElements import seqAND, findAlgorithm
 from AthenaCommon.Logging import logging
@@ -28,7 +28,7 @@ def addEventBuildingSequence(chain, eventBuildType, chainDict):
     def pebInfoWriterToolGenerator(chainDict):
         return pebInfoWriterTool(chainDict['chainName'], eventBuildType)
 
-    inputMaker = pebInputMaker(eventBuildType)
+    inputMaker = pebInputMaker(chain, eventBuildType)
     seq = MenuSequence(
         Sequence    = pebSequence(eventBuildType, inputMaker),
         Maker       = inputMaker,
@@ -114,10 +114,15 @@ def pebInfoWriterTool(name, eventBuildType):
     return tool
 
 
-def pebInputMaker(eventBuildType):
-    maker = InputMakerForRoI("IMpeb_"+eventBuildType)
-    maker.RoITool = ViewCreatorInitialROITool()
+def pebInputMaker(chain, eventBuildType):
+    maker = DecisionHandlingConf.InputMakerForRoI("IMpeb_"+eventBuildType)
     maker.RoIs = "pebInputRoI_" + eventBuildType
+    if len(chain.steps) == 0:
+        # Streamers: use initial RoI
+        maker.RoITool = DecisionHandlingConf.ViewCreatorInitialROITool()
+    else:
+        # Other chains: use previous RoI
+        maker.RoITool = DecisionHandlingConf.ViewCreatorPreviousROITool()
     return maker
 
 
-- 
GitLab