ATLAS Offline Software
Loading...
Searching...
No Matches
python.TriggerAPI.SerializeAPI Namespace Reference

Classes

class  TriggerAPIEncoder

Functions

 dump (db, f=privateJsonFile)
 load (centralFile="TriggerMenu/TriggerInfo_20210302.json")
 dumpJson (db, jsonFile)
 loadJson (jsonFile)
 fromJsonDump (thelist)
 toJsonDump (dct)

Variables

str __author__ = 'Javier Montejo'
str __version__ = "$Revision: 2.0 $"
str __doc__ = "Interface to retrieve lists of unprescaled triggers according to types and periods"
 log = logging.getLogger(__name__)
str privateJsonFile = "TriggerInfo.json"

Function Documentation

◆ dump()

python.TriggerAPI.SerializeAPI.dump ( db,
f = privateJsonFile )

Definition at line 16 of file SerializeAPI.py.

16def dump(db, f=privateJsonFile):
17 dumpJson(db, f)
18
-event-from-file

◆ dumpJson()

python.TriggerAPI.SerializeAPI.dumpJson ( db,
jsonFile )

Definition at line 44 of file SerializeAPI.py.

44def dumpJson(db, jsonFile):
45 with open(jsonFile, "w") as f:
46 log.info("Dumping cached information to: "+jsonFile)
47 json.dump( toJsonDump(db) , f, cls=TriggerAPIEncoder)
48

◆ fromJsonDump()

python.TriggerAPI.SerializeAPI.fromJsonDump ( thelist)

Definition at line 55 of file SerializeAPI.py.

55def fromJsonDump(thelist):
56 #Rebuild objects and dictionary structure from json
57 toret = {}
58 for key,thedict in thelist:
59 pk, grl = key
60 pk = TriggerPeriod.fromName( pk )
61 key = (pk, grl)
62 triggerinfo = TriggerInfo()
63 triggerinfo.period = TriggerPeriod.fromName( thedict["period"] )
64 #key and internal period value should be consistent
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
73 return toret
74
This class contains trigger related information.
Definition TriggerInfo.h:77

◆ load()

python.TriggerAPI.SerializeAPI.load ( centralFile = "TriggerMenu/TriggerInfo_20210302.json")

Definition at line 19 of file SerializeAPI.py.

19def load(centralFile="TriggerMenu/TriggerInfo_20210302.json"):
20 if centralFile:
21 centralJsonFile = PathResolver.FindCalibFile(centralFile)
22 if centralJsonFile:
23 log.info("Found json file:"+centralJsonFile)
24 centralJsonFile = os.path.realpath(centralJsonFile)
25 else: log.error("Couldn't find central json file")
26
27 if centralJsonFile:
28 try:
29 db = loadJson(centralJsonFile)
30 except (json.JSONDecodeError, ValueError):
31 log.info("Reading cached information failed")
32 db = {}
33 else:
34 db = {}
35 try:
36 privatedb = loadJson(privateJsonFile)
37 db.update(privatedb)
38 except (json.JSONDecodeError, ValueError):
39 log.error("Error loading the private json file")
40 except IOError:
41 pass
42 return db
43
static std::string FindCalibFile(const std::string &logical_file_name)

◆ loadJson()

python.TriggerAPI.SerializeAPI.loadJson ( jsonFile)

Definition at line 49 of file SerializeAPI.py.

49def loadJson(jsonFile):
50 with open(jsonFile) as f:
51 dct = json.load(f)
52 dct = fromJsonDump(dct)
53 return dct
54

◆ toJsonDump()

python.TriggerAPI.SerializeAPI.toJsonDump ( dct)

Definition at line 75 of file SerializeAPI.py.

75def toJsonDump(dct):
76 #tuple keys are not allowed, convert to list of pairs
77 #Dump the enum name instead of the value to allow flexibility in the future
78 return [ ((TriggerPeriod.toName(p) ,grl ),v) for (p,grl),v in dct.items()]
79

Variable Documentation

◆ __author__

str python.TriggerAPI.SerializeAPI.__author__ = 'Javier Montejo'
private

Definition at line 3 of file SerializeAPI.py.

◆ __doc__

str python.TriggerAPI.SerializeAPI.__doc__ = "Interface to retrieve lists of unprescaled triggers according to types and periods"
private

Definition at line 5 of file SerializeAPI.py.

◆ __version__

str python.TriggerAPI.SerializeAPI.__version__ = "$Revision: 2.0 $"
private

Definition at line 4 of file SerializeAPI.py.

◆ log

python.TriggerAPI.SerializeAPI.log = logging.getLogger(__name__)

Definition at line 13 of file SerializeAPI.py.

◆ privateJsonFile

str python.TriggerAPI.SerializeAPI.privateJsonFile = "TriggerInfo.json"

Definition at line 14 of file SerializeAPI.py.