ATLAS Offline Software
Public Member Functions | Public Attributes | List of all members
python.AtlCoolLib.TimeStampToRLB Class Reference
Collaboration diagram for python.AtlCoolLib.TimeStampToRLB:

Public Member Functions

def __init__ (self, dbconn, iovstart, iovend)
 
def getRLB (self, timestamp, StartType=True)
 

Public Attributes

 StartTime
 
 EndTime
 
 since
 
 until
 
 TSBeginMap
 
 TSEndMap
 
 RLMap
 
 readdb
 

Detailed Description

Definition at line 454 of file AtlCoolLib.py.

Constructor & Destructor Documentation

◆ __init__()

def python.AtlCoolLib.TimeStampToRLB.__init__ (   self,
  dbconn,
  iovstart,
  iovend 
)

Definition at line 457 of file AtlCoolLib.py.

457  def __init__(self,dbconn,iovstart,iovend):
458  "Initialise and cache using the given DB connection, for RLB start/end"
459  # dbconn must correspond to COOLONL_TRIGGER/COMP200
460  self.StartTime = -1
461  self.EndTime = -1
462  self.since=iovstart
463  self.until=iovend
464  self.TSBeginMap = []
465  self.TSEndMap = []
466  self.RLMap = []
467  self.readdb = dbconn
468 
469  lblbname='/TRIGGER/LUMI/LBLB'
470  try:
471  readfolder=self.readdb.getFolder(lblbname)
472  except Exception as e:
473  print (e)
474  print ("Could not access folder %s " % lblbname)
475  raise RuntimeError ("TimeStampToRLB initialisation error")
476  # First try to read timestamp info
477  isFirst=True
478  try:
479  readobjs=readfolder.browseObjects(self.since,self.until,cool.ChannelSelection.all())
480  while readobjs.goToNext():
481  readobj=readobjs.currentRef()
482  payload=readobj.payload()
483  if (isFirst is True):
484  isFirst=False
485  self.StartTime=payload['StartTime']
486  else:
487  self.EndTime = payload['EndTime']
488  except Exception as e:
489  print (e)
490  print ("Problem reading data from folder %s" % lblbname)
491  raise RuntimeError ("TimeStampToRLB: initialisation error")
492  if (self.StartTime==-1):
493  raise RuntimeError ("TimeStampToRLB: no data for given runs")
494 
495  # Now try to read the LBTIME folder to translate timestamps into run/lumi blocks
496  lbtimename='/TRIGGER/LUMI/LBTIME'
497  try:
498  readfolder=self.readdb.getFolder(lbtimename)
499  except Exception as e:
500  print (e)
501  print ("Problem accessing folder %s" % lbtimename)
502  raise RuntimeError ("TimeStampToRLB: Initialisation error")
503  try:
504  readobjs=readfolder.browseObjects(self.StartTime, self.EndTime, cool.ChannelSelection.all())
505  while readobjs.goToNext():
506  readobj=readobjs.currentRef()
507  payload=readobj.payload()
508  TimeStampStart = readobj.since()
509  TimeStampEnd = readobj.until()
510  iov=(payload['Run'] << 32)+payload['LumiBlock']
511  self.TSBeginMap+=[TimeStampStart]
512  self.TSEndMap+=[TimeStampEnd]
513  self.RLMap+=[iov]
514  except Exception as e:
515  print (e)
516  print ("Problem reading from folder %s" % lbtimename)
517  raise RuntimeError ("TimeStampToRLB: Time data access error")
518  print ("TimeStampToRLB initialised with %i entries in map" % len(self.RLMap))
519 

Member Function Documentation

◆ getRLB()

def python.AtlCoolLib.TimeStampToRLB.getRLB (   self,
  timestamp,
  StartType = True 
)
Lookup a timestamp value. If it is outside a run, round up to next
run (StartType=True) or down to previous (StartType=False)

Definition at line 520 of file AtlCoolLib.py.

520  def getRLB(self,timestamp,StartType=True):
521  """Lookup a timestamp value. If it is outside a run, round up to next
522 run (StartType=True) or down to previous (StartType=False)"""
523 
524  # New version. Let's take advantage of the fact that the DB entries should be time-ordered
525  if (StartType):
526  for TSbegin, RL in zip(self.TSBeginMap, self.RLMap):
527  if (timestamp <= TSbegin):
528  return RL
529  # Timestamp above cached endtime - return endtime
530  return self.until
531 
532  else:
533  for TSend, RL in reversed(zip(self.TSEndMap, self.RLMap)):
534  if (timestamp >= TSend):
535  return RL
536  # Timestamp below cached starttime - return starttime
537  return self.since
538 
539 
540 
541 # main code - run test of library functions

Member Data Documentation

◆ EndTime

python.AtlCoolLib.TimeStampToRLB.EndTime

Definition at line 461 of file AtlCoolLib.py.

◆ readdb

python.AtlCoolLib.TimeStampToRLB.readdb

Definition at line 467 of file AtlCoolLib.py.

◆ RLMap

python.AtlCoolLib.TimeStampToRLB.RLMap

Definition at line 466 of file AtlCoolLib.py.

◆ since

python.AtlCoolLib.TimeStampToRLB.since

Definition at line 462 of file AtlCoolLib.py.

◆ StartTime

python.AtlCoolLib.TimeStampToRLB.StartTime

Definition at line 460 of file AtlCoolLib.py.

◆ TSBeginMap

python.AtlCoolLib.TimeStampToRLB.TSBeginMap

Definition at line 464 of file AtlCoolLib.py.

◆ TSEndMap

python.AtlCoolLib.TimeStampToRLB.TSEndMap

Definition at line 465 of file AtlCoolLib.py.

◆ until

python.AtlCoolLib.TimeStampToRLB.until

Definition at line 463 of file AtlCoolLib.py.


The documentation for this class was generated from the following file:
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18