3 from AthenaCommon.Logging
import logging
4 log = logging.getLogger(__name__)
10 Returns tuple of L1Topo algorithm to board and item map: (alg_to_board, alg_to_item)
12 alg_to_board: Map between L1 algorithm name and board (Topo2, Topo3 or LegacyTopo,
13 items coming from other boards will not be listed in the map)
14 alg_to_item: Map between L1 item name and topo algorithm
17 lvl1items = lvl1access.items(includeKeys=[
"name"])
18 lvl1items_full = lvl1access.items()
20 l1topo_alg_to_board = {}
21 l1topo_alg_to_item = {}
22 connectors = [
'Topo2El',
'Topo3El',
'LegacyTopoMerged']
24 for l1item
in lvl1items:
27 l1item_def_list = re.split(
"[&|]+", lvl1items_full[l1item][
'definition'])
28 for l1item_def_aux
in l1item_def_list:
30 l1item_def = l1item_def_aux.strip(
'() ').
split(
'[')[0]
33 for connect
in connectors:
34 for v
in lvl1access.connector(connect)[
'triggerlines']:
35 if l1item_def==v[
'name']:
36 l1topo_alg_to_board[l1item_def] = connect
39 if 'TOPO' not in l1topo_alg_to_item.get(l1item,
''):
40 l1topo_alg_to_item[l1item] = l1item_def
42 log.debug(
"L1Topo alg to board map: %s",l1topo_alg_to_board)
43 log.debug(
"L1Topo alg to item map: %s",l1topo_alg_to_item)
44 return (l1topo_alg_to_board, l1topo_alg_to_item)
49 from TrigConfIO.L1TriggerConfigAccess
import L1MenuAccess
50 from TrigConfigSvc.TrigConfigSvcCfg
import getL1MenuFileName
52 lvl1access = L1MenuAccess(lvl1name)
53 lvl1thtypes = lvl1access.thresholdTypes()
54 lvl1items = lvl1access.items(includeKeys=[
"name"])
55 lvl1items_full = lvl1access.items()
56 from TriggerMenuMT.HLT.Config.Utility.HLTMenuConfig
import HLTMenuConfig
60 chainsWithWrongLabel = {}
65 for chain
in HLTMenuConfig.dictsList():
66 log.debug(
'[checkL1HLTConsistency] Checking the l1thresholds in the chain %s', chain[
"chainName"])
72 l1item_vec = chain[
'L1item'].
split(
',')
73 for l1item
in l1item_vec:
75 log.debug(
'[checkL1HLTConsistency] chain %s in L1Menu %s: L1item not set...', chain[
"chainName"], lvl1name)
77 if l1item
not in lvl1items:
78 log.error(
'[checkL1HLTConsistency] chain %s: L1item: %s, not found in the items list of the L1Menu %s', chain[
"chainName"], chain[
"L1item"], lvl1name)
79 missing_L1_items.append(l1item)
82 if l1item
not in allUsedItems:
83 allUsedItems.append(l1item)
91 for p
in chain[
'chainParts']:
93 th = p[
'L1threshold'][5:]
if p[
'L1threshold'].startswith(
"PROBE")
else p[
'L1threshold']
95 if (
'TAU' in th)
and th[0]
not in [
'e',
'j',
'c']:
96 th = th.replace(
'TAU',
'HA')
97 thFoundInL1Menu =
False
100 log.debug(
'[checkL1HLTConsistency] \t %s in L1thresholds', th)
102 for thtype
in lvl1thtypes:
103 l1thresholds = lvl1access.thresholds(thtype)
104 if th
in l1thresholds:
105 thFoundInL1Menu =
True
109 log.debug(
'[checkL1HLTConsistency] \t %s in L1HLTConsistency[%s]', th, l1type)
111 log.error(
'[checkL1HLTConsistency] chain %s: L1Threshold %s not found in the L1thresholds of the L1Menu %s', chain[
"chainName"], th, lvl1name)
112 raise Exception(
"Please fix the menu or the chain.")
118 foundPhase1CaloSeed =
False
119 foundLegacyCaloSeed =
False
120 for item
in l1item_vec:
123 if 'legacy' in lvl1items_full[item]:
124 if lvl1items_full[item][
'legacy']:
128 items = item[2:].
split(
'_')
130 if any(substring
in it
for substring
in [
'e',
'c',
'j',
'g']):
134 if len(l1item_vec)==1:
136 if l1topo_alg_to_item[item]
in l1topo_alg_to_board:
137 if not any(
'Topo' in g
for g
in chain[
'groups']):
138 errormsg = f
"Chain has item {item} ({l1topo_alg_to_board[l1topo_alg_to_item[item]]}) but has no topo group"
144 for group
in chain[
'groups']:
146 if l1topo_alg_to_item[item]
in l1topo_alg_to_board:
147 if group
in l1topo_alg_to_board[l1topo_alg_to_item[item]]:
148 log.debug(
"Chain correctly assigned topo board")
150 errormsg = f
"Chain should be labelled with topo board {l1topo_alg_to_board[l1topo_alg_to_item[item]]}"
151 elif l1topo_alg_to_item[item]
not in l1topo_alg_to_board:
152 errormsg = f
"Chain does not come from topo board but has Topo group {group}"
155 chainsWithWrongLabel.update({chain[
'chainName']: (chain[
'groups'], errormsg)})
160 if th[:1]
in [
'e',
'c',
'j',
'g']:
161 foundPhase1CaloSeed =
True
162 noCaloItemHLT =
False
163 if th[:1]
in [
'E',
'T',
'J',
'X']:
164 foundLegacyCaloSeed =
True
165 noCaloItemHLT =
False
167 mixedCaloSeed =
False
168 if legacyItem
and foundPhase1CaloSeed:
172 if foundLegacyCaloSeed:
175 if foundLegacyCaloSeed
and foundPhase1CaloSeed:
178 log.warning(
'[checkL1HLTConsistency] chain %s contains a mix of legacy and phase1 calo thresholds! L1 items: [%s] (legacy item = %s), L1 seeds: [%s] (foundPhase1CaloSeed = %s, foundLegacyCaloSeed = %s)', chain[
"chainName"],
",".
join(l1item_vec), legacyItem,
",".
join(l1thr_vec), foundPhase1CaloSeed, foundLegacyCaloSeed )
185 log.debug(
"Checking chain %s: noCaloItemL1 %s, noCaloItemHLT %s , legacyItem %s", chain[
'chainName'], noCaloItemL1, noCaloItemHLT, legacyItem )
187 log.debug(chain[
'groups'])
188 for group
in chain[
'groups']:
189 log.debug(
"Checking group %s: find 'Legacy' %s, find 'PhaseI' %s", group,
str(group.find(
'Legacy')),
str(group.find(
'PhaseI')) )
191 if noCaloItemL1
and noCaloItemHLT:
192 if group.find(
'Legacy')>-1
or group.find(
'PhaseI')>-1 :
194 if group.find(
'Legacy')<0
and group.find(
'PhaseI')<0 :
198 if group.find(
'Legacy')>-1 :
200 if group.find(
'PhaseI')>-1 :
204 if group.find(
'PhaseI')>-1 :
206 if group.find(
'Legacy')>-1 :
208 if noCaloItemL1
and not noCaloItemHLT:
209 if foundPhase1CaloSeed
and group.find(
'Legacy')>-1 :
211 if foundPhase1CaloSeed
and group.find(
'PhaseI')>-1 :
213 if foundLegacyCaloSeed
and group.find(
'PhaseI')>-1 :
215 if foundLegacyCaloSeed
and group.find(
'Legacy')>-1 :
217 if wrongLabel
or not rightLabel:
218 errormsg =
'Incorrect L1Calo version label -- check Legacy/Phase-I assignment'
219 chainsWithWrongLabel.update({chain[
'chainName']: (chain[
'groups'],errormsg)})
222 log.error(
'[checkL1HLTConsistency] Missing L1 items:')
223 for i
in missing_L1_items:
225 raise Exception(
"Please fix the menu or the chains.")
227 if len(chainsWithWrongLabel)
and (
'Physics' in lvl1name)
and not (
'HI' in lvl1name)
and not (
'lowMu' in lvl1name):
228 log.error(
'These chains have the wrong groups for l1menu %s:',lvl1name)
229 for key, (groups, errormsg)
in chainsWithWrongLabel.items():
230 log.error(
'%s: %s\n --> %s', key,
",".
join(groups), errormsg)
231 raise Exception(
"Please fix these chains.")
234 for item
in lvl1items:
235 if item
not in allUsedItems:
236 allUnusedItems.append(item)
237 if len(allUnusedItems)==0:
238 log.info(
'[checkL1HLTConsistency] All items in L1 menu are used')
240 log.info(
'[checkL1HLTConsistency] %i items in L1 menu are not used: %s', len(allUnusedItems),
",".
join(allUnusedItems))
241 log.info(
'[checkL1HLTConsistency] checkL1HLTConsistency completed succesfully')