3from TrigHLTJetHypo.FastReductionAlgToolFactory
import toolfactory
7from TrigHLTJetHypo.scenario_ht
import scenario_ht
8from TrigHLTJetHypo.scenario_dipz
import scenario_dipz
9from TrigHLTJetHypo.scenario_hitz
import scenario_hitz
10from TrigHLTJetHypo.scenario_htdipz
import scenario_htdipz
11from TrigHLTJetHypo.scenario_mult
import scenario_mult
12from TrigHLTJetHypo.scenario_dijet
import scenario_dijet
13from TrigHLTJetHypo.scenario_fbdjnoshared
import scenario_fbdjnoshared
14from TrigHLTJetHypo.scenario_fbdjshared
import scenario_fbdjshared
15from TrigHLTJetHypo.scenario_simple
import scenario_simple
17from TrigHLTJetHypo.prefilter_mask
import prefilter_mask
18from TrigHLTJetHypo.prefilter_ptrange
import prefilter_ptrange
19from TrigHLTJetHypo.prefilter_maxmult
import prefilter_maxmult
20from TrigHLTJetHypo.prefilter_clean
import prefilter_clean
22from TrigHLTJetHypo.hypoToolDisplay
import hypoToolDisplay
26from TrigHLTJetHypo.makeConditionFilterConfigurer
import (
27 makeConditionFilterConfigurer,
30from TrigHLTJetHypo.make_repeatedCondConfigurer
import (
32 make_repeatedCondCfgFromParams,
35from DecisionHandling.TrigCompositeUtils
import isLegId, getLegIndexInt
37from AthenaCommon.Logging
import logging
42logger = logging.getLogger( __name__)
47 'DJMASS200j20' :
'DIJET20j12ptXX200djmass',
48 'DJMASS350j20' :
'DIJET20j12ptXX350djmass',
49 'DJMASS300j35' :
'DIJET35j12ptXX300djmass',
50 'DJMASS500j35' :
'DIJET35j12ptXX500djmass',
51 'DJMASS700j35' :
'DIJET35j12ptXX700djmass',
52 'DJMASS1000j35' :
'DIJET35j12ptXX1000djmass',
53 'DJMASS700j40' :
'DIJET40j12ptXX700djmass',
54 'DJMASS700j50x0eta240' :
'DIJET50j12ptXX0j12eta240XX700djmass',
55 'DJMASS700j80x0eta240' :
'DIJET80j12ptXX0j12eta240XX700djmass',
56 'DJMASS900j50' :
'DIJET50j12ptXX900djmass',
57 'DJMASS1000j50' :
'DIJET50j12ptXX1000djmass',
58 'DJMASS1000j50dphi240' :
'DIJET50j12ptXX1000djmassXXdjdphi240',
59 'DJMASS900j50dphi240' :
'DIJET50j12ptXX900djmassXXdjdphi240',
60 'DJMASS1000j50dphi200x400deta' :
'DIJET50j12ptXX1000djmassXXdjdphi200XX400djdeta',
61 'DJMASS900j50dphi200x400deta' :
'DIJET50j12ptXX900djmassXXdjdphi200XX400djdeta',
62 'DJMASS1000j50dphi260x200deta' :
'DIJET50j12ptXX1000djmassXXdjdphi260XX200djdeta',
63 'DJMASS900j50dphi260x200deta' :
'DIJET50j12ptXX900djmassXXdjdphi260XX200djdeta',
64 'DJMASS1000j30dphi260x200deta' :
'DIJET30j12ptXX1000djmassXXdjdphi260XX200djdeta',
65 'DJMASS900j30dphi260x200deta' :
'DIJET30j12ptXX900djmassXXdjdphi260XX200djdeta',
66 'DJMASS1000j50x200deta' :
'DIJET50j12ptXX1000djmassXX200djdeta',
67 'DJMASS900j50x200deta' :
'DIJET50j12ptXX900djmassXX200djdeta',
69 'DJMASS1000j50dphi260' :
'DIJET50j12ptXX1000djmassXXdjdphi260',
70 'DJMASS900j50dphi260' :
'DIJET50j12ptXX900djmassXXdjdphi260',
75 """make a repeated condition configurer for the fast reduction
76 root node. This will will have a single accapt all internal node."""
78 toolclass, name = toolfactory(
'all')
80 conditionMakers = [toolclass(**args)]
82 configurer = make_repeatedCond(tree_id=0,
85 conditionMakers=conditionMakers)
90 """the parameter object passed in is built in the modules handling
91 scenarios. It contains the information needed to build the
92 configuration AlgTool that intialiases a hypo helper AlgTool"""
96 assert len(params.repcondargs) == len(params.filterparam_inds)
97 assert len(params.filterparam_inds) >= len(params.filterparams)
101 for ra
in params.repcondargs:
102 repcondobjs.append(make_repeatedCondCfgFromParams(ra))
106 filtConditionMakers = []
107 filtConditionMakerInds = [-1]
109 for ra_ind
in params.filterparam_inds:
111 ra = params.filterparams[ra_ind]
112 filtConditionMakers.append(makeConditionFilterConfigurer(ra))
113 filtConditionMakerInds.append(len(filtConditionMakers)-1)
115 filtConditionMakerInds.append(-1)
117 toolclass, name = toolfactory(
'HelperToolConfigTool')
119 vals = {
'name': name,
120 'conditionMakers': repcondobjs,
121 'filterMakers': filtConditionMakers,
122 'filterMakerInds': filtConditionMakerInds,
123 'treeVector': params.treevec,
124 'leafVector': params.leafvec,
127 return toolclass(**vals)
131 """Obtain the paramters needed to build an AlgTool
132 to initialise a jet hypo HelperAlgTool"""
136 helper_params = scenario_simple(chain_parts)
142 return helperconfigobjs
146 """Obtain the paramters needed to build an AlgTool
147 to initialise a jet hypo HelperAlgTool"""
151 helper_params = scenario_dipz(scenario, chainPartInd)
157 return helperconfigobjs
161 """Obtain the paramters needed to build an AlgTool
162 to initialise a jet hypo HelperAlgTool"""
166 helper_params = scenario_hitz(scenario, chainPartInd)
172 return helperconfigobjs
175 """Obtain the paramters needed to build an AlgTool
176 to initialise a jet hypo HelperAlgTool"""
180 helper_params = scenario_ht(scenario, chainPartInd)
186 return helperconfigobjs
189 """Obtain the paramters needed to build an AlgTool
190 to initialise a jet hypo HelperAlgTool"""
194 helper_params = scenario_htdipz(scenario, chainPartInd)
200 return helperconfigobjs
204 """Obtain the paramters needed to build an AlgTool
205 to initialise a jet hypo HelperAlgTool"""
209 helper_params = scenario_mult(scenario, chainPartInd)
215 return helperconfigobjs
219 """Obtain the paramters needed to build an AlgTool
220 to initialise a jet hypo HelperAlgTool"""
224 helper_params = scenario_dijet(scenario, chainPartInd)
230 return helperconfigobjs
234 """Obtain the paramters needed to build an AlgTool
235 to initialise a jet hypo HelperAlgTool"""
239 helper_params = scenario_fbdjshared(scenario, chainPartInd)
245 return helperconfigobjs
249 """Obtain the paramters needed to build an AlgTool
250 to initialise a jet hypo HelperAlgTool"""
254 helper_params = scenario_fbdjnoshared(scenario, chainPartInd)
260 return helperconfigobjs
264 """Maker a list of helper tool config tool for a non-simple scenario.
265 Note: a non-simple scenario will produce more than HelperToolConfigTool
266 if jet sharing among Conditions is required."""
269 if scenario
in aliasesDict.keys(): scenario = aliasesDict[scenario]
274 'HTZ': process_htdipz,
276 'MULT': process_mult,
277 'DIJET': process_dijet,
278 'FBDJSHARED': process_fbdjshared,
279 'FBDJNOSHARED': process_fbdjnoshared,
283 pattern =
r'^(?P<stub>[A-Z]+)'
284 rgx = re.compile(pattern)
285 m = rgx.match(scenario)
286 assert m
is not None,
'No scenario stub was found'
287 groupdict = m.groupdict()
288 assert groupdict[
'stub']
in router,
'scenario stub ({}) not recognized'.format(groupdict[
'stub'])
290 return router[groupdict[
'stub']](scenario, chainPartInd)
294 """Create HelperToolConfigTool instances. Each instance
295 configures a FastReduction tree. Chain parts with the 'simple' scenario
296 are used to form a single HelperToolConfigTool. The information
297 may be spread over a number of chain parts.
299 There is at most one chain part with a non-simple scenario.
300 This may give rise to > 1 HelperToolConfigTool instance - as this
301 is how jet sharing among Conditions is handled.
303 If there are both simple and non-simple scenarios, there will be
304 n HelperToolConfigTool instances, where n >=2: one for the simple
305 scenario chain parts, and n-1 for the non-simple scenario.
308 chain_parts = chain_dict[
'chainParts']
310 simple_chainparts = [
311 cp
for cp
in chain_parts
if cp[
'hypoScenario'] ==
'simple']
312 simple_cpis = [cp[
'chainPartIndex']
for cp
in simple_chainparts]
317 assert simple_cpis == sorted(simple_cpis),
"disordered chain parts"
318 assert simple_cpis[-1] - simple_cpis[0] == len(simple_cpis) - 1,
"nonsequential chainParts"
319 helperToolConfigTools = []
324 if simple_chainparts:
326 assert simple_chainparts[-1][
'tboundary'] ==
''
329 for cp
in simple_chainparts:
331 if cp[
'tboundary'] ==
'SHARED':
339 scenario_chainparts =[
340 cp
for cp
in chain_parts
if cp[
'hypoScenario'] !=
'simple']
342 if scenario_chainparts:
343 for scenario_chainpart
in scenario_chainparts:
347 assert scenario_chainpart[
'threshold'] ==
'0'
349 scenario = scenario_chainpart[
'hypoScenario']
355 chainPartInd = scenario_chainpart[
'chainPartIndex']
360 return helperToolConfigTools
364 """Set up the prefilters fo the chain."""
367 chain_parts = [cp
for cp
in chain_dict[
'chainParts']
if
368 cp[
'signature'] ==
'Jet' and 'prefilters' in cp]
370 [pf_strings.extend(cp[
'prefilters'])
for cp
in chain_parts]
380 'MASK': prefilter_mask,
381 'PTRANGE': prefilter_ptrange,
382 'MAXMULT': prefilter_maxmult,
383 'CLEAN': prefilter_clean,
386 pattern =
r'(?P<stub>[A-Z]*)'
387 rgx = re.compile(pattern)
390 for pf_string
in pf_strings:
392 m = rgx.match(pf_string)
393 assert m
is not None,
'No prefilter stub was found'
394 groupdict = m.groupdict()
395 assert groupdict[
'stub']
in prefilter_router,
'prefilter stub ({}) not recognized'.format(groupdict[
'stub'])
396 filters.append(prefilter_router[groupdict[
'stub']](pf_string))
404 if isLegId(chain_dict[
'chainName']):
405 start_index = getLegIndexInt(chain_dict[
'chainName'])
407 end_index = start_index + len(chain_dict[
'chainParts'])
409 return start_index, end_index
417 fn = chain_dict[
'chainName'] +
'_chaindict.log'
418 from pprint
import pprint
419 with open(fn,
'w')
as fh:
420 pprint(chain_dict, fh)
427 toolclass, name = toolfactory(
'helper_tool')
428 args = {
'name': name,
429 'HypoConfigurers': helperToolConfigTools,
430 'prefilterMakers': prefilterMakers
433 helper_tool = toolclass(**args)
435 toolclass, name = toolfactory(
'hypo_tool')
439 args = {
'name': chain_dict[
'chainName'],
441 'visit_debug': visit_debug,
442 'helper_tool': helper_tool,
443 'chain_name': chain_dict[
'chainName'],
444 'startLabelIndex': startLabelIndex,
445 'endLabelIndex': endLabelIndex,
448 hypo_tool = toolclass(**args)
449 hypo_tool.visit_debug = visit_debug
452 hypoToolDisplay(hypo_tool,
457if __name__ ==
'__main__':
459 'L1item':
'L1_EM22VHI',
460 'alignmentGroups': [
'Egamma',
'JetMET',
'JetMET'],
461 'chainCounter': 1451,
462 'chainMultiplicities': [1, 2, 2],
463 'chainName':
'leg001_HLT_g25_medium_2j35_pf_ftf_0eta490_bdl1r77_2j35_pf_ftf_0eta490_L1EM22VHI',
464 'chainNameHash': 4053501929,
465 'chainParts': [{
'L1threshold':
'FSNOSEED',
467 'alignmentGroup':
'JetMET',
475 'chainPartName':
'2j35_pf_ftf_0eta490_bdl1r77',
476 'clusterCalib':
'em',
479 'etaRange':
'0eta490',
482 'hypoScenario':
'simple',
484 'jetCalib':
'default',
491 'sigFolder': [
'Bjet'],
500 'trkpresel':
'nopresel'},
501 {
'L1threshold':
'FSNOSEED',
503 'alignmentGroup':
'JetMET',
511 'chainPartName':
'2j35_pf_ftf_0eta490',
512 'clusterCalib':
'em',
515 'etaRange':
'0eta490',
518 'hypoScenario':
'simple',
520 'jetCalib':
'default',
527 'sigFolder': [
'Jet'],
536 'trkpresel':
'nopresel'}],
537 'eventBuildType':
'',
538 'extraComboHypos': [],
539 'groups': [
'Support:Legacy',
'RATE:EgammaBjet',
'BW:BJet'],
542 'mergingStrategy':
'auto',
545 'sigDicts': {
'Bjet': [
'Bjet'],
'Egamma': [
'Photon'],
'Jet': [
'Jet']},
548 'signatures': [
'Photon',
'Bjet',
'Jet'],
process_fbdjshared(scenario, chainPartInd)
process_dipz(scenario, chainPartInd)
process_mult(scenario, chainPartInd)
process_dijet(scenario, chainPartInd)
buildHypoHelperConfigTool(params)
process_simple(chain_parts)
process_ht(scenario, chainPartInd)
make_prefilter_configurers(chain_dict)
hypotool_from_chaindict(chain_dict, visit_debug=False)
process_htdipz(scenario, chainPartInd)
process_nonsimple(scenario, chainPartInd)
make_fastreduction_configurers(chain_dict)
make_root_repcondconfig()
process_hitz(scenario, chainPartInd)
getLabelIndices(chain_dict)
process_fbdjnoshared(scenario, chainPartInd)