|
def | __init__ (self, db, folderPath, caloBlobType=None, isMultiVersionFolder=True, isRunLumiTimeStamp=True) |
|
def | register (self, since=(MINRUN, MINLBK), until=(MAXRUN, MAXLBK), tag="") |
|
def | getCells (self, systemId) |
|
def | zeroBlob (self, systemId) |
|
Helper class that enables writing to Calo DB
Definition at line 391 of file CaloCondTools.py.
◆ __init__()
def python.CaloCondTools.CaloBlobWriter.__init__ |
( |
|
self, |
|
|
|
db, |
|
|
|
folderPath, |
|
|
|
caloBlobType = None , |
|
|
|
isMultiVersionFolder = True , |
|
|
|
isRunLumiTimeStamp = True |
|
) |
| |
Input:
- db : db should be an open database connection
- folderPath: full folder path to create or update
Definition at line 397 of file CaloCondTools.py.
397 def __init__(self, db, folderPath, caloBlobType=None,
398 isMultiVersionFolder=True, isRunLumiTimeStamp=True):
401 - db : db should be an open database connection
402 - folderPath: full folder path to create or update
406 CaloCondLogger.__init__(self,
"CaloBlobWriter")
412 folderMode = cool.FolderVersioning.MULTI_VERSION
413 if not isMultiVersionFolder:
414 folderMode = cool.FolderVersioning.SINGLE_VERSION
422 if self.__db.existsFolder(folderPath):
423 self.__folder = self.__db.getFolder(folderPath)
425 modeInCool = self.__folder.versioningMode()
426 if modeInCool!=folderMode:
427 str =
"Incompatible folder mode detected, COOL folder has type "
428 if modeInCool==cool.FolderVersioning.MULTI_VERSION:
435 payloadSpec = cool.RecordSpecification()
436 payloadSpec.extend(
'CaloCondBlob16M', cool.StorageType.Blob16M )
437 folderSpec = cool.FolderSpecification(folderMode, payloadSpec)
438 self.__folder = db.createFolder(folderPath, folderSpec, folderDescr,
True)
439 except Exception
as e:
440 self.log().critical( e )
444 self.__chanDictRecord = {}
445 self.__chanDictCells = {}
◆ getCells()
def python.CaloCondTools.CaloBlobWriter.getCells |
( |
|
self, |
|
|
|
systemId |
|
) |
| |
Returns a CaloCondBlob object of given system Id.
Definition at line 515 of file CaloCondTools.py.
515 def getCells(self, systemId):
517 Returns a CaloCondBlob object of given system Id.
521 chanNum = cool.ChannelId(systemId)
522 flt = self.__chanDictCells.
get(chanNum,
None)
526 spec = self.__folder.payloadSpecification()
527 data = cool.Record( spec )
528 self.__chanDictRecord[chanNum] = data
531 flt = g.CaloCondBlobFlt.getInstance(blob)
533 self.__chanDictCells[chanNum] = flt
◆ register()
Registers the folder in the database.
- since: lower limit of IOV
- until: upper limit of IOV
- tag : The cool folder tag to write to
The interpretation of the 'since' and 'until' inputs depends on their type:
- tuple(int,int) : run and lbk number
- integer : Values are interpreted as unix time stamps
If since<0, current time is assumed
If until<0, infinity is assumed
- string : time stamp of format 'yyyy-mm-dd hh:mm:ss'
Definition at line 448 of file CaloCondTools.py.
448 def register(self, since=(MINRUN,MINLBK), until=(MAXRUN,MAXLBK), tag=
""):
450 Registers the folder in the database.
451 - since: lower limit of IOV
452 - until: upper limit of IOV
453 - tag : The cool folder tag to write to
455 The interpretation of the 'since' and 'until' inputs depends on their type:
456 - tuple(int,int) : run and lbk number
457 - integer : Values are interpreted as unix time stamps
458 If since<0, current time is assumed
459 If until<0, infinity is assumed
460 - string : time stamp of format 'yyyy-mm-dd hh:mm:ss'
465 raise Exception(
"Inconsistent types: since=%s, until=%s" % (
type(since),
type(until)))
469 if self.__folder.versioningMode()==cool.FolderVersioning.SINGLE_VERSION:
473 self.log().warning(
"Trying to store with tag \"%s\" to SINGLE_VERSION folder", tag )
474 self.log().warning(
"... resetting tag to \"\"!" )
480 if untilCool <= sinceCool:
481 raise Exception(
"Until(%i) <= Since(%i)" % (untilCool,sinceCool))
485 if isinstance(since, tuple):
486 iovString =
"[%i,%i] - [%i,%i]" % (since[0],since[1],until[0],until[1])
488 sinceInfo = time.localtime( sinceCool//UNIX2COOL )
489 untilInfo = time.localtime(
min(UNIXTMAX, (untilCool//UNIX2COOL)))
490 untilStr =
"<infinity>"
491 if untilCool<cool.ValidityKeyMax:
492 untilStr = time.asctime(untilInfo)
493 if (untilCool//UNIX2COOL)>UNIXTMAX:
494 untilStr =
" > "+untilStr
495 iovString =
"[%s] - [%s]" % (time.asctime(sinceInfo), untilStr)
501 self.log().
info(
"Registering folder %s with tag \"%s\"", self.__folder.
fullPath(),folderTag)
502 self.log().
info(
"... with IOV : %s", iovString )
506 chanList =
sorted(self.__chanDictRecord.
keys())
507 for chanNum
in chanList:
508 data = self.__chanDictRecord[chanNum]
509 strout =
"cool channel=%4i" % chanNum
510 self.log().
debug(
"Registering %s %s", (strout, data))
511 channelId = cool.ChannelId(chanNum)
512 self.__folder.storeObject(sinceCool, untilCool, data, channelId, folderTag, userTagOnly)
◆ zeroBlob()
def python.CaloCondTools.CaloBlobWriter.zeroBlob |
( |
|
self, |
|
|
|
systemId |
|
) |
| |
Resets blob size to zero
Definition at line 560 of file CaloCondTools.py.
560 def zeroBlob(self, systemId):
562 Resets blob size to zero
565 chanNum = cool.ChannelId(systemId)
566 data = self.__chanDictRecord.
get(systemId)
568 spec = self.__folder.payloadSpecification()
569 data = cool.Record( spec )
570 self.__chanDictRecord[chanNum] = data
571 blob = data[
'CaloCondBlob16M']
573 except Exception
as e:
574 self.log().critical( e )
◆ __chanDictCells
python.CaloCondTools.CaloBlobWriter.__chanDictCells |
|
private |
◆ __chanDictRecord
python.CaloCondTools.CaloBlobWriter.__chanDictRecord |
|
private |
◆ __db
python.CaloCondTools.CaloBlobWriter.__db |
|
private |
◆ __folder
python.CaloCondTools.CaloBlobWriter.__folder |
|
private |
The documentation for this class was generated from the following file: