3 __author__ =
'Javier Montejo'
4 __version__=
"$Revision: 2.0 $"
5 __doc__=
"Interface to retrieve lists of unprescaled triggers according to types and periods"
9 from TriggerMenuMT.TriggerAPI.TriggerInfo
import TriggerInfo, TriggerChain
10 from TriggerMenuMT.TriggerAPI.TriggerEnums
import TriggerPeriod
11 from PathResolver
import PathResolver
12 from AthenaCommon.Logging
import logging
13 log = logging.getLogger(__name__)
14 privateJsonFile =
"TriggerInfo.json"
16 def dump(db, f=privateJsonFile):
19 def load(centralFile="TriggerMenu/TriggerInfo_20210302.json"):
23 log.info(
"Found json file:"+centralJsonFile)
24 centralJsonFile = os.path.realpath(centralJsonFile)
25 else: log.error(
"Couldn't find central json file")
30 except (json.JSONDecodeError, ValueError):
31 log.info(
"Reading cached information failed")
36 privatedb =
loadJson(privateJsonFile)
38 except (json.JSONDecodeError, ValueError):
39 log.error(
"Error loading the private json file")
45 with open(jsonFile,
"w")
as f:
46 log.info(
"Dumping cached information to: "+jsonFile)
47 json.dump(
toJsonDump(db) , f, cls=TriggerAPIEncoder)
50 with open(jsonFile)
as f:
58 for key,thedict
in thelist:
60 pk = TriggerPeriod.fromName( pk )
62 triggerinfo = TriggerInfo()
63 triggerinfo.period = TriggerPeriod.fromName( thedict[
"period"] )
65 assert triggerinfo.period==pk, (triggerinfo.period, pk)
66 triggerinfo.totalLB = thedict[
"totalLB"]
67 triggerinfo.totalLBByRun = thedict.get(
"totalLBByRun",{})
68 triggerinfo.triggerChains = []
69 for tc
in thedict[
"triggerChains"]:
70 tc = TriggerChain(tc[
"name"],tc[
"l1seed"],tc[
"livefraction"],tc[
"activeLB"],tc[
"hasRerun"],tc.get(
"activeLBByRun",{}))
71 triggerinfo.triggerChains.append(tc)
72 toret[key] = triggerinfo
78 return [ ((TriggerPeriod.toName(p) ,grl ),v)
for (p,grl),v
in dct.items()]
82 if hasattr(obj,
'toJSON'):
85 return json.JSONEncoder.default(self, obj)