From c3218683c6043a4ffd94aa11c5c0cb72c47572b5 Mon Sep 17 00:00:00 2001 From: Tim Martin <Tim.Martin@cern.ch> Date: Thu, 5 Aug 2021 14:33:02 +0200 Subject: [PATCH 1/4] Add ModeOR and EnableOverride flags to ComboHypoTool base --- .../DecisionHandling/ComboHypoToolBase.h | 8 ++++ .../DecisionHandling/src/ComboHypo.cxx | 1 + .../src/ComboHypoToolBase.cxx | 38 +++++++++++++++++-- 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/Trigger/TrigSteer/DecisionHandling/DecisionHandling/ComboHypoToolBase.h b/Trigger/TrigSteer/DecisionHandling/DecisionHandling/ComboHypoToolBase.h index 210376495642..2ca8d6f1ffaa 100644 --- a/Trigger/TrigSteer/DecisionHandling/DecisionHandling/ComboHypoToolBase.h +++ b/Trigger/TrigSteer/DecisionHandling/DecisionHandling/ComboHypoToolBase.h @@ -28,6 +28,8 @@ class ComboHypoToolBase : public extends<AthAlgTool, IComboHypoTool> { public: ComboHypoToolBase(const std::string& type, const std::string& name, const IInterface* parent); + virtual StatusCode initialize() override; + /** * @brief retrieves the decisions associated to this decId, make their combinations and apply the algorithm * @param[in] LegDecisionsMap that lists all the passing decisions, to be updated by the tool depending on the outcome of executeAlg @@ -108,6 +110,12 @@ public: Gaudi::Property<size_t> m_combinationsThresholdBreak {this, "CombinationsThresholdBreak", 10000, "Events processing this many combinations will generate a second WARNING message, and the loop over combinations will be terminated at this point."}; + + Gaudi::Property<bool> m_modeOR {this, "ModeOR", true, + "Accepts based on the logical OR over all calls to executeAlg. If this flag is set to false then the logical AND is required instead."}; + + Gaudi::Property<bool> m_enableOverride {this, "EnableOverride", false, + "Stops processing combinations as soon as a valid combination is found, this is to save CPU. This flag can only be set to true in modeOR."}; // TODO - add optional write out of the data stored in passingCombinations in the decide function. diff --git a/Trigger/TrigSteer/DecisionHandling/src/ComboHypo.cxx b/Trigger/TrigSteer/DecisionHandling/src/ComboHypo.cxx index 716acc08b505..b2f0ae5eb907 100644 --- a/Trigger/TrigSteer/DecisionHandling/src/ComboHypo.cxx +++ b/Trigger/TrigSteer/DecisionHandling/src/ComboHypo.cxx @@ -35,6 +35,7 @@ StatusCode ComboHypo::initialize() { } for (auto& tool: m_hypoTools ) { + ATH_CHECK(tool->initialize()); ATH_CHECK(tool->setLegMultiplicity(m_multiplicitiesReqMap)); } diff --git a/Trigger/TrigSteer/DecisionHandling/src/ComboHypoToolBase.cxx b/Trigger/TrigSteer/DecisionHandling/src/ComboHypoToolBase.cxx index e9e9dca08831..8e953ed8fefd 100644 --- a/Trigger/TrigSteer/DecisionHandling/src/ComboHypoToolBase.cxx +++ b/Trigger/TrigSteer/DecisionHandling/src/ComboHypoToolBase.cxx @@ -13,6 +13,14 @@ ComboHypoToolBase::ComboHypoToolBase(const std::string& type, const std::string& {} +StatusCode ComboHypoToolBase::initialize() { + if (m_enableOverride and not m_modeOR) { + ATH_MSG_ERROR("EnableOverride mode is only available for a logical OR ComboHypoTool"); + return StatusCode::FAILURE; + } + return StatusCode::SUCCESS; +} + StatusCode ComboHypoToolBase::setLegMultiplicity(const Combo::MultiplicityReqMap& multiplicityRequiredMap) { const std::string nameOfToolsChain = m_decisionId.name(); const Combo::MultiplicityReqMap::const_iterator it = multiplicityRequiredMap.find(nameOfToolsChain); @@ -101,17 +109,21 @@ StatusCode ComboHypoToolBase::decide(Combo::LegDecisionsMap& passingLegs, const } } + ++iterations; + try { if (executeAlg(combinationToCheck)) { ATH_MSG_DEBUG("Combination " << iterations << " decided to be passing"); passingCombinations.push_back(combinationToCheck); + if (m_enableOverride) { + break; + } } } catch (std::exception& e) { ATH_MSG_ERROR(e.what()); return StatusCode::FAILURE; } - ++iterations; if ((iterations >= m_combinationsThresholdWarn && warnings == 0) or (iterations >= m_combinationsThresholdBreak)) { ATH_MSG_WARNING("Have so far processed " << iterations << " combinations for " << m_decisionId << " in this event, " << passingCombinations.size() << " passing."); ++warnings; @@ -123,8 +135,28 @@ StatusCode ComboHypoToolBase::decide(Combo::LegDecisionsMap& passingLegs, const } while (nucg); - ATH_MSG_DEBUG("Passing " << passingCombinations.size() << " combinations out of " << iterations << ", " - << m_decisionId << (passingCombinations.size() ? " **ACCEPTS**" : " **REJECTS**") << " this event."); + + if (m_modeOR) { + + ATH_MSG_DEBUG("Passing " << passingCombinations.size() << " combinations out of " << iterations << ", " + << m_decisionId << (passingCombinations.size() ? " **ACCEPTS**" : " **REJECTS**") << " this event based on OR logic."); + + if (m_enableOverride) { + ATH_MSG_DEBUG("Note: stopped after the first successful combination due to the EnableOverride flag."); + } + + } else { // modeAND + + const bool passAll = (passingCombinations.size() == iterations); + + ATH_MSG_DEBUG("Passing " << passingCombinations.size() << " combinations out of " << iterations << ", " + << m_decisionId << (passAll ? " **ACCEPTS**" : " **REJECTS**") << " this event based on AND logic."); + + if (not passAll) { + passingCombinations.clear(); + } + + } if (not passingCombinations.empty()) { // need partial erasure of the decsions (only those not present in any combination) updateLegDecisionsMap(passingCombinations, passingLegs); -- GitLab From 2133028eb1a8b9ad51fc09216e7586f69cc5cfb5 Mon Sep 17 00:00:00 2001 From: Tim Martin <Tim.Martin@cern.ch> Date: Thu, 5 Aug 2021 17:15:44 +0200 Subject: [PATCH 2/4] Print correct index for current iteration to pass unit test --- .../DecisionHandling/ComboHypoToolBase.h | 2 +- .../src/ComboHypoToolBase.cxx | 20 +++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Trigger/TrigSteer/DecisionHandling/DecisionHandling/ComboHypoToolBase.h b/Trigger/TrigSteer/DecisionHandling/DecisionHandling/ComboHypoToolBase.h index 2ca8d6f1ffaa..5d32e3b6a54f 100644 --- a/Trigger/TrigSteer/DecisionHandling/DecisionHandling/ComboHypoToolBase.h +++ b/Trigger/TrigSteer/DecisionHandling/DecisionHandling/ComboHypoToolBase.h @@ -115,7 +115,7 @@ public: "Accepts based on the logical OR over all calls to executeAlg. If this flag is set to false then the logical AND is required instead."}; Gaudi::Property<bool> m_enableOverride {this, "EnableOverride", false, - "Stops processing combinations as soon as a valid combination is found, this is to save CPU. This flag can only be set to true in modeOR."}; + "Stops processing combinations as soon as a valid combination is found in OR mode, or as soon as an invalid combination is found in AND mode. This is to save CPU."}; // TODO - add optional write out of the data stored in passingCombinations in the decide function. diff --git a/Trigger/TrigSteer/DecisionHandling/src/ComboHypoToolBase.cxx b/Trigger/TrigSteer/DecisionHandling/src/ComboHypoToolBase.cxx index 8e953ed8fefd..1a97e3ac2cb2 100644 --- a/Trigger/TrigSteer/DecisionHandling/src/ComboHypoToolBase.cxx +++ b/Trigger/TrigSteer/DecisionHandling/src/ComboHypoToolBase.cxx @@ -13,14 +13,6 @@ ComboHypoToolBase::ComboHypoToolBase(const std::string& type, const std::string& {} -StatusCode ComboHypoToolBase::initialize() { - if (m_enableOverride and not m_modeOR) { - ATH_MSG_ERROR("EnableOverride mode is only available for a logical OR ComboHypoTool"); - return StatusCode::FAILURE; - } - return StatusCode::SUCCESS; -} - StatusCode ComboHypoToolBase::setLegMultiplicity(const Combo::MultiplicityReqMap& multiplicityRequiredMap) { const std::string nameOfToolsChain = m_decisionId.name(); const Combo::MultiplicityReqMap::const_iterator it = multiplicityRequiredMap.find(nameOfToolsChain); @@ -113,9 +105,13 @@ StatusCode ComboHypoToolBase::decide(Combo::LegDecisionsMap& passingLegs, const try { if (executeAlg(combinationToCheck)) { - ATH_MSG_DEBUG("Combination " << iterations << " decided to be passing"); + ATH_MSG_DEBUG("Combination " << (iterations - 1) << " decided to be passing"); passingCombinations.push_back(combinationToCheck); - if (m_enableOverride) { + if (m_modeOR == true and m_enableOverride) { + break; + } + } else { // the combination failed + if (m_modeOR == false and m_enableOverride) { break; } } @@ -152,6 +148,10 @@ StatusCode ComboHypoToolBase::decide(Combo::LegDecisionsMap& passingLegs, const ATH_MSG_DEBUG("Passing " << passingCombinations.size() << " combinations out of " << iterations << ", " << m_decisionId << (passAll ? " **ACCEPTS**" : " **REJECTS**") << " this event based on AND logic."); + if (m_enableOverride) { + ATH_MSG_DEBUG("Note: stopped after the first failed combination due to the EnableOverride flag."); + } + if (not passAll) { passingCombinations.clear(); } -- GitLab From 207af8195ebb3e71eea9967588e64e5a6faa4165 Mon Sep 17 00:00:00 2001 From: Tim Martin <tim.martin@cern.ch> Date: Thu, 5 Aug 2021 16:49:32 +0000 Subject: [PATCH 3/4] Remove unnecessary initialization --- .../DecisionHandling/DecisionHandling/ComboHypoToolBase.h | 2 -- Trigger/TrigSteer/DecisionHandling/src/ComboHypo.cxx | 1 - 2 files changed, 3 deletions(-) diff --git a/Trigger/TrigSteer/DecisionHandling/DecisionHandling/ComboHypoToolBase.h b/Trigger/TrigSteer/DecisionHandling/DecisionHandling/ComboHypoToolBase.h index 5d32e3b6a54f..183fdf3636e5 100644 --- a/Trigger/TrigSteer/DecisionHandling/DecisionHandling/ComboHypoToolBase.h +++ b/Trigger/TrigSteer/DecisionHandling/DecisionHandling/ComboHypoToolBase.h @@ -28,8 +28,6 @@ class ComboHypoToolBase : public extends<AthAlgTool, IComboHypoTool> { public: ComboHypoToolBase(const std::string& type, const std::string& name, const IInterface* parent); - virtual StatusCode initialize() override; - /** * @brief retrieves the decisions associated to this decId, make their combinations and apply the algorithm * @param[in] LegDecisionsMap that lists all the passing decisions, to be updated by the tool depending on the outcome of executeAlg diff --git a/Trigger/TrigSteer/DecisionHandling/src/ComboHypo.cxx b/Trigger/TrigSteer/DecisionHandling/src/ComboHypo.cxx index b2f0ae5eb907..716acc08b505 100644 --- a/Trigger/TrigSteer/DecisionHandling/src/ComboHypo.cxx +++ b/Trigger/TrigSteer/DecisionHandling/src/ComboHypo.cxx @@ -35,7 +35,6 @@ StatusCode ComboHypo::initialize() { } for (auto& tool: m_hypoTools ) { - ATH_CHECK(tool->initialize()); ATH_CHECK(tool->setLegMultiplicity(m_multiplicitiesReqMap)); } -- GitLab From 71b8b51eb37b78ec03fc59b026395676f84cd366 Mon Sep 17 00:00:00 2001 From: Tim Martin <tim.martin@cern.ch> Date: Fri, 6 Aug 2021 09:41:56 +0000 Subject: [PATCH 4/4] Update test_ComboHypoTool.ref --- .../share/test_ComboHypoTool.ref | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Trigger/TrigSteer/DecisionHandling/share/test_ComboHypoTool.ref b/Trigger/TrigSteer/DecisionHandling/share/test_ComboHypoTool.ref index 34bb158195cb..54c3d83970ef 100644 --- a/Trigger/TrigSteer/DecisionHandling/share/test_ComboHypoTool.ref +++ b/Trigger/TrigSteer/DecisionHandling/share/test_ComboHypoTool.ref @@ -1,5 +1,4 @@ - ApplicationMgr INFO Application Manager Configured successfully EventLoopMgr WARNING Unable to locate service "EventSelector" EventLoopMgr WARNING No events will be processed from external input. @@ -52,7 +51,7 @@ HLT_e25 SUCCESS Next Combination: HLT_e25 SUCCESS -- HLT_e25 ID#3480115263 f:My_ELEC_Container i:1 pT:40 HLT_e25 SUCCESS Next Combination: HLT_e25 SUCCESS -- HLT_e25 ID#3480115263 f:My_ELEC_Container i:2 pT:30 -HLT_e25 DEBUG Passing 1 combinations out of 3, HLT_e25 ID#3480115263 **ACCEPTS** this event. +HLT_e25 DEBUG Passing 1 combinations out of 3, HLT_e25 ID#3480115263 **ACCEPTS** this event based on OR logic. HLT_e25 DEBUG -- Passing combination 0 of 1 HLT_e25 DEBUG -- -- HLT_e25 ID#3480115263 container:HLTNav_Elec, index:0 HLT_e25 DEBUG ComboHypoToolBase: End of HLT_e25 ID#3480115263, passing elements are: @@ -88,7 +87,7 @@ HLT_e25_mu35 SUCCESS -- leg001_HLT_e25_mu35 ID#4271136129 f:My_MUON_Contain HLT_e25_mu35 SUCCESS Next Combination: HLT_e25_mu35 SUCCESS -- leg000_HLT_e25_mu35 ID#2563460054 f:My_ELEC_Container i:2 pT:30 HLT_e25_mu35 SUCCESS -- leg001_HLT_e25_mu35 ID#4271136129 f:My_MUON_Container i:1 pT:40 -HLT_e25_mu35 DEBUG Passing 1 combinations out of 6, HLT_e25_mu35 ID#373038112 **ACCEPTS** this event. +HLT_e25_mu35 DEBUG Passing 1 combinations out of 6, HLT_e25_mu35 ID#373038112 **ACCEPTS** this event based on OR logic. HLT_e25_mu35 DEBUG -- Passing combination 0 of 1 HLT_e25_mu35 DEBUG -- -- leg000_HLT_e25_mu35 ID#2563460054 container:HLTNav_Elec, index:0 HLT_e25_mu35 DEBUG -- -- leg001_HLT_e25_mu35 ID#4271136129 container:HLTNav_Muon, index:0 @@ -120,7 +119,7 @@ HLT_e35_e35 SUCCESS -- leg001_HLT_e35_e35 ID#3593781442 f:My_ELEC_Containe HLT_e35_e35 SUCCESS Next Combination: HLT_e35_e35 SUCCESS -- leg000_HLT_e35_e35 ID#3620307964 f:My_ELEC_Container i:1 pT:40 HLT_e35_e35 SUCCESS -- leg001_HLT_e35_e35 ID#3593781442 f:My_ELEC_Container i:1 pT:40 -HLT_e35_e35 DEBUG Passing 1 combinations out of 4, HLT_e35_e35 ID#3161969949 **ACCEPTS** this event. +HLT_e35_e35 DEBUG Passing 1 combinations out of 4, HLT_e35_e35 ID#3161969949 **ACCEPTS** this event based on OR logic. HLT_e35_e35 DEBUG -- Passing combination 0 of 1 HLT_e35_e35 DEBUG -- -- leg000_HLT_e35_e35 ID#3620307964 container:HLTNav_Elec, index:0 HLT_e35_e35 DEBUG -- -- leg001_HLT_e35_e35 ID#3593781442 container:HLTNav_Elec, index:0 @@ -158,7 +157,7 @@ HLT_2mu15 SUCCESS -- HLT_2mu15 ID#1058481211 f:My_MUON_Container i:3 pT: HLT_2mu15 SUCCESS Next Combination: HLT_2mu15 SUCCESS -- HLT_2mu15 ID#1058481211 f:My_MUON_Container i:2 pT:30 HLT_2mu15 SUCCESS -- HLT_2mu15 ID#1058481211 f:My_MUON_Container i:3 pT:20 -HLT_2mu15 DEBUG Passing 3 combinations out of 6, HLT_2mu15 ID#1058481211 **ACCEPTS** this event. +HLT_2mu15 DEBUG Passing 3 combinations out of 6, HLT_2mu15 ID#1058481211 **ACCEPTS** this event based on OR logic. HLT_2mu15 DEBUG -- Passing combination 0 of 3 HLT_2mu15 DEBUG -- -- HLT_2mu15 ID#1058481211 container:HLTNav_Muon, index:0 HLT_2mu15 DEBUG -- -- HLT_2mu15 ID#1058481211 container:HLTNav_Muon, index:1 @@ -190,7 +189,7 @@ HLT_5mu5 SUCCESS -- HLT_5mu5 ID#1405614769 f:My_MUON_Container i:2 pT:3 HLT_5mu5 SUCCESS -- HLT_5mu5 ID#1405614769 f:My_MUON_Container i:3 pT:20 HLT_5mu5 SUCCESS -- HLT_5mu5 ID#1405614769 f:My_MUON_Container i:4 pT:10 HLT_5mu5 DEBUG Combination 0 decided to be passing -HLT_5mu5 DEBUG Passing 1 combinations out of 1, HLT_5mu5 ID#1405614769 **ACCEPTS** this event. +HLT_5mu5 DEBUG Passing 1 combinations out of 1, HLT_5mu5 ID#1405614769 **ACCEPTS** this event based on OR logic. HLT_5mu5 DEBUG -- Passing combination 0 of 1 HLT_5mu5 DEBUG -- -- HLT_5mu5 ID#1405614769 container:HLTNav_Muon, index:0 HLT_5mu5 DEBUG -- -- HLT_5mu5 ID#1405614769 container:HLTNav_Muon, index:1 @@ -307,7 +306,7 @@ HLT_2e25_3mu15 SUCCESS -- leg000_HLT_2e25_3mu15 ID#3088384102 f:My_ELEC_Conta HLT_2e25_3mu15 SUCCESS -- leg001_HLT_2e25_3mu15 ID#4138555611 f:My_MUON_Container i:1 pT:40 HLT_2e25_3mu15 SUCCESS -- leg001_HLT_2e25_3mu15 ID#4138555611 f:My_MUON_Container i:2 pT:30 HLT_2e25_3mu15 SUCCESS -- leg001_HLT_2e25_3mu15 ID#4138555611 f:My_MUON_Container i:3 pT:20 -HLT_2e25_3mu15 DEBUG Passing 6 combinations out of 12, HLT_2e25_3mu15 ID#270470543 **ACCEPTS** this event. +HLT_2e25_3mu15 DEBUG Passing 6 combinations out of 12, HLT_2e25_3mu15 ID#270470543 **ACCEPTS** this event based on OR logic. HLT_2e25_3mu15 DEBUG -- Passing combination 0 of 6 HLT_2e25_3mu15 DEBUG -- -- leg000_HLT_2e25_3mu15 ID#3088384102 container:HLTNav_Elec, index:0 HLT_2e25_3mu15 DEBUG -- -- leg000_HLT_2e25_3mu15 ID#3088384102 container:HLTNav_Elec, index:1 @@ -620,7 +619,7 @@ HLT_e35_2mu25_4j5 SUCCESS -- leg002_HLT_e35_2mu25_4j5 ID#862137673 f:My_JETS_Con HLT_e35_2mu25_4j5 SUCCESS -- leg002_HLT_e35_2mu25_4j5 ID#862137673 f:My_JETS_Container i:2 pT:30 HLT_e35_2mu25_4j5 SUCCESS -- leg002_HLT_e35_2mu25_4j5 ID#862137673 f:My_JETS_Container i:3 pT:20 HLT_e35_2mu25_4j5 SUCCESS -- leg002_HLT_e35_2mu25_4j5 ID#862137673 f:My_JETS_Container i:4 pT:10 -HLT_e35_2mu25_4j5 DEBUG Passing 8 combinations out of 30, HLT_e35_2mu25_4j5 ID#1056038866 **ACCEPTS** this event. +HLT_e35_2mu25_4j5 DEBUG Passing 8 combinations out of 30, HLT_e35_2mu25_4j5 ID#1056038866 **ACCEPTS** this event based on OR logic. HLT_e35_2mu25_4j5 DEBUG -- Passing combination 0 of 8 HLT_e35_2mu25_4j5 DEBUG -- -- leg000_HLT_e35_2mu25_4j5 ID#572077314 container:HLTNav_Elec, index:0 HLT_e35_2mu25_4j5 DEBUG -- -- leg001_HLT_e35_2mu25_4j5 ID#1863374539 container:HLTNav_Muon, index:0 @@ -957,7 +956,7 @@ HLT_2e35_e45_3m...SUCCESS -- leg002_HLT_2e35_e45_3mu15_mu35_j25 ID#873905799 f:M HLT_2e35_e45_3m...SUCCESS -- leg002_HLT_2e35_e45_3mu15_mu35_j25 ID#873905799 f:My_MUON_Container i:3 pT:20 HLT_2e35_e45_3m...SUCCESS -- leg003_HLT_2e35_e45_3mu15_mu35_j25 ID#1315781797 f:My_MUON_Container i:1 pT:40 HLT_2e35_e45_3m...SUCCESS -- leg004_HLT_2e35_e45_3mu15_mu35_j25 ID#4003323228 f:My_JETS_Container i:2 pT:30 -HLT_2e35_e45_3m... DEBUG Passing 3 combinations out of 24, HLT_2e35_e45_3mu15_mu35_j25 ID#1413975787 **ACCEPTS** this event. +HLT_2e35_e45_3m... DEBUG Passing 3 combinations out of 24, HLT_2e35_e45_3mu15_mu35_j25 ID#1413975787 **ACCEPTS** this event based on OR logic. HLT_2e35_e45_3m... DEBUG -- Passing combination 0 of 3 HLT_2e35_e45_3m... DEBUG -- -- leg000_HLT_2e35_e45_3mu15_mu35_j25 ID#1296237030 container:HLTNav_Elec, index:0 HLT_2e35_e45_3m... DEBUG -- -- leg000_HLT_2e35_e45_3mu15_mu35_j25 ID#1296237030 container:HLTNav_Elec, index:1 -- GitLab