From 7a4d45ef2aaf7800a18230069c5cb2f08ac22ccd Mon Sep 17 00:00:00 2001 From: Giulio Eulisse <10544+ktf@users.noreply.github.com> Date: Tue, 26 May 2026 14:21:21 +0200 Subject: [PATCH] Avoid std::map in EventSelectionModule --- Common/Tools/EventSelectionModule.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Common/Tools/EventSelectionModule.h b/Common/Tools/EventSelectionModule.h index 76e4cde6bd5..6418fc92fec 100644 --- a/Common/Tools/EventSelectionModule.h +++ b/Common/Tools/EventSelectionModule.h @@ -453,10 +453,11 @@ class BcSelectionModule return; // don't do anything in case configuration reported not ok int run = bcs.iteratorAt(0).runNumber(); - // map from GlobalBC to BcId needed to find triggerBc - std::map mapGlobalBCtoBcId; + // sorted vector from GlobalBC to BcId needed to find triggerBc + std::vector> vecGlobalBCtoBcId; + vecGlobalBCtoBcId.reserve(bcs.size()); for (const auto& bc : bcs) { - mapGlobalBCtoBcId[bc.globalBC()] = bc.globalIndex(); + vecGlobalBCtoBcId.emplace_back(bc.globalBC(), bc.globalIndex()); } int triggerBcShift = bcselOpts.confTriggerBcShift; @@ -482,7 +483,10 @@ class BcSelectionModule uint32_t alias{0}; // workaround for pp2022 (trigger info is shifted by -294 bcs) - int32_t triggerBcId = mapGlobalBCtoBcId[bc.globalBC() + triggerBcShift]; + uint64_t triggerBC = bc.globalBC() + triggerBcShift; + auto it = std::lower_bound(vecGlobalBCtoBcId.begin(), vecGlobalBCtoBcId.end(), triggerBC, + [](const std::pair& p, uint64_t val) { return p.first < val; }); + int32_t triggerBcId = (it != vecGlobalBCtoBcId.end() && it->first == triggerBC) ? it->second : 0; if (triggerBcId && aliases) { auto triggerBc = bcs.iteratorAt(triggerBcId); uint64_t triggerMask = triggerBc.triggerMask();