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 429 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 436 of file TileCalibCrest.py.

436  def __init__(self, db, folderPath, calibDrawerType, isMultiVersionFolder=True):
437  """
438  Input:
439  - db : db should be a database connection
440  - folderPath: full folder path to create or update
441  """
442 
443  #=== initialize base class
444  TileCalibLogger.__init__(self, "TileBlobWriter")
445 
446  #=== store db
447  self.__db = db
448  self.__folderPath = folderPath
449 
450  #=== create default vectors based on calibDrawerType
451  self.__calibDrawerType = calibDrawerType
452  if calibDrawerType in ['TileCalibDrawerFlt', 'Flt']:
453  self.__TileCalibDrawer = TileCalibDrawerFlt
454  self.__defVec = cppyy.gbl.std.vector('std::vector<float>')()
455  elif calibDrawerType in ['TileCalibDrawerBch', 'Bch']:
456  self.__TileCalibDrawer = TileCalibDrawerBch
457  self.__defVec = cppyy.gbl.std.vector('std::vector<unsigned int>')()
458  elif calibDrawerType in ['TileCalibDrawerInt', 'Int']:
459  self.__TileCalibDrawer = TileCalibDrawerInt
460  self.__defVec = cppyy.gbl.std.vector('std::vector<unsigned int>')()
461  else:
462  raise Exception("Unknown calibDrawerType: %s" % calibDrawerType)
463 
464  # Always all drawers should be written
465  self.__drawerBlob = {drawerIdx:Blob() for drawerIdx in range(0, TileCalibUtils.max_draweridx())}
466  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 525 of file TileCalibCrest.py.

525  def getComment(self, split=False):
526  """
527  Returns the general comment (default if none is set)
528  """
530  comment = self.__drawer.get(drawerIdx, None)
531  if comment:
532  if split:
533  return (comment.getAuthor(), self.__comment.getComment(), self.__comment.getDate())
534  else:
535  return comment.getFullComment()
536  else:
537  return "<No general comment!>"
538 

◆ 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 540 of file TileCalibCrest.py.

540  def getDrawer(self, ros, drawer, calibDrawerTemplate=None):
541  """
542  Returns a TileCalibDrawer object of requested type
543  for the given ROS and drawer.
544  """
545 
546  try:
547  drawerIdx = TileCalibUtils.getDrawerIdx(ros, drawer)
548  calibDrawer = self.__drawer.get(drawerIdx, None)
549 
550  if not calibDrawer:
551  calibDrawer = self.__TileCalibDrawer.getInstance(self.__drawerBlob[drawerIdx], self.__defVec,0,0)
552  self.__drawer[drawerIdx] = calibDrawer
553 
554  #=== clone if requested
555  if calibDrawerTemplate:
556  calibDrawer.clone(calibDrawerTemplate)
557 
558  return calibDrawer
559 
560  except Exception as e:
561  self.log().critical( e )
562  return None
563 

◆ 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 468 of file TileCalibCrest.py.

468  def register(self, since=(MINRUN,MINLBK), tag=""):
469  """
470  Registers the folder in the database.
471  - since: lower limit of IOV
472  - tag : The tag to write to
473 
474  The interpretation of the 'since' inputs depends on their type:
475  - tuple(int,int) : run and lbk number
476  """
477 
478  jdata = {}
479  for drawerIdx,blob in self.__drawerBlob.items():
480  if blob is None or blob==0:
481  b64string = ''
482  else:
483  b64string = str(base64.b64encode(blob.read()), 'ascii')
484  jdata[drawerIdx] = [b64string]
485 
486  (sinceRun, sinceLumi) = since
487 
488  if not self.__db or (self.__db and self.__db.endswith('.json')):
489  # Writting into the json file
490  fullTag = tag
491  if self.__folderPath and not (tag.upper().startswith('TILE') or tag.upper().startswith('CALO')):
492  fullTag = TileCalibUtils.getFullTag(self.__folderPath, tag)
493  fileName = f"{fullTag}.{sinceRun}.{sinceLumi}.json"
494  if self.__db:
495  fileName = f'{self.__db[:-5]}.{fileName}'
496 
497  with open(fileName, 'w') as the_file:
498  json.dump(jdata, the_file)
499  the_file.write('\n')
500 
501  #=== print info
502  self.log().info( 'Writting tag "%s"', fullTag)
503  self.log().info( '... since : [%s,%s]' , sinceRun, sinceLumi)
504  self.log().info( '... with comment field: "%s"', self.getComment())
505  self.log().info( '... into file : %s' , fileName)
506 

◆ setComment()

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

Definition at line 508 of file TileCalibCrest.py.

508  def setComment(self, author, comment=None):
509  """
510  Sets a general comment in the comment channel.
511  """
513  commentBlob = self.__drawer.get(drawerIdx, None)
514  if not commentBlob:
515  commentBlob = Blob()
516  self.__drawerBlob[drawerIdx] = commentBlob
517 
518  if isinstance(author, tuple) and len(author) == 3:
519  tm = time.mktime(datetime.datetime.strptime(author[2], "%a %b %d %H:%M:%S %Y").timetuple())
520  self.__drawer[drawerIdx] = TileCalibDrawerCmt.getInstance(commentBlob, author[0], author[1], int(tm))
521  else:
522  self.__drawer[drawerIdx] = TileCalibDrawerCmt.getInstance(commentBlob, author, comment)
523 

◆ zeroBlob()

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

Definition at line 565 of file TileCalibCrest.py.

565  def zeroBlob(self, ros, drawer):
566  """
567  Resets blob size to zero
568  """
569  try:
570  drawerIdx = TileCalibUtils.getDrawerIdx(ros, drawer)
571  blob = self.__drawerBlob[drawerIdx]
572  blob.resize(0)
573  except Exception as e:
574  self.log().critical( e )
575  return None

Member Data Documentation

◆ __calibDrawerType

python.TileCalibCrest.TileBlobWriterCrest.__calibDrawerType
private

Definition at line 451 of file TileCalibCrest.py.

◆ __db

python.TileCalibCrest.TileBlobWriterCrest.__db
private

Definition at line 447 of file TileCalibCrest.py.

◆ __defVec

python.TileCalibCrest.TileBlobWriterCrest.__defVec
private

Definition at line 454 of file TileCalibCrest.py.

◆ __drawer

python.TileCalibCrest.TileBlobWriterCrest.__drawer
private

Definition at line 466 of file TileCalibCrest.py.

◆ __drawerBlob

python.TileCalibCrest.TileBlobWriterCrest.__drawerBlob
private

Definition at line 465 of file TileCalibCrest.py.

◆ __folderPath

python.TileCalibCrest.TileBlobWriterCrest.__folderPath
private

Definition at line 448 of file TileCalibCrest.py.

◆ __TileCalibDrawer

python.TileCalibCrest.TileBlobWriterCrest.__TileCalibDrawer
private

Definition at line 453 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:130
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