From e7d4e9ffc942cb507f4a699873bf7962389f9de2 Mon Sep 17 00:00:00 2001
From: Tomasz Bold <tomasz.bold@gmail.com>
Date: Mon, 1 Feb 2021 22:19:49 +0100
Subject: [PATCH 1/8] Preliminary MBTS hypo alg/tool

---
 .../TrigT2MinBias/src/MbtsHypoAlg.cxx         |  31 +++
 .../TrigT2MinBias/src/MbtsHypoAlg.h           |  30 +++
 .../TrigT2MinBias/src/MbtsHypoTool.cxx        | 197 ++++++++++++++++++
 .../TrigT2MinBias/src/MbtsHypoTool.h          |  63 ++++++
 .../MinBias/MinBiasRecoSequence.py            |  29 ---
 5 files changed, 321 insertions(+), 29 deletions(-)
 create mode 100644 Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoAlg.cxx
 create mode 100644 Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoAlg.h
 create mode 100644 Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoTool.cxx
 create mode 100644 Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoTool.h
 delete mode 100644 Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/MinBias/MinBiasRecoSequence.py

diff --git a/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoAlg.cxx b/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoAlg.cxx
new file mode 100644
index 000000000000..24b48af05097
--- /dev/null
+++ b/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoAlg.cxx
@@ -0,0 +1,31 @@
+/*
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
+*/
+
+#include "MbtsHypoAlg.h"
+
+MbtsHypoAlg::MbtsHypoAlg(const std::string& name, ISvcLocator* pSvcLocator) :
+  AthReentrantAlgorithm(name, pSvcLocator)
+{
+}
+
+MbtsHypoAlg::~MbtsHypoAlg()
+{
+}
+
+StatusCode MbtsHypoAlg::initialize()
+{
+  //ATH_MSG_DEBUG("Use macros for logging!");
+  return StatusCode::SUCCESS;
+}
+
+StatusCode MbtsHypoAlg::finalize()
+{
+  return StatusCode::SUCCESS;
+}
+
+StatusCode MbtsHypoAlg::execute(const EventContext& context) const
+{
+  return StatusCode::SUCCESS;
+}
+
diff --git a/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoAlg.h b/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoAlg.h
new file mode 100644
index 000000000000..831aa15a8a6c
--- /dev/null
+++ b/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoAlg.h
@@ -0,0 +1,30 @@
+/*
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
+*/
+#ifndef TRIGT2MINBIAS_MBTSHYPOALG_H
+#define TRIGT2MINBIAS_MBTSHYPOALG_H
+
+// Framework includes
+#include "AthenaBaseComps/AthReentrantAlgorithm.h"
+
+// STL includes
+#include <string>
+
+/**
+ * @class MbtsHypoAlg
+ * @brief 
+ **/
+class MbtsHypoAlg : public AthReentrantAlgorithm {
+public:
+  MbtsHypoAlg(const std::string& name, ISvcLocator* pSvcLocator);
+  virtual ~MbtsHypoAlg() override;
+
+  virtual StatusCode initialize() override;
+  virtual StatusCode execute(const EventContext& context) const override;
+  virtual StatusCode finalize() override;
+
+private:
+  //Gaudi::Property<int> m_myInt{this, "MyInt", 0, "An Integer"};
+};
+
+#endif // TRIGT2MINBIAS_MBTSHYPOALG_H
diff --git a/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoTool.cxx b/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoTool.cxx
new file mode 100644
index 000000000000..bb1d6fd9f445
--- /dev/null
+++ b/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoTool.cxx
@@ -0,0 +1,197 @@
+
+/*
+Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+*/
+
+#include "TrigCompositeUtils/HLTIdentifier.h"
+#include "AthenaMonitoringKernel/Monitored.h"
+
+#include "MbtsHypoTool.h"
+
+using namespace TrigCompositeUtils;
+MbtsHypoTool::MbtsHypoTool(const std::string &type, const std::string &name, const IInterface *parent)
+	: AthAlgTool(type, name, parent),
+	  m_decisionId(HLT::Identifier::fromToolName(name)) {}
+
+StatusCode MbtsHypoTool::initialize()
+{
+	return StatusCode::SUCCESS;
+}
+
+StatusCode MbtsHypoTool::decide(MBTSInfo &info) const
+{
+	ATH_MSG_DEBUG("Executing this T2MbtsHypo " << name());
+
+	if (info.previousDecisionIDs.count(m_decisionId.numeric()) == 0)
+	{
+		ATH_MSG_DEBUG("Already rejected");
+		return StatusCode::SUCCESS;
+	}
+
+	// Calculate MBTS counter multiplicities after energy and an optional time cut.
+	Counts counts = calculateMultiplicities(info.mbtsBits);
+	if ( counts.sideA == 0 && counts.sideC == 0)
+	{
+		ATH_MSG_DEBUG("calculateMultiplicities failed");
+		return StatusCode::SUCCESS;
+	}
+	bool pass = false;
+	if (m_coincidence)
+	{ // Coincidence logic
+		if (!m_veto)
+		{
+			if (counts.sideA >= m_mbtsCounters && counts.sideC >= m_mbtsCounters)
+				pass = true;
+		}
+		else
+		{
+			if (counts.sideA < m_mbtsCounters && counts.sideC < m_mbtsCounters)
+				pass = true;
+		}
+	}
+	else
+	{
+		if (m_or)
+		{ // Or logic
+			if (!m_veto)
+			{
+				if ((counts.sideA >= m_mbtsCounters || counts.sideC >= m_mbtsCounters))
+					pass = true;
+			}
+			else
+			{
+				if ((counts.sideA < m_mbtsCounters || counts.sideC < m_mbtsCounters))
+					pass = true;
+			}
+		}
+		else
+		{ // Sum logic
+			if (!m_veto)
+			{
+				if ((counts.sideA + counts.sideC) >= m_mbtsCounters)
+					pass = true;
+			}
+			else
+			{
+				if ((counts.sideA + counts.sideC) < m_mbtsCounters)
+					pass = true;
+			}
+		}
+	}
+
+	ATH_MSG_DEBUG("REGTEST: event " << (pass ? "accepted" : "failed") << " with EBA(" << counts.sideA << ") + EBC(" << counts.sideC << ") hits above threshold.");
+
+	if ( pass ) 
+	{
+		addDecisionID(m_decisionId.numeric(), info.decision);
+		ATH_MSG_DEBUG("REGTEST event accepted");
+	}
+	return StatusCode::SUCCESS;
+}
+
+MbtsHypoTool::Counts MbtsHypoTool::calculateMultiplicities(const xAOD::TrigT2MbtsBits *t2mbtsBits) const
+{
+
+	if (!t2mbtsBits)
+	{
+		return {0, 0};
+	}
+
+	ATH_MSG_DEBUG("Getting energy and time values.");
+
+	std::vector<float> triggerEnergies = t2mbtsBits->triggerEnergies();
+	std::vector<float> triggerTimes = t2mbtsBits->triggerTimes();
+
+	if (triggerEnergies.size() != xAOD::TrigT2MbtsBits::NUM_MBTS || triggerTimes.size() != xAOD::TrigT2MbtsBits::NUM_MBTS)
+	{
+		ATH_MSG_WARNING("Vector sizes are not equal to number of MBTS counters.");
+		return {0, 0};
+	}
+
+	ATH_MSG_DEBUG("Forming hit multiplicities.");
+
+	std::bitset<16> ebaTriggerBits;
+	std::bitset<16> ebcTriggerBits;
+	unsigned ibit;
+	int ebaCounters = 0, ebcCounters = 0;
+
+	// Initialize monitoring variables.
+	double timeDiff_A_C = 0.;
+	double timeMean_A = 0.;
+	double timeMean_C = 0.;
+
+	// Loop over each counter and form bit sets from time and energy (optional).
+	for (ibit = 0; ibit < xAOD::TrigT2MbtsBits::NUM_MBTS; ibit++)
+	{
+		if (m_mbtsmode == 1 && !(ibit < 8 || (ibit >= 16 && ibit < 24)))
+			continue; // count only inner
+		if (m_mbtsmode == 2 && !((ibit >= 8 && ibit < 16) || (ibit >= 24 && ibit < 32)))
+			continue; // count only outer
+
+		// Check the energy threshold.
+		if (triggerEnergies[ibit] <= m_threshold)
+			continue;
+
+		// Calculate the mean time for this side;
+		if (ibit < 16)
+		{
+			timeMean_A += triggerTimes[ibit];
+			ebaCounters++;
+		}
+		else
+		{
+			timeMean_C += triggerTimes[ibit];
+			ebcCounters++;
+		}
+
+		// Check the time cut if it is active.
+		if (m_timeCut >= 0 && fabs(triggerTimes[ibit] - m_timeOffsets[ibit] - m_globalTimeOffset) >= m_timeCut)
+			continue;
+
+		// Set the bits for this side;
+		if (ibit < 16)
+		{
+			ebaTriggerBits.set(ibit);
+		}
+		else
+		{
+			ebcTriggerBits.set(ibit - 16);
+		}
+	}
+
+	if (ebaCounters > 0)
+	{
+		timeMean_A /= ebaCounters;
+	}
+	else
+	{
+		timeMean_A = -999.0;
+	}
+
+	if (ebcCounters > 0)
+	{
+		timeMean_C /= ebcCounters;
+	}
+	else
+	{
+		timeMean_C = -999.0;
+	}
+
+	if (ebaCounters > 0 && ebcCounters > 0)
+	{
+		timeDiff_A_C = timeMean_A - timeMean_C;
+	}
+	else
+	{
+		timeDiff_A_C = -999.0;
+	}
+	ATH_MSG_DEBUG("average MBTS trigger time"
+				  << " side A: " << timeMean_A
+				  << ", side C: " << timeMean_C
+				  << ", difference A-C: " << timeDiff_A_C);
+
+	ATH_MSG_DEBUG("MBTS EBA trigger bits: " << ebaTriggerBits);
+	ATH_MSG_DEBUG("MBTS EBC trigger bits: " << ebcTriggerBits);
+
+	return {ebaTriggerBits.count(), ebcTriggerBits.count()};
+}
diff --git a/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoTool.h b/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoTool.h
new file mode 100644
index 000000000000..12a99f71dc49
--- /dev/null
+++ b/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoTool.h
@@ -0,0 +1,63 @@
+/*
+Copyright! (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
+*/
+#ifndef TRIGT2MINBIAS_MbtsHypoTool_H
+#define TRIGT2MINBIAS_MbtsHypoTool_H
+
+#include "Gaudi/Property.h"
+#include "AthenaBaseComps/AthAlgTool.h"
+#include "TrigCompositeUtils/HLTIdentifier.h"
+#include "TrigCompositeUtils/TrigCompositeUtils.h"
+#include "xAODTrigMinBias/TrigT2MbtsBits.h"
+
+class MbtsHypoTool : virtual public ::AthAlgTool
+{
+public:
+  MbtsHypoTool(const std::string &type,
+               const std::string &name,
+               const IInterface *parent);
+
+  virtual StatusCode initialize() override;
+
+  struct MBTSInfo
+  {
+    TrigCompositeUtils::Decision *decision;
+    // do not know yet what is needed
+    const xAOD::TrigT2MbtsBits *mbtsBits;
+    const TrigCompositeUtils::DecisionIDContainer previousDecisionIDs;
+  };
+
+  StatusCode decide(MBTSInfo &decisions) const;
+
+private:
+  bool applyCut(const Gaudi::Property<int> &threshold, const xAOD::TrigComposite *composit) const;
+  HLT::Identifier m_decisionId;
+  Gaudi::Property<bool> m_accptAll{this, "AcceptAll", false, "Accept all events"};
+
+  Gaudi::Property<unsigned int> m_mbtsCounters{this, "MbtsCounters", 2, "The number of MBTS counters required to be above threshold"};
+
+  Gaudi::Property<bool> m_coincidence{this, "Coincidence", false, "A flag to control if this is a coincidence requirement or not"};
+
+  Gaudi::Property<bool> m_or{this, "Or", false, "Flag extending above choice to do Or between the two sides of MBTS"};
+
+  Gaudi::Property<bool> m_veto{this, "Veto", false, "Flag to select lowe than threshold multiplicities"};
+
+  Gaudi::Property<int> m_mbtsmode{this, "MBTSMode", 0, "Flag to count multiplicities only on inner or outer MBTS modules (see T2MBTSUtils) "};
+      
+  Gaudi::Property<float> m_threshold{this, "Threshold", 40.0/222.0, "Energy threshold in pC"};
+
+  Gaudi::Property<float> m_timeCut{this, "TimeCut", -1.0, "A time cut in ns.  Values <= 0 disable the time cut"};
+
+  Gaudi::Property<float> m_globalTimeOffset{this, "GlobalTimeOffset", 0, "A global time offset in ns about which the time window cuts"};
+  
+  Gaudi::Property<std::vector<float>> m_timeOffsets{this, "TimeOffset", std::vector<float>(32), "Offsets with respect to the global offset of all counters. (A0-15 then C0-C15) "};
+
+  ToolHandle<GenericMonitoringTool> m_monTool{this, "MonTool", "", "Monitoring tool"};
+  struct Counts{
+    size_t sideA; 
+    size_t sideC;
+  };
+  Counts calculateMultiplicities(const xAOD::TrigT2MbtsBits *t2mbtsBits) const;
+};
+
+#endif //> !TRIGT2MINBIAS_MbtsHypoTool_H
diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/MinBias/MinBiasRecoSequence.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/MinBias/MinBiasRecoSequence.py
deleted file mode 100644
index efc43587f90d..000000000000
--- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/MinBias/MinBiasRecoSequence.py
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-#  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
-#
-from AthenaCommon.CFElements import seqAND
-from TrigT2CaloCommon.CaloDef import clusterFSInputMaker
-
-def minbiasSpacePointAthSequence(ConfigFlags):
-    InputMakerAlg= clusterFSInputMaker()
-    (recoSequence, sequenceOut) = MinBiasRecoSequences()
-
-    minbiasSpacePointAthSequence =  seqAND("minbiasSpacePointAthSequence",[InputMakerAlg, recoSequence ])
-    return (minbiasSpacePointAthSequence, InputMakerAlg, sequenceOut)
-
-def minbiasTrackAthSequence(ConfigFlags):
-    InputMakerAlg= clusterFSInputMaker()
-    (recoSequence, sequenceOut) = MinBiasRecoSequences()
-
-    minbiasTrackAthSequence =  seqAND("minbiasTrackAthSequence",[InputMakerAlg, recoSequence ])
-    return (minbiasTrackAthSequence, InputMakerAlg, sequenceOut)
-
-
-def MinBiasRecoSequences():
-
-    from TrigT2CaloCommon.CaloDef import HLTFSMinBiasRecoSequences
-    (cellMakerSeq, CellsName) = HLTFSMinBiasRecoSequences()
-
-    #################################################
-    # Add SPCountHypoAlg and associated tools
-    #################################################
-- 
GitLab


From 7f022dbc6c90bf11617db3e1ab8c2811056e3cb7 Mon Sep 17 00:00:00 2001
From: Tomasz Bold <tomasz.bold@gmail.com>
Date: Mon, 1 Feb 2021 22:20:10 +0100
Subject: [PATCH 2/8] Adding MBTS chain

---
 .../TrigT2MinBias/src/MbtsFexMT.h             |  2 +-
 .../src/components/TrigT2MinBias_entries.cxx  |  5 +++-
 .../python/HLTMenuConfig/Menu/LS2_v1.py       |  3 +-
 .../MinBias/MinBiasChainConfiguration.py      | 30 ++++++++++++-------
 .../MinBias/MinBiasMenuSequences.py           | 23 ++++++++++++--
 5 files changed, 47 insertions(+), 16 deletions(-)

diff --git a/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsFexMT.h b/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsFexMT.h
index 27befd844e80..c2f9749bb3a2 100644
--- a/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsFexMT.h
+++ b/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsFexMT.h
@@ -39,7 +39,7 @@ public:
   virtual StatusCode execute(const EventContext& context) const override;
 
 private:
-  SG::WriteHandleKey<xAOD::TrigT2MbtsBitsContainer> m_t2MbtsBitsKey{this,"t2MbtsBitsKey","MbtsBitsContainer"," "};
+  SG::WriteHandleKey<xAOD::TrigT2MbtsBitsContainer> m_t2MbtsBitsKey{this, "t2MbtsBitsKey", "MbtsBitsContainer"," "};
   SG::ReadHandleKey<TileTBID> m_TileHelperKey{this,"TileHelperKey", "DetectorStore+TileTBID"," "};
   SG::ReadCondHandleKey<TileEMScale> m_emScaleKey{this, "TileEMScale", "TileEMScale", "Input Tile EMS calibration constants"};
   SG::ReadCondHandleKey<TileBadChannels> m_badChannelsKey{this, "TileBadChannels", "TileBadChannels", "Input Tile bad channel status"};
diff --git a/Trigger/TrigAlgorithms/TrigT2MinBias/src/components/TrigT2MinBias_entries.cxx b/Trigger/TrigAlgorithms/TrigT2MinBias/src/components/TrigT2MinBias_entries.cxx
index 89fcefd2a1d2..9c4744f05fbf 100644
--- a/Trigger/TrigAlgorithms/TrigT2MinBias/src/components/TrigT2MinBias_entries.cxx
+++ b/Trigger/TrigAlgorithms/TrigT2MinBias/src/components/TrigT2MinBias_entries.cxx
@@ -10,7 +10,8 @@
 #include "../SPCountHypoAlgMT.h"
 #include "../SPCountHypoTool.h"
 #include "../MbtsFexMT.h"
-
+#include "../MbtsHypoAlg.h"
+#include "../MbtsHypoTool.h"
 
 DECLARE_COMPONENT( T2MbtsFex )
 DECLARE_COMPONENT( T2MbtsHypo )
@@ -24,3 +25,5 @@ DECLARE_COMPONENT( TrigCountSpacePointsMT )
 DECLARE_COMPONENT( SPCountHypoAlgMT )
 DECLARE_COMPONENT( SPCountHypoTool )
 DECLARE_COMPONENT( MbtsFexMT )
+DECLARE_COMPONENT( MbtsHypoAlg )
+DECLARE_COMPONENT( MbtsHypoTool )
diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/LS2_v1.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/LS2_v1.py
index 5633ce212b7e..6fe8e546d7f2 100644
--- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/LS2_v1.py
+++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/LS2_v1.py
@@ -14,7 +14,7 @@ import TriggerMenuMT.HLTMenuConfig.Menu.MC_pp_run3_v1 as mc_menu
 import TriggerMenuMT.HLTMenuConfig.Menu.PhysicsP1_pp_run3_v1 as p1_menu
 
 # this is not the best option, due to flake violation, this list has to be changed when some groups are removed
-from TriggerMenuMT.HLTMenuConfig.Menu.Physics_pp_run3_v1 import PhysicsStream,SingleMuonGroup,MultiMuonGroup,SingleElectronGroup,MultiElectronGroup,SinglePhotonGroup,MultiPhotonGroup,SingleMETGroup,MultiMETGroup,SingleJetGroup,MultiJetGroup,SingleBjetGroup,SingleTauGroup,MultiTauGroup,BphysicsGroup,EgammaMuonGroup,MuonJetGroup,MuonMETGroup,EgammaJetGroup,EgammaMETGroup,EgammaTauGroup,MuonTauGroup,TauMETGroup
+from TriggerMenuMT.HLTMenuConfig.Menu.Physics_pp_run3_v1 import PhysicsStream,SingleMuonGroup,MultiMuonGroup,SingleElectronGroup,MultiElectronGroup,SinglePhotonGroup,MultiPhotonGroup,SingleMETGroup,MultiMETGroup,SingleJetGroup,MultiJetGroup,SingleBjetGroup,SingleTauGroup,MultiTauGroup,BphysicsGroup,EgammaMuonGroup,MuonJetGroup,MuonMETGroup,EgammaJetGroup,EgammaMETGroup,EgammaTauGroup,MuonTauGroup,TauMETGroup,MinBiasGroup
 
 
 def setupMenu():
@@ -556,6 +556,7 @@ def setupMenu():
         ChainProp(name='HLT_beamspot_allTE_trkfast_BeamSpotPEB_L1J15',  l1SeedThresholds=['FSNOSEED'], stream=['BeamSpot'], groups=['PS:Online', 'RATE:BeamSpot',  'BW:BeamSpot']),
     ]
     TriggerFlags.MinBiasSlice.signatures   = TriggerFlags.MinBiasSlice.signatures() + [
+        ChainProp(name="HLT_mb_mbts_L1MBTS_1", l1SeedThresholds=['FSNOSEED'], stream=[PhysicsStream], groups=MinBiasGroup)
         # ChainProp(name='HLT_mb_sp400_trk40_hmt_L1RD0_FILLED',        l1SeedThresholds=['FSNOSEED'], stream=[PhysicsStream], groups=MinBiasGroup),
         # ChainProp(name='HLT_mb_sp600_trk45_hmt_L1RD0_FILLED',        l1SeedThresholds=['FSNOSEED'], stream=[PhysicsStream], groups=MinBiasGroup),
     ]
diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/MinBias/MinBiasChainConfiguration.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/MinBias/MinBiasChainConfiguration.py
index 711585555813..b950dde45daa 100644
--- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/MinBias/MinBiasChainConfiguration.py
+++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/MinBias/MinBiasChainConfiguration.py
@@ -6,7 +6,7 @@ log = logging.getLogger( __name__ )
 
 
 from TriggerMenuMT.HLTMenuConfig.Menu.ChainConfigurationBase import ChainConfigurationBase
-from TriggerMenuMT.HLTMenuConfig.MinBias.MinBiasMenuSequences import MinBiasSPSequence, MinBiasTrkSequence
+from TriggerMenuMT.HLTMenuConfig.MinBias.MinBiasMenuSequences import MinBiasSPSequence, MinBiasTrkSequence, MinBiasMBTSSequence 
 
 #----------------------------------------------------------------
 # fragments generating configuration will be functions in New JO,
@@ -19,6 +19,10 @@ def MinBiasTrkSequenceCfg(flags):
     return MinBiasTrkSequence()
 
 
+def MinBiasMBTSSequenceCfg(flags):
+    return MinBiasMBTSSequence()
+
+
 class MinBiasChainConfig(ChainConfigurationBase):
 
     def __init__(self, chainDict):
@@ -29,20 +33,24 @@ class MinBiasChainConfig(ChainConfigurationBase):
     # ----------------------
     def assembleChain(self):
         log.debug("Assembling chain for %s", self.chainName)
+        steps = []
+        if "_mbts" in self.chainName:
+            pass
+
+        if "_sp" in self.chainName:
+            steps.append(self.getMinBiasSpStep())
+        
         # mb_sptrk chains
-        if "mb_sptrk" in self.chainName or "hmt" in self.chainName:
-            SpStep = self.getMinBiasSpStep()
-            TrkStep = self.getMinBiasTrkStep()
-            return self.buildChain([SpStep,TrkStep])
-        # performance chain for the aboce
-        if "mb_sp_" in self.chainName:
-            SpStep = self.getMinBiasSpStep()
-            return self.buildChain([SpStep])
+        if "_sptrk" in self.chainName or "hmt" in self.chainName:
+            steps.append(self.getMinBiasTrkStep())
 
+        return self.buildChain(steps)
 
+    def getMBTSStep(self):
+        return self.getStep(1, 'MBTS',[MinBiasMBTSSequenceCfg])
     
     def getMinBiasSpStep(self):
-        return self.getStep(1,'SPCount',[MinBiasSPSequenceCfg])
+        return self.getStep(2,'SPCount',[MinBiasSPSequenceCfg])
 
     def getMinBiasTrkStep(self):
-        return self.getStep(2,'TrkCount',[MinBiasTrkSequenceCfg])
+        return self.getStep(3,'TrkCount',[MinBiasTrkSequenceCfg])
diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/MinBias/MinBiasMenuSequences.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/MinBias/MinBiasMenuSequences.py
index e09226a2e0e5..973beffea059 100644
--- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/MinBias/MinBiasMenuSequences.py
+++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/MinBias/MinBiasMenuSequences.py
@@ -102,7 +102,6 @@ def MinBiasTrkSequence():
         trkInputMakerAlg.InViewRoIs = "InputRoI" # contract with the consumer
         trkInputMakerAlg.Views = "TrkView"
         trkInputMakerAlg.RequireParentView = True
-        trkInputMakerAlg.ViewNodeName = "TrkCountHypoAlgMTNode"
 
         # prepare algorithms to run in views, first,
         # inform scheduler that input data is available in parent view (has to be done by hand)
@@ -116,7 +115,7 @@ def MinBiasTrkSequence():
         from TrigMinBias.TrackCountMonitoringMT import TrackCountMonitoring
         trackCountHypo.MonTool = TrackCountMonitoring()
 
-        trkRecoSeq = parOR("TrkrecoSeq", algs)
+        trkRecoSeq = parOR("TrkRecoSeq", algs)
         trkSequence = seqAND("TrkSequence", [trkInputMakerAlg, trkRecoSeq])
         trkInputMakerAlg.ViewNodeName = trkRecoSeq.name()
 
@@ -124,3 +123,23 @@ def MinBiasTrkSequence():
                             Maker       = trkInputMakerAlg,
                             Hypo        = trackCountHypo,
                             HypoToolGen = TrackCountHypoToolGen)
+
+def MinBiasMBTSSequence():
+    from TrigT2MinBias.TrigT2MinBiasConf import MbtsFexMT
+    MBTSRecoSeq = parOR("MBTSRecoSeq", [MbtsFexMT()])
+
+    MBTSInputMakerAlg = EventViewCreatorAlgorithm("IM_MBTSEventViewCreator")
+    MBTSInputMakerAlg.ViewFallThrough = True
+    MBTSInputMakerAlg.RoITool = ViewCreatorInitialROITool()
+    MBTSInputMakerAlg.InViewRoIs = "InputRoI" # contract with the consumer
+    MBTSInputMakerAlg.Views = "MBTSView"
+    MBTSInputMakerAlg.RequireParentView = True
+    MBTSInputMakerAlg.ViewNodeName = MBTSRecoSeq.name()
+    MBTSSequence = seqAND("MBTSSequence", [MBTSInputMakerAlg, MBTSRecoSeq])
+
+    
+
+    return MenuSequence(Sequence    = MBTSSequence,
+                        Maker       = MBTSInputMakerAlg,
+                        Hypo        = MBTSHypo,
+                        HypoToolGen = MBTSHypoToolGen)
\ No newline at end of file
-- 
GitLab


From a9fec1bca7e82c0309c18c2a022cb03805bf052d Mon Sep 17 00:00:00 2001
From: Tomasz Bold <tomasz.bold@gmail.com>
Date: Wed, 3 Feb 2021 18:40:04 +0100
Subject: [PATCH 3/8] Added MBTS HLT chain

---
 .../TriggerMenuMT/python/HLTMenuConfig/Menu/LS2_v1.py           | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/LS2_v1.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/LS2_v1.py
index 6fe8e546d7f2..840d52484d8e 100644
--- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/LS2_v1.py
+++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/LS2_v1.py
@@ -556,7 +556,7 @@ def setupMenu():
         ChainProp(name='HLT_beamspot_allTE_trkfast_BeamSpotPEB_L1J15',  l1SeedThresholds=['FSNOSEED'], stream=['BeamSpot'], groups=['PS:Online', 'RATE:BeamSpot',  'BW:BeamSpot']),
     ]
     TriggerFlags.MinBiasSlice.signatures   = TriggerFlags.MinBiasSlice.signatures() + [
-        ChainProp(name="HLT_mb_mbts_L1MBTS_1", l1SeedThresholds=['FSNOSEED'], stream=[PhysicsStream], groups=MinBiasGroup)
+        ChainProp(name="HLT_mb_mbts_L1MBTS_1_EMPTY", l1SeedThresholds=['FSNOSEED'], stream=[PhysicsStream], groups=MinBiasGroup) #TODO - need item in FILLED BC item
         # ChainProp(name='HLT_mb_sp400_trk40_hmt_L1RD0_FILLED',        l1SeedThresholds=['FSNOSEED'], stream=[PhysicsStream], groups=MinBiasGroup),
         # ChainProp(name='HLT_mb_sp600_trk45_hmt_L1RD0_FILLED',        l1SeedThresholds=['FSNOSEED'], stream=[PhysicsStream], groups=MinBiasGroup),
     ]
-- 
GitLab


From 23fbac01fb8d4dcb32c50dcaea4b5ce9014a7b8b Mon Sep 17 00:00:00 2001
From: Tomasz Bold <tomasz.bold@gmail.com>
Date: Wed, 3 Feb 2021 20:31:21 +0100
Subject: [PATCH 4/8] Added Mbts Hypo and Mbts HLT chain

---
 .../TrigT2MinBias/python/MbtsConfig.py        | 14 ++++--
 .../TrigT2MinBias/src/MbtsFexMT.cxx           |  5 +-
 .../TrigT2MinBias/src/MbtsFexMT.h             |  4 +-
 .../TrigT2MinBias/src/MbtsHypoAlg.cxx         | 39 ++++++++++++++--
 .../TrigT2MinBias/src/MbtsHypoAlg.h           | 10 ++--
 .../TrigT2MinBias/src/MbtsHypoTool.cxx        |  4 +-
 .../TrigT2MinBias/src/MbtsHypoTool.h          | 10 ++--
 .../MinBias/MinBiasChainConfiguration.py      | 12 ++---
 .../MinBias/MinBiasMenuSequences.py           | 46 +++++++++++--------
 9 files changed, 94 insertions(+), 50 deletions(-)

diff --git a/Trigger/TrigAlgorithms/TrigT2MinBias/python/MbtsConfig.py b/Trigger/TrigAlgorithms/TrigT2MinBias/python/MbtsConfig.py
index efd8baa3af5e..2213130142d8 100644
--- a/Trigger/TrigAlgorithms/TrigT2MinBias/python/MbtsConfig.py
+++ b/Trigger/TrigAlgorithms/TrigT2MinBias/python/MbtsConfig.py
@@ -2,8 +2,12 @@
 from TrigT2MinBias.TrigT2MinBiasConf import MbtsFexMT
 from TrigT2MinBias.TrigT2MinBiasMonitoringMT import MbtsFexMTMonitoring
 
-class MbtsFexMT( MbtsFexMT ):
-    __slots__ = []
-    def __init__ (self, name ):
-        super(MbtsFexMT, self).__init__(name)
-        self.monTool += [ MbtsFexMTMonitoring()]
+
+def MbtsFexMTCfg(flags=None, name="MbtsFex", **kwargs):
+    alg = MbtsFexMT(name, **kwargs)
+    alg.MonTool =  MbtsFexMTMonitoring()
+    from TrigT2CaloCommon.TrigCaloDataAccessConfig import CaloDataAccessSvcDependencies
+    alg.ExtraInputs = CaloDataAccessSvcDependencies
+    return alg
+
+
diff --git a/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsFexMT.cxx b/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsFexMT.cxx
index 0a626962ea81..0840c3d8c971 100644
--- a/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsFexMT.cxx
+++ b/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsFexMT.cxx
@@ -18,7 +18,7 @@ StatusCode MbtsFexMT::initialize()
   ATH_CHECK( m_badChannelsKey.initialize() );
   ATH_CHECK( m_TileHelperKey.initialize() );
   ATH_CHECK( m_dataAccessSvc.retrieve() );
-  ATH_CHECK(m_t2MbtsBitsKey.initialize());
+  ATH_CHECK(m_MbtsBitsKey.initialize());
   if (! m_monTool.empty() ) ATH_CHECK( m_monTool.retrieve() );
 
   return StatusCode::SUCCESS;
@@ -88,7 +88,7 @@ StatusCode MbtsFexMT::execute(const EventContext& context) const
   auto mon_triggerTimes = Monitored::Collection("triggerTime ",triggerTimes);
   Monitored::Group(m_monTool,mon_triggerEnergies,mon_triggerEta,mon_triggerPhi,mon_triggerTimes);
 
-  SG::WriteHandle<xAOD::TrigT2MbtsBitsContainer> mbtsHandle (m_t2MbtsBitsKey, context);
+  SG::WriteHandle<xAOD::TrigT2MbtsBitsContainer> mbtsHandle (m_MbtsBitsKey, context);
 
   auto trigMbtsContainer = std::make_unique< xAOD::TrigT2MbtsBitsContainer>();
   auto trigMbtsAuxContainer = std::make_unique< xAOD::TrigT2MbtsBitsAuxContainer>();
@@ -100,6 +100,7 @@ StatusCode MbtsFexMT::execute(const EventContext& context) const
   mbtsObj->setTriggerEnergies(triggerEnergies);
   mbtsObj->setTriggerTimes(triggerTimes);
 
+  ATH_MSG_DEBUG("Recording " << mbtsHandle.key());
   ATH_CHECK(mbtsHandle.record( std::move(trigMbtsContainer), std::move( trigMbtsAuxContainer ) ) );
   return StatusCode::SUCCESS;
 }
diff --git a/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsFexMT.h b/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsFexMT.h
index c2f9749bb3a2..9bfddb82e142 100644
--- a/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsFexMT.h
+++ b/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsFexMT.h
@@ -39,13 +39,11 @@ public:
   virtual StatusCode execute(const EventContext& context) const override;
 
 private:
-  SG::WriteHandleKey<xAOD::TrigT2MbtsBitsContainer> m_t2MbtsBitsKey{this, "t2MbtsBitsKey", "MbtsBitsContainer"," "};
+  SG::WriteHandleKey<xAOD::TrigT2MbtsBitsContainer> m_MbtsBitsKey{this, "MbtsBitsKey", "unspecified"," "};
   SG::ReadHandleKey<TileTBID> m_TileHelperKey{this,"TileHelperKey", "DetectorStore+TileTBID"," "};
   SG::ReadCondHandleKey<TileEMScale> m_emScaleKey{this, "TileEMScale", "TileEMScale", "Input Tile EMS calibration constants"};
   SG::ReadCondHandleKey<TileBadChannels> m_badChannelsKey{this, "TileBadChannels", "TileBadChannels", "Input Tile bad channel status"};
   ServiceHandle<ITrigCaloDataAccessSvc> m_dataAccessSvc{ this, "TrigDataAccessMT", "TrigCaloDataAccessSvc/TrigCaloDataAccessSvc", "Data Access for LVL2 Calo Algorithms in MT" };
   ToolHandle< GenericMonitoringTool > m_monTool { this, "MonTool", "", "Monitoring tool" };
-
-
 };
 #endif
diff --git a/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoAlg.cxx b/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoAlg.cxx
index 24b48af05097..f75fb2b277fb 100644
--- a/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoAlg.cxx
+++ b/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoAlg.cxx
@@ -3,9 +3,16 @@
 */
 
 #include "MbtsHypoAlg.h"
+using TrigCompositeUtils::createAndStore;
+using TrigCompositeUtils::DecisionContainer;
+using TrigCompositeUtils::DecisionIDContainer;
+using TrigCompositeUtils::decisionIDs;
+using TrigCompositeUtils::hypoAlgNodeName;
+using TrigCompositeUtils::linkToPrevious;
+using TrigCompositeUtils::newDecisionIn;
 
-MbtsHypoAlg::MbtsHypoAlg(const std::string& name, ISvcLocator* pSvcLocator) :
-  AthReentrantAlgorithm(name, pSvcLocator)
+MbtsHypoAlg::MbtsHypoAlg(const std::string& name, ISvcLocator* pSvcLocator) 
+  : ::HypoBase(name, pSvcLocator)
 {
 }
 
@@ -15,7 +22,9 @@ MbtsHypoAlg::~MbtsHypoAlg()
 
 StatusCode MbtsHypoAlg::initialize()
 {
-  //ATH_MSG_DEBUG("Use macros for logging!");
+  ATH_CHECK(m_hypoTools.retrieve());
+  ATH_CHECK(m_MbtsBitsKey.initialize());
+  ATH_CHECK(m_hypoTools.retrieve());
   return StatusCode::SUCCESS;
 }
 
@@ -26,6 +35,28 @@ StatusCode MbtsHypoAlg::finalize()
 
 StatusCode MbtsHypoAlg::execute(const EventContext& context) const
 {
-  return StatusCode::SUCCESS;
+  ATH_MSG_DEBUG("Executing ...");
+
+  SG::ReadHandle<DecisionContainer> previousDecisionsHandle = SG::makeHandle(decisionInput(), context);
+  ATH_CHECK(previousDecisionsHandle.isValid());
+  auto bitsHandle = SG::makeHandle(m_MbtsBitsKey, context);
+  TrigCompositeUtils::DecisionIDContainer prev;
+  TrigCompositeUtils::decisionIDs(previousDecisionsHandle->at(0), prev);
+
+  ATH_MSG_DEBUG("Obtained input");
+
+  SG::WriteHandle<DecisionContainer> outputHandle = createAndStore(decisionOutput(), context);
+  auto decisions = outputHandle.ptr();
+  auto d = newDecisionIn(decisions, hypoAlgNodeName());
+  linkToPrevious(d, decisionInput().key(), 0);
+
+
+  MbtsHypoTool::MbtsHypoInfo info = { prev, bitsHandle.cptr()->at(0),  d};
+
+  for ( const auto& tool : m_hypoTools ) {
+    ATH_CHECK(tool->decide(info));
+  }
+
+  return StatusCode::SUCCESS;  
 }
 
diff --git a/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoAlg.h b/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoAlg.h
index 831aa15a8a6c..3095833c45d9 100644
--- a/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoAlg.h
+++ b/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoAlg.h
@@ -4,8 +4,9 @@
 #ifndef TRIGT2MINBIAS_MBTSHYPOALG_H
 #define TRIGT2MINBIAS_MBTSHYPOALG_H
 
-// Framework includes
-#include "AthenaBaseComps/AthReentrantAlgorithm.h"
+#include "DecisionHandling/HypoBase.h"
+#include "MbtsHypoTool.h"
+#include "xAODTrigMinBias/TrigT2MbtsBitsContainer.h"
 
 // STL includes
 #include <string>
@@ -14,7 +15,7 @@
  * @class MbtsHypoAlg
  * @brief 
  **/
-class MbtsHypoAlg : public AthReentrantAlgorithm {
+class MbtsHypoAlg : public ::HypoBase {
 public:
   MbtsHypoAlg(const std::string& name, ISvcLocator* pSvcLocator);
   virtual ~MbtsHypoAlg() override;
@@ -24,7 +25,8 @@ public:
   virtual StatusCode finalize() override;
 
 private:
-  //Gaudi::Property<int> m_myInt{this, "MyInt", 0, "An Integer"};
+  ToolHandleArray<MbtsHypoTool> m_hypoTools{this, "HypoTools", {}};
+  SG::ReadHandleKey<xAOD::TrigT2MbtsBitsContainer> m_MbtsBitsKey{this, "MbtsBitsKey", "Undefined", ""};
 };
 
 #endif // TRIGT2MINBIAS_MBTSHYPOALG_H
diff --git a/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoTool.cxx b/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoTool.cxx
index bb1d6fd9f445..39ce51b0d04a 100644
--- a/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoTool.cxx
+++ b/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoTool.cxx
@@ -18,7 +18,7 @@ StatusCode MbtsHypoTool::initialize()
 	return StatusCode::SUCCESS;
 }
 
-StatusCode MbtsHypoTool::decide(MBTSInfo &info) const
+StatusCode MbtsHypoTool::decide(MbtsHypoInfo &info) const
 {
 	ATH_MSG_DEBUG("Executing this T2MbtsHypo " << name());
 
@@ -32,7 +32,7 @@ StatusCode MbtsHypoTool::decide(MBTSInfo &info) const
 	Counts counts = calculateMultiplicities(info.mbtsBits);
 	if ( counts.sideA == 0 && counts.sideC == 0)
 	{
-		ATH_MSG_DEBUG("calculateMultiplicities failed");
+		ATH_MSG_DEBUG("calculateMultiplicities failed, no multiplicities");
 		return StatusCode::SUCCESS;
 	}
 	bool pass = false;
diff --git a/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoTool.h b/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoTool.h
index 12a99f71dc49..064240617285 100644
--- a/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoTool.h
+++ b/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoTool.h
@@ -7,6 +7,7 @@ Copyright! (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 #include "Gaudi/Property.h"
 #include "AthenaBaseComps/AthAlgTool.h"
 #include "TrigCompositeUtils/HLTIdentifier.h"
+#include "AthenaMonitoringKernel/GenericMonitoringTool.h"
 #include "TrigCompositeUtils/TrigCompositeUtils.h"
 #include "xAODTrigMinBias/TrigT2MbtsBits.h"
 
@@ -19,15 +20,14 @@ public:
 
   virtual StatusCode initialize() override;
 
-  struct MBTSInfo
+  struct MbtsHypoInfo
   {
-    TrigCompositeUtils::Decision *decision;
-    // do not know yet what is needed
-    const xAOD::TrigT2MbtsBits *mbtsBits;
     const TrigCompositeUtils::DecisionIDContainer previousDecisionIDs;
+    const xAOD::TrigT2MbtsBits *mbtsBits;
+    TrigCompositeUtils::Decision *decision;
   };
 
-  StatusCode decide(MBTSInfo &decisions) const;
+  StatusCode decide(MbtsHypoInfo &decisions) const;
 
 private:
   bool applyCut(const Gaudi::Property<int> &threshold, const xAOD::TrigComposite *composit) const;
diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/MinBias/MinBiasChainConfiguration.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/MinBias/MinBiasChainConfiguration.py
index b950dde45daa..c810512fa5c5 100644
--- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/MinBias/MinBiasChainConfiguration.py
+++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/MinBias/MinBiasChainConfiguration.py
@@ -6,7 +6,7 @@ log = logging.getLogger( __name__ )
 
 
 from TriggerMenuMT.HLTMenuConfig.Menu.ChainConfigurationBase import ChainConfigurationBase
-from TriggerMenuMT.HLTMenuConfig.MinBias.MinBiasMenuSequences import MinBiasSPSequence, MinBiasTrkSequence, MinBiasMBTSSequence 
+from TriggerMenuMT.HLTMenuConfig.MinBias.MinBiasMenuSequences import MinBiasSPSequence, MinBiasTrkSequence, MinBiasMbtsSequence 
 
 #----------------------------------------------------------------
 # fragments generating configuration will be functions in New JO,
@@ -19,8 +19,8 @@ def MinBiasTrkSequenceCfg(flags):
     return MinBiasTrkSequence()
 
 
-def MinBiasMBTSSequenceCfg(flags):
-    return MinBiasMBTSSequence()
+def MinBiasMbtsSequenceCfg(flags):
+    return MinBiasMbtsSequence()
 
 
 class MinBiasChainConfig(ChainConfigurationBase):
@@ -35,7 +35,7 @@ class MinBiasChainConfig(ChainConfigurationBase):
         log.debug("Assembling chain for %s", self.chainName)
         steps = []
         if "_mbts" in self.chainName:
-            pass
+            steps.append(self.getMinBiasMbtsStep())
 
         if "_sp" in self.chainName:
             steps.append(self.getMinBiasSpStep())
@@ -46,8 +46,8 @@ class MinBiasChainConfig(ChainConfigurationBase):
 
         return self.buildChain(steps)
 
-    def getMBTSStep(self):
-        return self.getStep(1, 'MBTS',[MinBiasMBTSSequenceCfg])
+    def getMinBiasMbtsStep(self):
+        return self.getStep(1, 'Mbts',[MinBiasMbtsSequenceCfg])
     
     def getMinBiasSpStep(self):
         return self.getStep(2,'SPCount',[MinBiasSPSequenceCfg])
diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/MinBias/MinBiasMenuSequences.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/MinBias/MinBiasMenuSequences.py
index 973beffea059..6e8424d7e9fd 100644
--- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/MinBias/MinBiasMenuSequences.py
+++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/MinBias/MinBiasMenuSequences.py
@@ -124,22 +124,30 @@ def MinBiasTrkSequence():
                             Hypo        = trackCountHypo,
                             HypoToolGen = TrackCountHypoToolGen)
 
-def MinBiasMBTSSequence():
-    from TrigT2MinBias.TrigT2MinBiasConf import MbtsFexMT
-    MBTSRecoSeq = parOR("MBTSRecoSeq", [MbtsFexMT()])
-
-    MBTSInputMakerAlg = EventViewCreatorAlgorithm("IM_MBTSEventViewCreator")
-    MBTSInputMakerAlg.ViewFallThrough = True
-    MBTSInputMakerAlg.RoITool = ViewCreatorInitialROITool()
-    MBTSInputMakerAlg.InViewRoIs = "InputRoI" # contract with the consumer
-    MBTSInputMakerAlg.Views = "MBTSView"
-    MBTSInputMakerAlg.RequireParentView = True
-    MBTSInputMakerAlg.ViewNodeName = MBTSRecoSeq.name()
-    MBTSSequence = seqAND("MBTSSequence", [MBTSInputMakerAlg, MBTSRecoSeq])
-
-    
-
-    return MenuSequence(Sequence    = MBTSSequence,
-                        Maker       = MBTSInputMakerAlg,
-                        Hypo        = MBTSHypo,
-                        HypoToolGen = MBTSHypoToolGen)
\ No newline at end of file
+def MinBiasMbtsSequence():
+    from TrigT2MinBias.TrigT2MinBiasConf import MbtsHypoAlg, MbtsHypoTool
+    from TrigT2MinBias.MbtsConfig import MbtsFexMTCfg
+    fex = MbtsFexMTCfg(MbtsBitsKey="HLT_MbtsBitsContainer")
+    MbtsRecoSeq = parOR("MbtsRecoSeq", [fex])
+
+    from DecisionHandling.DecisionHandlingConf import InputMakerForRoI, ViewCreatorInitialROITool
+    MbtsInputMakerAlg = InputMakerForRoI("IM_Mbts", 
+                                        RoIsLink="initialRoI", 
+                                        RoITool = ViewCreatorInitialROITool(),
+                                        RoIs='MbtsRoI', # not used in fact
+                                        )
+
+#InputMakerAlg.InputMakerInputDecisions=[mapThresholdToL1DecisionCollection("XE")]
+#InputMakerAlg.InputMakerOutputDecisions="InputMaker_from_L1MET"
+
+    MbtsSequence = seqAND("MbtsSequence", [MbtsInputMakerAlg, MbtsRecoSeq])
+
+    hypo = MbtsHypoAlg("MbtsHypoAlg", MbtsBitsKey=fex.MbtsBitsKey)
+
+    def hypoToolGen(chainDict):
+        return MbtsHypoTool(chainDict["chainName"]) # to now no additional settings
+
+    return MenuSequence(Sequence    = MbtsSequence,
+                        Maker       = MbtsInputMakerAlg,
+                        Hypo        = hypo,
+                        HypoToolGen = hypoToolGen)
\ No newline at end of file
-- 
GitLab


From 306b9012205bfe8bbdfbf38de52f6351ef78ca59 Mon Sep 17 00:00:00 2001
From: Tomasz Bold <tomasz.bold@gmail.com>
Date: Thu, 4 Feb 2021 10:50:53 +0100
Subject: [PATCH 5/8] Completed Mbts chain & updated references

---
 .../TrigT2MinBias/src/MbtsHypoAlg.cxx             | 15 +++++++--------
 .../TrigT2MinBias/src/MbtsHypoAlg.h               |  9 +++++----
 .../TrigT2MinBias/src/MbtsHypoTool.cxx            |  4 ++--
 .../TrigT2MinBias/src/MbtsHypoTool.h              | 11 ++++++-----
 .../share/ref_RDOtoRDOTrig_v1Dev_build.ref        |  2 ++
 .../TriggerTest/share/ref_data_v1Dev_build.ref    |  6 ++++++
 6 files changed, 28 insertions(+), 19 deletions(-)

diff --git a/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoAlg.cxx b/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoAlg.cxx
index f75fb2b277fb..a41fa26c343a 100644
--- a/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoAlg.cxx
+++ b/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoAlg.cxx
@@ -11,8 +11,8 @@ using TrigCompositeUtils::hypoAlgNodeName;
 using TrigCompositeUtils::linkToPrevious;
 using TrigCompositeUtils::newDecisionIn;
 
-MbtsHypoAlg::MbtsHypoAlg(const std::string& name, ISvcLocator* pSvcLocator) 
-  : ::HypoBase(name, pSvcLocator)
+MbtsHypoAlg::MbtsHypoAlg(const std::string &name, ISvcLocator *pSvcLocator)
+    : ::HypoBase(name, pSvcLocator)
 {
 }
 
@@ -33,7 +33,7 @@ StatusCode MbtsHypoAlg::finalize()
   return StatusCode::SUCCESS;
 }
 
-StatusCode MbtsHypoAlg::execute(const EventContext& context) const
+StatusCode MbtsHypoAlg::execute(const EventContext &context) const
 {
   ATH_MSG_DEBUG("Executing ...");
 
@@ -50,13 +50,12 @@ StatusCode MbtsHypoAlg::execute(const EventContext& context) const
   auto d = newDecisionIn(decisions, hypoAlgNodeName());
   linkToPrevious(d, decisionInput().key(), 0);
 
+  MbtsHypoTool::MbtsHypoInfo info = {prev, bitsHandle.cptr()->at(0), d};
 
-  MbtsHypoTool::MbtsHypoInfo info = { prev, bitsHandle.cptr()->at(0),  d};
-
-  for ( const auto& tool : m_hypoTools ) {
+  for (const auto &tool : m_hypoTools)
+  {
     ATH_CHECK(tool->decide(info));
   }
 
-  return StatusCode::SUCCESS;  
+  return StatusCode::SUCCESS;
 }
-
diff --git a/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoAlg.h b/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoAlg.h
index 3095833c45d9..aff8d91d9024 100644
--- a/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoAlg.h
+++ b/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoAlg.h
@@ -13,15 +13,16 @@
 
 /**
  * @class MbtsHypoAlg
- * @brief 
+ * @brief
  **/
-class MbtsHypoAlg : public ::HypoBase {
+class MbtsHypoAlg : public ::HypoBase
+{
 public:
-  MbtsHypoAlg(const std::string& name, ISvcLocator* pSvcLocator);
+  MbtsHypoAlg(const std::string &name, ISvcLocator *pSvcLocator);
   virtual ~MbtsHypoAlg() override;
 
   virtual StatusCode initialize() override;
-  virtual StatusCode execute(const EventContext& context) const override;
+  virtual StatusCode execute(const EventContext &context) const override;
   virtual StatusCode finalize() override;
 
 private:
diff --git a/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoTool.cxx b/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoTool.cxx
index 39ce51b0d04a..f9d341d96450 100644
--- a/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoTool.cxx
+++ b/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoTool.cxx
@@ -30,7 +30,7 @@ StatusCode MbtsHypoTool::decide(MbtsHypoInfo &info) const
 
 	// Calculate MBTS counter multiplicities after energy and an optional time cut.
 	Counts counts = calculateMultiplicities(info.mbtsBits);
-	if ( counts.sideA == 0 && counts.sideC == 0)
+	if (counts.sideA == 0 && counts.sideC == 0)
 	{
 		ATH_MSG_DEBUG("calculateMultiplicities failed, no multiplicities");
 		return StatusCode::SUCCESS;
@@ -81,7 +81,7 @@ StatusCode MbtsHypoTool::decide(MbtsHypoInfo &info) const
 
 	ATH_MSG_DEBUG("REGTEST: event " << (pass ? "accepted" : "failed") << " with EBA(" << counts.sideA << ") + EBC(" << counts.sideC << ") hits above threshold.");
 
-	if ( pass ) 
+	if (pass)
 	{
 		addDecisionID(m_decisionId.numeric(), info.decision);
 		ATH_MSG_DEBUG("REGTEST event accepted");
diff --git a/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoTool.h b/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoTool.h
index 064240617285..918e25b1e400 100644
--- a/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoTool.h
+++ b/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoTool.h
@@ -43,18 +43,19 @@ private:
   Gaudi::Property<bool> m_veto{this, "Veto", false, "Flag to select lowe than threshold multiplicities"};
 
   Gaudi::Property<int> m_mbtsmode{this, "MBTSMode", 0, "Flag to count multiplicities only on inner or outer MBTS modules (see T2MBTSUtils) "};
-      
-  Gaudi::Property<float> m_threshold{this, "Threshold", 40.0/222.0, "Energy threshold in pC"};
+
+  Gaudi::Property<float> m_threshold{this, "Threshold", 40.0 / 222.0, "Energy threshold in pC"};
 
   Gaudi::Property<float> m_timeCut{this, "TimeCut", -1.0, "A time cut in ns.  Values <= 0 disable the time cut"};
 
   Gaudi::Property<float> m_globalTimeOffset{this, "GlobalTimeOffset", 0, "A global time offset in ns about which the time window cuts"};
-  
+
   Gaudi::Property<std::vector<float>> m_timeOffsets{this, "TimeOffset", std::vector<float>(32), "Offsets with respect to the global offset of all counters. (A0-15 then C0-C15) "};
 
   ToolHandle<GenericMonitoringTool> m_monTool{this, "MonTool", "", "Monitoring tool"};
-  struct Counts{
-    size_t sideA; 
+  struct Counts
+  {
+    size_t sideA;
     size_t sideC;
   };
   Counts calculateMultiplicities(const xAOD::TrigT2MbtsBits *t2mbtsBits) const;
diff --git a/Trigger/TrigValidation/TrigAnalysisTest/share/ref_RDOtoRDOTrig_v1Dev_build.ref b/Trigger/TrigValidation/TrigAnalysisTest/share/ref_RDOtoRDOTrig_v1Dev_build.ref
index 0e3f6e3c9181..3d0dc3fa6239 100644
--- a/Trigger/TrigValidation/TrigAnalysisTest/share/ref_RDOtoRDOTrig_v1Dev_build.ref
+++ b/Trigger/TrigValidation/TrigAnalysisTest/share/ref_RDOtoRDOTrig_v1Dev_build.ref
@@ -2272,6 +2272,8 @@ HLT_larnoiseburst_L1XE60:
     0: 6
   stepFeatures:
     0: 6
+HLT_mb_mbts_L1MBTS_1_EMPTY:
+  eventCount: 0
 HLT_mb_sp_L1RD0_FILLED:
   eventCount: 0
 HLT_mb_sptrk_L1RD0_FILLED:
diff --git a/Trigger/TrigValidation/TriggerTest/share/ref_data_v1Dev_build.ref b/Trigger/TrigValidation/TriggerTest/share/ref_data_v1Dev_build.ref
index 23f4bfbc4d27..08d6c0050bd0 100644
--- a/Trigger/TrigValidation/TriggerTest/share/ref_data_v1Dev_build.ref
+++ b/Trigger/TrigValidation/TriggerTest/share/ref_data_v1Dev_build.ref
@@ -1204,6 +1204,12 @@ HLT_j85_pf_ftf_L1J20:
     1: 3
 HLT_larnoiseburst_L1XE60:
   eventCount: 0
+HLT_mb_mbts_L1MBTS_1_EMPTY:
+  eventCount: 9
+  stepCounts:
+    0: 9
+  stepFeatures:
+    0: 9
 HLT_mb_sp_L1RD0_FILLED:
   eventCount: 20
   stepCounts:
-- 
GitLab


From 1e4899ec2fddae63ba529b3e88533685b99c7f08 Mon Sep 17 00:00:00 2001
From: Tomasz Bold <tomasz.bold@gmail.com>
Date: Fri, 5 Feb 2021 12:19:06 +0100
Subject: [PATCH 6/8] Updated references

---
 .../TriggerTest/share/ref_data_v1Dev_build.ref       | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/Trigger/TrigValidation/TriggerTest/share/ref_data_v1Dev_build.ref b/Trigger/TrigValidation/TriggerTest/share/ref_data_v1Dev_build.ref
index 2f1e92b40683..8e1094617277 100644
--- a/Trigger/TrigValidation/TriggerTest/share/ref_data_v1Dev_build.ref
+++ b/Trigger/TrigValidation/TriggerTest/share/ref_data_v1Dev_build.ref
@@ -1224,12 +1224,6 @@ HLT_j85_pf_ftf_L1J20:
     1: 3
 HLT_larnoiseburst_L1XE60:
   eventCount: 0
-HLT_mb_mbts_L1MBTS_1_EMPTY:
-  eventCount: 9
-  stepCounts:
-    0: 9
-  stepFeatures:
-    0: 9
 HLT_larpebcalib_LArPEBCalib_L1RD0_BGRP11:
   eventCount: 20
   stepCounts:
@@ -1242,6 +1236,12 @@ HLT_larpebcalib_LArPEBCalib_L1RD0_EMPTY:
     0: 20
   stepFeatures:
     0: 20
+HLT_mb_mbts_L1MBTS_1_EMPTY:
+  eventCount: 9
+  stepCounts:
+    0: 9
+  stepFeatures:
+    0: 9
 HLT_mb_sp_L1RD0_FILLED:
   eventCount: 20
   stepCounts:
-- 
GitLab


From 172197223da8f27190149a6d2d142037c795eb28 Mon Sep 17 00:00:00 2001
From: Tomasz Bold <tomasz.bold@gmail.com>
Date: Fri, 5 Feb 2021 17:02:45 +0100
Subject: [PATCH 7/8] Post review fixes

---
 Trigger/TrigAlgorithms/TrigT2MinBias/python/MbtsConfig.py    | 2 +-
 Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoTool.cxx    | 4 ++--
 Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoTool.h      | 2 +-
 .../python/HLTMenuConfig/MinBias/MinBiasMenuSequences.py     | 5 +----
 4 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/Trigger/TrigAlgorithms/TrigT2MinBias/python/MbtsConfig.py b/Trigger/TrigAlgorithms/TrigT2MinBias/python/MbtsConfig.py
index 2213130142d8..827e19e8e38f 100644
--- a/Trigger/TrigAlgorithms/TrigT2MinBias/python/MbtsConfig.py
+++ b/Trigger/TrigAlgorithms/TrigT2MinBias/python/MbtsConfig.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
+# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 from TrigT2MinBias.TrigT2MinBiasConf import MbtsFexMT
 from TrigT2MinBias.TrigT2MinBiasMonitoringMT import MbtsFexMTMonitoring
 
diff --git a/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoTool.cxx b/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoTool.cxx
index f9d341d96450..1a4109078cf9 100644
--- a/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoTool.cxx
+++ b/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoTool.cxx
@@ -1,6 +1,6 @@
 
 /*
-Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #include "TrigCompositeUtils/HLTIdentifier.h"
@@ -145,7 +145,7 @@ MbtsHypoTool::Counts MbtsHypoTool::calculateMultiplicities(const xAOD::TrigT2Mbt
 		}
 
 		// Check the time cut if it is active.
-		if (m_timeCut >= 0 && fabs(triggerTimes[ibit] - m_timeOffsets[ibit] - m_globalTimeOffset) >= m_timeCut)
+		if (m_timeCut >= 0 && std::abs(triggerTimes[ibit] - m_timeOffsets[ibit] - m_globalTimeOffset) >= m_timeCut)
 			continue;
 
 		// Set the bits for this side;
diff --git a/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoTool.h b/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoTool.h
index 918e25b1e400..16d2cbbc7734 100644
--- a/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoTool.h
+++ b/Trigger/TrigAlgorithms/TrigT2MinBias/src/MbtsHypoTool.h
@@ -1,5 +1,5 @@
 /*
-Copyright! (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
+Copyright! (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 #ifndef TRIGT2MINBIAS_MbtsHypoTool_H
 #define TRIGT2MINBIAS_MbtsHypoTool_H
diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/MinBias/MinBiasMenuSequences.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/MinBias/MinBiasMenuSequences.py
index 6e8424d7e9fd..a413a94a9ab6 100644
--- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/MinBias/MinBiasMenuSequences.py
+++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/MinBias/MinBiasMenuSequences.py
@@ -1,5 +1,5 @@
 #
-#  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
+#  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 #
 from TriggerMenuMT.HLTMenuConfig.Menu.MenuComponents import MenuSequence
 from AthenaCommon.CFElements import parOR
@@ -137,9 +137,6 @@ def MinBiasMbtsSequence():
                                         RoIs='MbtsRoI', # not used in fact
                                         )
 
-#InputMakerAlg.InputMakerInputDecisions=[mapThresholdToL1DecisionCollection("XE")]
-#InputMakerAlg.InputMakerOutputDecisions="InputMaker_from_L1MET"
-
     MbtsSequence = seqAND("MbtsSequence", [MbtsInputMakerAlg, MbtsRecoSeq])
 
     hypo = MbtsHypoAlg("MbtsHypoAlg", MbtsBitsKey=fex.MbtsBitsKey)
-- 
GitLab


From c727062039a4bf7990576d39c7f56714a2223e32 Mon Sep 17 00:00:00 2001
From: Tomasz Bold <tomasz.bold@gmail.com>
Date: Fri, 5 Feb 2021 19:22:12 +0100
Subject: [PATCH 8/8] Disable chain running in MC

---
 .../TriggerMenuMT/python/HLTMenuConfig/Menu/LS2_v1.py           | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/LS2_v1.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/LS2_v1.py
index bb516e9df8e0..d9d8d9538493 100644
--- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/LS2_v1.py
+++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/LS2_v1.py
@@ -564,7 +564,7 @@ def setupMenu():
         ChainProp(name='HLT_beamspot_allTE_trkfast_BeamSpotPEB_L1J15',  l1SeedThresholds=['FSNOSEED'], stream=['BeamSpot'], groups=['PS:Online', 'RATE:BeamSpot',  'BW:BeamSpot']),
     ]
     TriggerFlags.MinBiasSlice.signatures   = TriggerFlags.MinBiasSlice.signatures() + [
-        ChainProp(name="HLT_mb_mbts_L1MBTS_1_EMPTY", l1SeedThresholds=['FSNOSEED'], stream=[PhysicsStream], groups=MinBiasGroup) #TODO - need item in FILLED BC item
+        ChainProp(name="HLT_mb_mbts_L1MBTS_1_EMPTY", l1SeedThresholds=['FSNOSEED'], stream=[PhysicsStream], groups=MinBiasGroup+['PS:Online']) #TODO - need item in FILLED BC item
         # ChainProp(name='HLT_mb_sp400_trk40_hmt_L1RD0_FILLED',        l1SeedThresholds=['FSNOSEED'], stream=[PhysicsStream], groups=MinBiasGroup),
         # ChainProp(name='HLT_mb_sp600_trk45_hmt_L1RD0_FILLED',        l1SeedThresholds=['FSNOSEED'], stream=[PhysicsStream], groups=MinBiasGroup),
     ]
-- 
GitLab