|
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 361 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 367 of file CaloCondTools.py.
367 def __init__(self, db, folderPath, caloBlobType=None,
368 isMultiVersionFolder=True, isRunLumiTimeStamp=True):
371 - db : db should be an open database connection
372 - folderPath: full folder path to create or update
376 CaloCondLogger.__init__(self,
"CaloBlobWriter")
382 folderMode = cool.FolderVersioning.MULTI_VERSION
383 if not isMultiVersionFolder:
384 folderMode = cool.FolderVersioning.SINGLE_VERSION
392 if self.__db.existsFolder(folderPath):
393 self.__folder = self.__db.getFolder(folderPath)
395 modeInCool = self.__folder.versioningMode()
396 if modeInCool!=folderMode:
397 str =
"Incompatible folder mode detected, COOL folder has type "
398 if modeInCool==cool.FolderVersioning.MULTI_VERSION:
405 payloadSpec = cool.RecordSpecification()
406 payloadSpec.extend(
'CaloCondBlob16M', cool.StorageType.Blob16M )
407 folderSpec = cool.FolderSpecification(folderMode, payloadSpec)
408 self.__folder = db.createFolder(folderPath, folderSpec, folderDescr,
True)
409 except Exception
as e:
410 self.log().critical( e )
414 self.__chanDictRecord = {}
415 self.__chanDictCells = {}
◆ getCells()
def python.CaloCondTools.CaloBlobWriter.getCells |
( |
|
self, |
|
|
|
systemId |
|
) |
| |
Returns a CaloCondBlob object of given system Id.
Definition at line 485 of file CaloCondTools.py.
485 def getCells(self, systemId):
487 Returns a CaloCondBlob object of given system Id.
491 chanNum = cool.ChannelId(systemId)
492 flt = self.__chanDictCells.
get(chanNum,
None)
496 spec = self.__folder.payloadSpecification()
497 data = cool.Record( spec )
498 self.__chanDictRecord[chanNum] = data
501 flt = g.CaloCondBlobFlt.getInstance(blob)
503 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 418 of file CaloCondTools.py.
418 def register(self, since=(MINRUN,MINLBK), until=(MAXRUN,MAXLBK), tag=
""):
420 Registers the folder in the database.
421 - since: lower limit of IOV
422 - until: upper limit of IOV
423 - tag : The cool folder tag to write to
425 The interpretation of the 'since' and 'until' inputs depends on their type:
426 - tuple(int,int) : run and lbk number
427 - integer : Values are interpreted as unix time stamps
428 If since<0, current time is assumed
429 If until<0, infinity is assumed
430 - string : time stamp of format 'yyyy-mm-dd hh:mm:ss'
435 raise Exception(
"Inconsistent types: since=%s, until=%s" % (
type(since),
type(until)))
439 if self.__folder.versioningMode()==cool.FolderVersioning.SINGLE_VERSION:
443 self.log().warning(
"Trying to store with tag \"%s\" to SINGLE_VERSION folder", tag )
444 self.log().warning(
"... resetting tag to \"\"!" )
450 if untilCool <= sinceCool:
451 raise Exception(
"Until(%i) <= Since(%i)" % (untilCool,sinceCool))
455 if isinstance(since, tuple):
456 iovString =
"[%i,%i] - [%i,%i]" % (since[0],since[1],until[0],until[1])
458 sinceInfo = time.localtime( sinceCool//UNIX2COOL )
459 untilInfo = time.localtime(
min(UNIXTMAX, (untilCool//UNIX2COOL)))
460 untilStr =
"<infinity>"
461 if untilCool<cool.ValidityKeyMax:
462 untilStr = time.asctime(untilInfo)
463 if (untilCool//UNIX2COOL)>UNIXTMAX:
464 untilStr =
" > "+untilStr
465 iovString =
"[%s] - [%s]" % (time.asctime(sinceInfo), untilStr)
471 self.log().
info(
"Registering folder %s with tag \"%s\"", self.__folder.
fullPath(),folderTag)
472 self.log().
info(
"... with IOV : %s", iovString )
476 chanList =
sorted(self.__chanDictRecord.
keys())
477 for chanNum
in chanList:
478 data = self.__chanDictRecord[chanNum]
479 strout =
"cool channel=%4i" % chanNum
480 self.log().
debug(
"Registering %s %s", (strout, data))
481 channelId = cool.ChannelId(chanNum)
482 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 530 of file CaloCondTools.py.
530 def zeroBlob(self, systemId):
532 Resets blob size to zero
535 chanNum = cool.ChannelId(systemId)
536 data = self.__chanDictRecord.
get(systemId)
538 spec = self.__folder.payloadSpecification()
539 data = cool.Record( spec )
540 self.__chanDictRecord[chanNum] = data
541 blob = data[
'CaloCondBlob16M']
543 except Exception
as e:
544 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: