ATLAS Offline Software
Loading...
Searching...
No Matches
python.CaloCondTools.CaloBlobWriter Class Reference
Inheritance diagram for python.CaloCondTools.CaloBlobWriter:
Collaboration diagram for python.CaloCondTools.CaloBlobWriter:

Public Member Functions

 __init__ (self, db, folderPath, caloBlobType=None, isMultiVersionFolder=True, isRunLumiTimeStamp=True)
 register (self, since=(MINRUN, MINLBK), until=(MAXRUN, MAXLBK), tag="")
 getCells (self, systemId)
 zeroBlob (self, systemId)

Private Attributes

 __db = db
 __folder = self.__db.getFolder(folderPath)
dict __chanDictRecord = {}
dict __chanDictCells = {}

Detailed Description

Helper class that enables writing to Calo DB

Definition at line 391 of file CaloCondTools.py.

Constructor & Destructor Documentation

◆ __init__()

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.

398 isMultiVersionFolder=True, isRunLumiTimeStamp=True):
399 """
400 Input:
401 - db : db should be an open database connection
402 - folderPath: full folder path to create or update
403 """
404
405 #=== initialize base class
406 CaloCondLogger.__init__(self,"CaloBlobWriter")
407
408 #=== store db
409 self.__db = db
410
411 #=== determine folder mode
412 folderMode = cool.FolderVersioning.MULTI_VERSION
413 if not isMultiVersionFolder:
414 folderMode = cool.FolderVersioning.SINGLE_VERSION
415
416 #=== determine folder description
417 folderDescr = getAthenaFolderDescr()
418
419 #=== access folder in db
420 try:
421 #=== create folder if it does not exist
422 if self.__db.existsFolder(folderPath):
423 self.__folder = self.__db.getFolder(folderPath)
424 #=== check folder mode
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:
429 str += "MULTI"
430 else:
431 str += "SINGLE"
432 raise Exception(str)
433 else:
434 #=== create folder if it does not exist
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 )
441 raise
442
443 #=== initialize channel dictionaries
444 self.__chanDictRecord = {} # <int, cool.Record >
445 self.__chanDictCells = {} # <int, CaloCondBlobFlt>
446

Member Function Documentation

◆ getCells()

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):
516 """
517 Returns a CaloCondBlob object of given system Id.
518 """
519
520 #try:
521 chanNum = cool.ChannelId(systemId)
522 flt = self.__chanDictCells.get(chanNum,None)
523 #=== ... if not, get it from DB
524 if not flt:
525 #=== create new blob
526 spec = self.__folder.payloadSpecification()
527 data = cool.Record( spec )
528 self.__chanDictRecord[chanNum] = data
529 for key in data:
530 blob = data[key]
531 flt = g.CaloCondBlobFlt.getInstance(blob)
532
533 self.__chanDictCells[chanNum] = flt
534 return flt
535
536 #except Exception as e:
537 # self.log().critical( e )
538 # return None
539
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:130

◆ register()

python.CaloCondTools.CaloBlobWriter.register ( self,
since = (MINRUN,MINLBK),
until = (MAXRUN,MAXLBK),
tag = "" )
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=""):
449 """
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
454
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'
461 """
462
463 #=== check for inconsistent input
464 if type(since)!=type(until):
465 raise Exception("Inconsistent types: since=%s, until=%s" % (type(since),type(until)))
466
467 #=== write to user tag only if multiversion mode
468 userTagOnly = True
469 if self.__folder.versioningMode()==cool.FolderVersioning.SINGLE_VERSION:
470 userTagOnly = False
471 #=== no folder Tag allowed for singleversion
472 if tag!="":
473 self.log().warning( "Trying to store with tag \"%s\" to SINGLE_VERSION folder", tag )
474 self.log().warning( "... resetting tag to \"\"!" )
475 tag=""
476
477 #=== get IOV limits
478 sinceCool = getCoolValidityKey(since, True )
479 untilCool = getCoolValidityKey(until, False)
480 if untilCool <= sinceCool:
481 raise Exception("Until(%i) <= Since(%i)" % (untilCool,sinceCool))
482
483 #=== build IOV string
484 iovString = ""
485 if isinstance(since, tuple):
486 iovString = "[%i,%i] - [%i,%i]" % (since[0],since[1],until[0],until[1])
487 else:
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)
496
497 #=== build tag
498 folderTag=tag
499
500 #=== print info
501 self.log().info( "Registering folder %s with tag \"%s\"", self.__folder.fullPath(),folderTag)
502 self.log().info( "... with IOV : %s", iovString )
503 #self.log().info( "... with comment field: \"%s\"", self.__chanDictDrawer[48].getComment() )
504
505 #=== register all channels by increasing channel number
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)
513
const bool debug
#define min(a, b)
Definition cfImp.cxx:40
#define register
Definition dictionary.h:21

◆ zeroBlob()

python.CaloCondTools.CaloBlobWriter.zeroBlob ( self,
systemId )
Resets blob size to zero

Definition at line 560 of file CaloCondTools.py.

560 def zeroBlob(self, systemId):
561 """
562 Resets blob size to zero
563 """
564 try:
565 chanNum = cool.ChannelId(systemId)
566 data = self.__chanDictRecord.get(systemId)
567 if not data:
568 spec = self.__folder.payloadSpecification()
569 data = cool.Record( spec )
570 self.__chanDictRecord[chanNum] = data
571 blob = data['CaloCondBlob16M']
572 blob.resize(0)
573 except Exception as e:
574 self.log().critical( e )
575 return None
576

Member Data Documentation

◆ __chanDictCells

dict python.CaloCondTools.CaloBlobWriter.__chanDictCells = {}
private

Definition at line 445 of file CaloCondTools.py.

◆ __chanDictRecord

dict python.CaloCondTools.CaloBlobWriter.__chanDictRecord = {}
private

Definition at line 444 of file CaloCondTools.py.

◆ __db

python.CaloCondTools.CaloBlobWriter.__db = db
private

Definition at line 409 of file CaloCondTools.py.

◆ __folder

python.CaloCondTools.CaloBlobWriter.__folder = self.__db.getFolder(folderPath)
private

Definition at line 423 of file CaloCondTools.py.


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