3 from AthenaCommon.Logging
import logging
5 from ..Config.MonitorDef
import MonitorDef
6 from .PrescaleHelper
import getCutFromPrescale, getPrescaleFromCut
7 from .MenuUtils
import binstr
10 log = logging.getLogger(__name__)
15 splitBunchGroups =
False
27 return self.
items[key]
32 if name
in self.
items:
33 log.warning(
"LVL1 item %s is already in the menu, will not add it again", name)
35 if item.ctpid
in [x.ctpid
for x
in self.
items]:
36 log.warning(
"LVL1 item with ctpid %i is already in the menu, will not add %s", item.ctpid, name)
38 self.
items[ name ] = item
44 if item.name
in self.
items:
45 msg =
"LVL1 item %s is already in the menu, will not add it again" % item.name
47 raise RuntimeError(msg)
48 if item.ctpid
in [x.ctpid
for x
in self.
items.
values()]:
49 msg =
"LVL1 item %s with ctpid %i is already in the menu, will not add %s with the same ctpid" % (self.
itemById(item.ctpid).name, item.ctpid, item.name)
51 raise RuntimeError(msg)
52 self.
items[ item.name ] = item
56 return itemname
in self.
items
59 return len(self.
items)
62 itemById = {it.ctpid:it
for it
in self.
items.
values()}
63 return itemById[ctpid]
if ctpid
in itemById
else None
69 confObj = {item.name: item.json()
for item
in self}
76 l1configForRegistration =
None
80 MenuItem.l1configForRegistration = mc
85 __slots__ = [
'name',
'group',
'ctpid',
'psCut',
'trigger_type',
'partition',
'logic',
'bunchGroups',
'legacy',
'monitorsLF',
'monitorsHF',
'verbose']
86 def __init__(self, name, ctpid=-1, group='1', prescale=1, psCut=None, verbose=False):
100 if MenuItem.l1configForRegistration:
101 MenuItem.l1configForRegistration.registerItem(self.
name, self)
104 s =
"Item %s (ctp id=%i) [%s]" % (self.
name, self.
ctpid, self.
logic)
117 if frequency == MonitorDef.LOW_FREQ:
119 if frequency == MonitorDef.HIGH_FREQ:
123 if MenuItemsCollection.splitBunchGroups:
134 if self.
logic is not None:
140 if self.
logic is not None:
153 """Turns integer triggertype in a binary string of given width"""
158 confObj[
"name"] = self.
name
160 confObj[
"legacy"] = self.
legacy
161 confObj[
"ctpid"] = self.
ctpid
162 confObj[
"definition"] =
str(self.
logic)
180 for item
in menuitems:
184 itemList.sort(key =
lambda x: x.ctpid)
190 isTopo = any(
filter(
lambda x: attr.startswith(x), [
"R2TOPO_",
"TOPO_",
"MUTOPO_",
"MULTTOPO_"]))
191 fs = traceback.extract_stack()[-2]
192 expProdFile =
"L1/Config/"
194 if attr.startswith(
"R2TOPO_"):
195 expProdFile +=
"TopoAlgoDefLegacy.py"
196 elif attr.startswith(
"TOPO_"):
197 expProdFile +=
"TopoAlgoDef.py"
198 elif attr.startswith(
"MUTOPO_"):
199 expProdFile +=
"TopoAlgoDefMuctpi.py"
200 elif attr.startswith(
"MULTTOPO_"):
201 expProdFile +=
"TopoMultiplicityAlgoDef.py"
203 isLegacyThr = any(
filter(
lambda x: attr.startswith(x), [
"EM",
"TAU",
"J",
"XE",
"TE",
"XS"]))
205 expProdFile +=
"ThresholdDefLegacy.py"
207 expProdFile +=
"ThresholdDef.py"
209 msg =
"Item definition issue in file %s, line %i. Threshold %s has not been defined in %s" % (
'/'.
join(fs.filename.rsplit(
'/',4)[1:]),fs.lineno, attr, expProdFile)
211 raise RuntimeError(msg)