diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/python/TrigJetHypoToolConfig.py b/Trigger/TrigHypothesis/TrigHLTJetHypo/python/TrigJetHypoToolConfig.py index e5a870341f8a5299f43ece301a8a91c71976cb64..a1e5c78989eb28ef3c7e0c546823be1e8d8ccb38 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/python/TrigJetHypoToolConfig.py +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/python/TrigJetHypoToolConfig.py @@ -176,24 +176,8 @@ class TestDebugFlagIsFalse(unittest.TestCase): self.assertFalse(tool.visit_debug) -def _tests(): - - from TriggerMenuMT.HLTMenuConfig.Menu import DictFromChainName - - chainNameDecoder = DictFromChainName.DictFromChainName() - - chain_names = ( - 'j80_0eta240_2j60_320eta490_L1J20', - 'j80_0eta240_2j60_320eta490_j0_dijetSEP80j1etSEP0j1eta240SEP80j2etSEP0j2eta240SEP700djmass_L1J20', - ) - for cn in chain_names: - chain_dict = chainNameDecoder.getChainDict(cn) - - trigJetHypoToolFromDict(chain_dict) - 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 b60f1b83b9fea7c282242895b9822829884758ff..42d7d53e798c317e89f6927aa52c50a4cb63cfdb 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/python/treeVisitors.py b/Trigger/TrigHypothesis/TrigHLTJetHypo/python/treeVisitors.py index cc704db08835720846664915e7c22c2d91ca29ed..fbdf5b60bf4927a31e7accbc0a6144fc104686ee 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 diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/CapacityCheckedCondition.h b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/CapacityCheckedCondition.h new file mode 100644 index 0000000000000000000000000000000000000000..1455d594aca74b0d974e00e28cbf10abd9961a94 --- /dev/null +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/CapacityCheckedCondition.h @@ -0,0 +1,61 @@ +/* + 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(std::size_t jgMultiplicity, + const Collector&) const override { + + 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); + } + + 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 0000000000000000000000000000000000000000..f26ccc1bc85cb07b2aef955bdeb9169e818acee9 --- /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 49c56a2e137775e9ec9a616e302272f501fa7342..f4f36af1ae37c9e77be29521401929ffdf265984 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, @@ -179,10 +179,10 @@ 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()) { + if (!capacitySatisfied(i, collector)) { return false; } } @@ -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. @@ -497,8 +497,24 @@ 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; } + +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 5aba889c93be587fc7327d8d96a7c293190af371..e92217ae5e438e3d06471d6dada1a3175d725a37 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReducer.h +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReducer.h @@ -5,8 +5,7 @@ #ifndef TRIGHLTJETHYPO_FASTREDUCER_H #define TRIGHLTJETHYPO_FASTREDUCER_H - -#include "./ConditionsDefsMT.h" +#include "./CapacityCheckedConditionsDefs.h" #include "./Tree.h" #include "./JetGroupProduct.h" #include "./JetGroupIndAllocator.h" @@ -30,7 +29,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 +46,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 @@ -114,6 +113,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/FastReductionMatcher.cxx b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReductionMatcher.cxx index 7f78b0ca100e5cb2af754bdabb1184881526a309..4dfffac4ca42c542b11b33516585717d0b95716a 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 b7fe4d2eb74798727e77e033e913da80c944c347..62210f404a39f23639f2a4984ecba85e4ed2855b 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReductionMatcher.h +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReductionMatcher.h @@ -7,7 +7,7 @@ #include "./IGroupsMatcherMT.h" -#include "./ConditionsDefsMT.h" +#include "./CapacityCheckedConditionsDefs.h" #include "./Tree.h" using TreeVec = std::vector<std::size_t>; @@ -16,9 +16,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 +42,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 0000000000000000000000000000000000000000..033ce81570cf017b1b735e9a459460049dbc31e8 --- /dev/null +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/ICapacityCheckedCondition.h @@ -0,0 +1,38 @@ +/* + 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> +typedef std::unique_ptr<ITrigJetHypoInfoCollector> Collector; + + +class ITrigJetHypoInfoCollector; + +class ICapacityCheckedCondition: public IConditionMT { + public: + virtual ~ICapacityCheckedCondition(){} + + virtual bool capacitySatisfied(std::size_t jgMultiplicity, + const Collector&) const = 0; + +}; + +#endif diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoToolConfig_fastreduction.cxx b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoToolConfig_fastreduction.cxx index 051697a152ed5525bb3c3fe3ff74ad7c00deb355..4c4e6691b6d2caf4242090217cd3086d5d7e4c14 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 5625120313e9da076d19961faaebf4dbf0087dd1..2e70bf1b81674df6139e148c17ce8a25d1342f89 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 100bfcc525f308147a50a227649422fe5eae2d33..a580b25257e508076ea4c922811da62bac5ac510 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 5b6d1f1f25ccb58089147b8384565ab9ff5be93f..1865de3d94bf3f4a37849b295db109fa3c1a7924 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