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

Public Member Functions

def __init__ (self, db, folderPath, calibDrawerType, isMultiVersionFolder=True)
 
def register (self, since=(MINRUN, MINLBK), tag="")
 
def setComment (self, author, comment=None)
 
def getComment (self, split=False)
 
def getDrawer (self, ros, drawer, calibDrawerTemplate=None)
 
def zeroBlob (self, ros, drawer)
 

Private Attributes

 __db
 
 __folderPath
 
 __calibDrawerType
 
 __TileCalibDrawer
 
 __defVec
 
 __drawerBlob
 
 __drawer
 

Detailed Description

TileBlobWriterCrest is a helper class, managing the details of
CREST interactions for the user of TileCalibBlobs.

Definition at line 365 of file TileCalibCrest.py.

Constructor & Destructor Documentation

◆ __init__()

def python.TileCalibCrest.TileBlobWriterCrest.__init__ (   self,
  db,
  folderPath,
  calibDrawerType,
  isMultiVersionFolder = True 
)
Input:
- db        : db should be a database connection
- folderPath: full folder path to create or update

Definition at line 372 of file TileCalibCrest.py.

372  def __init__(self, db, folderPath, calibDrawerType, isMultiVersionFolder=True):
373  """
374  Input:
375  - db : db should be a database connection
376  - folderPath: full folder path to create or update
377  """
378 
379  #=== initialize base class
380  TileCalibLogger.__init__(self, "TileBlobWriter")
381 
382  #=== store db
383  self.__db = db
384  self.__folderPath = folderPath
385 
386  #=== create default vectors based on calibDrawerType
387  self.__calibDrawerType = calibDrawerType
388  if calibDrawerType in ['TileCalibDrawerFlt', 'Flt']:
389  self.__TileCalibDrawer = TileCalibDrawerFlt
390  self.__defVec = cppyy.gbl.std.vector('std::vector<float>')()
391  elif calibDrawerType in ['TileCalibDrawerBch', 'Bch']:
392  self.__TileCalibDrawer = TileCalibDrawerBch
393  self.__defVec = cppyy.gbl.std.vector('std::vector<unsigned int>')()
394  elif calibDrawerType in ['TileCalibDrawerInt', 'Int']:
395  self.__TileCalibDrawer = TileCalibDrawerInt
396  self.__defVec = cppyy.gbl.std.vector('std::vector<unsigned int>')()
397  else:
398  raise Exception("Unknown calibDrawerType: %s" % calibDrawerType)
399 
400  # Always all drawers should be written
401  self.__drawerBlob = {drawerIdx:Blob() for drawerIdx in range(0, TileCalibUtils.max_draweridx())}
402  self.__drawer = {}

Member Function Documentation

◆ getComment()

def python.TileCalibCrest.TileBlobWriterCrest.getComment (   self,
  split = False 
)
Returns the general comment (default if none is set)

Definition at line 458 of file TileCalibCrest.py.

458  def getComment(self, split=False):
459  """
460  Returns the general comment (default if none is set)
461  """
463  comment = self.__drawer.get(drawerIdx, None)
464  if comment:
465  if split:
466  return (comment.getAuthor(), self.__comment.getComment(), self.__comment.getDate())
467  else:
468  return comment.getFullComment()
469  else:
470  return "<No general comment!>"
471 

◆ getDrawer()

def python.TileCalibCrest.TileBlobWriterCrest.getDrawer (   self,
  ros,
  drawer,
  calibDrawerTemplate = None 
)
Returns a TileCalibDrawer object of requested type
for the given ROS and drawer.

Definition at line 473 of file TileCalibCrest.py.

473  def getDrawer(self, ros, drawer, calibDrawerTemplate=None):
474  """
475  Returns a TileCalibDrawer object of requested type
476  for the given ROS and drawer.
477  """
478 
479  try:
480  drawerIdx = TileCalibUtils.getDrawerIdx(ros, drawer)
481  calibDrawer = self.__drawer.get(drawerIdx, None)
482 
483  if not calibDrawer:
484  calibDrawer = self.__TileCalibDrawer.getInstance(self.__drawerBlob[drawerIdx], self.__defVec,0,0)
485  self.__drawer[drawerIdx] = calibDrawer
486 
487  #=== clone if requested
488  if calibDrawerTemplate:
489  calibDrawer.clone(calibDrawerTemplate)
490 
491  return calibDrawer
492 
493  except Exception as e:
494  self.log().critical( e )
495  return None
496 

◆ register()

def python.TileCalibCrest.TileBlobWriterCrest.register (   self,
  since = (MINRUN,MINLBK),
  tag = "" 
)
Registers the folder in the database.
- since: lower limit of IOV
- tag  : The tag to write to

The interpretation of the 'since' inputs depends on their type:
- tuple(int,int) : run and lbk number

Definition at line 404 of file TileCalibCrest.py.

404  def register(self, since=(MINRUN,MINLBK), tag=""):
405  """
406  Registers the folder in the database.
407  - since: lower limit of IOV
408  - tag : The tag to write to
409 
410  The interpretation of the 'since' inputs depends on their type:
411  - tuple(int,int) : run and lbk number
412  """
413 
414  jdata = {}
415  for drawerIdx,blob in self.__drawerBlob.items():
416  b64string = str(base64.b64encode(blob.read()), 'ascii')
417  jdata[drawerIdx] = [b64string]
418 
419  (sinceRun, sinceLumi) = since
420 
421  if not self.__db or (self.__db and self.__db.endswith('.json')):
422  # Writting into the json file
423  fullTag = tag
424  if self.__folderPath and not (tag.startswith('Tile') or tag.startswith('Calo')):
425  fullTag = TileCalibUtils.getFullTag(self.__folderPath, tag)
426  fileName = f"{fullTag}.{sinceRun}.{sinceLumi}.json"
427  if self.__db:
428  fileName = f'{self.__db[:-5]}.{fileName}'
429 
430  with open(fileName, 'w') as the_file:
431  json.dump(jdata, the_file)
432  the_file.write('\n')
433 
434  #=== print info
435  self.log().info( 'Writting tag "%s"', fullTag)
436  self.log().info( '... since : [%s,%s]' , sinceRun, sinceLumi)
437  self.log().info( '... with comment field: "%s"', self.getComment())
438  self.log().info( '... into file : %s' , fileName)
439 

◆ setComment()

def python.TileCalibCrest.TileBlobWriterCrest.setComment (   self,
  author,
  comment = None 
)
Sets a general comment in the comment channel.

Definition at line 441 of file TileCalibCrest.py.

441  def setComment(self, author, comment=None):
442  """
443  Sets a general comment in the comment channel.
444  """
446  commentBlob = self.__drawer.get(drawerIdx, None)
447  if not commentBlob:
448  commentBlob = Blob()
449  self.__drawerBlob[drawerIdx] = commentBlob
450 
451  if isinstance(author, tuple) and len(author) == 3:
452  tm = time.mktime(datetime.datetime.strptime(author[2], "%a %b %d %H:%M:%S %Y").timetuple())
453  self.__drawer[drawerIdx] = TileCalibDrawerCmt.getInstance(commentBlob, author[0], author[1], int(tm))
454  else:
455  self.__drawer[drawerIdx] = TileCalibDrawerCmt.getInstance(commentBlob, author, comment)
456 

◆ zeroBlob()

def python.TileCalibCrest.TileBlobWriterCrest.zeroBlob (   self,
  ros,
  drawer 
)
Resets blob size to zero

Definition at line 498 of file TileCalibCrest.py.

498  def zeroBlob(self, ros, drawer):
499  """
500  Resets blob size to zero
501  """
502  try:
503  drawerIdx = TileCalibUtils.getDrawerIdx(ros, drawer)
504  blob = self.__drawerBlob[drawerIdx]
505  blob.resize(0)
506  except Exception as e:
507  self.log().critical( e )
508  return None

Member Data Documentation

◆ __calibDrawerType

python.TileCalibCrest.TileBlobWriterCrest.__calibDrawerType
private

Definition at line 387 of file TileCalibCrest.py.

◆ __db

python.TileCalibCrest.TileBlobWriterCrest.__db
private

Definition at line 383 of file TileCalibCrest.py.

◆ __defVec

python.TileCalibCrest.TileBlobWriterCrest.__defVec
private

Definition at line 390 of file TileCalibCrest.py.

◆ __drawer

python.TileCalibCrest.TileBlobWriterCrest.__drawer
private

Definition at line 402 of file TileCalibCrest.py.

◆ __drawerBlob

python.TileCalibCrest.TileBlobWriterCrest.__drawerBlob
private

Definition at line 401 of file TileCalibCrest.py.

◆ __folderPath

python.TileCalibCrest.TileBlobWriterCrest.__folderPath
private

Definition at line 384 of file TileCalibCrest.py.

◆ __TileCalibDrawer

python.TileCalibCrest.TileBlobWriterCrest.__TileCalibDrawer
private

Definition at line 389 of file TileCalibCrest.py.


The documentation for this class was generated from the following file:
python.processes.powheg.ZZj_MiNNLO.ZZj_MiNNLO.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZj_MiNNLO.py:18
register
#define register
Definition: dictionary.h:21
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:194
TileCalibUtils::getCommentChannel
static unsigned int getCommentChannel()
Returns the COOL channel number for the comment channel.
Definition: TileCalibUtils.h:82
TileCalibUtils::max_draweridx
static unsigned int max_draweridx()
Python compatibility function.
Definition: TileCalibUtils.h:116
TrigJetMonitorAlgorithm.items
items
Definition: TrigJetMonitorAlgorithm.py:71
Trk::open
@ open
Definition: BinningType.h:40
python.CaloAddPedShiftConfig.int
int
Definition: CaloAddPedShiftConfig.py:45
TileCalibDrawerCmt::getInstance
static const TileCalibDrawerCmt * getInstance(const coral::Blob &blob)
Returns a pointer to a const TileCalibDrawerCmt.
Definition: TileCalibDrawerCmt.cxx:24
get
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition: hcg.cxx:127
python.TileCalibCrest.Blob
Blob
Definition: TileCalibCrest.py:16
str
Definition: BTagTrackIpAccessor.cxx:11
TileCalibUtils::getDrawerIdx
static unsigned int getDrawerIdx(unsigned int ros, unsigned int drawer)
Returns a drawer hash.
Definition: TileCalibUtils.cxx:60
python.ParticleTypeUtil.info
def info
Definition: ParticleTypeUtil.py:87
TileCalibUtils::getFullTag
static std::string getFullTag(const std::string &folder, const std::string &tag)
Returns the full tag string, composed of camelized folder name and tag part.
Definition: TileCalibUtils.cxx:33