From 996402684fe5cd85c21987105a275838bcc1d4b5 Mon Sep 17 00:00:00 2001 From: sherwood <peter.sherwood@cern.ch> Date: Fri, 30 Oct 2020 15:35:21 +0100 Subject: [PATCH 1/6] Start work on optimizing of how job groups propagate up a hypo tree. Job group propagation is correct but inefficient in the presence of identical conditions. Jet group propagation is currently handled in the following manner. Let a parent condition P have n siblings: S_1... S_n Let J_1... J_2 be the jet groups that pass each of the n siblings. JetGroupProduct finds all the distinct job groups formed by selecting one jet group from is taken fron each of the J_i. Only distinct jet groups are retained. Distinct job groups are those obtained by flattening the JobGroup calculated by the combination process, and discounting differences due to the order of the jets. When the siblings are identical Conditions, the same jets pass each of the conditions. The combination process can be optimized. The optimazation exploits the repetion that is _always_ present for identical Conditions. As an example, let J_1 = J_2 = J_3 = {1,2,3}. Then the combinations are - excluding repeated jets - {1,2,3}, {1,3,2}, {2, 1, 3}, {2, 3, 1}, {3, 1, 2}, {3, 2, 1}. After repetition removal, we are left with {1,2,3}. Further we only need to look at jets passing C_1. This optimatiztion replaces n repeated Conditions of capacity = 1 by a single Condition of capacity n. After initially allocating jets to Conditions, a further test needs now to be made: were there enough distinct jets to satisfy the n conditions - i.e. were there at least n jets fulfilling the condition. To this end, the IConditionMT interface is extended by ICheckedCapacityCondition. This PABC provides a checking function: bool capacitySatisfied(const HypoJetVector&,..) which will be passed the selected jets as an argument. Currently, the sole implementation is CheckedCapacityCondition. This commit uses this CheckedCapacityCondition. However the hypo trees remain as before, and no checks are made. It is therefor expected that they will be no visible effects at this stage. --- .../src/CapacityCheckedCondition.h | 60 +++++++++++++++++++ .../src/CapacityCheckedConditionsDefs.h | 23 +++++++ .../TrigHLTJetHypo/src/FastReducer.cxx | 6 +- .../TrigHLTJetHypo/src/FastReducer.h | 7 ++- .../src/FastReductionMatcher.cxx | 2 +- .../TrigHLTJetHypo/src/FastReductionMatcher.h | 11 ++-- .../src/ICapacityCheckedCondition.h | 37 ++++++++++++ .../TrigJetHypoToolConfig_fastreduction.cxx | 27 ++++++--- .../src/TrigJetHypoToolConfig_fastreduction.h | 6 +- .../src/groupsMatcherFactoryMT.cxx | 2 +- .../src/groupsMatcherFactoryMT.h | 3 +- 11 files changed, 161 insertions(+), 23 deletions(-) create mode 100644 Trigger/TrigHypothesis/TrigHLTJetHypo/src/CapacityCheckedCondition.h create mode 100644 Trigger/TrigHypothesis/TrigHLTJetHypo/src/CapacityCheckedConditionsDefs.h create mode 100644 Trigger/TrigHypothesis/TrigHLTJetHypo/src/ICapacityCheckedCondition.h diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/CapacityCheckedCondition.h b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/CapacityCheckedCondition.h new file mode 100644 index 000000000000..05ae970c2dc8 --- /dev/null +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/CapacityCheckedCondition.h @@ -0,0 +1,60 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRIGHLTJETHYPO_CAPACITYCHECKEDCONDITIONMT_H +#define TRIGHLTJETHYPO_CAPACITYCHECKEDCONDITIONMT_H + +/******************************************************************** + * + * NAME: CapacityCheckedConditionMT.h + * PACKAGE: Trigger/TrigHypothesis/TrigHLTJetHypo + * + * AUTHOR: P. Sherwood + * + * an implementation of the ICapacityCheckedConditionMT PABC. + * + *********************************************************************/ + +#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/HypoJetDefs.h" +#include "ICapacityCheckedCondition.h" + +#include <memory> +#include <string> + + +class ITrigJetHypoInfoCollector; + +class CapacityCheckedCondition: public ICapacityCheckedCondition { + public: + CapacityCheckedCondition(std::unique_ptr<IConditionMT> cp): + m_condition{std::move(cp)} { + } + + virtual ~CapacityCheckedCondition(){ + } + + virtual bool + capacitySatisfied(const HypoJetVector& v, + const std::unique_ptr<ITrigJetHypoInfoCollector>&) const override { + return m_condition -> capacity() <= v.size(); + } + + virtual bool isSatisfied(const HypoJetVector& v, + const std::unique_ptr<ITrigJetHypoInfoCollector>& c) const override { + return m_condition -> isSatisfied(v, c); + } + + virtual unsigned int capacity() const override { + return m_condition -> capacity(); + } + + virtual std::string toString() const noexcept override { + return m_condition -> toString(); + } + + private: + std::unique_ptr<IConditionMT> m_condition; +}; + +#endif diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/CapacityCheckedConditionsDefs.h b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/CapacityCheckedConditionsDefs.h new file mode 100644 index 000000000000..f26ccc1bc85c --- /dev/null +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/CapacityCheckedConditionsDefs.h @@ -0,0 +1,23 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRIGHLTJETHYPO_CAPCACITYCHECKEDCONDITIONSDEFSMT_H +#define TRIGHLTJETHYPO_CAPCACITYCHECKEDCONDITIONSDEFSMT_H +/******************************************************************** + * + * NAME: ConditionsDefs.h + * PACKAGE: Trigger/TrigHypothesis/TrigHLTJetHypo + * + * AUTHOR: P. Sherwood + *********************************************************************/ + +#include <string> +#include <memory> +#include "./ICapacityCheckedCondition.h" + +using ConditionPtr = std::unique_ptr<ICapacityCheckedCondition>; +using ConditionPtrs = std::vector<ConditionPtr>; +using ConditionPtrsIter = ConditionPtrs::iterator; + +#endif diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReducer.cxx b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReducer.cxx index 49c56a2e1377..d06fc94dbcbc 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReducer.cxx +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReducer.cxx @@ -38,7 +38,7 @@ struct IndexVecComp{ FastReducer::FastReducer(const HypoJetGroupCIter& groups_b, const HypoJetGroupCIter& groups_e, - const ConditionsMT& conditions, + const ConditionPtrs& conditions, const Tree& tree, const std::vector<std::vector<int>>& sharedConditions, xAODJetCollector& jetCollector, @@ -328,7 +328,7 @@ bool FastReducer::propagate_(std::size_t child, auto jg_product = JetGroupProduct(siblings, m_satisfiedBy); - // obtain the next product of hob groups passing siblings + // obtain the next product of jet groups passing siblings auto next = jg_product.next(collector); // step through the jet groups found by combining ghe child groups @@ -351,7 +351,7 @@ bool FastReducer::propagate_(std::size_t child, m_jg2elemjgs[i].end()); } - // if any of the elemetal jet group indices are repeated, + // if any of the elemental jet group indices are repeated, // stop processing of the new jet group. (do not allow sharing for // among leaf nodes. Sharing is handled by processing > 1 leaf groups // each of which does not share. diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReducer.h b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReducer.h index 5aba889c93be..2b331ff63f45 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReducer.h +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReducer.h @@ -6,7 +6,8 @@ #define TRIGHLTJETHYPO_FASTREDUCER_H -#include "./ConditionsDefsMT.h" +// #include "./ConditionsDefsMT.h" +#include "./CapacityCheckedConditionsDefs.h" #include "./Tree.h" #include "./JetGroupProduct.h" #include "./JetGroupIndAllocator.h" @@ -30,7 +31,7 @@ class FastReducer { FastReducer(const HypoJetGroupCIter& groups_b, const HypoJetGroupCIter& groups_e, - const ConditionsMT& conditionObjects, + const ConditionPtrs& conditionObjects, const Tree& conditionsTree, const std::vector<std::vector<int>>& sharedConditions, xAODJetCollector& jetCollector, @@ -47,7 +48,7 @@ class FastReducer { private: - const ConditionsMT& m_conditions; + const ConditionPtrs& m_conditions; /** tree structure for Conditions objects. The conditions tree gives relations among conditions (eg parent-child diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReductionMatcher.cxx b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReductionMatcher.cxx index 7f78b0ca100e..4dfffac4ca42 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReductionMatcher.cxx +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReductionMatcher.cxx @@ -12,7 +12,7 @@ -FastReductionMatcher::FastReductionMatcher(ConditionsMT conditions, +FastReductionMatcher::FastReductionMatcher(ConditionPtrs conditions, const Tree& tree, const std::vector<std::vector<int>>& sharedNodes): m_conditions(std::move(conditions)), diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReductionMatcher.h b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReductionMatcher.h index b7fe4d2eb747..e931455ca555 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReductionMatcher.h +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReductionMatcher.h @@ -7,7 +7,8 @@ #include "./IGroupsMatcherMT.h" -#include "./ConditionsDefsMT.h" +//#include "./ConditionsDefsMT.h" +#include "./CapacityCheckedConditionsDefs.h" #include "./Tree.h" using TreeVec = std::vector<std::size_t>; @@ -16,9 +17,9 @@ class ITrigJetHypoInfoCollector; class FastReductionMatcher: public IGroupsMatcherMT { public: - FastReductionMatcher(ConditionsMT, - const Tree&, - const std::vector<std::vector<int>>&); + FastReductionMatcher(ConditionPtrs, + const Tree&, + const std::vector<std::vector<int>>&); /** determine whether a set of jets satisfies all hypo conditions. @@ -42,7 +43,7 @@ class FastReductionMatcher: public IGroupsMatcherMT { private: - ConditionsMT m_conditions; + ConditionPtrs m_conditions; /** tree structure for Conditions objects. The conditions tree gives relations among conditions (eg parent-child diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/ICapacityCheckedCondition.h b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/ICapacityCheckedCondition.h new file mode 100644 index 000000000000..93e2d155a217 --- /dev/null +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/ICapacityCheckedCondition.h @@ -0,0 +1,37 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRIGHLTJETHYPO_ICAPACITYCHECKEDCONDITIONMT_H +#define TRIGHLTJETHYPO_ICAPACITYCHECKEDCONDITIONMT_H + +/******************************************************************** + * + * NAME: ICapacityCheckedConditionMT.h + * PACKAGE: Trigger/TrigHypothesis/TrigHLTJetHypo + * + * AUTHOR: P. Sherwood + * + * extend IConditionMT by adding a method that checks whether the + * capacity of the Condition has been attained. + * + *********************************************************************/ + +#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/HypoJetDefs.h" +#include "IConditionMT.h" + +#include <string> + + +class ITrigJetHypoInfoCollector; + +class ICapacityCheckedCondition: public IConditionMT { + public: + virtual ~ICapacityCheckedCondition(){} + + virtual bool capacitySatisfied(const HypoJetVector&, + const std::unique_ptr<ITrigJetHypoInfoCollector>&) const = 0; + +}; + +#endif diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoToolConfig_fastreduction.cxx b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoToolConfig_fastreduction.cxx index 051697a152ed..4c4e6691b6d2 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoToolConfig_fastreduction.cxx +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoToolConfig_fastreduction.cxx @@ -15,6 +15,7 @@ #include "TrigHLTJetHypo/TrigHLTJetHypoUtils/CleanerFactory.h" #include "TrigHLTJetHypo/TrigHLTJetHypoUtils/TrigHLTJetHypoHelper2.h" #include "./groupsMatcherFactoryMT.h" +#include "./CapacityCheckedCondition.h" #include "TrigCompositeUtils/TrigCompositeUtils.h" @@ -126,20 +127,32 @@ StatusCode TrigJetHypoToolConfig_fastreduction::initialize() { -std::optional<ConditionsMT> -TrigJetHypoToolConfig_fastreduction::getConditions() const { +std::optional<ConditionPtrs> +TrigJetHypoToolConfig_fastreduction::getCapacityCheckedConditions() const { - ConditionsMT conditions; + ConditionPtrs conditions; // collect the Conditions objects from the various sources // return an invalid optional if any src signals a problem + for(const auto& cm : m_conditionMakers){ - conditions.push_back(cm->getCondition()); + conditions.push_back(std::make_unique<CapacityCheckedCondition>(std::move(cm->getCondition()))); } - - return std::make_optional<ConditionsMT>(std::move(conditions)); + + return std::make_optional<ConditionPtrs>(std::move(conditions)); } +std::optional<ConditionsMT> +TrigJetHypoToolConfig_fastreduction::getConditions() const { + /* obtain an unchecked set of conditions */ + + ConditionsMT conditions; + for(const auto& cm : m_conditionMakers){ + conditions.push_back(std::move(cm->getCondition())); + } + + return std::make_optional<ConditionsMT>(std::move(conditions)); +} // following function not used for treeless hypos std::size_t @@ -156,7 +169,7 @@ TrigJetHypoToolConfig_fastreduction::getJetGrouper() const { std::unique_ptr<IGroupsMatcherMT> TrigJetHypoToolConfig_fastreduction::getMatcher () const { - auto opt_conds = getConditions(); + auto opt_conds = getCapacityCheckedConditions(); if(!opt_conds.has_value()){ return std::unique_ptr<IGroupsMatcherMT>(nullptr); diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoToolConfig_fastreduction.h b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoToolConfig_fastreduction.h index 5625120313e9..2e70bf1b8167 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoToolConfig_fastreduction.h +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoToolConfig_fastreduction.h @@ -14,7 +14,7 @@ #include "ITrigJetHypoToolConfig.h" -#include "./ConditionsDefsMT.h" +#include "./CapacityCheckedConditionsDefs.h" #include "TrigCompositeUtils/HLTIdentifier.h" #include "AthenaBaseComps/AthAlgTool.h" #include "TrigCompositeUtils/TrigCompositeUtils.h" @@ -57,6 +57,8 @@ public extends<AthAlgTool, ITrigJetHypoToolConfig> { this, "sharedVector", {}, "nodeID groups for nodes that see input jets"}; std::vector<std::vector<int>> m_sharedNodes{}; - + + std::optional<ConditionPtrs> getCapacityCheckedConditions() const; + }; #endif diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/groupsMatcherFactoryMT.cxx b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/groupsMatcherFactoryMT.cxx index 100bfcc525f3..a580b25257e5 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/groupsMatcherFactoryMT.cxx +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/groupsMatcherFactoryMT.cxx @@ -47,7 +47,7 @@ groupsMatcherFactoryMT_Partitions (ConditionsMT&& conditions){ std::unique_ptr<IGroupsMatcherMT> -groupsMatcherFactoryMT_FastReduction (ConditionsMT&& conditions, +groupsMatcherFactoryMT_FastReduction (ConditionPtrs&& conditions, const std::vector<std::size_t>& treeVec, const std::vector<std::vector<int>>& sharedNodes){ diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/groupsMatcherFactoryMT.h b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/groupsMatcherFactoryMT.h index 5b6d1f1f25cc..1865de3d94bf 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/groupsMatcherFactoryMT.h +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/groupsMatcherFactoryMT.h @@ -7,6 +7,7 @@ #include "./IGroupsMatcherMT.h" #include "./ConditionsDefsMT.h" +#include "./CapacityCheckedConditionsDefs.h" #include <memory> std::unique_ptr<IGroupsMatcherMT> @@ -20,7 +21,7 @@ groupsMatcherFactoryMT_Partitions(ConditionsMT&&); std::unique_ptr<IGroupsMatcherMT> -groupsMatcherFactoryMT_FastReduction(ConditionsMT&&, +groupsMatcherFactoryMT_FastReduction(ConditionPtrs&&, const std::vector<std::size_t>& treeVec, const std::vector<std::vector<int>>&); #endif -- GitLab From f63d87ad96961e01629cf43a721c203e0f26b8f8 Mon Sep 17 00:00:00 2001 From: sherwood <peter.sherwood@cern.ch> Date: Mon, 2 Nov 2020 10:54:26 +0100 Subject: [PATCH 2/6] Add check to ensure coapacity of a condition is reached by the satisfying jet groups. This check is used in particular to ensure that there are suficient jets to satisfy single Conditions wich represent multiple identical conditions. such single Conditions are part of an optimisation to reduce the computation time for identical Conditions. src/ICapacityCheckedCondition.h change the capacitySatisfied method to take a muliplicity (std::size_T) instead of a JetGroup. src/CapacityCheckedCondition.h adjust for interface change src/FastReducer.h,cxx add capacityCheck to findInitialJobGroups() --- .../src/CapacityCheckedCondition.h | 7 +++--- .../TrigHLTJetHypo/src/FastReducer.cxx | 25 +++++++++++++++++++ .../TrigHLTJetHypo/src/FastReducer.h | 2 ++ .../src/ICapacityCheckedCondition.h | 5 ++-- 4 files changed, 34 insertions(+), 5 deletions(-) diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/CapacityCheckedCondition.h b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/CapacityCheckedCondition.h index 05ae970c2dc8..82974e9107fe 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/CapacityCheckedCondition.h +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/CapacityCheckedCondition.h @@ -35,9 +35,10 @@ class CapacityCheckedCondition: public ICapacityCheckedCondition { } virtual bool - capacitySatisfied(const HypoJetVector& v, - const std::unique_ptr<ITrigJetHypoInfoCollector>&) const override { - return m_condition -> capacity() <= v.size(); + capacitySatisfied(std::size_t jgMultiplicity, + const Collector&) const override { + + return m_condition -> capacity() <= jgMultiplicity; } virtual bool isSatisfied(const HypoJetVector& v, diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReducer.cxx b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReducer.cxx index d06fc94dbcbc..6826dbb9a2e9 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReducer.cxx +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReducer.cxx @@ -180,12 +180,21 @@ bool FastReducer::findInitialJetGroups(const std::vector<int>& leaves, } // check all leaf conditions are satisfied + /* for (const auto& i : leaves) { auto& satisfiedBy = m_satisfiedBy.at(i); if (satisfiedBy.empty()) { return false; } } + */ + + // check all leaf conditions are satisfied + for (const auto& i : leaves) { + if (!capacitySatisfied(i, collector)) { + return false; + } + } /* For the special but important case where all leaf nodes have @@ -502,3 +511,19 @@ void FastReducer::recordJetGroup(std::size_t ind, bool FastReducer::pass() const { return m_pass; } + +bool FastReducer::capacitySatisfied(std::size_t ind, + const Collector& collector) const { + // Check that the number of satisfying job groups is sufficient to + // satisfy the capacity of the Condition. Uses include handling + // of Conditions which represent multiple identical conditions. + + auto jgMult = m_satisfiedBy.at(ind).size(); + auto capSat = m_conditions.at(ind) -> capacitySatisfied(jgMult, collector); + if (!capSat and collector) { + collector -> collect("FastReduce", "Condition " + std::to_string(ind) + + " unsatisfied capacity, aborting"); + } + + return capSat; +} diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReducer.h b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReducer.h index 2b331ff63f45..59c0a4d44daa 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReducer.h +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReducer.h @@ -115,6 +115,8 @@ class FastReducer { void collectLeafJets(xAODJetCollector& jetCollector, const Collector& collector) const; + bool capacitySatisfied(std::size_t ind, + const Collector& collector) const; }; #endif diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/ICapacityCheckedCondition.h b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/ICapacityCheckedCondition.h index 93e2d155a217..033ce81570cf 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/ICapacityCheckedCondition.h +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/ICapacityCheckedCondition.h @@ -21,6 +21,7 @@ #include "IConditionMT.h" #include <string> +typedef std::unique_ptr<ITrigJetHypoInfoCollector> Collector; class ITrigJetHypoInfoCollector; @@ -29,8 +30,8 @@ class ICapacityCheckedCondition: public IConditionMT { public: virtual ~ICapacityCheckedCondition(){} - virtual bool capacitySatisfied(const HypoJetVector&, - const std::unique_ptr<ITrigJetHypoInfoCollector>&) const = 0; + virtual bool capacitySatisfied(std::size_t jgMultiplicity, + const Collector&) const = 0; }; -- GitLab From 4e40f58ec4bc08ad482b22c4acec99c7aa8d0604 Mon Sep 17 00:00:00 2001 From: sherwood <peter.sherwood@cern.ch> Date: Tue, 3 Nov 2020 14:32:36 +0100 Subject: [PATCH 3/6] minor syntax changes + dead code removal --- .../python/TrigJetHypoToolConfig.py | 9 ++++---- .../python/testChainDictMaker.py | 21 ++++++++++++++++++- .../src/CapacityCheckedCondition.h | 8 +++---- .../TrigHLTJetHypo/src/FastReducer.cxx | 9 -------- .../TrigHLTJetHypo/src/FastReductionMatcher.h | 1 - 5 files changed, 29 insertions(+), 19 deletions(-) diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/python/TrigJetHypoToolConfig.py b/Trigger/TrigHypothesis/TrigHLTJetHypo/python/TrigJetHypoToolConfig.py index e5a870341f8a..62e5a185c5e0 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/python/TrigJetHypoToolConfig.py +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/python/TrigJetHypoToolConfig.py @@ -183,17 +183,18 @@ def _tests(): chainNameDecoder = DictFromChainName.DictFromChainName() chain_names = ( + '2j80_2j60_L1J20', 'j80_0eta240_2j60_320eta490_L1J20', 'j80_0eta240_2j60_320eta490_j0_dijetSEP80j1etSEP0j1eta240SEP80j2etSEP0j2eta240SEP700djmass_L1J20', ) - for cn in chain_names: + for cn in chain_names[:1]: chain_dict = chainNameDecoder.getChainDict(cn) - trigJetHypoToolFromDict(chain_dict) + print ('\nchain name: ', cn) + print (trigJetHypoToolFromDict(chain_dict(cn))) if __name__ == '__main__': unittest.main() - # run _tests outide untit tests so as to see stdout - # _tests() + # other local tests have been moved to testChainDictMaker.py diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/python/testChainDictMaker.py b/Trigger/TrigHypothesis/TrigHLTJetHypo/python/testChainDictMaker.py index b60f1b83b9fe..42d7d53e798c 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/python/testChainDictMaker.py +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/python/testChainDictMaker.py @@ -10,7 +10,9 @@ from TriggerMenuMT.HLTMenuConfig.Menu.Physics_pp_run3_v1 import ( from TriggerMenuMT.HLTMenuConfig.Menu.ChainDefInMenu import ChainProp from TriggerMenuMT.HLTMenuConfig.Menu.DictFromChainName import dictFromChainName - +from chainDict2jetLabel import chainDict2jetLabel +from TrigJetHypoToolConfig import trigJetHypoToolFromDict + def testChainDictMaker(): chain_props = [ @@ -20,6 +22,10 @@ def testChainDictMaker(): ChainProp(name='HLT_j80_j60_L1J15', l1SeedThresholds=['FSNOSEED']*2, groups=MultiJetGroup), + ChainProp(name='HLT_2j80_3j60_L1J15', + l1SeedThresholds=['FSNOSEED']*2, groups=MultiJetGroup), + + ChainProp(name='HLT_j0_HTSEP1000htSEP100etSEP0eta320_L1J15', l1SeedThresholds=['FSNOSEED'], groups=MultiJetGroup), @@ -45,3 +51,16 @@ if __name__ == '__main__': for d in dicts: print('') print (d) + + print ('\n chain_labels:\n') + + for d in dicts: + print (d[0]) + print (chainDict2jetLabel(d[1])) + print () + + print ('\nMaking TrigJetHypoTool for each dictiomary\n') + for d in dicts: + print (d[0]) + print (trigJetHypoToolFromDict(d[1])) + print () diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/CapacityCheckedCondition.h b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/CapacityCheckedCondition.h index 82974e9107fe..1455d594aca7 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/CapacityCheckedCondition.h +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/CapacityCheckedCondition.h @@ -38,20 +38,20 @@ class CapacityCheckedCondition: public ICapacityCheckedCondition { capacitySatisfied(std::size_t jgMultiplicity, const Collector&) const override { - return m_condition -> capacity() <= jgMultiplicity; + return m_condition->capacity() <= jgMultiplicity; } virtual bool isSatisfied(const HypoJetVector& v, const std::unique_ptr<ITrigJetHypoInfoCollector>& c) const override { - return m_condition -> isSatisfied(v, c); + return m_condition->isSatisfied(v, c); } virtual unsigned int capacity() const override { - return m_condition -> capacity(); + return m_condition->capacity(); } virtual std::string toString() const noexcept override { - return m_condition -> toString(); + return m_condition->toString(); } private: diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReducer.cxx b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReducer.cxx index 6826dbb9a2e9..8ab15e1744ae 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReducer.cxx +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReducer.cxx @@ -179,15 +179,6 @@ bool FastReducer::findInitialJetGroups(const std::vector<int>& leaves, } } - // check all leaf conditions are satisfied - /* - for (const auto& i : leaves) { - auto& satisfiedBy = m_satisfiedBy.at(i); - if (satisfiedBy.empty()) { - return false; - } - } - */ // check all leaf conditions are satisfied for (const auto& i : leaves) { diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReductionMatcher.h b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReductionMatcher.h index e931455ca555..62210f404a39 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReductionMatcher.h +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReductionMatcher.h @@ -7,7 +7,6 @@ #include "./IGroupsMatcherMT.h" -//#include "./ConditionsDefsMT.h" #include "./CapacityCheckedConditionsDefs.h" #include "./Tree.h" -- GitLab From 406a827db02ad9a39949cdf8e9064fcff5652cae Mon Sep 17 00:00:00 2001 From: sherwood <peter.sherwood@cern.ch> Date: Wed, 4 Nov 2020 09:52:13 +0100 Subject: [PATCH 4/6] adding explanatory comments to TrigJetHypoToolConfig.py --- .../TrigHLTJetHypo/python/treeVisitors.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/python/treeVisitors.py b/Trigger/TrigHypothesis/TrigHLTJetHypo/python/treeVisitors.py index cc704db08835..fbdf5b60bf49 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/python/treeVisitors.py +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/python/treeVisitors.py @@ -181,7 +181,6 @@ class ConditionsDictMaker(object): def makeDict(self, params): - # conditions example: ['10et,0eta320', '20et'] conditions = self.get_conditions(params) @@ -256,8 +255,21 @@ class ConditionsDictMaker(object): result.append(cdict) + + # Example: input condition string: + # + # 260et,320eta490 + # + # result: + # + # [ + # defaultdict(<class 'dict'>, {'et': {'min': '260000.0', 'max': 'inf'}, + # 'eta': {'min': '3.2', 'max': '4.9'}}) + # ] + msgs = ['ConditionsDict OK'] error = False + print ('ConditionsDictMaker::makeDict(), result', result) return result, error, msgs -- GitLab From e6076074831a7333fe80da25497369d08aa3c82a Mon Sep 17 00:00:00 2001 From: sherwood <peter.sherwood@cern.ch> Date: Wed, 4 Nov 2020 10:04:03 +0100 Subject: [PATCH 5/6] responding to reviewers comments --- .../python/TrigJetHypoToolConfig.py | 19 +------------------ .../TrigHLTJetHypo/src/FastReducer.cxx | 6 +++--- .../TrigHLTJetHypo/src/FastReducer.h | 2 -- 3 files changed, 4 insertions(+), 23 deletions(-) diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/python/TrigJetHypoToolConfig.py b/Trigger/TrigHypothesis/TrigHLTJetHypo/python/TrigJetHypoToolConfig.py index 62e5a185c5e0..444e216e55dd 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/python/TrigJetHypoToolConfig.py +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/python/TrigJetHypoToolConfig.py @@ -176,25 +176,8 @@ class TestDebugFlagIsFalse(unittest.TestCase): self.assertFalse(tool.visit_debug) -def _tests(): - from TriggerMenuMT.HLTMenuConfig.Menu import DictFromChainName - - chainNameDecoder = DictFromChainName.DictFromChainName() - - chain_names = ( - '2j80_2j60_L1J20', - 'j80_0eta240_2j60_320eta490_L1J20', - 'j80_0eta240_2j60_320eta490_j0_dijetSEP80j1etSEP0j1eta240SEP80j2etSEP0j2eta240SEP700djmass_L1J20', - ) - for cn in chain_names[:1]: - chain_dict = chainNameDecoder.getChainDict(cn) - - print ('\nchain name: ', cn) - print (trigJetHypoToolFromDict(chain_dict(cn))) - - -if __name__ == '__main__': +If __name__ == '__main__': unittest.main() # other local tests have been moved to testChainDictMaker.py diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReducer.cxx b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReducer.cxx index 8ab15e1744ae..f4f36af1ae37 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReducer.cxx +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReducer.cxx @@ -497,7 +497,7 @@ void FastReducer::recordJetGroup(std::size_t ind, << " et " << ip->et(); } ss1 << '\n'; - collector -> collect(ss0.str(), ss1.str()); + collector->collect(ss0.str(), ss1.str()); } bool FastReducer::pass() const { return m_pass; } @@ -510,9 +510,9 @@ bool FastReducer::capacitySatisfied(std::size_t ind, // of Conditions which represent multiple identical conditions. auto jgMult = m_satisfiedBy.at(ind).size(); - auto capSat = m_conditions.at(ind) -> capacitySatisfied(jgMult, collector); + auto capSat = m_conditions.at(ind)->capacitySatisfied(jgMult, collector); if (!capSat and collector) { - collector -> collect("FastReduce", "Condition " + std::to_string(ind) + collector->collect("FastReduce", "Condition " + std::to_string(ind) + " unsatisfied capacity, aborting"); } diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReducer.h b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReducer.h index 59c0a4d44daa..e92217ae5e43 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReducer.h +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReducer.h @@ -5,8 +5,6 @@ #ifndef TRIGHLTJETHYPO_FASTREDUCER_H #define TRIGHLTJETHYPO_FASTREDUCER_H - -// #include "./ConditionsDefsMT.h" #include "./CapacityCheckedConditionsDefs.h" #include "./Tree.h" #include "./JetGroupProduct.h" -- GitLab From b0e643ec23d31b6f244d4aa716554f4938316d8e Mon Sep 17 00:00:00 2001 From: sherwood <peter.sherwood@cern.ch> Date: Wed, 4 Nov 2020 12:31:10 +0100 Subject: [PATCH 6/6] typo fix --- .../TrigHLTJetHypo/python/TrigJetHypoToolConfig.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/python/TrigJetHypoToolConfig.py b/Trigger/TrigHypothesis/TrigHLTJetHypo/python/TrigJetHypoToolConfig.py index 444e216e55dd..a1e5c78989eb 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/python/TrigJetHypoToolConfig.py +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/python/TrigJetHypoToolConfig.py @@ -177,7 +177,7 @@ class TestDebugFlagIsFalse(unittest.TestCase): -If __name__ == '__main__': +if __name__ == '__main__': unittest.main() # other local tests have been moved to testChainDictMaker.py -- GitLab