2 from functools
import lru_cache, reduce
4 from TrigConfIO.TriggerConfigAccessBase
import TriggerConfigAccess, ConfigType
6 from AthenaCommon.Logging
import logging
7 log = logging.getLogger(
'HLTTriggerConfigAccess.py')
11 this class provides access to the HLT menu
12 the methods are self-explanatory for people with knowledge of the configuration
14 def __init__(self, filename = None, jsonString = None, dbalias = None, smkey = None,
15 useCrest=False, crestServer=""):
17 accessor needs to be initialized with either a filename or the dbalias and smkey
19 super().
__init__(ConfigType.HLTMENU, mainkey =
"chains",
20 filename = filename, jsonString = jsonString, dbalias = dbalias, dbkey = smkey,
21 useCrest=useCrest, crestServer=crestServer)
22 self.loader.setQuery({
23 2:
"SELECT HMT.HTM_DATA FROM {schema}.SUPER_MASTER_TABLE SMT, {schema}.HLT_MENU HMT WHERE HMT.HTM_ID=SMT.SMT_HLT_MENU_ID AND SMT.SMT_ID=:dbkey",
24 1:
"SELECT HMT.HMT_MENU FROM {schema}.SUPER_MASTER_TABLE SMT, {schema}.HLT_MASTER_TABLE HMT WHERE HMT.HMT_ID=SMT.SMT_HLT_MASTER_TABLE_ID AND SMT.SMT_ID=:dbkey"
28 log.info(f
"Loaded HLT menu {self.name()} with {len(self)} chains from {dbalias} with smk {smkey}{' using CREST' if useCrest else ''}")
29 elif filename
is not None:
30 log.info(f
"Loaded HLT menu {self.name()} with {len(self)} chains from file {filename}")
33 return self[
"chains"].
keys()
39 return self[
"streams"]
42 return self[
"sequencers"]
45 print(
"HLT menu %s" % self.name())
61 this class provides access to the HLT prescales set
62 the methods are self-explanatory for people with knowledge of the configuration
64 def __init__(self, filename = None, jsonString = None, dbalias = None, hltpskey = None,
65 useCrest=False, crestServer=""):
67 accessor needs to be initialized with either a filename or the dbalias and hlpskey
69 super().
__init__(ConfigType.HLTPS, mainkey =
"prescales",
70 jsonString = jsonString, filename = filename, dbalias = dbalias, dbkey = hltpskey,
71 useCrest=useCrest, crestServer=crestServer)
72 self.loader.setQuery({
73 1:
"SELECT HPS_DATA FROM {schema}.HLT_PRESCALE_SET HPS WHERE HPS_ID=:dbkey"
76 if hltpskey
is not None:
77 log.info(f
"Loaded HLT prescales {self.name()} (size {len(self)}) from {dbalias} with psk {hltpskey}{' using CREST' if useCrest else ''}")
78 elif filename
is not None:
79 log.info(f
"Loaded HLT prescales {self.name()} with {len(self)} chains from file {filename}")
82 return self[
"prescales"]
88 return self[
"prescales"][chainName][
"prescale"]
91 return self[
"prescales"][chainName][
"enabled"]
94 print(
"HLT prescales set %s" % self.name())
95 print(
"Number of prescales: %i" % len(self) )
96 print(
"Number of enabled prescales: %i" %
sum(x[
"enabled"]
for x
in self[
"prescales"].
values()) )
102 this class provides access to the HLT algorithm configuration
103 the methods are self-explanatory for people with knowledge of the configuration
105 def __init__(self, filename = None, dbalias = None, smkey = None,
106 useCrest = False, crestServer = ""):
108 accessor needs to be initialized with either a filename or the dbalias and smkey
110 super().
__init__(ConfigType.HLTJO, mainkey =
"properties",
111 filename = filename, dbalias = dbalias, dbkey = smkey,
112 useCrest=useCrest, crestServer=crestServer)
113 self.loader.setQuery({
114 2:
"SELECT JO.HJO_DATA FROM {schema}.SUPER_MASTER_TABLE SMT, {schema}.HLT_JOBOPTIONS JO WHERE JO.HJO_ID=SMT.SMT_HLT_JOBOPTIONS_ID AND SMT.SMT_ID=:dbkey",
115 1:
"SELECT JO.JO_CONTENT FROM {schema}.SUPER_MASTER_TABLE SMT, {schema}.JO_MASTER_TABLE JO WHERE JO.JO_ID=SMT.SMT_JO_MASTER_TABLE_ID AND SMT.SMT_ID=:dbkey"
118 if smkey
is not None:
119 log.info(f
"Loaded HLT job options {self.name()} with {len(self)} algorithms from {dbalias} with smk {smkey}{' using CREST' if useCrest else ''}")
120 elif filename
is not None:
121 log.info(f
"Loaded HLT job options {self.name()} with {len(self)} chains from file {filename}")
124 return self[
"properties"]
130 return self[
"properties"][algName]
134 return "HLT JobOptions"
139 print(
"Number of algorithms: %i" % len(self) )
145 this class provides access to the HLT monitoring json
147 def __init__(self, filename = None, jsonString = None, dbalias = None, smkey = None, monikey = None,
148 useCrest=False, crestServer=""):
150 accessor needs to be initialized with either a filename or the dbalias and hlpskey
152 super().
__init__(ConfigType.HLTMON, mainkey =
"signatures",
153 jsonString = jsonString, filename = filename, dbalias = dbalias, dbkey = smkey
if smkey
else monikey,
154 useCrest=useCrest, crestServer=crestServer)
155 self.loader.setQuery({
157 "SELECT HMG.HMG_DATA FROM {schema}.HLT_MONITORING_GROUPS HMG, {schema}.SUPER_MASTER_TABLE SMT WHERE HMG.HMG_IN_USE=1 "
158 "AND SMT.SMT_HLT_MENU_ID = HMG.HMG_HLT_MENU_ID AND SMT.SMT_ID=:dbkey ORDER BY HMG.HMG_ID DESC"
161 7:
"SELECT HMG.HMG_DATA FROM {schema}.HLT_MONITORING_GROUPS HMG WHERE HMG.HMG_ID=:dbkey"
164 if smkey
is not None:
165 log.info(f
"Loaded HLT monitoring {self.name()} with {len(self)} signatures from {dbalias} with smk {smkey}{' using CREST' if useCrest else ''}")
166 elif filename
is not None:
167 log.info(f
"Loaded HLT monitoring {self.name()} with {len(self)} signatures from file {filename}")
172 return stored monitoring dictionary
174 return self[
"signatures"]
179 return list of all monitored shifter chains for given signature and for a given monitoring level
181 signatures - monitored signature or list of signatures for which to return the chains
182 empty string means all signatures
183 monLevels - levels of monitoring (shifter, t0 (expert), val (validation))
184 wildcard - regexp pattern to match the chains' names
186 if monitoring level is not defined return all the chains for given signature
187 if signature is not defined return all the chains for given monitoring level
188 if both monitoring level and signature are not defined, raturn all chains
190 return can be filtered by wildcard
195 signatures =
set(self)
198 if isinstance(signatures, str):
199 signatures =
set([signatures])
200 signatures =
set(signatures)
203 noMonAvailable = signatures.difference(self)
205 log.warning(
"These monitoring signatures are requested but not available in HLT monitoring: %s",
', '.
join(noMonAvailable))
206 signatures.intersection_update(self)
209 if isinstance(monLevels, str):
210 monLevels =
set([monLevels])
211 monLevels =
set(monLevels)
213 for signature
in signatures:
214 for chainName, targets
in self[
"signatures"][signature].
items():
215 if monLevels.intersection(targets+[
""]):
216 chains.add(chainName)
220 r = re.compile(wildcard)
221 chains =
filter(r.search, chains)
222 except re.error
as exc:
223 log.warning(
"Wildcard regex: %r is not correct!", exc)
229 @lru_cache(maxsize=5)
232 return all monitoring levels
233 If one ore more signatures are specified, return only monitoring levels for those
235 if signatures
is None:
236 signatures =
set(self)
237 if isinstance(signatures, str):
238 signatures =
set([signatures])
239 signatures =
set(signatures)
241 for signatureName, chains
in self[
"signatures"].
items():
242 if signatureName
in signatures:
243 levels =
reduce(
lambda x, y: x.union(y), chains.values(), levels )
248 print(
"HLT monitoring groups %s" % self.name())
249 print(
"Signatures (%i): %s" % (len(self),
", ".
join(self)) )