diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/python/HelperConfigToolParams.py b/Trigger/TrigHypothesis/TrigHLTJetHypo/python/HelperConfigToolParams.py index a28501fb326e9ae666e85003e81679fbfd6a1ba5..8275a01cb084038adeecc35d836b8b4f5d940b1a 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/python/HelperConfigToolParams.py +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/python/HelperConfigToolParams.py @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration from AthenaCommon.Logging import logging from AthenaCommon.Constants import DEBUG @@ -14,12 +14,17 @@ class HelperConfigToolParams: and Conditions that will filter for the node. """ - def __init__(self, treevec=[], repcondargs=[], filterparams=[]): + def __init__(self, + treevec=[], + repcondargs=[], + filterparams=[], + filterparam_inds=[]): self.treevec = treevec self.repcondargs = repcondargs self.filterparams = filterparams + self.filterparam_inds = filterparam_inds @property def treevec(self): @@ -69,11 +74,22 @@ class HelperConfigToolParams: @filterparams.setter def filterparams(self, filterparams): self.__filterparams = filterparams + + + @property + def filterparam_inds(self): + return self.__filterparam_inds + + @filterparam_inds.setter + def filterparam_inds(self, filterparam_inds): + self.__filterparam_inds = filterparam_inds + def __str__(self): s = [self.__class__.__name__ + ':'] - to_show = ['treevec', 'leafvec', 'repcondargs', 'filterparams'] + to_show = ['treevec', 'leafvec', 'repcondargs', 'filterparams', + 'filterparam_inds'] width = max([len(a) for a in to_show]) [s.append('%s %s' % (a.ljust(width), getattr(self, a))) for a in to_show] return '\n'.join(s) diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/python/hypoConfigBuilder.py b/Trigger/TrigHypothesis/TrigHLTJetHypo/python/hypoConfigBuilder.py index 8833849444046c1689632ad4f8d8e118a9537ea3..1d26e2fbb884b27beba268f4939dcae93f3c5c45 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/python/hypoConfigBuilder.py +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/python/hypoConfigBuilder.py @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration from TrigHLTJetHypo.FastReductionAlgToolFactory import toolfactory @@ -18,10 +18,6 @@ from TrigHLTJetHypo.makeConditionFilterConfigurer import ( makeConditionFilterConfigurer, ) -from TrigHLTJetHypo.makePassThroughFilterConfigurer import ( - makePassThroughFilterConfigurer, -) - from TrigHLTJetHypo.make_repeatedCondConfigurer import ( make_repeatedCond, make_repeatedCondCfgFromParams, @@ -73,8 +69,10 @@ def buildHypoHelperConfigTool(params): scenarios. It contains the information needed to build the configuration AlgTool that intialiases a hypo helper AlgTool""" - # check that each Condition has a Filter - assert len(params.repcondargs) == len(params.filterparams) + # check that each Condition has a Filter index. + # the index is -1 for no Condition filtering. + assert len(params.repcondargs) == len(params.filterparam_inds) + assert len(params.filterparam_inds) >= len(params.filterparams) # FastReducer root node repcondobjs = [make_root_repcondconfig()] @@ -82,24 +80,24 @@ def buildHypoHelperConfigTool(params): repcondobjs.append(make_repeatedCondCfgFromParams(ra)) - # filter for FastReducer root node - filtConditionMakers = [makePassThroughFilterConfigurer()] + # filter for FastReducer root node (use position 0) + filtConditionMakers = [] + filtConditionMakerInds = [-1] # no condition filtering for root - for ra in params.filterparams: - if ra.typename == 'ConditionFilter': + for ra_ind in params.filterparam_inds: + if ra_ind != -1: + ra = params.filterparams[ra_ind] filtConditionMakers.append(makeConditionFilterConfigurer(ra)) - elif ra.typename == 'PassThroughFilter': - filtConditionMakers.append(makePassThroughFilterConfigurer()) + filtConditionMakerInds.append(len(filtConditionMakers)-1) else: - raise NotImplementedError( - 'Filter type %s not implemented' % ra.typename - ) + filtConditionMakerInds.append(-1) toolclass, name = toolfactory('HelperToolConfigTool') vals = {'name': name, 'conditionMakers': repcondobjs, 'filterMakers': filtConditionMakers, + 'filterMakerInds': filtConditionMakerInds, 'treeVector': params.treevec, 'leafVector': params.leafvec, } @@ -294,7 +292,7 @@ def make_prefilter_configurers(chain_dict): # a PassThroughFilter configurer is made. if not pf_strings: - return [makePassThroughFilterConfigurer()] + return [] # route the prefilter strings to the appropriate handler prefilter_router = { diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/python/hypoToolTests.py b/Trigger/TrigHypothesis/TrigHLTJetHypo/python/hypoToolTests.py index 1f958c38a55db5a1c8fe3194c9a391590b56faeb..c264e0015d92f24d20064d98dceb91833e5c56e9 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/python/hypoToolTests.py +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/python/hypoToolTests.py @@ -30,8 +30,8 @@ class HypoToolStructure(unittest.TestCase): ChainProp(name='HLT_j420_subresjesgscIS_ftf_L1J100', groups=SingleJetGroup), 'connections': dict(((0, [1]), - (1, [2, 10]), - (2, [3, 5, 8, 9]), + (1, [2]), + (2, [3, 5]), (3, [4]), (5, [6, 7]))), 'values': [] @@ -41,8 +41,8 @@ class HypoToolStructure(unittest.TestCase): ChainProp(name='HLT_j260f_L1J75_31ETA49', groups=SingleJetGroup), 'connections': dict(((0, [1]), - (1, [2, 10]), - (2, [3, 5, 8, 9]), + (1, [2]), + (2, [3, 5]), (3, [4]), (5, [6, 7]))), 'values': [] @@ -53,8 +53,8 @@ class HypoToolStructure(unittest.TestCase): ChainProp(name='HLT_j80_j60_L1J15', l1SeedThresholds=['FSNOSEED']*2, groups=MultiJetGroup), 'connections': dict(((0, [1]), - (1, [2, 14]), - (2, [3, 5, 8, 11,12, 13]), + (1, [2]), + (2, [3, 5, 8]), (3, [4]), (5, [6, 7]), (8, [9, 10]))), @@ -64,8 +64,8 @@ class HypoToolStructure(unittest.TestCase): { 'prop': ChainProp(name='HLT_2j80_3j60_L1J15', l1SeedThresholds=['FSNOSEED']*2, groups=MultiJetGroup), - 'connections': dict(((0, [1]), (1, [2, 14]), - (2, [3, 5, 8, 11, 12, 13]), + 'connections': dict(((0, [1]), (1, [2]), + (2, [3, 5, 8]), (3, [4]), (5, [6, 7]), (8, [9,10]))), @@ -77,12 +77,12 @@ class HypoToolStructure(unittest.TestCase): groups=SingleJetGroup), 'connections': dict(((0, [1]), - (1, [2, 12]), - (2, [3, 5, 7, 8]), + (1, [2]), + (2, [3, 5, 7]), (3, [4]), (5, [6]), - (8, [9]), - (9, [10, 11]))), + (7, [8]), + (8, [9, 10]))), 'values': [] }, @@ -93,15 +93,15 @@ class HypoToolStructure(unittest.TestCase): groups=MultiJetGroup), 'connections': dict(((0, [1]), - (1, [2, 14, 27]), - (2, [3, 5, 8, 11, 12, 13]), + (1, [2, 11]), + (2, [3, 5, 8]), (3, [4]), (5, [6, 7]), (8, [9, 10]), - (14, [15, 17, 21, 24, 25, 26]), - (15, [16]), - (17, [18, 19, 20]), - (21, [22, 23]),)), + (11, [12, 14, 18]), + (12, [13]), + (14, [15, 16, 17]), + (18, [19, 20]),)), 'values': [] }, @@ -111,8 +111,8 @@ class HypoToolStructure(unittest.TestCase): groups=MultiJetGroup), 'connections': dict(((0, [1]), - (1, [2, 10]), - (2, [3, 5, 8, 9]), + (1, [2]), + (2, [3, 5]), (3, [4]), (5, [6, 7]))), 'values': [{'nodeid': 5, @@ -124,16 +124,16 @@ class HypoToolStructure(unittest.TestCase): groups=SingleJetGroup), 'connections': dict(((0, [1]), - (1, [2, 14, 30]), - (2, [3, 5, 8, 11, 12, 13]), + (1, [2, 11]), + (2, [3, 5, 8]), (3, [4]), (5, [6, 7]), (8, [9, 10]), - (14, [15, 17, 20, 23, 26, 27, 28, 29]), - (15, [16]), + (11, [12, 14, 17, 20]), + (12, [13]), + (14, [15, 16]), (17, [18, 19]), - (20, [21, 22]), - (23, [24, 25]))), + (20, [21, 22]))), 'values': [] }, @@ -143,15 +143,15 @@ class HypoToolStructure(unittest.TestCase): groups=MultiJetGroup), 'connections': dict(((0, [1]), - (1, [2, 10, 20]), - (2, [3, 5, 8, 9]), + (1, [2, 8]), + (2, [3, 5]), (3, [4]), (5, [6, 7]), - (10, [11, 13, 15, 16]), + (8, [9, 11, 13]), + (9, [10]), (11, [12]), (13, [14]), - (16, [17,]), - (17, [18, 19]))), + (14, [15, 16]))), 'values': [] }, @@ -160,8 +160,8 @@ class HypoToolStructure(unittest.TestCase): groups=SingleJetGroup), 'connections': dict(((0, [1]), - (1, [2, 26]), - (2, [3, 5, 8, 11, 14, 17, 20, 21, 22, 23, 24, 25]), + (1, [2]), + (2, [3, 5, 8, 11, 14, 17]), (3, [4]), (5, [6, 7]), (8, [9, 10]), @@ -177,8 +177,8 @@ class HypoToolStructure(unittest.TestCase): groups=SingleJetGroup), 'connections': dict(((0, [1]), - (1, [2, 10]), - (2, [3, 5, 8, 9]), + (1, [2]), + (2, [3, 5]), (3, [4]), (5, [6, 7]))), 'values': [] @@ -190,12 +190,12 @@ class HypoToolStructure(unittest.TestCase): 'connections': dict(((0, [1]), - (1, [2, 10]), - (2, [3, 5, 8, 9]), + (1, [2, 8]), + (2, [3, 5]), (3, [4]), (5, [6, 7]), - (10, [11]), - (11, [12, 13]))), + (8, [9]), + (9, [10, 11]))), 'values': [] }, @@ -207,8 +207,8 @@ class HypoToolStructure(unittest.TestCase): 'connections': dict(((0, [1]), - (1, [2, 13]), - (2, [3, 5, 7, 10, 11, 12]), + (1, [2]), + (2, [3, 5, 7]), (3, [4]), (5, [6]), (7, [8, 9]))), @@ -237,11 +237,18 @@ class HypoToolStructure(unittest.TestCase): analyser = HypoToolAnalyser(tool) + node_table = [] + for k in sorted(analyser.node_table.keys()): + node_table.append ('%d: %s' % (k, analyser.node_table[k])) + + node_table = '\n'.join(node_table) + self.assertTrue(analyser.connections == td['connections'], - 'fail for case %s expected %s; saw %s' %( + 'fail for case %s expected %s; saw %s \n %s' %( chain_name, str(td['connections']), - str(analyser.connections))) + str(analyser.connections), + node_table)) # check selected attributes of inner (nested) tools. @@ -259,7 +266,7 @@ class HypoToolStructure(unittest.TestCase): for attrname, testval in ref_values.items(): toolval = getattr(subtool, attrname) self.assertEqual(toolval, testval, - msg='%s: node: %d expected %s saw %s' % ( + msg='%s: node: %d expected %s saw %s' % ( chain_name, nodeid, str(testval), diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/python/scenario_dijet.py b/Trigger/TrigHypothesis/TrigHLTJetHypo/python/scenario_dijet.py index 1429e242c68bedcae1af02c6af90a482791d3765..d9d9f64ba79c10e76f41c9ac6c93c2df74edc762 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/python/scenario_dijet.py +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/python/scenario_dijet.py @@ -1,7 +1,6 @@ # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration from TrigHLTJetHypo.RepeatedConditionParams import RepeatedConditionParams -from TrigHLTJetHypo.FilterParams import FilterParams from TrigHLTJetHypo.HelperConfigToolParams import HelperConfigToolParams from TrigHLTJetHypo.ConditionDefaults import defaults from TrigHLTJetHypo.make_treevec import make_treevec @@ -208,8 +207,8 @@ def scenario_dijet(scenario, chainPartInd): # make pass through filter params for each condition in the tree. nconds = len(repcondargs) - filterparams = [FilterParams(typename='PassThroughFilter') - for i in range(nconds)] + filterparams = [] + filterparam_inds = [-1 for i in range(nconds)] # parameters to initalise the AlgTool that initialises the helper AlgTool @@ -221,10 +220,13 @@ def scenario_dijet(scenario, chainPartInd): assert treevec == [0, 0, 1] else: assert treevec == [0, 0, 1, 1] - + + assert len(repcondargs) == len(filterparam_inds) + helper_params = HelperConfigToolParams(treevec=treevec, repcondargs=repcondargs, - filterparams=filterparams) + filterparams=filterparams, + filterparam_inds=filterparam_inds) return [helper_params] # a list is one entry per FastReduction tree diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/python/scenario_fbdjnoshared.py b/Trigger/TrigHypothesis/TrigHLTJetHypo/python/scenario_fbdjnoshared.py index e541926691c93c7a7b1c1a3a5a804e5ea240cfa8..a0fac201f6f2fe7c4b1b566d6e57841af4db7ab8 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/python/scenario_fbdjnoshared.py +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/python/scenario_fbdjnoshared.py @@ -1,7 +1,6 @@ # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration from TrigHLTJetHypo.RepeatedConditionParams import RepeatedConditionParams -from TrigHLTJetHypo.FilterParams import FilterParams from TrigHLTJetHypo.HelperConfigToolParams import HelperConfigToolParams from TrigHLTJetHypo.ConditionDefaults import defaults from TrigHLTJetHypo.make_treevec import make_treevec @@ -134,8 +133,8 @@ def scenario_fbdjnoshared(scenario, chainPartInd): # make pass through filter params for each condition in the tree. nconds = len(repcondargs) - filterparams = [FilterParams(typename='PassThroughFilter') - for i in range(nconds)] + filterparams = [] + filterparam_inds = [-1 for i in range(nconds)] # parameters to initalise the AlgTool that initialises the helper AlgTool @@ -147,7 +146,10 @@ def scenario_fbdjnoshared(scenario, chainPartInd): helper_params = HelperConfigToolParams(treevec=treevec, repcondargs=repcondargs, - filterparams=filterparams) - + filterparams=filterparams, + filterparam_inds=filterparam_inds) + + assert len(repcondargs) == len(filterparam_inds) + return [helper_params] # a list is one entry per FastReduction tree diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/python/scenario_fbdjshared.py b/Trigger/TrigHypothesis/TrigHLTJetHypo/python/scenario_fbdjshared.py index b18f0eb81de2df88392f69dec988d0b198aaa005..1decf12134e8c5fae8eadf01a7f83fd86f8365e6 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/python/scenario_fbdjshared.py +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/python/scenario_fbdjshared.py @@ -1,7 +1,6 @@ # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration from TrigHLTJetHypo.RepeatedConditionParams import RepeatedConditionParams -from TrigHLTJetHypo.FilterParams import FilterParams from TrigHLTJetHypo.HelperConfigToolParams import HelperConfigToolParams from TrigHLTJetHypo.ConditionDefaults import defaults from TrigHLTJetHypo.make_treevec import make_treevec @@ -62,8 +61,8 @@ def scenario_fbdjshared(scenario, chainPartInd): # make pass through filter params for each condition in the tree. nconds = len(repcondargs) - filterparams = [FilterParams(typename='PassThroughFilter') - for i in range(nconds)] + filterparams = [] + filterparam_inds = [-1 for i in range(nconds)] # treevec[i] gives the tree_id of the parent of the # node with tree_id = i @@ -72,7 +71,8 @@ def scenario_fbdjshared(scenario, chainPartInd): helperparams = HelperConfigToolParams(treevec=treevec, repcondargs=repcondargs, - filterparams=filterparams) + filterparams=filterparams, + filterparam_inds=filterparam_inds) helperparamslist = [helperparams] #############################################33 @@ -125,8 +125,8 @@ def scenario_fbdjshared(scenario, chainPartInd): # make pass through filter params for each condition in the tree. nconds = len(repcondargs) - filterparams = [FilterParams(typename='PassThroughFilter') - for i in range(nconds)] + filterparams = [] + filterparam_inds = [-1 for i in range(nconds)] # parameters to initalise the AlgTool that initialises the helper AlgTool @@ -137,8 +137,12 @@ def scenario_fbdjshared(scenario, chainPartInd): helperparams = HelperConfigToolParams(treevec=treevec, repcondargs=repcondargs, - filterparams=filterparams) + filterparams=filterparams, + filterparam_inds=filterparam_inds) # a list is one entry per FastReduction tree + + assert len(repcondargs) == len(filterparam_inds) + helperparamslist.append(helperparams) return helperparamslist diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/python/scenario_ht.py b/Trigger/TrigHypothesis/TrigHLTJetHypo/python/scenario_ht.py index 5f8a428e635d61b3867e443ff365488b1965e788..e253feaaab5318079b2252a0c8f863fefa178efb 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/python/scenario_ht.py +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/python/scenario_ht.py @@ -100,8 +100,11 @@ def scenario_ht(scenario, chainPartInd): condargs=condargs)] filterparams = [FilterParams(typename='ConditionFilter', args=repfiltargs)] + filterparam_inds = [0] + else: - filterparams = [FilterParams(typename='PassThroughFilter')] + filterparams = [] + filterparam_inds = [-1] # no condition filter # parameters to initalise the AlgTool that initialises the helper AlgTool @@ -110,9 +113,13 @@ def scenario_ht(scenario, chainPartInd): treevec = make_treevec(repcondargs) assert treevec == [0, 0] + assert len(repcondargs) == len(filterparam_inds) + + helper_params = HelperConfigToolParams(treevec=treevec, repcondargs=repcondargs, - filterparams=filterparams) + filterparams=filterparams, + filterparam_inds=filterparam_inds) return [helper_params] # a list with one entry per FastReduction tree diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/python/scenario_simple.py b/Trigger/TrigHypothesis/TrigHLTJetHypo/python/scenario_simple.py index ccb5df695a8958f6e3479dc1fe8e409e52622779..42473068314ed948fb7439cb700dde78d5e3e65b 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/python/scenario_simple.py +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/python/scenario_simple.py @@ -1,7 +1,6 @@ # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration from TrigHLTJetHypo.RepeatedConditionParams import RepeatedConditionParams -from TrigHLTJetHypo.FilterParams import FilterParams from TrigHLTJetHypo.HelperConfigToolParams import HelperConfigToolParams from TrigHLTJetHypo.ConditionDefaults import defaults from TrigHLTJetHypo.make_treevec import make_treevec @@ -170,6 +169,7 @@ def scenario_simple(chain_parts): repcondargs = [] filterparams = [] + filterparam_inds = [] ncp = 0 @@ -191,8 +191,8 @@ def scenario_simple(chain_parts): multiplicity = int(cp['multiplicity']) chainPartInd = cp['chainPartIndex'] - # make an empty filter condition for the FR condition - filterparams.append(FilterParams(typename='PassThroughFilter')) + # no condition filtering + filterparam_inds.append(-1) # no Condition filter clique = None try: @@ -215,8 +215,10 @@ def scenario_simple(chain_parts): treevec = make_treevec(repcondargs) assert treevec == [0 for i in range(len(chain_parts) + 1)] + assert len(repcondargs) == len(filterparam_inds) helper_params = HelperConfigToolParams(treevec=treevec, repcondargs=repcondargs, - filterparams=filterparams) + filterparams=filterparams, + filterparam_inds=filterparam_inds) return [helper_params] # a list is one entry per FastReduction tree diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReducer.cxx b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReducer.cxx index 670f92a2740677a8151c2135451229b79a8fe86a..dd4dc2f9ae9781f804b9bdeee683c16cd53c16b2 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReducer.cxx +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReducer.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration */ #include "./FastReducer.h" @@ -41,10 +41,12 @@ struct IndexVecComp{ FastReducer::FastReducer(const HypoJetVector& jv, const ConditionPtrs& conditions, const ConditionFilters& filters, + const ConditionFilterInds& filterInds, const Tree& tree, xAODJetCollector& jetCollector, const Collector& collector): - m_conditions(conditions), m_conditionFilters(filters), m_tree(tree) { + m_conditions(conditions), m_conditionFilters(filters), + m_conditionFilterInds(filterInds), m_tree(tree) { // create an empty vector of indices of satisfying jet groups // for each Condition. @@ -181,9 +183,13 @@ bool FastReducer::findInitialJetGroups(const HypoJetVector& jv, for(const auto& leaf: leaves){ - auto& filter = m_conditionFilters[leaf]; - auto filtered_jets = filter->filter(jv, collector); - + auto filtered_jets = jv; + auto& filter_ind = m_conditionFilterInds[leaf]; + if (filter_ind != -1) { + const auto& filter = m_conditionFilters[filter_ind]; + filtered_jets = filter->filter(filtered_jets, collector); + } + auto iters = std::make_pair(filtered_jets.begin(), filtered_jets.end()); diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReducer.h b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReducer.h index 043322009f0aa17c7a854d151cc9cefc97bfda5d..510b56d56ebf66973fc5f77ac55f14c0d772bcfb 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReducer.h +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReducer.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration */ #ifndef TRIGHLTJETHYPO_FASTREDUCER_H @@ -30,12 +30,15 @@ using JetGroupInd2ElemInds = std::map<int, std::vector<std::size_t>>; using ConditionFilters = std::vector<std::unique_ptr<IHypoJetVectorFilter>>; +using ConditionFilterInds = std::vector<int>; + class FastReducer { public: FastReducer(const HypoJetVector& jv, const ConditionPtrs& conditionObjects, const ConditionFilters& conditionFilters, + const ConditionFilterInds& conditionFilterInds, const Tree& conditionsTree, xAODJetCollector& jetCollector, const Collector& collector); @@ -59,6 +62,7 @@ class FastReducer { // conditionFilters owned by the matcher const ConditionFilters& m_conditionFilters; + ConditionFilterInds m_conditionFilterInds; /** 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 2cb5b2642e1fea4bdea08e47d4c08828ca73893e..9c1d17dfd2d2be9ca8efd6fb8f10801ab8347067 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReductionMatcher.cxx +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReductionMatcher.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration */ #include "./FastReductionMatcher.h" @@ -12,9 +12,11 @@ FastReductionMatcher::FastReductionMatcher(ConditionPtrs& conditions, ConditionFilters& filters, + const ConditionFilterInds& filterInds, const Tree& tree): m_conditions(std::move(conditions)), m_conditionFilters(std::move(filters)), + m_conditionFilterInds(filterInds), m_tree(tree){ if (m_conditions[0]->capacity() != 0 or @@ -37,9 +39,12 @@ FastReductionMatcher::FastReductionMatcher(ConditionPtrs& conditions, m_minNjets = std::max(1, minNjets); - if (filters.size() != conditions.size()) { + if (filterInds.size() != m_conditions.size()) { m_validState = false; - m_msg = "Conditions and ConditionFilters sequence sizes differ"; + std::stringstream ss; + ss << "ConditionFilterInds and Conditions sequence sizes differ: "; + ss << filterInds.size() << " " << m_conditions.size(); + m_msg = ss.str(); } } @@ -78,6 +83,7 @@ FastReductionMatcher::match(const HypoJetVector& jv, FastReducer reducer(jv, m_conditions, m_conditionFilters, + m_conditionFilterInds, m_tree, jetCollector, collector); @@ -101,6 +107,19 @@ std::string FastReductionMatcher::toString() const { ss << sc <<": "<< c->toString() + '\n'; } + + ss << "FastReductionMatcher ConditionFilter indices [" + << m_conditionFilterInds.size() << "]: \n"; + + + count = 0; + for(const auto& c : m_conditionFilterInds){ + auto sc = std::to_string(count++); + sc.insert(sc.begin(), 3-sc.length(), ' '); + ss << sc <<": "<< c << '\n'; + } + + ss << "FastReductionMatcher ConditionFilters [" << m_conditionFilters.size() << "]: \n"; diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReductionMatcher.h b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReductionMatcher.h index 1fc2c926d58931c9c483ef3110e7a1b1b82aa0c9..74174f6a12fc5a985f47f44149c10ad66b16058f 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReductionMatcher.h +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/FastReductionMatcher.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration */ #ifndef TRIGHLTJETHYPO_FASTREDUCTIONMATCHER_H @@ -18,11 +18,14 @@ class ITrigJetHypoInfoCollector; using ConditionFilters = std::vector<std::unique_ptr<IHypoJetVectorFilter>>; +using ConditionFilterInds = std::vector<int>; + class FastReductionMatcher: public IJetsMatcher { public: FastReductionMatcher(ConditionPtrs&, ConditionFilters&, + const ConditionFilterInds&, const Tree&); @@ -53,6 +56,7 @@ class FastReductionMatcher: public IJetsMatcher { ConditionPtrs m_conditions; ConditionFilters m_conditionFilters; + ConditionFilterInds m_conditionFilterInds; /** tree structure for Conditions objects. The conditions tree gives relations among conditions (eg parent-child diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoToolConfig_fastreduction.cxx b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoToolConfig_fastreduction.cxx index bd12fcf53857e25e30400e571f9797c1f6d955f9..d3af15d7acd016323d75aede9b7b053bb49de124 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoToolConfig_fastreduction.cxx +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoToolConfig_fastreduction.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration */ @@ -43,6 +43,16 @@ StatusCode TrigJetHypoToolConfig_fastreduction::initialize() { " require at least 2" ); return StatusCode::FAILURE; } + + if(m_filterMakerInds.size() != m_conditionMakers.size()){ + // need an index for each condition + ATH_MSG_ERROR("No. of conditions " + + std::to_string( m_conditionMakers.size()) + + " no. of filter inds " + + std::to_string( m_filterMakerInds.size()) + + " must be equal" ); + return StatusCode::FAILURE; + } return StatusCode::SUCCESS; } @@ -111,18 +121,18 @@ TrigJetHypoToolConfig_fastreduction::requiresNJets() const { std::unique_ptr<IJetsMatcher> TrigJetHypoToolConfig_fastreduction::getMatcher () const { - auto repeatedConds = getRepeatedConditions(); + auto matcher = std::unique_ptr<IJetsMatcher>(nullptr); - if(repeatedConds.empty()){ - return std::unique_ptr<IJetsMatcher>(nullptr); - } - - auto matcher = std::unique_ptr<IJetsMatcher>(); + auto repeatedConds = getRepeatedConditions(); + + if(repeatedConds.empty()){return matcher;} auto conditions = std::move(repeatedConds); auto filters = getFilters(); + auto fpm = new FastReductionMatcher(conditions, filters, + m_filterMakerInds, Tree(m_treeVec)); matcher.reset(fpm); return matcher; diff --git a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoToolConfig_fastreduction.h b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoToolConfig_fastreduction.h index 5b3d944d8bd97590646bd29b64a98556c506a215..cb081dd11dc78d458564030c4f572baaf525eac0 100644 --- a/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoToolConfig_fastreduction.h +++ b/Trigger/TrigHypothesis/TrigHLTJetHypo/src/TrigJetHypoToolConfig_fastreduction.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration */ #ifndef TRIGJETHYPOTOOLCONFIG_FASTREDUCTION_H @@ -51,6 +51,13 @@ public extends<AthAlgTool, ITrigJetHypoToolNoGrouperConfig> { this, "filterMakers", {}, "AlgTools that construct Condition filters" }; + + // indirection to allow non-specification of PassThrough filters. + // as requested in ATR-27619 + Gaudi::Property<std::vector<int>> m_filterMakerInds{ + this, "filterMakerInds", {}, "Indicies into m_filterMakers" + }; + Gaudi::Property<std::vector<std::size_t>> m_treeVec{ this, "treeVector", {}, "integer sequence representation of jet hypo tree"};