ATLAS Offline Software
Loading...
Searching...
No Matches
AFPAlignDBCreate.AFPDBDict Class Reference
Collaboration diagram for AFPAlignDBCreate.AFPDBDict:

Public Member Functions

 __init__ (self, folderBlk)
 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)
 savePayload (self, folderBlk, fromRun=-2, fromLB=0)

Public Attributes

dict mydict

Detailed Description

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.

Constructor & Destructor Documentation

◆ __init__()

AFPAlignDBCreate.AFPDBDict.__init__ ( self,
folderBlk )

Definition at line 59 of file AFPAlignDBCreate.py.

59 def __init__ (self, folderBlk):
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}
64 else:
65 print ("unknown folder %s, please edit \"AFPDBDict\" class constructor, exiting now" % folderBlk.folderName)
66 sys.exit(1)
67
68 self.mydict={"author":"Petr Balek",
69 "version":"AFP_DB_v2",
70 "nchannels":16,
71 "data": dict.fromkeys(range(0, 16))}
72
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"
83
if(febId1==febId2)

Member Function Documentation

◆ append()

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."""
86
87 # perform some simple check so basic mistakes are avoided
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)
90 sys.exit(1)
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)
93 sys.exit(1)
94
95 if(stationID<0 or stationID>=4):
96 print ("cannot save payload, got stationID=%d, unknown" % stationID)
97 sys.exit(1)
98
99 channel=0
100 # station 0 occupies channels 0-3, station 1 occupies channels 4-7, ..., and station 3 occupies channels 12-15
101 # if you are insterested in e.g. "beam" constants, look at channels 1, 5, 9, and 13
102 if(alignType!="None"):
103 channel=stationID*4
104 if(alignType=="tracker"):
105 channel+=0
106 elif(alignType=="beam"):
107 channel+=1
108 elif(alignType=="RP"):
109 channel+=2
110 elif(alignType=="correction"):
111 channel+=3
112 else:
113 print ("cannot save payload, got alignType=%s, unknown" % alignType)
114 sys.exit(1)
115
116 # overwrite it
117 self.mydict["data"][channel]['alignType']=alignType
118
119 # station 0 again occupies channels 0-3 etc.
120 if(layerID!=-1):
121 channel=stationID*4
122 if(0<=layerID and layerID<4):
123 channel+=layerID
124 else:
125 print ("cannot save payload, got layerID=%d, unknown" % layerID)
126 sys.exit(1)
127
128 # overwrite it
129 self.mydict["data"][channel]['layerID']=layerID
130
131 # overwrite it
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
136
137

◆ savePayload()

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."""
140
141 # perform some simple check so basic mistakes are avoided
142 if(fromRun<=0):
143 print ("cannot save payload, got fromRun=%d, it has to be positive" % fromRun)
144 sys.exit(1)
145
146 # transform run nr. and LB to the right integers
147 since=runLBtoDB(run=fromRun,lb=fromLB)
148 until=cool.ValidityKeyMax
149
150 # provided set of constants have to be the right one for the provided specification
151 payload=cool.Record(folderBlk.spec)
152 # transform dictionary to JSON
153 payload["data"]=json.dumps(self.mydict, indent = 1)
154 # save everything (that "0" stands for channel nr. 0, there is only 1 real channel in the DB)
155 folderBlk.folder.storeObject(since,until,payload,0,folderBlk.tag)
156
157

Member Data Documentation

◆ mydict

dict AFPAlignDBCreate.AFPDBDict.mydict
Initial value:
= {"author":"Petr Balek",
"version":"AFP_DB_v2",
"nchannels":16,
"data": dict.fromkeys(range(0, 16))}

Definition at line 68 of file AFPAlignDBCreate.py.


The documentation for this class was generated from the following file: