3 from TrigHLTJetHypo.FastReductionAlgToolFactory
import toolfactory
7 from TrigHLTJetHypo.scenario_ht
import scenario_ht
8 from TrigHLTJetHypo.scenario_dipz
import scenario_dipz
9 from TrigHLTJetHypo.scenario_htdipz
import scenario_htdipz
10 from TrigHLTJetHypo.scenario_mult
import scenario_mult
11 from TrigHLTJetHypo.scenario_dijet
import scenario_dijet
12 from TrigHLTJetHypo.scenario_fbdjnoshared
import scenario_fbdjnoshared
13 from TrigHLTJetHypo.scenario_fbdjshared
import scenario_fbdjshared
14 from TrigHLTJetHypo.scenario_simple
import scenario_simple
16 from TrigHLTJetHypo.prefilter_mask
import prefilter_mask
17 from TrigHLTJetHypo.prefilter_ptrange
import prefilter_ptrange
18 from TrigHLTJetHypo.prefilter_maxmult
import prefilter_maxmult
19 from TrigHLTJetHypo.prefilter_clean
import prefilter_clean
21 from TrigHLTJetHypo.hypoToolDisplay
import hypoToolDisplay
25 from TrigHLTJetHypo.makeConditionFilterConfigurer
import (
26 makeConditionFilterConfigurer,
29 from TrigHLTJetHypo.make_repeatedCondConfigurer
import (
31 make_repeatedCondCfgFromParams,
34 from DecisionHandling.TrigCompositeUtils
import isLegId, getLegIndexInt
36 from AthenaCommon.Logging
import logging
41 logger = logging.getLogger( __name__)
42 logger.setLevel(DEBUG)
46 'DJMASS200j20' :
'DIJET20j12ptXX200djmass',
47 'DJMASS350j20' :
'DIJET20j12ptXX350djmass',
48 'DJMASS300j35' :
'DIJET35j12ptXX300djmass',
49 'DJMASS500j35' :
'DIJET35j12ptXX500djmass',
50 'DJMASS700j35' :
'DIJET35j12ptXX700djmass',
51 'DJMASS1000j35' :
'DIJET35j12ptXX1000djmass',
52 'DJMASS700j40' :
'DIJET40j12ptXX700djmass',
53 'DJMASS700j50x0eta240' :
'DIJET50j12ptXX0j12eta240XX700djmass',
54 'DJMASS700j80x0eta240' :
'DIJET80j12ptXX0j12eta240XX700djmass',
55 'DJMASS900j50' :
'DIJET50j12ptXX900djmass',
56 'DJMASS1000j50' :
'DIJET50j12ptXX1000djmass',
57 'DJMASS1000j50dphi240' :
'DIJET50j12ptXX1000djmassXXdjdphi240',
58 'DJMASS900j50dphi240' :
'DIJET50j12ptXX900djmassXXdjdphi240',
59 'DJMASS1000j50dphi200x400deta' :
'DIJET50j12ptXX1000djmassXXdjdphi200XX400djdeta',
60 'DJMASS900j50dphi200x400deta' :
'DIJET50j12ptXX900djmassXXdjdphi200XX400djdeta',
61 'DJMASS1000j50dphi260x200deta' :
'DIJET50j12ptXX1000djmassXXdjdphi260XX200djdeta',
62 'DJMASS900j50dphi260x200deta' :
'DIJET50j12ptXX900djmassXXdjdphi260XX200djdeta',
63 'DJMASS1000j30dphi260x200deta' :
'DIJET30j12ptXX1000djmassXXdjdphi260XX200djdeta',
64 'DJMASS900j30dphi260x200deta' :
'DIJET30j12ptXX900djmassXXdjdphi260XX200djdeta',
65 'DJMASS1000j50x200deta' :
'DIJET50j12ptXX1000djmassXX200djdeta',
66 'DJMASS900j50x200deta' :
'DIJET50j12ptXX900djmassXX200djdeta',
68 'DJMASS1000j50dphi260' :
'DIJET50j12ptXX1000djmassXXdjdphi260',
69 'DJMASS900j50dphi260' :
'DIJET50j12ptXX900djmassXXdjdphi260',
74 """make a repeated condition configurer for the fast reduction
75 root node. This will will have a single accapt all internal node."""
79 conditionMakers = [toolclass(**args)]
84 conditionMakers=conditionMakers)
89 """the parameter object passed in is built in the modules handling
90 scenarios. It contains the information needed to build the
91 configuration AlgTool that intialiases a hypo helper AlgTool"""
95 assert len(params.repcondargs) == len(params.filterparam_inds)
96 assert len(params.filterparam_inds) >= len(params.filterparams)
100 for ra
in params.repcondargs:
105 filtConditionMakers = []
106 filtConditionMakerInds = [-1]
108 for ra_ind
in params.filterparam_inds:
110 ra = params.filterparams[ra_ind]
112 filtConditionMakerInds.append(len(filtConditionMakers)-1)
114 filtConditionMakerInds.append(-1)
116 toolclass, name =
toolfactory(
'HelperToolConfigTool')
118 vals = {
'name': name,
119 'conditionMakers': repcondobjs,
120 'filterMakers': filtConditionMakers,
121 'filterMakerInds': filtConditionMakerInds,
122 'treeVector': params.treevec,
123 'leafVector': params.leafvec,
126 return toolclass(**vals)
130 """Obtain the paramters needed to build an AlgTool
131 to initialise a jet hypo HelperAlgTool"""
141 return helperconfigobjs
145 """Obtain the paramters needed to build an AlgTool
146 to initialise a jet hypo HelperAlgTool"""
156 return helperconfigobjs
159 """Obtain the paramters needed to build an AlgTool
160 to initialise a jet hypo HelperAlgTool"""
164 helper_params =
scenario_ht(scenario, chainPartInd)
170 return helperconfigobjs
173 """Obtain the paramters needed to build an AlgTool
174 to initialise a jet hypo HelperAlgTool"""
184 return helperconfigobjs
188 """Obtain the paramters needed to build an AlgTool
189 to initialise a jet hypo HelperAlgTool"""
199 return helperconfigobjs
203 """Obtain the paramters needed to build an AlgTool
204 to initialise a jet hypo HelperAlgTool"""
214 return helperconfigobjs
218 """Obtain the paramters needed to build an AlgTool
219 to initialise a jet hypo HelperAlgTool"""
229 return helperconfigobjs
233 """Obtain the paramters needed to build an AlgTool
234 to initialise a jet hypo HelperAlgTool"""
244 return helperconfigobjs
248 """Maker a list of helper tool config tool for a non-simple scenario.
249 Note: a non-simple scenario will produce more than HelperToolConfigTool
250 if jet sharing among Conditions is required."""
253 if scenario
in aliasesDict.keys(): scenario = aliasesDict[scenario]
257 'HTZ': process_htdipz,
259 'MULT': process_mult,
260 'DIJET': process_dijet,
261 'FBDJSHARED': process_fbdjshared,
262 'FBDJNOSHARED': process_fbdjnoshared,
266 pattern =
r'^(?P<stub>[A-Z]+)'
267 rgx = re.compile(pattern)
268 m = rgx.match(scenario)
269 assert m
is not None,
'No scenario stub was found'
270 groupdict = m.groupdict()
271 assert groupdict[
'stub']
in router,
'scenario stub ({}) not recognized'.
format(groupdict[
'stub'])
273 return router[groupdict[
'stub']](scenario, chainPartInd)
277 """Create HelperToolConfigTool instances. Each instance
278 configures a FastReduction tree. Chain parts with the 'simple' scenario
279 are used to form a single HelperToolConfigTool. The information
280 may be spread over a number of chain parts.
282 There is at most one chain part with a non-simple scenario.
283 This may give rise to > 1 HelperToolConfigTool instance - as this
284 is how jet sharing among Conditions is handled.
286 If there are both simple and non-simple scenarios, there will be
287 n HelperToolConfigTool instances, where n >=2: one for the simple
288 scenario chain parts, and n-1 for the non-simple scenario.
291 chain_parts = chain_dict[
'chainParts']
293 simple_chainparts = [
294 cp
for cp
in chain_parts
if cp[
'hypoScenario'] ==
'simple']
295 simple_cpis = [cp[
'chainPartIndex']
for cp
in simple_chainparts]
300 assert simple_cpis ==
sorted(simple_cpis),
"disordered chain parts"
301 assert simple_cpis[-1] - simple_cpis[0] == len(simple_cpis) - 1,
"nonsequential chainParts"
302 helperToolConfigTools = []
307 if simple_chainparts:
309 assert simple_chainparts[-1][
'tboundary'] ==
''
312 for cp
in simple_chainparts:
314 if cp[
'tboundary'] ==
'SHARED':
322 scenario_chainparts =[
323 cp
for cp
in chain_parts
if cp[
'hypoScenario'] !=
'simple']
325 if scenario_chainparts:
326 for scenario_chainpart
in scenario_chainparts:
330 assert scenario_chainpart[
'threshold'] ==
'0'
332 scenario = scenario_chainpart[
'hypoScenario']
338 chainPartInd = scenario_chainpart[
'chainPartIndex']
343 return helperToolConfigTools
347 """Set up the prefilters fo the chain."""
350 chain_parts = [cp
for cp
in chain_dict[
'chainParts']
if
351 cp[
'signature'] ==
'Jet' and 'prefilters' in cp]
353 [pf_strings.extend(cp[
'prefilters'])
for cp
in chain_parts]
363 'MASK': prefilter_mask,
364 'PTRANGE': prefilter_ptrange,
365 'MAXMULT': prefilter_maxmult,
366 'CLEAN': prefilter_clean,
369 pattern =
r'(?P<stub>[A-Z]*)'
370 rgx = re.compile(pattern)
373 for pf_string
in pf_strings:
375 m = rgx.match(pf_string)
376 assert m
is not None,
'No prefilter stub was found'
377 groupdict = m.groupdict()
378 assert groupdict[
'stub']
in prefilter_router,
'prefilter stub ({}) not recognized'.
format(groupdict[
'stub'])
379 filters.append(prefilter_router[groupdict[
'stub']](pf_string))
387 if isLegId(chain_dict[
'chainName']):
390 end_index = start_index + len(chain_dict[
'chainParts'])
392 return start_index, end_index
400 fn = chain_dict[
'chainName'] +
'_chaindict.log'
401 from pprint
import pprint
402 with open(fn,
'w')
as fh:
403 pprint(chain_dict, fh)
411 args = {
'name': name,
412 'HypoConfigurers': helperToolConfigTools,
413 'prefilterMakers': prefilterMakers
416 helper_tool = toolclass(**args)
422 args = {
'name': chain_dict[
'chainName'],
424 'visit_debug': visit_debug,
425 'helper_tool': helper_tool,
426 'chain_name': chain_dict[
'chainName'],
427 'startLabelIndex': startLabelIndex,
428 'endLabelIndex': endLabelIndex,
431 hypo_tool = toolclass(**args)
432 hypo_tool.visit_debug = visit_debug
440 if __name__ ==
'__main__':
442 'L1item':
'L1_EM22VHI',
443 'alignmentGroups': [
'Egamma',
'JetMET',
'JetMET'],
444 'chainCounter': 1451,
445 'chainMultiplicities': [1, 2, 2],
446 'chainName':
'leg001_HLT_g25_medium_2j35_pf_ftf_0eta490_bdl1r77_2j35_pf_ftf_0eta490_L1EM22VHI',
447 'chainNameHash': 4053501929,
448 'chainParts': [{
'L1threshold':
'FSNOSEED',
450 'alignmentGroup':
'JetMET',
458 'chainPartName':
'2j35_pf_ftf_0eta490_bdl1r77',
459 'clusterCalib':
'em',
462 'etaRange':
'0eta490',
465 'hypoScenario':
'simple',
467 'jetCalib':
'default',
474 'sigFolder': [
'Bjet'],
483 'trkpresel':
'nopresel'},
484 {
'L1threshold':
'FSNOSEED',
486 'alignmentGroup':
'JetMET',
494 'chainPartName':
'2j35_pf_ftf_0eta490',
495 'clusterCalib':
'em',
498 'etaRange':
'0eta490',
501 'hypoScenario':
'simple',
503 'jetCalib':
'default',
510 'sigFolder': [
'Jet'],
519 'trkpresel':
'nopresel'}],
520 'eventBuildType':
'',
521 'extraComboHypos': [],
522 'groups': [
'Support:Legacy',
'RATE:EgammaBjet',
'BW:BJet'],
525 'mergingStrategy':
'auto',
528 'sigDicts': {
'Bjet': [
'Bjet'],
'Egamma': [
'Photon'],
'Jet': [
'Jet']},
531 'signatures': [
'Photon',
'Bjet',
'Jet'],