ATLAS Offline Software
Functions | Variables
python.hypoConfigBuilder Namespace Reference

Functions

def make_root_repcondconfig ()
 
def buildHypoHelperConfigTool (params)
 
def process_simple (chain_parts)
 
def process_dipz (scenario, chainPartInd)
 
def process_ht (scenario, chainPartInd)
 
def process_htdipz (scenario, chainPartInd)
 
def process_dijet (scenario, chainPartInd)
 
def process_fbdjshared (scenario, chainPartInd)
 
def process_fbdjnoshared (scenario, chainPartInd)
 
def process_nonsimple (scenario, chainPartInd)
 
def make_fastreduction_configurers (chain_dict)
 
def make_prefilter_configurers (chain_dict)
 
def getLabelIndices (chain_dict)
 
def hypotool_from_chaindict (chain_dict, visit_debug=False)
 

Variables

 logger
 
 aliasesDict
 
 cd
 

Function Documentation

◆ buildHypoHelperConfigTool()

def python.hypoConfigBuilder.buildHypoHelperConfigTool (   params)
the parameter object passed in is built in the modules handling
scenarios. It contains the information needed to build the
configuration AlgTool that intialiases a hypo helper AlgTool

Definition at line 87 of file hypoConfigBuilder.py.

87 def buildHypoHelperConfigTool(params):
88  """the parameter object passed in is built in the modules handling
89  scenarios. It contains the information needed to build the
90  configuration AlgTool that intialiases a hypo helper AlgTool"""
91 
92  # check that each Condition has a Filter index.
93  # the index is -1 for no Condition filtering.
94  assert len(params.repcondargs) == len(params.filterparam_inds)
95  assert len(params.filterparam_inds) >= len(params.filterparams)
96 
97  # FastReducer root node
98  repcondobjs = [make_root_repcondconfig()]
99  for ra in params.repcondargs:
100  repcondobjs.append(make_repeatedCondCfgFromParams(ra))
101 
102 
103  # filter for FastReducer root node (use position 0)
104  filtConditionMakers = []
105  filtConditionMakerInds = [-1] # no condition filtering for root
106 
107  for ra_ind in params.filterparam_inds:
108  if ra_ind != -1:
109  ra = params.filterparams[ra_ind]
110  filtConditionMakers.append(makeConditionFilterConfigurer(ra))
111  filtConditionMakerInds.append(len(filtConditionMakers)-1)
112  else:
113  filtConditionMakerInds.append(-1)
114 
115  toolclass, name = toolfactory('HelperToolConfigTool')
116 
117  vals = {'name': name,
118  'conditionMakers': repcondobjs,
119  'filterMakers': filtConditionMakers,
120  'filterMakerInds': filtConditionMakerInds,
121  'treeVector': params.treevec,
122  'leafVector': params.leafvec,
123  }
124 
125  return toolclass(**vals)
126 
127 

◆ getLabelIndices()

def python.hypoConfigBuilder.getLabelIndices (   chain_dict)

Definition at line 366 of file hypoConfigBuilder.py.

366 def getLabelIndices(chain_dict):
367 
368  start_index = 0
369  if isLegId(chain_dict['chainName']):
370  start_index = getLegIndexInt(chain_dict['chainName'])
371 
372  end_index = start_index + len(chain_dict['chainParts'])
373 
374  return start_index, end_index
375 
376 

◆ hypotool_from_chaindict()

def python.hypoConfigBuilder.hypotool_from_chaindict (   chain_dict,
  visit_debug = False 
)

Definition at line 377 of file hypoConfigBuilder.py.

377 def hypotool_from_chaindict(chain_dict, visit_debug=False):
378 
379  toolfactory.reset()
380 
381  if visit_debug:
382  fn = chain_dict['chainName'] + '_chaindict.log'
383  from pprint import pprint
384  with open(fn, 'w') as fh:
385  pprint(chain_dict, fh)
386 
387 
388  helperToolConfigTools = make_fastreduction_configurers(chain_dict)
389 
390  prefilterMakers = make_prefilter_configurers(chain_dict)
391 
392  toolclass, name = toolfactory('helper_tool')
393  args = {'name': name,
394  'HypoConfigurers': helperToolConfigTools,
395  'prefilterMakers': prefilterMakers
396  }
397 
398  helper_tool = toolclass(**args)
399 
400  toolclass, name = toolfactory('hypo_tool')
401 
402  startLabelIndex, endLabelIndex = getLabelIndices(chain_dict)
403 
404  args = {'name': chain_dict['chainName'],
405  # for reporting passing jets:
406  'visit_debug': visit_debug,
407  'helper_tool': helper_tool,
408  'chain_name': chain_dict['chainName'],
409  'startLabelIndex': startLabelIndex,
410  'endLabelIndex': endLabelIndex,
411  }
412 
413  hypo_tool = toolclass(**args)
414  hypo_tool.visit_debug = visit_debug
415 
416  if (visit_debug):
417  hypoToolDisplay(hypo_tool,
418  do_dot=True)
419 
420  return hypo_tool
421 

◆ make_fastreduction_configurers()

def python.hypoConfigBuilder.make_fastreduction_configurers (   chain_dict)
Create HelperToolConfigTool  instances. Each instance
configures a FastReduction tree. Chain parts with the 'simple' scenario
are used to form a single HelperToolConfigTool. The information 
may be spread over a number of chain parts. 

There is at most one chain part with a non-simple scenario. 
This may give rise to > 1 HelperToolConfigTool instance - as this
is how jet sharing among Conditions is handled.

If there are both simple and non-simple scenarios, there will be
n HelperToolConfigTool instances, where n >=2: one for the simple 
scenario chain parts, and n-1 for the non-simple scenario.

Definition at line 258 of file hypoConfigBuilder.py.

258 def make_fastreduction_configurers(chain_dict):
259  """Create HelperToolConfigTool instances. Each instance
260  configures a FastReduction tree. Chain parts with the 'simple' scenario
261  are used to form a single HelperToolConfigTool. The information
262  may be spread over a number of chain parts.
263 
264  There is at most one chain part with a non-simple scenario.
265  This may give rise to > 1 HelperToolConfigTool instance - as this
266  is how jet sharing among Conditions is handled.
267 
268  If there are both simple and non-simple scenarios, there will be
269  n HelperToolConfigTool instances, where n >=2: one for the simple
270  scenario chain parts, and n-1 for the non-simple scenario.
271  """
272 
273  chain_parts = chain_dict['chainParts']
274 
275  simple_chainparts = [
276  cp for cp in chain_parts if cp['hypoScenario'] == 'simple']
277  simple_cpis = [cp['chainPartIndex'] for cp in simple_chainparts]
278  # check that all the simple scenario parts occur before
279  # non-simple scenario chain parts
280 
281  if simple_cpis:
282  assert simple_cpis == sorted(simple_cpis), "disordered chain parts"
283  assert simple_cpis[-1] - simple_cpis[0] == len(simple_cpis) - 1, "nonsequential chainParts"
284  helperToolConfigTools = []
285 
286  # check for SHARED markers (chainPart['tboundary'] = 'SHARED')
287  # in the list of simple chain parts.
288  # Get a tree configuration each time SHARED == 1 is encountered.
289  if simple_chainparts:
290 
291  assert simple_chainparts[-1]['tboundary'] == ''
292 
293  tree_cps = []
294  for cp in simple_chainparts:
295  tree_cps.append(cp)
296  if cp['tboundary'] == 'SHARED':
297  helperToolConfigTools.extend(process_simple(tree_cps))
298  tree_cps = []
299 
300  # tree_cps cannot be empty here
301  assert tree_cps
302  helperToolConfigTools.extend(process_simple(tree_cps))
303 
304  scenario_chainparts =[
305  cp for cp in chain_parts if cp['hypoScenario'] != 'simple']
306 
307  if scenario_chainparts:
308  for scenario_chainpart in scenario_chainparts:
309  # scenario_chainpart = scenario_chainparts[0]
310 
311  # We only allow threshold != 0 for the simple scenario.
312  assert scenario_chainpart['threshold'] == '0'
313 
314  scenario = scenario_chainpart['hypoScenario']
315  # find the chain part index for a non-simple scenario.
316  # assume simple is processed before non-simple, and that
317  # there is at most one non-simple chainpart.
318  # chainPartInd is needed to report passing jets to the
319  # trigger framework.
320  chainPartInd = scenario_chainpart['chainPartIndex']
321 
322  helperToolConfigTools.extend(process_nonsimple(scenario,
323  chainPartInd))
324 
325  return helperToolConfigTools
326 
327 

◆ make_prefilter_configurers()

def python.hypoConfigBuilder.make_prefilter_configurers (   chain_dict)
Set up the prefilters fo the chain.

Definition at line 328 of file hypoConfigBuilder.py.

328 def make_prefilter_configurers(chain_dict):
329  """Set up the prefilters fo the chain."""
330 
331  pf_strings = []
332  chain_parts = [cp for cp in chain_dict['chainParts'] if
333  cp['signature'] == 'Jet' and 'prefilters' in cp]
334 
335  [pf_strings.extend(cp['prefilters']) for cp in chain_parts]
336 
337  # if not pre filter strings (pf_strings) are found in the chainDict,
338  # a PassThroughFilter configurer is made.
339 
340  if not pf_strings:
341  return []
342 
343  # route the prefilter strings to the appropriate handler
344  prefilter_router = {
345  'MASK': prefilter_mask,
346  'PTRANGE': prefilter_ptrange,
347  'MAXMULT': prefilter_maxmult,
348  'CLEAN': prefilter_clean,
349  }
350 
351  pattern = r'(?P<stub>[A-Z]*)'
352  rgx = re.compile(pattern)
353 
354  filters = []
355  for pf_string in pf_strings:
356  # get prefilter stub and make sure is correct
357  m = rgx.match(pf_string)
358  assert m is not None,'No prefilter stub was found'
359  groupdict = m.groupdict()
360  assert groupdict['stub'] in prefilter_router,'prefilter stub ({}) not recognized'.format(groupdict['stub'])
361  filters.append(prefilter_router[groupdict['stub']](pf_string))
362 
363  return filters
364 
365 

◆ make_root_repcondconfig()

def python.hypoConfigBuilder.make_root_repcondconfig ( )
make a repeated condition configurer for the fast reduction
root node. This will will have a single accapt all internal node.

Definition at line 72 of file hypoConfigBuilder.py.

73  """make a repeated condition configurer for the fast reduction
74  root node. This will will have a single accapt all internal node."""
75 
76  toolclass, name = toolfactory('all')
77  args = {'name': name}
78  conditionMakers = [toolclass(**args)]
79 
80  configurer = make_repeatedCond(tree_id=0,
81  tree_pid=0,
82  clique=-1,
83  conditionMakers=conditionMakers)
84 
85  return configurer
86 

◆ process_dijet()

def python.hypoConfigBuilder.process_dijet (   scenario,
  chainPartInd 
)
Obtain the paramters needed to build an AlgTool
to initialise a jet hypo HelperAlgTool

Definition at line 185 of file hypoConfigBuilder.py.

185 def process_dijet(scenario, chainPartInd):
186  """Obtain the paramters needed to build an AlgTool
187  to initialise a jet hypo HelperAlgTool"""
188 
189  # obtain a list of parameter objects that will be used
190  # to build a helper config AlgTools
191  helper_params = scenario_dijet(scenario, chainPartInd)
192 
193  # build the helper config AlgTools
194  helperconfigobjs = [buildHypoHelperConfigTool(params) for params in
195  helper_params]
196 
197  return helperconfigobjs
198 
199 

◆ process_dipz()

def python.hypoConfigBuilder.process_dipz (   scenario,
  chainPartInd 
)
Obtain the paramters needed to build an AlgTool
to initialise a jet hypo HelperAlgTool

Definition at line 143 of file hypoConfigBuilder.py.

143 def process_dipz(scenario, chainPartInd):
144  """Obtain the paramters needed to build an AlgTool
145  to initialise a jet hypo HelperAlgTool"""
146 
147  # obtain a list of parameter objects that will be used
148  # to build a helper config AlgTools
149  helper_params = scenario_dipz(scenario, chainPartInd)
150 
151  # build the helper config AlgTools
152  helperconfigobjs = [buildHypoHelperConfigTool(params) for params in
153  helper_params]
154 
155  return helperconfigobjs
156 

◆ process_fbdjnoshared()

def python.hypoConfigBuilder.process_fbdjnoshared (   scenario,
  chainPartInd 
)
Obtain the paramters needed to build an AlgTool
to initialise a jet hypo HelperAlgTool

Definition at line 215 of file hypoConfigBuilder.py.

215 def process_fbdjnoshared(scenario, chainPartInd):
216  """Obtain the paramters needed to build an AlgTool
217  to initialise a jet hypo HelperAlgTool"""
218 
219  # obtain a list of parameter objects that will be used
220  # to build a helper config AlgTools
221  helper_params = scenario_fbdjnoshared(scenario, chainPartInd)
222 
223  # build the helper config AlgTools
224  helperconfigobjs = [buildHypoHelperConfigTool(params) for params in
225  helper_params]
226 
227  return helperconfigobjs
228 
229 

◆ process_fbdjshared()

def python.hypoConfigBuilder.process_fbdjshared (   scenario,
  chainPartInd 
)
Obtain the paramters needed to build an AlgTool
to initialise a jet hypo HelperAlgTool

Definition at line 200 of file hypoConfigBuilder.py.

200 def process_fbdjshared(scenario, chainPartInd):
201  """Obtain the paramters needed to build an AlgTool
202  to initialise a jet hypo HelperAlgTool"""
203 
204  # obtain a list of parameter objects that will be used
205  # to build a helper config AlgTools
206  helper_params = scenario_fbdjshared(scenario, chainPartInd)
207 
208  # build the helper config AlgTools
209  helperconfigobjs = [buildHypoHelperConfigTool(params) for params in
210  helper_params]
211 
212  return helperconfigobjs
213 
214 

◆ process_ht()

def python.hypoConfigBuilder.process_ht (   scenario,
  chainPartInd 
)
Obtain the paramters needed to build an AlgTool
to initialise a jet hypo HelperAlgTool

Definition at line 157 of file hypoConfigBuilder.py.

157 def process_ht(scenario, chainPartInd):
158  """Obtain the paramters needed to build an AlgTool
159  to initialise a jet hypo HelperAlgTool"""
160 
161  # obtain a list of parameter objects that will be used
162  # to build a helper config AlgTools
163  helper_params = scenario_ht(scenario, chainPartInd)
164 
165  # build the helper config AlgTools
166  helperconfigobjs = [buildHypoHelperConfigTool(params) for params in
167  helper_params]
168 
169  return helperconfigobjs
170 

◆ process_htdipz()

def python.hypoConfigBuilder.process_htdipz (   scenario,
  chainPartInd 
)
Obtain the paramters needed to build an AlgTool
to initialise a jet hypo HelperAlgTool

Definition at line 171 of file hypoConfigBuilder.py.

171 def process_htdipz(scenario, chainPartInd):
172  """Obtain the paramters needed to build an AlgTool
173  to initialise a jet hypo HelperAlgTool"""
174 
175  # obtain a list of parameter objects that will be used
176  # to build a helper config AlgTools
177  helper_params = scenario_htdipz(scenario, chainPartInd)
178 
179  # build the helper config AlgTools
180  helperconfigobjs = [buildHypoHelperConfigTool(params) for params in
181  helper_params]
182 
183  return helperconfigobjs
184 

◆ process_nonsimple()

def python.hypoConfigBuilder.process_nonsimple (   scenario,
  chainPartInd 
)
Maker a list of helper tool config tool for a non-simple scenario.
Note:  a non-simple scenario will  produce more than HelperToolConfigTool
if jet sharing among Conditions is required.

Definition at line 230 of file hypoConfigBuilder.py.

230 def process_nonsimple(scenario, chainPartInd):
231  """Maker a list of helper tool config tool for a non-simple scenario.
232  Note: a non-simple scenario will produce more than HelperToolConfigTool
233  if jet sharing among Conditions is required."""
234 
235  # interpret scenario aliases
236  if scenario in aliasesDict.keys(): scenario = aliasesDict[scenario]
237 
238  router = {
239  'Z': process_dipz,
240  'HTZ': process_htdipz,
241  'HT': process_ht,
242  'DIJET': process_dijet,
243  'FBDJSHARED': process_fbdjshared,
244  'FBDJNOSHARED': process_fbdjnoshared,
245  }
246 
247  # get scenario stub and make sure is correct
248  pattern = r'^(?P<stub>[A-Z]+)'
249  rgx = re.compile(pattern)
250  m = rgx.match(scenario)
251  assert m is not None,'No scenario stub was found'
252  groupdict = m.groupdict()
253  assert groupdict['stub'] in router,'scenario stub ({}) not recognized'.format(groupdict['stub'])
254 
255  return router[groupdict['stub']](scenario, chainPartInd) # list of HelperToolConfigTool
256 
257 

◆ process_simple()

def python.hypoConfigBuilder.process_simple (   chain_parts)
Obtain the paramters needed to build an AlgTool
to initialise a jet hypo HelperAlgTool

Definition at line 128 of file hypoConfigBuilder.py.

128 def process_simple(chain_parts):
129  """Obtain the paramters needed to build an AlgTool
130  to initialise a jet hypo HelperAlgTool"""
131 
132  # obtain a list of parameter objects that will be used
133  # to build a helper config AlgTools
134  helper_params = scenario_simple(chain_parts)
135 
136  # build the helper config AlgTools
137  helperconfigobjs = [buildHypoHelperConfigTool(params) for params in
138  helper_params]
139 
140  return helperconfigobjs
141 
142 

Variable Documentation

◆ aliasesDict

python.hypoConfigBuilder.aliasesDict

Definition at line 44 of file hypoConfigBuilder.py.

◆ cd

python.hypoConfigBuilder.cd

Definition at line 423 of file hypoConfigBuilder.py.

◆ logger

python.hypoConfigBuilder.logger

Definition at line 40 of file hypoConfigBuilder.py.

python.hypoConfigBuilder.getLabelIndices
def getLabelIndices(chain_dict)
Definition: hypoConfigBuilder.py:366
python.hypoConfigBuilder.process_dipz
def process_dipz(scenario, chainPartInd)
Definition: hypoConfigBuilder.py:143
python.scenario_fbdjshared.scenario_fbdjshared
def scenario_fbdjshared(scenario, chainPartInd)
Definition: scenario_fbdjshared.py:9
vtune_athena.format
format
Definition: vtune_athena.py:14
python.scenario_htdipz.scenario_htdipz
def scenario_htdipz(scenario, chainPartInd)
Definition: scenario_htdipz.py:62
python.scenario_ht.scenario_ht
def scenario_ht(scenario, chainPartInd)
Definition: scenario_ht.py:64
python.makeConditionFilterConfigurer.makeConditionFilterConfigurer
def makeConditionFilterConfigurer(filterparams)
Definition: makeConditionFilterConfigurer.py:12
python.TrigCompositeUtils.isLegId
def isLegId(chainName)
Definition: DecisionHandling/python/TrigCompositeUtils.py:18
python.scenario_dipz.scenario_dipz
def scenario_dipz(scenario, chainPartInd)
Definition: scenario_dipz.py:65
python.hypoConfigBuilder.process_ht
def process_ht(scenario, chainPartInd)
Definition: hypoConfigBuilder.py:157
python.hypoConfigBuilder.process_fbdjshared
def process_fbdjshared(scenario, chainPartInd)
Definition: hypoConfigBuilder.py:200
python.scenario_dijet.scenario_dijet
def scenario_dijet(scenario, chainPartInd)
Definition: scenario_dijet.py:73
python.hypoConfigBuilder.process_nonsimple
def process_nonsimple(scenario, chainPartInd)
Definition: hypoConfigBuilder.py:230
python.hypoConfigBuilder.process_htdipz
def process_htdipz(scenario, chainPartInd)
Definition: hypoConfigBuilder.py:171
python.make_repeatedCondConfigurer.make_repeatedCond
def make_repeatedCond(tree_id, tree_pid, clique, multiplicity=1, chainPartInd=-1, conditionMakers=[], invert=False)
Definition: make_repeatedCondConfigurer.py:11
python.hypoConfigBuilder.process_dijet
def process_dijet(scenario, chainPartInd)
Definition: hypoConfigBuilder.py:185
python.hypoConfigBuilder.buildHypoHelperConfigTool
def buildHypoHelperConfigTool(params)
Definition: hypoConfigBuilder.py:87
python.hypoConfigBuilder.hypotool_from_chaindict
def hypotool_from_chaindict(chain_dict, visit_debug=False)
Definition: hypoConfigBuilder.py:377
DerivationFramework::TriggerMatchingUtils::sorted
std::vector< typename T::value_type > sorted(T begin, T end)
Helper function to create a sorted vector from an unsorted one.
python.scenario_fbdjnoshared.scenario_fbdjnoshared
def scenario_fbdjnoshared(scenario, chainPartInd)
Definition: scenario_fbdjnoshared.py:70
python.TrigCompositeUtils.getLegIndexInt
def getLegIndexInt(chainName)
Definition: DecisionHandling/python/TrigCompositeUtils.py:21
Trk::open
@ open
Definition: BinningType.h:40
python.hypoToolDisplay.hypoToolDisplay
def hypoToolDisplay(tool, do_dot=False, dotdir='')
Definition: hypoToolDisplay.py:72
python.hypoConfigBuilder.make_fastreduction_configurers
def make_fastreduction_configurers(chain_dict)
Definition: hypoConfigBuilder.py:258
python.hypoConfigBuilder.process_simple
def process_simple(chain_parts)
Definition: hypoConfigBuilder.py:128
python.scenario_simple.scenario_simple
def scenario_simple(chain_parts)
Definition: scenario_simple.py:274
python.hypoConfigBuilder.make_prefilter_configurers
def make_prefilter_configurers(chain_dict)
Definition: hypoConfigBuilder.py:328
python.make_repeatedCondConfigurer.make_repeatedCondCfgFromParams
def make_repeatedCondCfgFromParams(repcondarg)
Definition: make_repeatedCondConfigurer.py:44
python.hypoConfigBuilder.process_fbdjnoshared
def process_fbdjnoshared(scenario, chainPartInd)
Definition: hypoConfigBuilder.py:215
python.hypoConfigBuilder.make_root_repcondconfig
def make_root_repcondconfig()
Definition: hypoConfigBuilder.py:72
python.FastReductionAlgToolFactory.toolfactory
toolfactory
Definition: FastReductionAlgToolFactory.py:106