|
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, fromRun=-2, fromLB=0) |
|
A class to create a dictionary, fill it with zeros in the constructor and to overwrite zeros later
Definition at line 57 of file AFPAlignDBCreate.py.
◆ __init__()
def AFPAlignDBCreate.AFPDBDict.__init__ |
( |
|
self, |
|
|
|
folderBlk |
|
) |
| |
Definition at line 59 of file AFPAlignDBCreate.py.
60 if(folderBlk.folderName==
"/FWD/Onl/AFP/Align/Local"):
61 emptydict={
"stationID":0,
"layerID":-1,
"shiftX":0.0,
"shiftY":0.0,
"shiftZ":0.0,
"alpha":0.0,
"beta":0.0,
"gamma":0.0}
62 elif(folderBlk.folderName==
"/FWD/Onl/AFP/Align/Global"):
63 emptydict={
"stationID":0,
"alignType":
"None",
"shiftX":0.0,
"shiftY":0.0,
"shiftZ":0.0,
"alpha":0.0,
"beta":0.0,
"gamma":0.0}
65 print (
"unknown folder %s, please edit \"AFPDBDict\" class constructor, exiting now" % folderBlk.folderName)
68 self.mydict={
"author":
"Petr Balek",
69 "version":
"AFP_DB_v2",
71 "data": dict.fromkeys(
range(0, 16))}
73 for i
in range(0, 16):
74 self.mydict[
"data"][i]=copy.deepcopy(emptydict)
75 self.mydict[
"data"][i][
"stationID"]=i//4
76 if(folderBlk.folderName==
"/FWD/Onl/AFP/Align/Local"):
77 self.mydict[
"data"][i][
"layerID"]=i%4
78 if(folderBlk.folderName==
"/FWD/Onl/AFP/Align/Global"):
79 if i%4==0: self.mydict[
"data"][i][
"alignType"]=
"tracker"
80 if i%4==1: self.mydict[
"data"][i][
"alignType"]=
"beam"
81 if i%4==2: self.mydict[
"data"][i][
"alignType"]=
"RP"
82 if i%4==3: self.mydict[
"data"][i][
"alignType"]=
"correction"
◆ append()
def AFPAlignDBCreate.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 84 of file AFPAlignDBCreate.py.
84 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):
85 """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."""
88 if(layerID==-1
and alignType==
"None"):
89 print (
"cannot save payload, got layerID=%d and alignType=%s; one of them has to be specified" % layerID, alignType)
91 elif(layerID!=-1
and alignType!=
"None"):
92 print (
"cannot save payload, got layerID=%d and alignType=%s; one of them should not be specified" % layerID, alignType)
95 if(stationID<0
or stationID>=4):
96 print (
"cannot save payload, got stationID=%d, unknown" % stationID)
102 if(alignType!=
"None"):
104 if(alignType==
"tracker"):
106 elif(alignType==
"beam"):
108 elif(alignType==
"RP"):
110 elif(alignType==
"correction"):
113 print (
"cannot save payload, got alignType=%s, unknown" % alignType)
117 self.mydict[
"data"][channel][
'alignType']=alignType
122 if(0<=layerID
and layerID<4):
125 print (
"cannot save payload, got layerID=%d, unknown" % layerID)
129 self.mydict[
"data"][channel][
'layerID']=layerID
132 mydict_helper=self.mydict[
"data"][channel]
133 mydict_helper[
'shiftX'], mydict_helper[
'shiftY'], mydict_helper[
'shiftZ'] = shiftX, shiftY, shiftZ
134 mydict_helper[
'alpha'], mydict_helper[
'beta'], mydict_helper[
'gamma'] = alpha, beta, gamma
135 mydict_helper[
'stationID']=stationID
◆ savePayload()
def AFPAlignDBCreate.AFPDBDict.savePayload |
( |
|
self, |
|
|
|
folderBlk, |
|
|
|
fromRun = -2 , |
|
|
|
fromLB = 0 |
|
) |
| |
A function to transform the dictionary to JSON and save it in IOV from a given run and LB; upper limits are undefined and the maximum value (until beginning of a next entry) is used.
Definition at line 138 of file AFPAlignDBCreate.py.
138 def savePayload(self, folderBlk, fromRun=-2, fromLB=0):
139 """A function to transform the dictionary to JSON and save it in IOV from a given run and LB; upper limits are undefined and the maximum value (until beginning of a next entry) is used."""
143 print (
"cannot save payload, got fromRun=%d, it has to be positive" % fromRun)
148 until=cool.ValidityKeyMax
151 payload=cool.Record(folderBlk.spec)
153 payload[
"data"]=json.dumps(self.mydict, indent = 1)
155 folderBlk.folder.storeObject(since,until,payload,0,folderBlk.tag)
◆ mydict
AFPAlignDBCreate.AFPDBDict.mydict |
The documentation for this class was generated from the following file: