|
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 59 of file AFPAlignMCDBCreate.py.
◆ __init__()
def AFPAlignMCDBCreate.AFPDBDict.__init__ |
( |
|
self, |
|
|
|
folderBlk |
|
) |
| |
Definition at line 61 of file AFPAlignMCDBCreate.py.
62 if(folderBlk.folderName==
"/FWD/AFP/Align/Local"):
63 emptydict={
"stationID":0,
"layerID":-1,
"shiftX":0.0,
"shiftY":0.0,
"shiftZ":0.0,
"alpha":0.0,
"beta":0.0,
"gamma":0.0}
64 elif(folderBlk.folderName==
"/FWD/AFP/Align/Global"):
65 emptydict={
"stationID":0,
"alignType":
"None",
"shiftX":0.0,
"shiftY":0.0,
"shiftZ":0.0,
"alpha":0.0,
"beta":0.0,
"gamma":0.0}
67 print (
"unknown folder %s, please edit \"AFPDBDict\" class constructor, exiting now" % folderBlk.folderName)
70 self.mydict={
"author":
"Petr Balek",
71 "version":
"AFP_DB_v2",
73 "data": dict.fromkeys(
range(0, 16))}
75 for i
in range(0, 16):
76 self.mydict[
"data"][i]=copy.deepcopy(emptydict)
77 self.mydict[
"data"][i][
"stationID"]=i//4
78 if(folderBlk.folderName==
"/FWD/AFP/Align/Local"):
79 self.mydict[
"data"][i][
"layerID"]=i%4
80 if(folderBlk.folderName==
"/FWD/AFP/Align/Global"):
81 if i%4==0: self.mydict[
"data"][i][
"alignType"]=
"tracker"
82 if i%4==1: self.mydict[
"data"][i][
"alignType"]=
"beam"
83 if i%4==2: self.mydict[
"data"][i][
"alignType"]=
"RP"
84 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 86 of file AFPAlignMCDBCreate.py.
86 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):
87 """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."""
90 if(layerID==-1
and alignType==
"None"):
91 print (
"cannot save payload, got layerID=%d and alignType=%s; one of them has to be specified" % layerID, alignType)
93 elif(layerID!=-1
and alignType!=
"None"):
94 print (
"cannot save payload, got layerID=%d and alignType=%s; one of them should not be specified" % layerID, alignType)
97 if(stationID<0
or stationID>=4):
98 print (
"cannot save payload, got stationID=%d, unknown" % stationID)
104 if(alignType!=
"None"):
106 if(alignType==
"tracker"):
108 elif(alignType==
"beam"):
110 elif(alignType==
"RP"):
112 elif(alignType==
"correction"):
115 print (
"cannot save payload, got alignType=%s, unknown" % alignType)
119 self.mydict[
"data"][channel][
'alignType']=alignType
124 if(0<=layerID
and layerID<4):
127 print (
"cannot save payload, got layerID=%d, unknown" % layerID)
131 self.mydict[
"data"][channel][
'layerID']=layerID
134 mydict_helper=self.mydict[
"data"][channel]
135 mydict_helper[
'shiftX'], mydict_helper[
'shiftY'], mydict_helper[
'shiftZ'] = shiftX, shiftY, shiftZ
136 mydict_helper[
'alpha'], mydict_helper[
'beta'], mydict_helper[
'gamma'] = alpha, beta, gamma
137 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 140 of file AFPAlignMCDBCreate.py.
140 def savePayload(self, folderBlk):
141 """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."""
145 until=cool.ValidityKeyMax
148 payload=cool.Record(folderBlk.spec)
150 payload[
"data"]=json.dumps(self.mydict, indent = 1)
152 folderBlk.folder.storeObject(since,until,payload,0,folderBlk.tag)
◆ mydict
AFPAlignMCDBCreate.AFPDBDict.mydict |
The documentation for this class was generated from the following file: