ATLAS Offline Software
Loading...
Searching...
No Matches
python.COOLUtils Namespace Reference

Classes

class  COOLQuery

Functions

 openBeamSpotDbFile (fileName, forceNew=False, folderName='/Indet/Beampos', dbName='BEAMSPOT')
 writeBeamSpotEntry (folderHandle, tag='nominal', runMin=0, runMax=(1<< 31) -1, lbMin=0, lbMax=(1<< 32) -2, status=0, posX=0., posY=0., posZ=0., sigmaX=30., sigmaY=30., sigmaZ=500., tiltX=0., tiltY=0., sigmaXY=0., posXErr=0., posYErr=0., posZErr=0., sigmaXErr=0., sigmaYErr=0., sigmaZErr=0., tiltXErr=0., tiltYErr=0., sigmaXYErr=0.)
 COOLToUnixTime (coolTime)
 resolveCurrentAlias (tagtype='ST')
 resolveNextAlias (tagtype='ST')
 resolveCurrentBeamSpotFolder (db='COOLOFL_INDET/CONDBR2', folder='/Indet/Beampos')
 resolveNextBeamSpotFolder (db='COOLOFL_INDET/CONDBR2', folder='/Indet/Beampos')
 resolveBLKTag (blktag, db='COOLOFL_INDET/CONDBR2', folder='/Indet/Beampos')

Variables

str __author__ = 'Juerg Beringer'
str __version__ = 'COOLUtils.py atlas/athena'
 c = COOLQuery()
 lbDict = c.getLbTimes(142193)

Detailed Description

Miscellaneous utilities related to COOL.

Function Documentation

◆ COOLToUnixTime()

python.COOLUtils.COOLToUnixTime ( coolTime)

Definition at line 111 of file COOLUtils.py.

111def COOLToUnixTime(coolTime):
112 if coolTime is not None:
113 return int(coolTime/1000000000)
114 else:
115 return
116
117
118#
119# Class to convert query COOL for various quantities related to runs,
120# such as start and end times of runs and LBs, LHC fill number, etc.
121#

◆ openBeamSpotDbFile()

python.COOLUtils.openBeamSpotDbFile ( fileName,
forceNew = False,
folderName = '/Indet/Beampos',
dbName = 'BEAMSPOT' )
Open a beam spot SQLite COOL file and get a `folderHandle` to the beam spot folder. If the folder
   doesn't exist yet, it is created. If the SQLite file doesn't exist, it is created. If forceNew=True,
   any previously existing output file with the specified name is overwritten.

Definition at line 22 of file COOLUtils.py.

22def openBeamSpotDbFile(fileName, forceNew=False, folderName='/Indet/Beampos', dbName='BEAMSPOT'):
23 """Open a beam spot SQLite COOL file and get a `folderHandle` to the beam spot folder. If the folder
24 doesn't exist yet, it is created. If the SQLite file doesn't exist, it is created. If forceNew=True,
25 any previously existing output file with the specified name is overwritten."""
26 connString = 'sqlite://;schema=%s;dbname=%s' % (fileName,dbName)
27 dbSvc = cool.DatabaseSvcFactory.databaseService()
28 if forceNew and os.path.exists(fileName):
29 os.remove(fileName)
30 if os.path.exists(fileName):
31 db = dbSvc.openDatabase(connString,False)
32 else:
33 db = dbSvc.createDatabase(connString)
34
35 # Make sure we have /Indet/Beampos with the correct schema
36 spec=cool.RecordSpecification()
37 spec.extend("status",cool.StorageType.Int32)
38 spec.extend("posX",cool.StorageType.Float)
39 spec.extend("posY",cool.StorageType.Float)
40 spec.extend("posZ",cool.StorageType.Float)
41 spec.extend("sigmaX",cool.StorageType.Float)
42 spec.extend("sigmaY",cool.StorageType.Float)
43 spec.extend("sigmaZ",cool.StorageType.Float)
44 spec.extend("tiltX",cool.StorageType.Float)
45 spec.extend("tiltY",cool.StorageType.Float)
46 spec.extend("sigmaXY",cool.StorageType.Float)
47 spec.extend("posXErr",cool.StorageType.Float)
48 spec.extend("posYErr",cool.StorageType.Float)
49 spec.extend("posZErr",cool.StorageType.Float)
50 spec.extend("sigmaXErr",cool.StorageType.Float)
51 spec.extend("sigmaYErr",cool.StorageType.Float)
52 spec.extend("sigmaZErr",cool.StorageType.Float)
53 spec.extend("tiltXErr",cool.StorageType.Float)
54 spec.extend("tiltYErr",cool.StorageType.Float)
55 spec.extend("sigmaXYErr",cool.StorageType.Float)
56
57 folder = AtlCoolLib.ensureFolder(db,folderName,spec,AtlCoolLib.athenaDesc(True,'AthenaAttributeList'),cool.FolderVersioning.MULTI_VERSION)
58
59 folderHandle = (db,folder,spec)
60 return folderHandle
61
62

◆ resolveBLKTag()

python.COOLUtils.resolveBLKTag ( blktag,
db = 'COOLOFL_INDET/CONDBR2',
folder = '/Indet/Beampos' )
Resolve a global tag into the corresponding tag for given folder in the database specified

Definition at line 322 of file COOLUtils.py.

322def resolveBLKTag(blktag, db = 'COOLOFL_INDET/CONDBR2', folder = '/Indet/Beampos'):
323 """
324 Resolve a global tag into the corresponding tag for given folder in the database specified
325 """
326
327 dbSvc = cool.DatabaseSvcFactory.databaseService()
328 dbconn = dbSvc.openDatabase(db)
329 folder = dbconn.getFolder(folder)
330 try:
331 tag = folder.resolveTag(blktag)
332 finally:
333 del dbconn
334
335 return tag
336
337# Test code for modules

◆ resolveCurrentAlias()

python.COOLUtils.resolveCurrentAlias ( tagtype = 'ST')

Definition at line 280 of file COOLUtils.py.

280def resolveCurrentAlias(tagtype='ST'):
281 "Resolve the current BLK tag alias"
282
283 from CondUtilsLib.AtlCoolBKLib import resolveAlias
284
285 # Will raise exception if alias not defined
286 alias = resolveAlias.getCurrent()
287 return alias.replace('*', tagtype)
288

◆ resolveCurrentBeamSpotFolder()

python.COOLUtils.resolveCurrentBeamSpotFolder ( db = 'COOLOFL_INDET/CONDBR2',
folder = '/Indet/Beampos' )
Resolve the beamspot folder tag for the current BLK tag alisa

Definition at line 305 of file COOLUtils.py.

305def resolveCurrentBeamSpotFolder(db = 'COOLOFL_INDET/CONDBR2', folder = '/Indet/Beampos'):
306 """
307 Resolve the beamspot folder tag for the current BLK tag alisa
308 """
309 tag = resolveCurrentAlias()
310 return resolveBLKTag(tag)
311

◆ resolveNextAlias()

python.COOLUtils.resolveNextAlias ( tagtype = 'ST')

Definition at line 289 of file COOLUtils.py.

289def resolveNextAlias(tagtype='ST'):
290 "Resolve the next BLK tag alias"
291
292 from CondUtilsLib.AtlCoolBKLib import resolveAlias
293
294 # Returns an empty string if Next not existing or exception thrown
295
296 alias = ''
297 try:
298 alias = resolveAlias.getNext()
299 except Exception:
300 alias = ''
301
302 return alias.replace('*', tagtype)
303
304

◆ resolveNextBeamSpotFolder()

python.COOLUtils.resolveNextBeamSpotFolder ( db = 'COOLOFL_INDET/CONDBR2',
folder = '/Indet/Beampos' )
Resolve the beamspot folder tag for the next BLK tag alias

Definition at line 312 of file COOLUtils.py.

312def resolveNextBeamSpotFolder(db = 'COOLOFL_INDET/CONDBR2', folder = '/Indet/Beampos'):
313 """
314 Resolve the beamspot folder tag for the next BLK tag alias
315 """
316
317 tag = resolveNextAlias()
318 if tag == '': return ''
319
320 return resolveBLKTag(tag)
321

◆ writeBeamSpotEntry()

python.COOLUtils.writeBeamSpotEntry ( folderHandle,
tag = 'nominal',
runMin = 0,
runMax = (1 << 31)-1,
lbMin = 0,
lbMax = (1 << 32)-2,
status = 0,
posX = 0.,
posY = 0.,
posZ = 0.,
sigmaX = 30.,
sigmaY = 30.,
sigmaZ = 500.,
tiltX = 0.,
tiltY = 0.,
sigmaXY = 0.,
posXErr = 0.,
posYErr = 0.,
posZErr = 0.,
sigmaXErr = 0.,
sigmaYErr = 0.,
sigmaZErr = 0.,
tiltXErr = 0.,
tiltYErr = 0.,
sigmaXYErr = 0. )
Write a beam spot entry for a given IOV into a beam spot folder whose 'folderHandle' is passsed.
   The IOV is specified in terms of run and LB range. Note that lbMax is inclusive.
   The default parameters for the position and tilt are zero, the ones for the widths are large
   non-constraining widths of 30mm (500mm) transverse (longitudinal).

Definition at line 63 of file COOLUtils.py.

73 sigmaXYErr=0.):
74 """Write a beam spot entry for a given IOV into a beam spot folder whose 'folderHandle' is passsed.
75 The IOV is specified in terms of run and LB range. Note that lbMax is inclusive.
76 The default parameters for the position and tilt are zero, the ones for the widths are large
77 non-constraining widths of 30mm (500mm) transverse (longitudinal)."""
78 since = (runMin << 32)+lbMin
79 until = (runMax << 32)+lbMax+1
80 payload=cool.Record(folderHandle[2])
81 payload['status'] = int(status)
82 payload['posX'] = float(posX)
83 payload['posY'] = float(posY)
84 payload['posZ'] = float(posZ)
85 payload['sigmaX'] = float(sigmaX)
86 payload['sigmaY'] = float(sigmaY)
87 payload['sigmaZ'] = float(sigmaZ)
88 payload['tiltX'] = float(tiltX)
89 payload['tiltY'] = float(tiltY)
90 payload['sigmaXY'] = float(sigmaXY)
91 payload['posXErr'] = float(posXErr)
92 payload['posYErr'] = float(posYErr)
93 payload['posZErr'] = float(posZErr)
94 payload['sigmaXErr'] = float(sigmaXErr)
95 payload['sigmaYErr'] = float(sigmaYErr)
96 payload['sigmaZErr'] = float(sigmaZErr)
97 payload['tiltXErr'] = float(tiltXErr)
98 payload['tiltYErr'] = float(tiltYErr)
99 payload['sigmaXYErr'] = float(sigmaXYErr)
100
101 if tag=='HEAD':
102 folderHandle[1].storeObject(since,until,payload,0)
103 else:
104 folderHandle[1].storeObject(since,until,payload,0,tag)
105
106
107
108#
109# Utility function to convert from COOL time to Unix time (seconds since epoch)
110#

Variable Documentation

◆ __author__

str python.COOLUtils.__author__ = 'Juerg Beringer'
private

Definition at line 6 of file COOLUtils.py.

◆ __version__

str python.COOLUtils.__version__ = 'COOLUtils.py atlas/athena'
private

Definition at line 7 of file COOLUtils.py.

◆ c

python.COOLUtils.c = COOLQuery()

Definition at line 339 of file COOLUtils.py.

◆ lbDict

python.COOLUtils.lbDict = c.getLbTimes(142193)

Definition at line 343 of file COOLUtils.py.