ATLAS Offline Software
test_hypoConfigBuilder.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
2 """Make chain dicts for testing jet hypo config modules"""
3 
4 from TriggerMenuMT.HLT.Menu.Physics_pp_run3_v1 import (
5  SingleJetGroup,
6  MultiJetGroup,
7  PhysicsStream,
8  SupportLegGroup,
9 )
10 
11 DevGroup = ['Development']
12 
13 
14 from TriggerMenuMT.HLT.Config.Utility.ChainDefInMenu import ChainProp
15 from TriggerMenuMT.HLT.Config.Utility.DictFromChainName import dictFromChainName
16 
17 from TrigHLTJetHypo.hypoToolDisplay import hypoToolDisplay
18 
19 import sys
20 
21 from pprint import pprint
22 
23 # from TrigHLTJetHypo.xmlConfig import hypotool_from_chaindict
24 from TrigHLTJetHypo.hypoConfigBuilder import hypotool_from_chaindict
25 
26 from AthenaCommon.Logging import logging
27 from AthenaCommon.Constants import DEBUG
28 logger = logging.getLogger( __name__)
29 
30 logger.setLevel(DEBUG)
31 
32 from AthenaConfiguration.AllConfigFlags import initConfigFlags
33 flags = initConfigFlags()
34 flags.Input.Files = []
35 flags.lock()
36 
37 
38 
39 chains = [
40 
41  ChainProp(name='HLT_j45a_pf_ftf_preselj20_L1J15', l1SeedThresholds=['FSNOSEED'], stream=[PhysicsStream,'express'], groups=SingleJetGroup+SupportLegGroup+['RATE:CPS_J15'], monGroups=['jetMon:t0','jetMon:online','idMon:shifter','caloMon:t0']),
42 
43  ChainProp(name='HLT_j0_DIPZ50XX4j20_roiftf_preselj20_L13J35p0ETA23', l1SeedThresholds=['FSNOSEED'], stream=[PhysicsStream,'express'], groups=MultiJetGroup+SupportLegGroup, monGroups=['jetMon:t0','jetMon:online']),
44  ChainProp(name='HLT_j0_DIPZ50XX4j20_MAXMULT20_roiftf_preselj20_L13J35p0ETA23', l1SeedThresholds=['FSNOSEED'], stream=[PhysicsStream,'express'], groups=MultiJetGroup+SupportLegGroup, monGroups=['jetMon:t0','jetMon:online']),
45  ChainProp(name='HLT_4j110_pf_ftf_presel4jDIPZ50X20pt_L13J50', l1SeedThresholds=['FSNOSEED'], stream=[PhysicsStream,'express'], groups=MultiJetGroup+SupportLegGroup, monGroups=['jetMon:t0','jetMon:online']),
46 
47  ChainProp(name='HLT_j0_HT400XX15ptXX0eta490_j45a_pf_ftf_preselj20_L1J15', l1SeedThresholds=['FSNOSEED']*2, stream=[PhysicsStream,'express'], groups=SingleJetGroup+SupportLegGroup+['RATE:CPS_J15'], monGroups=['jetMon:t0','jetMon:online','idMon:shifter','caloMon:t0']),
48 
49 
50  ChainProp(name='HLT_j0_HT400XX15ptXX0eta490XXveto_j45a_pf_ftf_preselj20_L1J15', l1SeedThresholds=['FSNOSEED']*2, stream=[PhysicsStream,'express'], groups=SingleJetGroup+SupportLegGroup+['RATE:CPS_J15'], monGroups=['jetMon:t0','jetMon:online','idMon:shifter','caloMon:t0']),
51 
52  ChainProp(name='HLT_j0_MULT0mult11XX15ptXX0eta490_j45a_pf_ftf_preselj20_L1J15', l1SeedThresholds=['FSNOSEED']*2, stream=[PhysicsStream,'express'], groups=SingleJetGroup+SupportLegGroup+['RATE:CPS_J15'], monGroups=['jetMon:t0','jetMon:online','idMon:shifter','caloMon:t0']),
53  ]
54 
55 def testChainDictMaker(idict):
56 
57  if idict >= 0:
58  chain_props = [chains[idict]]
59  else:
60  chain_props = chains
61 
62  result = []
63  for cp in chain_props:
64  logger.debug(cp)
65  chain_dict = dictFromChainName(flags, cp)
66  result.append((cp.name, chain_dict))
67 
68  return result
69 
70 
72  for i, c in enumerate(chains):
73  logger.debug('%2d ' + c.name, i)
74 
75 
76 if __name__ == '__main__':
77  import argparse
78  import os
79 
80  parser = argparse.ArgumentParser()
81 
82  parser.add_argument(
83  '-i',
84  '--iprop',
85  help='index of chainProp to run, -1: do all',
86  type=int)
87 
88  parser.add_argument('-d', '--dot', help='write out a dot file',
89  action='store_true')
90 
91  parser.add_argument(
92  '--dotdir',
93  help='specify directory to which dot file is to be written [$HOME]',
94  default=os.environ['HOME'])
95 
96 
97  args = parser.parse_args()
98 
99  if args.iprop is None:
100  list_chains()
101  sys.exit()
102 
103  iprop = args.iprop
104  dicts = testChainDictMaker(iprop)
105 
107  cdict = d[1]
108  # crass "fix" for out of order chainparts
109  # these errors probably arise from calling
110  # not-quite-correct menu code.
111  chain_part_inds = [cp['chainPartIndex'] for cp in cdict['chainParts']]
112  fix = chain_part_inds == sorted(chain_part_inds)
113  if not fix:
114  fix = chain_part_inds[-1] - chain_part_inds[0] == len(chain_part_inds)
115 
116 
117  if fix:
118  cpi = 0
119  for cp in cdict['chainParts']:
120  cp['chainPartIndex'] = cpi
121  cpi += 1
122 
123 
124  for d in dicts:
126  pprint(d)
127 
128  do_dot = args.dot
129  if args.dotdir:
130  do_dot = True
131 
132  for cn, d in dicts:
133  hypo_tool = hypotool_from_chaindict(d)
134  hypoToolDisplay(hypo_tool,
135  do_dot=do_dot,
136  dotdir=args.dotdir)
137 
138 
python.test_hypoConfigBuilder.order_chainparts
def order_chainparts(d)
Definition: test_hypoConfigBuilder.py:106
DictFromChainName.dictFromChainName
def dictFromChainName(flags, chainInfo)
Definition: DictFromChainName.py:626
python.test_hypoConfigBuilder.list_chains
def list_chains()
Definition: test_hypoConfigBuilder.py:71
python.test_hypoConfigBuilder.testChainDictMaker
def testChainDictMaker(idict)
Definition: test_hypoConfigBuilder.py:55
Constants
some useful constants -------------------------------------------------—
python.hypoConfigBuilder.hypotool_from_chaindict
def hypotool_from_chaindict(chain_dict, visit_debug=False)
Definition: hypoConfigBuilder.py:395
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.hypoToolDisplay.hypoToolDisplay
def hypoToolDisplay(tool, do_dot=False, dotdir='')
Definition: hypoToolDisplay.py:72
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19