ATLAS Offline Software
Classes | Functions | Variables
python.TriggerAPI.SerializeAPI Namespace Reference

Classes

class  TriggerAPIEncoder
 

Functions

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

Variables

 __author__
 
 __version__
 
 __doc__
 
 log
 
 privateJsonFile
 

Function Documentation

◆ dump()

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

Definition at line 16 of file SerializeAPI.py.

16 def dump(db, f=privateJsonFile):
17  dumpJson(db, f)
18 

◆ dumpJson()

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

Definition at line 44 of file SerializeAPI.py.

44 def 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()

def python.TriggerAPI.SerializeAPI.fromJsonDump (   thelist)

Definition at line 55 of file SerializeAPI.py.

55 def 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 

◆ load()

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

Definition at line 19 of file SerializeAPI.py.

19 def 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 

◆ loadJson()

def python.TriggerAPI.SerializeAPI.loadJson (   jsonFile)

Definition at line 49 of file SerializeAPI.py.

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

◆ toJsonDump()

def python.TriggerAPI.SerializeAPI.toJsonDump (   dct)

Definition at line 75 of file SerializeAPI.py.

75 def 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__

python.TriggerAPI.SerializeAPI.__author__
private

Definition at line 3 of file SerializeAPI.py.

◆ __doc__

python.TriggerAPI.SerializeAPI.__doc__
private

Definition at line 5 of file SerializeAPI.py.

◆ __version__

python.TriggerAPI.SerializeAPI.__version__
private

Definition at line 4 of file SerializeAPI.py.

◆ log

python.TriggerAPI.SerializeAPI.log

Definition at line 13 of file SerializeAPI.py.

◆ privateJsonFile

python.TriggerAPI.SerializeAPI.privateJsonFile

Definition at line 14 of file SerializeAPI.py.

PathResolver::FindCalibFile
static std::string FindCalibFile(const std::string &logical_file_name)
Definition: PathResolver.h:108
python.TriggerAPI.SerializeAPI.dump
def dump(db, f=privateJsonFile)
Definition: SerializeAPI.py:16
python.TriggerAPI.SerializeAPI.load
def load(centralFile="TriggerMenu/TriggerInfo_20210302.json")
Definition: SerializeAPI.py:19
TriggerInfo
This class contains trigger related information.
Definition: TriggerInfo.h:77
Trk::open
@ open
Definition: BinningType.h:40
python.TriggerAPI.SerializeAPI.fromJsonDump
def fromJsonDump(thelist)
Definition: SerializeAPI.py:55
python.TriggerAPI.SerializeAPI.dumpJson
def dumpJson(db, jsonFile)
Definition: SerializeAPI.py:44
python.TriggerAPI.SerializeAPI.toJsonDump
def toJsonDump(dct)
Definition: SerializeAPI.py:75
python.TriggerAPI.SerializeAPI.loadJson
def loadJson(jsonFile)
Definition: SerializeAPI.py:49