3 """Instantiates TrigJetHypoToolConfig_fastreduction AlgTool
7 from collections
import defaultdict
9 from AthenaCommon.Logging
import logging
10 log = logging.getLogger(
'ConditionsToolSetterFastReduction' )
13 return node.scenario
in (
'simple',
'dijet',
'qjet',
'agg')
17 return node.scenario
in (
'root',
'all')
22 """Visitor to set instantiated AlgTools to a jet hypo tree"""
36 """attach Conditions to leaf nodes"""
40 for cn
in node.children:
45 """conf_dict: a dict containing names of elemental conditions
46 and min, max valies. These will be used to instantiate
47 conditon building AlgTools, one for eac conditon
49 for 2j80_2j60, the dictionaries are:
50 {'et': {'min': '80000.0', 'max': 'inf'},
51 'eta': {'min': '0.0', 'max': '3.2'}}
56 {'et': {'min': '60000.0', 'max': 'inf'},
57 'eta': {'min': '0.0', 'max': '3.2'}})
63 for k, v
in conf_dict.items():
68 for lim, val
in v.items():
69 setattr(condition_tool, lim, val)
73 if (k.startswith (
'mom')):
74 moment = k[len(
'mom'):]
75 if moment
in self.JetMoments:
76 condition_tool.moment = self.JetMoments[moment]
77 else:
raise RuntimeError(
'%s not supported' % (moment))
81 condition_tools.append(condition_tool)
83 return condition_tools
88 """Condition filters use a list of CompoundCondition containing
89 single jet elemental conditions select a subset of the reco
90 jets to send to the a Condition"""
92 el_condition_tools = []
94 for fc
in node.filter_dicts:
101 condition_tool.conditionMakers = el_condition_tools
102 condition_tool.multiplicity = 1
104 return condition_tool
108 """For each element of node.conf_attrs, construct a
109 ConditionContainer. Example for chain HLT_2j80_3j60_L1J15:
113 (defaultdict(<class 'dict'>, {
114 'et': {'min': '80000.0', 'max': 'inf'},
115 'eta': {'min': '0.0', 'max': '3.2'}}), 2)
119 (defaultdict(<class 'dict'>, {'et': {'min': '60000.0', 'max': 'inf'},
120 'eta': {'min': '0.0', 'max': '3.2'}}), 3)
126 outer_condition_tools = []
131 assert len(node.conf_attrs) == 1
132 mult = node.multiplicity
133 for i
in range(len(node.conf_attrs)):
134 c = node.conf_attrs[i]
137 if node.chainpartinds:
138 cpi = node.chainpartinds[i]
149 condition_tool.chainPartInd =
int(cpi[len(
'leg'):])
151 condition_tool.conditionMakers = el_condition_tools
152 condition_tool.multiplicity = mult
154 outer_condition_tools.append(condition_tool)
156 return outer_condition_tools
160 """ Add Condition tools to For a leaf node."""
185 tmap[node.node_id] = node.parent_id
186 for cn
in node.children:
193 assert (len(node.compound_condition_tools) == 1)
194 cmap[node.node_id] = node.compound_condition_tools[0]
196 fmap[node.node_id] = node.filter_condition_tool
202 cmap[node.node_id].multiplicity = 1
205 fmap[node.node_id].conditionMakers = []
206 fmap[node.node_id].multiplicity = 1
209 for cn
in node.children:
215 vec = [0
for i
in range(len(amap))]
216 for nid, value
in amap.items():
223 'ConditionsToolSetter: illegal scenario: %s' % node.scenario)
225 for cn
in node.children:
229 """Entry point for this module.
230 Modifies a (usually compound) hypo tree node to
231 reduce it to form from whuch the treevector, and conditionsVector
232 These will be used to initialise FastReductionMatcher.
234 In particular: all leaf nodes will have a single ConmpoundCondition
235 All other nodes will be assigned an AcceptAll condition.
253 filterConditionsMap = {}
260 filterConditionsVec = self.
_map_2_vec(filterConditionsMap)
267 config_tool.filtConditionsMakers = filterConditionsVec
268 config_tool.treeVector = treeVec