5 Dumps the trigger menu, optionally running some checks for name
9 _h_names =
"print the names of all chains"
10 _h_parse =
"parse names to dictionary"
11 _h_menu =
"name of the menu to dump (default Physics_pp_run3_v1)"
12 _h_l1check =
"do check of L1 items vs L1 menu"
13 _h_stream =
"filter by stream"
14 _h_dump_dicts =
"dump dicts to json"
15 _h_check_CPS =
"verify that Support chains are in CPS"
18 from AthenaCommon.Logging
import logging
21 logging.INFO = logging.DEBUG
23 from TriggerMenuMT.HLT.Config.Utility.DictFromChainName
import dictFromChainName
28 'dev':
'Dev_pp_run3_v1',
29 'hi':
'PhysicsP1_HI_run3_v1',
34 aliases =
'\n'.
join(f
'{a} -> {f}' for a, f
in MENU_ALIASES.items())
35 epi=
'menu aliases:\n' + aliases
36 parser = flags.getArgumentParser(
37 description=__doc__, epilog=epi,
39 parser.add_argument(
'-m',
'--menu',
40 default=
'Physics_pp_run3_v1',
42 output = parser.add_mutually_exclusive_group()
43 output.add_argument(
'-n',
'--names', action=
'store_true',
45 output.add_argument(
'-p',
'--parse-names', action=
'store_true',
47 parser.add_argument(
'-L',
'--check-l1', action=
'store_true',
49 parser.add_argument(
'-C',
'--check-CPS', action=
'store_true',
51 parser.add_argument(
'-s',
'--stream', const=
'Main', nargs=
'?',
53 parser.add_argument(
'-D',
'--dump-dicts', action=
'store_true',
55 group = parser.add_mutually_exclusive_group()
74 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
78 args = flags.fillFromArgs(parser=parser)
79 menu_name = MENU_ALIASES.get(args.menu, args.menu)
82 if args.check_l1
or args.check_CPS
or args.dump_dicts:
83 args.parse_names =
True
85 flags.Trigger.triggerConfig=
'FILE'
87 flags.Trigger.triggerMenuSetup=menu_name
91 from TrigConfigSvc.TrigConfigSvcCfg
import generateL1Menu
95 menumodule = importlib.import_module(f
'TriggerMenuMT.HLT.Menu.{menu_name}')
96 menu = menumodule.setupMenu()
101 return args.stream
in chain.stream
107 groupstr = args.group
108 def filt(x, old=filt):
111 for group
in x.groups:
112 if group.startswith(groupstr):
119 elif args.parse_names:
126 for chain, chain_dict
in chain_to_dict.items():
127 if not chain_dict[
'L1item']:
130 this_l1items = chain_dict[
'L1item'].
split(
',')
131 for this_l1
in this_l1items:
132 if this_l1
not in l1items:
133 sys.stderr.write(f
'L1 item not in menu for HLT item {chain}\n')
142 def match_group(expr,chain):
143 for group
in chain.groups:
152 chain_dict = chain_to_dict[chain.name]
154 not chain_dict[
'L1item']
155 or not match_group(
'Support',chain)
156 or match_group(
'TagAndProbe',chain)
162 if len(chain_dict[
'L1item'].
split(
',')) == 1:
163 if chain_dict[
'L1item']
not in L1_to_chains:
164 L1_to_chains[chain_dict[
'L1item']] =
set()
165 L1_to_chains[chain_dict[
'L1item']].
add(chain.name)
167 if match_group(
'RATE:CPS',chain):
169 for group
in chain.groups:
170 if group.startswith(
'RATE:CPS_'):
171 cps_item =
'L1_'+group[9:]
172 if cps_item ==
'L1_ZB':
173 cps_item =
'L1_ZeroBias'
174 if cps_item
not in cps_to_chains:
175 cps_to_chains[cps_item] =
set()
176 cps_to_chains[cps_item].
add(chain.name)
178 for cps_item, cps_chains
in cps_to_chains.items():
179 L1_chains = L1_to_chains[cps_item]
180 if len(L1_chains) < len(cps_chains):
181 raise RuntimeError(
'More CPS chains than L1-seeded, something wrong in parsing')
182 if len(cps_chains) < len(L1_chains):
183 print(f
'CPS group seeded by {cps_item} does not include all support chains')
184 print(f
' Contains {len(cps_chains)} / {len(L1_chains)}')
186 for missing
in L1_chains.difference(cps_chains):
193 for group, chains
in menu.items():
201 sys.stdout.write(f
'{chain.name}\n')
202 except BrokenPipeError:
207 from TriggerMenuMT.L1.Menu
import MenuMapping
208 l1menuname = MenuMapping.menuMap[menu][0]
209 l1module = importlib.import_module(f
'TriggerMenuMT.L1.Menu.Menu_{l1menuname}')
210 l1module.defineMenu()
211 return set(l1module.L1MenuFlags.items())
215 returns map of chain names to dictionaries with a set of failed chains
218 logging.WARNING = logging.DEBUG
220 known_failure =
set()
225 name = chain_dict[
'chainName']
226 chain_to_dict[name] = chain_dict
229 f
'Passed: {len(passed)}, Known failures: {len(known_failure)}\n')
231 return chain_to_dict, new_failure
235 fname = f
'dictdump_{menu}.json'
236 sys.stdout.write(f
'Dumping chain dicts to file "{fname}"')
237 fdict =
open(fname,
'w')
238 json.dump(chain_to_dict,fdict,indent=2)
241 if __name__ ==
'__main__':