|
def | __init__ (self, folderBlk) |
|
def | append (self, stationID, layerID=-1, alignType="None", shiftX=0.0, shiftY=0.0, shiftZ=0.0, alpha=0.0, beta=0.0, gamma=0.0) |
|
def | savePayload (self, folderBlk) |
|
A class to create a dictionary, fill it with zeros in the constructor and to overwrite zeros later
Definition at line 58 of file AFPAlignMCDBCreate.py.
◆ __init__()
def AFPAlignMCDBCreate.AFPDBDict.__init__ |
( |
|
self, |
|
|
|
folderBlk |
|
) |
| |
Definition at line 60 of file AFPAlignMCDBCreate.py.
61 if(folderBlk.folderName==
"/FWD/AFP/Align/Local"):
62 emptydict={
"stationID":0,
"layerID":-1,
"shiftX":0.0,
"shiftY":0.0,
"shiftZ":0.0,
"alpha":0.0,
"beta":0.0,
"gamma":0.0}
63 elif(folderBlk.folderName==
"/FWD/AFP/Align/Global"):
64 emptydict={
"stationID":0,
"alignType":
"None",
"shiftX":0.0,
"shiftY":0.0,
"shiftZ":0.0,
"alpha":0.0,
"beta":0.0,
"gamma":0.0}
66 print (
"unknown folder %s, please edit \"AFPDBDict\" class constructor, exiting now" % folderBlk.folderName)
69 self.mydict={
"author":
"Petr Balek",
70 "version":
"AFP_DB_v2",
72 "data": dict.fromkeys(
range(0, 16))}
74 for i
in range(0, 16):
75 self.mydict[
"data"][i]=copy.deepcopy(emptydict)
76 self.mydict[
"data"][i][
"stationID"]=i//4
77 if(folderBlk.folderName==
"/FWD/AFP/Align/Local"):
78 self.mydict[
"data"][i][
"layerID"]=i%4
79 if(folderBlk.folderName==
"/FWD/AFP/Align/Global"):
80 if i%4==0: self.mydict[
"data"][i][
"alignType"]=
"tracker"
81 if i%4==1: self.mydict[
"data"][i][
"alignType"]=
"beam"
82 if i%4==2: self.mydict[
"data"][i][
"alignType"]=
"RP"
83 if i%4==3: self.mydict[
"data"][i][
"alignType"]=
"correction"
◆ append()
def AFPAlignMCDBCreate.AFPDBDict.append |
( |
|
self, |
|
|
|
stationID, |
|
|
|
layerID = -1 , |
|
|
|
alignType = "None" , |
|
|
|
shiftX = 0.0 , |
|
|
|
shiftY = 0.0 , |
|
|
|
shiftZ = 0.0 , |
|
|
|
alpha = 0.0 , |
|
|
|
beta = 0.0 , |
|
|
|
gamma = 0.0 |
|
) |
| |
A function that overwrites one slice of the alignment constants in the dictionary. Local constants have to have layerID defined, while alignType is undefined. Global constants have to have alignType defined (tracker/RP/beam/correction) and layerID undefined.
Definition at line 85 of file AFPAlignMCDBCreate.py.
85 def append(self, stationID, layerID=-1, alignType="None", shiftX=0.0, shiftY=0.0, shiftZ=0.0, alpha=0.0, beta=0.0, gamma=0.0):
86 """A function that overwrites one slice of the alignment constants in the dictionary. Local constants have to have layerID defined, while alignType is undefined. Global constants have to have alignType defined (tracker/RP/beam/correction) and layerID undefined."""
89 if(layerID==-1
and alignType==
"None"):
90 print (
"cannot save payload, got layerID=%d and alignType=%s; one of them has to be specified" % layerID, alignType)
92 elif(layerID!=-1
and alignType!=
"None"):
93 print (
"cannot save payload, got layerID=%d and alignType=%s; one of them should not be specified" % layerID, alignType)
96 if(stationID<0
or stationID>=4):
97 print (
"cannot save payload, got stationID=%d, unknown" % stationID)
103 if(alignType!=
"None"):
105 if(alignType==
"tracker"):
107 elif(alignType==
"beam"):
109 elif(alignType==
"RP"):
111 elif(alignType==
"correction"):
114 print (
"cannot save payload, got alignType=%s, unknown" % alignType)
118 self.mydict[
"data"][channel][
'alignType']=alignType
123 if(0<=layerID
and layerID<4):
126 print (
"cannot save payload, got layerID=%d, unknown" % layerID)
130 self.mydict[
"data"][channel][
'layerID']=layerID
133 mydict_helper=self.mydict[
"data"][channel]
134 mydict_helper[
'shiftX'], mydict_helper[
'shiftY'], mydict_helper[
'shiftZ'] = shiftX, shiftY, shiftZ
135 mydict_helper[
'alpha'], mydict_helper[
'beta'], mydict_helper[
'gamma'] = alpha, beta, gamma
136 mydict_helper[
'stationID']=stationID
◆ savePayload()
def AFPAlignMCDBCreate.AFPDBDict.savePayload |
( |
|
self, |
|
|
|
folderBlk |
|
) |
| |
A function to transform the dictionary to JSON and save it in IOV from 0 to infinity; technically, upper limits are undefined and the maximum value (until beginning of a next entry) would be used.
Definition at line 139 of file AFPAlignMCDBCreate.py.
139 def savePayload(self, folderBlk):
140 """A function to transform the dictionary to JSON and save it in IOV from 0 to infinity; technically, upper limits are undefined and the maximum value (until beginning of a next entry) would be used."""
144 until=cool.ValidityKeyMax
147 payload=cool.Record(folderBlk.spec)
149 payload[
"data"]=json.dumps(self.mydict, indent = 1)
151 folderBlk.folder.storeObject(since,until,payload,0,folderBlk.tag)
◆ mydict
AFPAlignMCDBCreate.AFPDBDict.mydict |
The documentation for this class was generated from the following file: