ATLAS Offline Software
Classes | Functions
AFPAlignMCDBCreate Namespace Reference

Classes

class  AFPDBDict
 
class  folderBulk
 

Functions

def runLBtoDB (run, lb)
 
def makeFolderAndSpec (db, folderName, tag)
 
def main ()
 

Function Documentation

◆ main()

def AFPAlignMCDBCreate.main ( )

Definition at line 155 of file AFPAlignMCDBCreate.py.

155 def main():
156  dbFile = "ExampleMC.db"
157  dbName = "OFLP200"
158 
159  # remove the old db file so that we can write the new one
160  try:
161  import os
162  os.remove(dbFile)
163  except IOError:
164  pass
165 
166  # get database service and open database
167  dbSvc = cool.DatabaseSvcFactory.databaseService()
168 
169  # database accessed via physical name
170  dbString = "sqlite://;schema=%s;dbname=%s" % (dbFile, dbName)
171  try:
172  db = dbSvc.createDatabase(dbString)
173  except Exception as e:
174  print ('Problem creating database', e)
175  sys.exit(-1)
176  print ("Created database", dbString)
177 
178  # define the folder in the database, its specification and its tag
179  folderBlkLoc_ideal_01 =makeFolderAndSpec(db,folderName="/FWD/AFP/Align/Local", tag="AFPMCAlignLoc-ideal-01")
180  folderBlkLoc_329484_01=makeFolderAndSpec(db,folderName="/FWD/AFP/Align/Local", tag="AFPMCAlignLoc-329484-01")
181  folderBlkLoc_329484_02=makeFolderAndSpec(db,folderName="/FWD/AFP/Align/Local", tag="AFPMCAlignLoc-329484-02")
182 
183  folderBlkGlob_ideal_01 =makeFolderAndSpec(db,folderName="/FWD/AFP/Align/Global", tag="AFPMCAlignGlob-ideal-01")
184  folderBlkGlob_203302_01=makeFolderAndSpec(db,folderName="/FWD/AFP/Align/Global", tag="AFPMCAlignGlob-203302-01")
185  folderBlkGlob_329484_01=makeFolderAndSpec(db,folderName="/FWD/AFP/Align/Global", tag="AFPMCAlignGlob-329484-01")
186  folderBlkGlob_331020_01=makeFolderAndSpec(db,folderName="/FWD/AFP/Align/Global", tag="AFPMCAlignGlob-331020-01")
187  folderBlkGlob_336288_01=makeFolderAndSpec(db,folderName="/FWD/AFP/Align/Global", tag="AFPMCAlignGlob-336288-01")
188  folderBlkGlob_347955_01=makeFolderAndSpec(db,folderName="/FWD/AFP/Align/Global", tag="AFPMCAlignGlob-347955-01")
189 
190 
191  # local
192  myDict = AFPDBDict(folderBlkLoc_ideal_01)
193  myDict.savePayload(folderBlk=folderBlkLoc_ideal_01)
194 
195 
196  myDict = AFPDBDict(folderBlkLoc_329484_01)
197  myDict.append(stationID=0, layerID=1, shiftX=17.1871e-3, shiftY=-31.4828e-3, shiftZ=0.0000, alpha=2.8832e-3,beta=0.0000, gamma=0.0000)
198  myDict.append(stationID=0, layerID=2, shiftX=15.2353e-3, shiftY=-51.4641e-3, shiftZ=0.0000, alpha=3.1571e-3,beta=0.0000, gamma=0.0000)
199  myDict.append(stationID=0, layerID=3, shiftX=0.0000, shiftY=0.0000, shiftZ=0.0000, alpha=0.0000, beta=0.0000, gamma=0.0000)
200  myDict.append(stationID=1, layerID=1, shiftX=137.0504e-3, shiftY=5.5895e-3, shiftZ=0.0000, alpha=-1.5424e-3,beta=0.0000, gamma=0.0000)
201  myDict.append(stationID=1, layerID=2, shiftX=-81.5657e-3, shiftY=21.9504e-3, shiftZ=0.0000, alpha=-3.4834e-3,beta=0.0000, gamma=0.0000)
202  myDict.append(stationID=1, layerID=3, shiftX=-52.5330e-3, shiftY=-31.8738e-3, shiftZ=0.0000, alpha=0.9359e-3, beta=0.0000, gamma=0.0000)
203  myDict.append(stationID=2, layerID=1, shiftX=148.6858e-3, shiftY=104.3183e-3, shiftZ=0.0000, alpha=-3.3322e-3,beta=0.0000, gamma=0.0000)
204  myDict.append(stationID=2, layerID=2, shiftX=150.8107e-3, shiftY=82.0611e-3, shiftZ=0.0000, alpha=4.2123e-3, beta=0.0000, gamma=0.0000)
205  myDict.append(stationID=2, layerID=3, shiftX=116.9848e-3, shiftY=113.5771e-3, shiftZ=0.0000, alpha=29.2103e-3,beta=0.0000, gamma=0.0000)
206  myDict.append(stationID=3, layerID=1, shiftX=-184.2146e-3,shiftY=55.3273e-3, shiftZ=0.0000, alpha=-0.7655e-3,beta=0.0000, gamma=0.0000)
207  myDict.append(stationID=3, layerID=2, shiftX=-154.2151e-3,shiftY=133.8304e-3, shiftZ=0.0000, alpha=-3.2126e-3,beta=0.0000, gamma=0.0000)
208  myDict.append(stationID=3, layerID=3, shiftX=13.2748e-3, shiftY=138.4570e-3, shiftZ=0.0000, alpha=0.5984e-3, beta=0.0000, gamma=0.0000)
209  myDict.savePayload(folderBlk=folderBlkLoc_329484_01)
210 
211 
212  myDict = AFPDBDict(folderBlkLoc_329484_02)
213  myDict.append(stationID=0, layerID=1, shiftX=17.1313e-3, shiftY=-46.7438e-3, shiftZ=0.0000, alpha=2.9785e-3, beta=0.0000, gamma=0.0000)
214  myDict.append(stationID=0, layerID=2, shiftX=15.7960e-3, shiftY=-53.7707e-3, shiftZ=0.0000, alpha=3.3048e-3, beta=0.0000, gamma=0.0000)
215  myDict.append(stationID=0, layerID=3, shiftX=0.0000, shiftY=0.0000, shiftZ=0.0000, alpha=0.0000, beta=0.0000, gamma=0.0000)
216  myDict.append(stationID=1, layerID=1, shiftX=138.0070e-3, shiftY=6.0528e-3, shiftZ=0.0000, alpha=-1.4420e-3, beta=0.0000, gamma=0.0000)
217  myDict.append(stationID=1, layerID=2, shiftX=-80.6720e-3, shiftY=24.1310e-3, shiftZ=0.0000, alpha=-3.6605e-3, beta=0.0000, gamma=0.0000)
218  myDict.append(stationID=1, layerID=3, shiftX=-51.5111e-3, shiftY=-32.9151e-3, shiftZ=0.0000, alpha=1.0762e-3, beta=0.0000, gamma=0.0000)
219  myDict.append(stationID=2, layerID=1, shiftX=149.6927e-3, shiftY=103.5674e-3, shiftZ=0.0000, alpha=-3.9565e-3, beta=0.0000, gamma=0.0000)
220  myDict.append(stationID=2, layerID=2, shiftX=144.1316e-3, shiftY=88.0891e-3, shiftZ=0.0000, alpha=3.3219e-3, beta=0.0000, gamma=0.0000)
221  myDict.append(stationID=2, layerID=3, shiftX=47.8090e-3, shiftY=153.5737e-3, shiftZ=0.0000, alpha=5.1961e-3, beta=0.0000, gamma=0.0000)
222  myDict.append(stationID=3, layerID=1, shiftX=0.0000, shiftY=0.0000, shiftZ=0.0000, alpha=0.0000, beta=0.0000, gamma=0.0000)
223  myDict.append(stationID=3, layerID=2, shiftX=-153.0397e-3,shiftY=132.8483e-3, shiftZ=0.0000, alpha=-3.9787e-3, beta=0.0000, gamma=0.0000)
224  myDict.append(stationID=3, layerID=3, shiftX=13.9500e-3, shiftY=136.9500e-3, shiftZ=0.0000, alpha=0.3829e-3, beta=0.0000, gamma=0.0000)
225  myDict.savePayload(folderBlk=folderBlkLoc_329484_02)
226 
227 
228  # global
229  myDict = AFPDBDict(folderBlkGlob_ideal_01)
230  myDict.savePayload(folderBlk=folderBlkGlob_ideal_01)
231 
232 
233  myDict = AFPDBDict(folderBlk=folderBlkGlob_203302_01)
234  myDict.append(stationID=0, alignType="RP", shiftX=-2.34, shiftY=-13.22)
235  myDict.append(stationID=1, alignType="RP", shiftX=-3.68, shiftY=-13.28)
236  myDict.append(stationID=2, alignType="RP", shiftX=-3.61, shiftY=-10.09)
237  myDict.append(stationID=3, alignType="RP", shiftX=-2.39, shiftY=-10.53)
238  myDict.savePayload(folderBlk=folderBlkGlob_203302_01)
239 
240 
241  myDict = AFPDBDict(folderBlk=folderBlkGlob_329484_01)
242  myDict.append(stationID=0, alignType="tracker", shiftX=-0.5)
243  myDict.append(stationID=1, alignType="tracker", shiftX=-0.5)
244  myDict.append(stationID=2, alignType="tracker", shiftX=-0.5)
245  myDict.append(stationID=3, alignType="tracker", shiftX=-0.5)
246  myDict.append(stationID=0, alignType="beam", shiftX=-1.045)
247  myDict.append(stationID=1, alignType="beam", shiftX=-0.864)
248  myDict.append(stationID=2, alignType="beam", shiftX=-1.155)
249  myDict.append(stationID=3, alignType="beam", shiftX=-0.891)
250  myDict.append(stationID=0, alignType="RP", shiftX=-3.16)
251  myDict.append(stationID=1, alignType="RP", shiftX=-4.07)
252  myDict.append(stationID=2, alignType="RP", shiftX=-4.26)
253  myDict.append(stationID=3, alignType="RP", shiftX=-2.93)
254  myDict.append(stationID=0, alignType="correction", shiftX=-0.420)
255  myDict.append(stationID=1, alignType="correction", shiftX=-0.320)
256  myDict.append(stationID=2, alignType="correction", shiftX=-0.220)
257  myDict.append(stationID=3, alignType="correction", shiftX=-0.320)
258  myDict.savePayload(folderBlk=folderBlkGlob_329484_01)
259 
260 
261  myDict = AFPDBDict(folderBlk=folderBlkGlob_331020_01)
262  myDict.append(stationID=0, alignType="tracker", shiftX=-0.5)
263  myDict.append(stationID=1, alignType="tracker", shiftX=-0.5)
264  myDict.append(stationID=2, alignType="tracker", shiftX=-0.5)
265  myDict.append(stationID=3, alignType="tracker", shiftX=-0.5)
266  myDict.append(stationID=0, alignType="beam", shiftX=-1.045)
267  myDict.append(stationID=1, alignType="beam", shiftX=-0.864)
268  myDict.append(stationID=2, alignType="beam", shiftX=-1.155)
269  myDict.append(stationID=3, alignType="beam", shiftX=-0.891)
270  myDict.append(stationID=0, alignType="RP", shiftX=-2.65)
271  myDict.append(stationID=1, alignType="RP", shiftX=-3.57)
272  myDict.append(stationID=2, alignType="RP", shiftX=-3.76)
273  myDict.append(stationID=3, alignType="RP", shiftX=-2.43)
274  myDict.append(stationID=0, alignType="correction", shiftX=-0.420)
275  myDict.append(stationID=1, alignType="correction", shiftX=-0.320)
276  myDict.append(stationID=2, alignType="correction", shiftX=-0.220)
277  myDict.append(stationID=3, alignType="correction", shiftX=-0.320)
278  myDict.savePayload(folderBlk=folderBlkGlob_331020_01)
279 
280 
281  myDict = AFPDBDict(folderBlk=folderBlkGlob_336288_01)
282  myDict.append(stationID=0, alignType="tracker", shiftX=-0.5)
283  myDict.append(stationID=1, alignType="tracker", shiftX=-0.5)
284  myDict.append(stationID=2, alignType="tracker", shiftX=-0.5)
285  myDict.append(stationID=3, alignType="tracker", shiftX=-0.5)
286  myDict.append(stationID=0, alignType="beam", shiftX=-1.045)
287  myDict.append(stationID=1, alignType="beam", shiftX=-0.864)
288  myDict.append(stationID=2, alignType="beam", shiftX=-1.155)
289  myDict.append(stationID=3, alignType="beam", shiftX=-0.891)
290  myDict.append(stationID=0, alignType="RP", shiftX=-2.38)
291  myDict.append(stationID=1, alignType="RP", shiftX=-3.60)
292  myDict.append(stationID=2, alignType="RP", shiftX=-3.87)
293  myDict.append(stationID=3, alignType="RP", shiftX=-2.23)
294  myDict.append(stationID=0, alignType="correction", shiftX=-0.420)
295  myDict.append(stationID=1, alignType="correction", shiftX=-0.320)
296  myDict.append(stationID=2, alignType="correction", shiftX=-0.220)
297  myDict.append(stationID=3, alignType="correction", shiftX=-0.320)
298  myDict.savePayload(folderBlk=folderBlkGlob_336288_01)
299 
300 
301  myDict = AFPDBDict(folderBlk=folderBlkGlob_347955_01)
302  myDict.append(stationID=0, alignType="RP", shiftX=-2.34, shiftY=-13.22)
303  myDict.append(stationID=1, alignType="RP", shiftX=-3.68, shiftY=-13.28)
304  myDict.append(stationID=2, alignType="RP", shiftX=-6.46, shiftY=-5.47)
305  myDict.append(stationID=3, alignType="RP", shiftX=-6.79, shiftY=-5.03)
306  myDict.savePayload(folderBlk=folderBlkGlob_347955_01)
307 
308  print ("\nClose database")
309  db.closeDatabase()
310 
311 

◆ makeFolderAndSpec()

def AFPAlignMCDBCreate.makeFolderAndSpec (   db,
  folderName,
  tag 
)
A function that will ensure a folder is in the database, it creates it if necessary. Also defines content of the folders. There are two folders: one for local constants and one for global constants. They both contain single entry of a long string

Definition at line 40 of file AFPAlignMCDBCreate.py.

40 def makeFolderAndSpec(db,folderName,tag):
41  """A function that will ensure a folder is in the database, it creates it if necessary. Also defines content of the folders. There are two folders: one for local constants and one for global constants. They both contain single entry of a long string"""
42 
43  spec=cool.RecordSpecification()
44 
45  # each folder contain just a single entry, this string will be JSON entry
46  spec.extend("data",cool.StorageType.String64k)
47 
48  runLumi=True
49 
50  # if there are more channels, use "CondAttrListCollection"; if there is only one channel, use "AthenaAttributeList"
51  # it's also possible to use "CondAttrListCollection" if there's only one channel
52  folder=AtlCoolLib.ensureFolder(db,folderName,spec,AtlCoolLib.athenaDesc(runLumi,'CondAttrListCollection'),cool.FolderVersioning.MULTI_VERSION)
53 
54  if(folder is None):
55  sys.exit(1)
56 
57  return folderBulk(folder, folderName, spec, tag)
58 

◆ runLBtoDB()

def AFPAlignMCDBCreate.runLBtoDB (   run,
  lb 
)
Turns run number and lumibock into integrer needed by the database

Definition at line 36 of file AFPAlignMCDBCreate.py.

36 def runLBtoDB(run,lb):
37  """Turns run number and lumibock into integrer needed by the database"""
38  return (run<<32) + lb
39 
AFPAlignMCDBCreate.main
def main()
Definition: AFPAlignMCDBCreate.py:155
AFPAlignMCDBCreate.makeFolderAndSpec
def makeFolderAndSpec(db, folderName, tag)
Definition: AFPAlignMCDBCreate.py:40
AFPAlignMCDBCreate.runLBtoDB
def runLBtoDB(run, lb)
Definition: AFPAlignMCDBCreate.py:36
if
if(febId1==febId2)
Definition: LArRodBlockPhysicsV0.cxx:567