ATLAS Offline Software
Loading...
Searching...
No Matches
AFPAlignMCDBCreate.AFPDBDict Class Reference
Collaboration diagram for AFPAlignMCDBCreate.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)

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 58 of file AFPAlignMCDBCreate.py.

Constructor & Destructor Documentation

◆ __init__()

AFPAlignMCDBCreate.AFPDBDict.__init__ ( self,
folderBlk )

Definition at line 60 of file AFPAlignMCDBCreate.py.

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

Member Function Documentation

◆ append()

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

◆ savePayload()

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."""
141
142 # transform run nr. and LB to the right integers
143 since=runLBtoDB(0,0)
144 until=cool.ValidityKeyMax
145
146 # provided set of constants have to be the right one for the provided specification
147 payload=cool.Record(folderBlk.spec)
148 # transform dictionary to JSON
149 payload["data"]=json.dumps(self.mydict, indent = 1)
150 # save everything (that "0" stands for channel nr. 0, there is only 1 real channel in the DB)
151 folderBlk.folder.storeObject(since,until,payload,0,folderBlk.tag)
152
153

Member Data Documentation

◆ mydict

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

Definition at line 69 of file AFPAlignMCDBCreate.py.


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