ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
python.CaloCondTools.CaloBlobWriter Class Reference
Inheritance diagram for python.CaloCondTools.CaloBlobWriter:
Collaboration diagram for python.CaloCondTools.CaloBlobWriter:

Public Member Functions

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)
 

Private Attributes

 __db
 
 __folder
 
 __chanDictRecord
 
 __chanDictCells
 

Detailed Description

Helper class that enables writing to Calo DB

Definition at line 361 of file CaloCondTools.py.

Constructor & Destructor Documentation

◆ __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):
369  """
370  Input:
371  - db : db should be an open database connection
372  - folderPath: full folder path to create or update
373  """
374 
375  #=== initialize base class
376  CaloCondLogger.__init__(self,"CaloBlobWriter")
377 
378  #=== store db
379  self.__db = db
380 
381  #=== determine folder mode
382  folderMode = cool.FolderVersioning.MULTI_VERSION
383  if not isMultiVersionFolder:
384  folderMode = cool.FolderVersioning.SINGLE_VERSION
385 
386  #=== determine folder description
387  folderDescr = getAthenaFolderDescr()
388 
389  #=== access folder in db
390  try:
391  #=== create folder if it does not exist
392  if self.__db.existsFolder(folderPath):
393  self.__folder = self.__db.getFolder(folderPath)
394  #=== check folder mode
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:
399  str += "MULTI"
400  else:
401  str += "SINGLE"
402  raise Exception(str)
403  else:
404  #=== create folder if it does not exist
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 )
411  raise
412 
413  #=== initialize channel dictionaries
414  self.__chanDictRecord = {} # <int, cool.Record >
415  self.__chanDictCells = {} # <int, CaloCondBlobFlt>
416 

Member Function Documentation

◆ 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):
486  """
487  Returns a CaloCondBlob object of given system Id.
488  """
489 
490  #try:
491  chanNum = cool.ChannelId(systemId)
492  flt = self.__chanDictCells.get(chanNum,None)
493  #=== ... if not, get it from DB
494  if not flt:
495  #=== create new blob
496  spec = self.__folder.payloadSpecification()
497  data = cool.Record( spec )
498  self.__chanDictRecord[chanNum] = data
499  for key in data:
500  blob = data[key]
501  flt = g.CaloCondBlobFlt.getInstance(blob)
502 
503  self.__chanDictCells[chanNum] = flt
504  return flt
505 
506  #except Exception as e:
507  # self.log().critical( e )
508  # return None
509 

◆ register()

def 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 418 of file CaloCondTools.py.

418  def register(self, since=(MINRUN,MINLBK), until=(MAXRUN,MAXLBK), tag=""):
419  """
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
424 
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'
431  """
432 
433  #=== check for inconsistent input
434  if type(since)!=type(until):
435  raise Exception("Inconsistent types: since=%s, until=%s" % (type(since),type(until)))
436 
437  #=== write to user tag only if multiversion mode
438  userTagOnly = True
439  if self.__folder.versioningMode()==cool.FolderVersioning.SINGLE_VERSION:
440  userTagOnly = False
441  #=== no folder Tag allowed for singleversion
442  if tag!="":
443  self.log().warning( "Trying to store with tag \"%s\" to SINGLE_VERSION folder", tag )
444  self.log().warning( "... resetting tag to \"\"!" )
445  tag=""
446 
447  #=== get IOV limits
448  sinceCool = getCoolValidityKey(since, True )
449  untilCool = getCoolValidityKey(until, False)
450  if untilCool <= sinceCool:
451  raise Exception("Until(%i) <= Since(%i)" % (untilCool,sinceCool))
452 
453  #=== build IOV string
454  iovString = ""
455  if isinstance(since, tuple):
456  iovString = "[%i,%i] - [%i,%i]" % (since[0],since[1],until[0],until[1])
457  else:
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)
466 
467  #=== build tag
468  folderTag=tag
469 
470  #=== print info
471  self.log().info( "Registering folder %s with tag \"%s\"", self.__folder.fullPath(),folderTag)
472  self.log().info( "... with IOV : %s", iovString )
473  #self.log().info( "... with comment field: \"%s\"", self.__chanDictDrawer[48].getComment() )
474 
475  #=== register all channels by increasing channel number
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)
483 

◆ 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):
531  """
532  Resets blob size to zero
533  """
534  try:
535  chanNum = cool.ChannelId(systemId)
536  data = self.__chanDictRecord.get(systemId)
537  if not data:
538  spec = self.__folder.payloadSpecification()
539  data = cool.Record( spec )
540  self.__chanDictRecord[chanNum] = data
541  blob = data['CaloCondBlob16M']
542  blob.resize(0)
543  except Exception as e:
544  self.log().critical( e )
545  return None
546 

Member Data Documentation

◆ __chanDictCells

python.CaloCondTools.CaloBlobWriter.__chanDictCells
private

Definition at line 414 of file CaloCondTools.py.

◆ __chanDictRecord

python.CaloCondTools.CaloBlobWriter.__chanDictRecord
private

Definition at line 413 of file CaloCondTools.py.

◆ __db

python.CaloCondTools.CaloBlobWriter.__db
private

Definition at line 378 of file CaloCondTools.py.

◆ __folder

python.CaloCondTools.CaloBlobWriter.__folder
private

Definition at line 392 of file CaloCondTools.py.


The documentation for this class was generated from the following file:
grepfile.info
info
Definition: grepfile.py:38
python.CaloCondTools.getCoolValidityKey
def getCoolValidityKey(pointInTime, isSince=True)
Definition: CaloCondTools.py:195
CscCalibQuery.fullPath
string fullPath
Definition: CscCalibQuery.py:360
python.CaloCondTools.getAthenaFolderDescr
def getAthenaFolderDescr()
Definition: CaloCondTools.py:40
register
#define register
Definition: dictionary.h:21
DerivationFramework::TriggerMatchingUtils::sorted
std::vector< typename T::value_type > sorted(T begin, T end)
Helper function to create a sorted vector from an unsorted one.
min
#define min(a, b)
Definition: cfImp.cxx:40
debug
const bool debug
Definition: MakeUncertaintyPlots.cxx:53
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
get
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition: hcg.cxx:127
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:798