ATLAS Offline Software
Loading...
Searching...
No Matches
python.AtlCoolLib.TimeStampToRLB Class Reference
Collaboration diagram for python.AtlCoolLib.TimeStampToRLB:

Public Member Functions

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

Public Attributes

int StartTime = -1
int EndTime = -1
 since = iovstart
 until = iovend
list TSBeginMap = []
list TSEndMap = []
list RLMap = []
 readdb = dbconn

Detailed Description

Definition at line 453 of file AtlCoolLib.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 456 of file AtlCoolLib.py.

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

Member Function Documentation

◆ getRLB()

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 519 of file AtlCoolLib.py.

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

Member Data Documentation

◆ EndTime

int python.AtlCoolLib.TimeStampToRLB.EndTime = -1

Definition at line 460 of file AtlCoolLib.py.

◆ readdb

python.AtlCoolLib.TimeStampToRLB.readdb = dbconn

Definition at line 466 of file AtlCoolLib.py.

◆ RLMap

python.AtlCoolLib.TimeStampToRLB.RLMap = []

Definition at line 465 of file AtlCoolLib.py.

◆ since

python.AtlCoolLib.TimeStampToRLB.since = iovstart

Definition at line 461 of file AtlCoolLib.py.

◆ StartTime

int python.AtlCoolLib.TimeStampToRLB.StartTime = -1

Definition at line 459 of file AtlCoolLib.py.

◆ TSBeginMap

python.AtlCoolLib.TimeStampToRLB.TSBeginMap = []

Definition at line 463 of file AtlCoolLib.py.

◆ TSEndMap

python.AtlCoolLib.TimeStampToRLB.TSEndMap = []

Definition at line 464 of file AtlCoolLib.py.

◆ until

python.AtlCoolLib.TimeStampToRLB.until = iovend

Definition at line 462 of file AtlCoolLib.py.


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