3 """Instantiates TrigJetHypoToolConfig_fastreduction AlgTool
6 from __future__
import print_function
8 from collections
import defaultdict
10 from AthenaCommon.Logging
import logging
11 log = logging.getLogger(
'ConditionsToolSetterFastReduction' )
14 return node.scenario
in (
'simple',
'dijet',
'qjet',
'agg')
18 return node.scenario
in (
'root',
'all')
23 """Visitor to set instantiated AlgTools to a jet hypo tree"""
37 """attach Conditions to leaf nodes"""
41 for cn
in node.children:
46 """conf_dict: a dict containing names of elemental conditions
47 and min, max valies. These will be used to instantiate
48 conditon building AlgTools, one for eac conditon
50 for 2j80_2j60, the dictionaries are:
51 {'et': {'min': '80000.0', 'max': 'inf'},
52 'eta': {'min': '0.0', 'max': '3.2'}}
57 {'et': {'min': '60000.0', 'max': 'inf'},
58 'eta': {'min': '0.0', 'max': '3.2'}})
64 for k, v
in conf_dict.items():
69 for lim, val
in v.items():
70 setattr(condition_tool, lim, val)
74 if (k.startswith (
'mom')):
75 moment = k[len(
'mom'):]
76 if moment
in self.JetMoments:
77 condition_tool.moment = self.JetMoments[moment]
78 else:
raise RuntimeError(
'%s not supported' % (moment))
82 condition_tools.append(condition_tool)
84 return condition_tools
89 """Condition filters use a list of CompoundCondition containing
90 single jet elemental conditions select a subset of the reco
91 jets to send to the a Condition"""
93 el_condition_tools = []
95 for fc
in node.filter_dicts:
102 condition_tool.conditionMakers = el_condition_tools
103 condition_tool.multiplicity = 1
105 return condition_tool
109 """For each element of node.conf_attrs, construct a
110 ConditionContainer. Example for chain HLT_2j80_3j60_L1J15:
114 (defaultdict(<class 'dict'>, {
115 'et': {'min': '80000.0', 'max': 'inf'},
116 'eta': {'min': '0.0', 'max': '3.2'}}), 2)
120 (defaultdict(<class 'dict'>, {'et': {'min': '60000.0', 'max': 'inf'},
121 'eta': {'min': '0.0', 'max': '3.2'}}), 3)
127 outer_condition_tools = []
132 assert len(node.conf_attrs) == 1
133 mult = node.multiplicity
134 for i
in range(len(node.conf_attrs)):
135 c = node.conf_attrs[i]
138 if node.chainpartinds:
139 cpi = node.chainpartinds[i]
150 condition_tool.chainPartInd =
int(cpi[len(
'leg'):])
152 condition_tool.conditionMakers = el_condition_tools
153 condition_tool.multiplicity = mult
155 outer_condition_tools.append(condition_tool)
157 return outer_condition_tools
161 """ Add Condition tools to For a leaf node."""
186 tmap[node.node_id] = node.parent_id
187 for cn
in node.children:
194 assert (len(node.compound_condition_tools) == 1)
195 cmap[node.node_id] = node.compound_condition_tools[0]
197 fmap[node.node_id] = node.filter_condition_tool
203 cmap[node.node_id].multiplicity = 1
206 fmap[node.node_id].conditionMakers = []
207 fmap[node.node_id].multiplicity = 1
210 for cn
in node.children:
216 vec = [0
for i
in range(len(amap))]
217 for nid, value
in amap.items():
224 'ConditionsToolSetter: illegal scenario: %s' % node.scenario)
226 for cn
in node.children:
230 """Entry point for this module.
231 Modifies a (usually compound) hypo tree node to
232 reduce it to form from whuch the treevector, and conditionsVector
233 These will be used to initialise FastReductionMatcher.
235 In particular: all leaf nodes will have a single ConmpoundCondition
236 All other nodes will be assigned an AcceptAll condition.
254 filterConditionsMap = {}
261 filterConditionsVec = self.
_map_2_vec(filterConditionsMap)
268 config_tool.filtConditionsMakers = filterConditionsVec
269 config_tool.treeVector = treeVec