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

Public Member Functions

def __init__ (self, db, folder, tag="")
 
def getComment (self, pointInTime, split=False)
 
def getDefault (self, ros, drawer)
 
def getDrawer (self, ros, drawer, pointInTime, printError=True, useDefault=True)
 
def getDefaultDrawer (self, ros, drawer, pointInTime, printError=True)
 
def getDBobjsWithinRange (self, ros, drawer, point1inTime=(0, 0), point2inTime=(2147483647, 4294967295), printError=True)
 
def getIOVsWithinRange (self, ros, drawer, point1inTime=(0, 0), point2inTime=(2147483647, 4294967295), printError=True)
 
def getBlobsWithinRange (self, ros, drawer, point1inTime=(0, 0), point2inTime=(2147483647, 4294967295))
 
def folderIsMultiVersion (self)
 

Private Attributes

 __db
 
 __folder
 
 __folderType
 
 __tag
 
 __objDict
 

Detailed Description

TileCalibBlobReader is a helper class, managing the details of COOL interactions for
the user of TileCalibBlobs.

Definition at line 753 of file TileCalibTools.py.

Constructor & Destructor Documentation

◆ __init__()

def python.TileCalibTools.TileBlobReader.__init__ (   self,
  db,
  folder,
  tag = "" 
)
Input:
- db    : db should be an open database connection
- folder: full folder path
- tag   : The folder tag, e.g. \"000-00\"

Definition at line 760 of file TileCalibTools.py.

760  def __init__(self, db, folder, tag=""):
761  """
762  Input:
763  - db : db should be an open database connection
764  - folder: full folder path
765  - tag : The folder tag, e.g. \"000-00\"
766  """
767  #=== initialize base class
768  TileCalibLogger.__init__(self,"TileBlobReader")
769 
770  #=== try to open db
771  try:
772  self.__db = db # CoraCoolDatabase
773  self.__folder = self.__db.getFolder(folder) # CoraCoolFolder
774  except Exception as e:
775  self.log().critical( e )
776  raise
777 
778  #=== determine if "run-lumi" or "time" folder
779  validFolderTypes = ("run-lumi","time")
780  folderDescr = self.__folder.description()
781  self.__folderType = getAthenaFolderType(folderDescr)
782  if self.__folderType not in validFolderTypes:
783  raise Exception("Invalid folder type found: \'%s\'" % self.__folderType)
784 
785  #=== use camelized full folder path only if tag is given
786  self.__tag = tag
787 
788  #=== initialize dictionary to keep reference to DB object of given ros/drawer
789  #=== and timestamp, so they do not go out of scope
790  self.__objDict = {}
791 

Member Function Documentation

◆ folderIsMultiVersion()

def python.TileCalibTools.TileBlobReader.folderIsMultiVersion (   self)
Returns true if MultiVersion folder is connected

Definition at line 1083 of file TileCalibTools.py.

1083  def folderIsMultiVersion(self):
1084  """
1085  Returns true if MultiVersion folder is connected
1086  """
1087  if self.__folder.versioningMode()==cool.FolderVersioning.MULTI_VERSION:
1088  return True
1089  else:
1090  return False
1091 
1092 
1093 #======================================================================
1094 #===
1095 #=== TileASCIIParser
1096 #===
1097 #======================================================================
1098 
1099 #
1100 #______________________________________________________________________

◆ getBlobsWithinRange()

def python.TileCalibTools.TileBlobReader.getBlobsWithinRange (   self,
  ros,
  drawer,
  point1inTime = (0,0),
  point2inTime = (2147483647,4294967295) 
)
Returns all blob objects for the given ROS and drawer, within given validity range -- default: [0-Infty)
Note: the blobs don't contain validity range info.  Check method getDBobjsWithinRange()

Definition at line 1017 of file TileCalibTools.py.

1017  def getBlobsWithinRange(self, ros, drawer, point1inTime=(0,0), point2inTime=(2147483647,4294967295)):
1018  """
1019  Returns all blob objects for the given ROS and drawer, within given validity range -- default: [0-Infty)
1020  Note: the blobs don't contain validity range info. Check method getDBobjsWithinRange()
1021  """
1022 
1023  validityKey1 = getCoolValidityKey(point1inTime,True)
1024  validityKey2 = getCoolValidityKey(point2inTime,False)
1025 
1026  print ("Validity keys range is %s - %s" % (validityKey1, validityKey2))
1027  self.log().debug("Validity key range is %s - %s", validityKey1,validityKey2)
1028 
1029  objs = self.getDBobjsWithinRange(self, ros, drawer, point1inTime, point2inTime)
1030 
1031  #-- Loop over objs to extract blobs
1032  blobs = []
1033  calibDrawer = None
1034  while objs.goToNext():
1035  obj=objs.currentRef()
1036  sinceCool=obj.since()
1037  if sinceCool < validityKey1:
1038  sinceCool = validityKey1
1039  untilCool=obj.until()
1040  blob = obj.payload()[0]
1041  print ("[%d,%d)-[%d,%d) - %s" % ((sinceCool>>32),(sinceCool&0xFFFFFFFF),(untilCool>>32),(untilCool&0xFFFFFFFF),blob))
1042  self.log().debug("blob size: %d", blob.size())
1043 
1044  #=== default policy
1045  while blob.size()==0:
1046  #=== no default at all?
1047  if ros==0 and drawer==0:
1048  raise Exception('No default available')
1049  #=== follow default policy
1050  ros,drawer = self.getDefault(ros,drawer)
1051  chanNum = TileCalibUtils.getDrawerIdx(ros,drawer)
1052  obj = self.__folder.findObject(sinceCool, chanNum, self.__tag)
1053  blob = obj.payload()[0]
1054  self.log().debug("blob size: 0 --> default: %d", blob.size())
1055 
1056  #=== store object in dictionary
1057  self.__objDict[sinceCool] = obj
1058 
1059  #=== create calibDrawer depending on type
1060  calibDrawer = TileCalibDrawerCmt.getInstance(blob)
1061  typeName = TileCalibType.getClassName(calibDrawer.getObjType())
1062  del calibDrawer
1063  if typeName=='TileCalibDrawerFlt':
1064  calibDrawer = TileCalibDrawerFlt.getInstance(blob)
1065  self.log().debug( "typeName = Flt " )
1066  elif typeName=='TileCalibDrawerInt':
1067  calibDrawer = TileCalibDrawerInt.getInstance(blob)
1068  self.log().debug( "typeName = Int " )
1069  elif typeName=='TileCalibDrawerBch':
1070  calibDrawer = TileCalibDrawerBch.getInstance(blob)
1071  self.log().debug( "typeName = Bch " )
1072  elif typeName=='TileCalibDrawerOfc':
1073  calibDrawer = TileCalibDrawerOfc.getInstance(blob)
1074  self.log().debug( "typeName = Ofc " )
1075  else:
1076  raise Exception( "Invalid blob type requested: %s" % typeName )
1077 
1078  blobs.append( calibDrawer )
1079 
1080  return blobs
1081 

◆ getComment()

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

Definition at line 793 of file TileCalibTools.py.

793  def getComment(self, pointInTime, split=False):
794  """
795  Returns the general comment (default if none is set)
796  """
797  validityKey = getCoolValidityKey(pointInTime)
798  try:
800  obj = self.__folder.findObject(validityKey, chanNum, self.__tag)
801  self.log().debug("getComment:Fetching from DB: %s", obj)
802  blob = obj.payload()[0]
804  if split:
805  return (cmt.getAuthor(),cmt.getComment(),cmt.getDate())
806  else:
807  return cmt.getFullComment()
808  except Exception:
809  return "<no comment found>"
810 

◆ getDBobjsWithinRange()

def python.TileCalibTools.TileBlobReader.getDBobjsWithinRange (   self,
  ros,
  drawer,
  point1inTime = (0,0),
  point2inTime = (2147483647,4294967295),
  printError = True 
)
Returns all DB objects for the given ROS and drawer, within given validity range -- default: [0-Infty)
Check getBlobsWithinRange for an example on how to loop over objects and check validity ranges.

Definition at line 973 of file TileCalibTools.py.

973  def getDBobjsWithinRange(self, ros, drawer, point1inTime=(0,0), point2inTime=(2147483647,4294967295), printError=True):
974  """
975  Returns all DB objects for the given ROS and drawer, within given validity range -- default: [0-Infty)
976  Check getBlobsWithinRange for an example on how to loop over objects and check validity ranges.
977  """
978 
979  validityKey1 = getCoolValidityKey(point1inTime,True)
980  validityKey2 = getCoolValidityKey(point2inTime,False)
981 
982  #print "Validity keys range is %s - %s" % (validityKey1, validityKey2)
983  self.log().debug("Validity key range is %s - %s", validityKey1,validityKey2)
984 
985  objs = None
986  try:
987  dbChanNum = drawer if ros<0 else TileCalibUtils.getDrawerIdx(ros,drawer)
988  dbChanSel = cool.ChannelSelection(dbChanNum)
989  #self.log().debug("Fetching blobs from DB: %s" % obj)
990  objs = self.__folder.browseObjects(validityKey1,validityKey2,dbChanSel,self.__tag)
991  except Exception as e:
992  if printError:
993  self.log().error("TileCalibTools.getDBobjsWithinRange(): Fetching of ros=%i, drawer=%i failed with exception %s", ros,drawer,e)
994 
995  return objs
996 

◆ getDefault()

def python.TileCalibTools.TileBlobReader.getDefault (   self,
  ros,
  drawer 
)
Returns a default drawer number (among first 20 COOL channels) for any drawer in any partition

Definition at line 812 of file TileCalibTools.py.

812  def getDefault(self, ros, drawer):
813  """
814  Returns a default drawer number (among first 20 COOL channels) for any drawer in any partition
815  """
816  if ros==0:
817  if drawer<=4 or drawer==12 or drawer>=20:
818  drawer1=0
819  elif drawer<12:
820  drawer1=4
821  else:
822  drawer1=12
823  elif ros==1 or ros==2:
824  drawer1=4
825  elif ros==3:
826  OffsetEBA = [ 0, 0, 0, 0, 0, 0, 3, 2, #// Merged E+1: EBA07; Outer MBTS: EBA08
827  0, 0, 0, 0, 7, 6, 5, 7, #// D+4: EBA13, EBA16; Special D+4: EBA14; Special D+40: EBA15
828  7, 6, 6, 7, 0, 0, 0, 2, #// D+4: EBA17, EBA20; Special D+4: EBA18, EBA19; Outer MBTS: EBA24
829  3, 0, 0, 0, 0, 0, 0, 0, #// Merged E+1: EBA25
830  0, 0, 0, 0, 0, 0, 1, 1, #// Inner MBTS + special C+10: EBA39, EBA40
831  1, 1, 2, 3, 0, 0, 0, 0, #// Inner MBTS + special C+10: EBA41, EBA42; Outer MBTS: EBA43; Merged E+1: EBA44
832  0, 0, 0, 0, 3, 2, 1, 1, #// Merged E+1: EBA53; Outer MBTS: EBA54; Inner MBTS + special C+10: EBA55, EBA56
833  1, 1, 0, 0, 0, 0, 0, 0] #// Inner MBTS + special C+10: EBA57, EBA58
834  drawer1 = 12 + OffsetEBA[drawer]
835  elif ros==4:
836  OffsetEBC = [ 0, 0, 0, 0, 0, 0, 3, 2, #// Merged E-1: EBC07; Outer MBTS: EBC08
837  0, 0, 0, 0, 7, 6, 6, 7, # // D-4: EBC13, EBC16; Special D-4: EBC14, EBC15;
838  7, 5, 6, 7, 0, 0, 0, 2, #// D-4: EBC17, EBC20; Special D-40 EBC18; Special D-4: EBC19; Outer MBTS: EBC24
839  3, 0, 0, 3, 4, 0, 3, 4, #// Merged E-1: EBC25, EBC28, EBC31; E-4': EBC29, EBC32
840  0, 4, 3, 0, 4, 3, 1, 1, #// E-4': EBC34, EBC37; Merged E-1: EBC35, EBC38; Inner MBTS + special C-10: EBC39, EBC40
841  1, 1, 2, 3, 0, 0, 0, 0, #// Inner MBTS + special C-10: EBC41, EBC42; Outer MBTS: EBC43; Merged E-1: EBC44
842  0, 0, 0, 0, 3, 2, 1, 1, #// Merged E-1: EBC53; Outer MBTS: EBC54; Inner MBTS + special C-10: EBC55, EBC56
843  1, 1, 0, 0, 0, 0, 0, 0] #// Inner MBTS + special C-10: EBC57, EBC58
844  drawer1 = 12 + OffsetEBC[drawer]
845  else:
846  drawer1=0
847 
848  return (0,drawer1)
849 

◆ getDefaultDrawer()

def python.TileCalibTools.TileBlobReader.getDefaultDrawer (   self,
  ros,
  drawer,
  pointInTime,
  printError = True 
)
Returns a TileCalibDrawer object for the given ROS and drawer.

Definition at line 913 of file TileCalibTools.py.

913  def getDefaultDrawer(self, ros, drawer, pointInTime, printError=True):
914  """
915  Returns a TileCalibDrawer object for the given ROS and drawer.
916  """
917 
918  validityKey = getCoolValidityKey(pointInTime)
919  self.log().debug("Validity key is %s", validityKey)
920  try:
921  calibDrawer = None
922  #=== Have we retrieved data previously?
923  key = (ros,drawer,validityKey)
924  obj = self.__objDict.get(key)
925  #=== ... if not, get it from DB
926  if not obj:
927  chanNum = TileCalibUtils.getDrawerIdx(ros,drawer)
928  obj = self.__folder.findObject(validityKey, chanNum, self.__tag)
929  self.log().debug("Fetching from DB: %s", obj)
930  blob = obj.payload()[0]
931  self.log().debug("blob size: %d", blob.size())
932  #=== default policy
933  while blob.size()==0:
934  #=== no default at all?
935  if ros==0 and drawer==0:
936  raise Exception('No default available')
937  #=== follow default policy
938  ros,drawer = self.getDefault(ros,drawer)
939  chanNum = TileCalibUtils.getDrawerIdx(ros,drawer)
940  obj = self.__folder.findObject(validityKey, chanNum, self.__tag)
941  blob = obj.payload()[0]
942  #=== store object in dictionary
943  self.__objDict[key] = obj
944  #=== get blob
945  blob = obj.payload()[0]
946  self.log().debug("blob size: %d", blob.size())
947 
948  #=== create calibDrawer depending on type
949  calibDrawer = TileCalibDrawerCmt.getInstance(blob)
950  typeName = TileCalibType.getClassName(calibDrawer.getObjType())
951  del calibDrawer
952  if typeName=='TileCalibDrawerFlt':
953  calibDrawer = TileCalibDrawerFlt.getInstance(blob)
954  self.log().debug( "typeName = Flt " )
955  elif typeName=='TileCalibDrawerInt':
956  calibDrawer = TileCalibDrawerInt.getInstance(blob)
957  self.log().debug( "typeName = Int " )
958  elif typeName=='TileCalibDrawerBch':
959  calibDrawer = TileCalibDrawerBch.getInstance(blob)
960  self.log().debug( "typeName = Bch " )
961  elif typeName=='TileCalibDrawerOfc':
962  calibDrawer = TileCalibDrawerOfc.getInstance(blob)
963  self.log().debug( "typeName = Ofc " )
964  else:
965  raise Exception( "Invalid blob type requested: %s" % typeName )
966  return calibDrawer
967  except Exception as e:
968  if printError:
969  self.log().error("TileCalibTools.getDefaultDrawer(): Fetching of ros=%i, drawer=%i failed with exception %s", ros,drawer,e)
970  return None
971 

◆ getDrawer()

def python.TileCalibTools.TileBlobReader.getDrawer (   self,
  ros,
  drawer,
  pointInTime,
  printError = True,
  useDefault = True 
)
Returns a TileCalibDrawer object for the given ROS and drawer.

Definition at line 851 of file TileCalibTools.py.

851  def getDrawer(self, ros, drawer, pointInTime, printError=True, useDefault=True):
852  """
853  Returns a TileCalibDrawer object for the given ROS and drawer.
854  """
855 
856  validityKey = getCoolValidityKey(pointInTime)
857  self.log().debug("Validity key is %s", validityKey)
858  try:
859  calibDrawer = None
860  #=== Have we retrieved data previously?
861  key = (ros,drawer,validityKey)
862  obj = self.__objDict.get(key)
863  #=== ... if not, get it from DB
864  if not obj:
865  chanNum = TileCalibUtils.getDrawerIdx(ros,drawer)
866  obj = self.__folder.findObject(validityKey, chanNum, self.__tag)
867  self.log().debug("Fetching from DB: %s", obj)
868  blob = obj.payload()[0]
869  self.log().debug("blob size: %d", blob.size())
870  #=== default policy
871  if not useDefault and blob.size()==0:
872  return 0
873  while blob.size()==0:
874  #=== no default at all?
875  if ros==0 and drawer==0:
876  raise Exception('No default available')
877  #=== follow default policy
878  ros,drawer = self.getDefault(ros,drawer)
879  chanNum = TileCalibUtils.getDrawerIdx(ros,drawer)
880  obj = self.__folder.findObject(validityKey, chanNum, self.__tag)
881  blob = obj.payload()[0]
882  #=== store object in dictionary
883  self.__objDict[key] = obj
884  #=== get blob
885  blob = obj.payload()[0]
886  self.log().debug("blob size: %d", blob.size())
887 
888  #=== create calibDrawer depending on type
889  calibDrawer = TileCalibDrawerCmt.getInstance(blob)
890  typeName = TileCalibType.getClassName(calibDrawer.getObjType())
891  del calibDrawer
892  if typeName=='TileCalibDrawerFlt':
893  calibDrawer = TileCalibDrawerFlt.getInstance(blob)
894  self.log().debug( "typeName = Flt " )
895  elif typeName=='TileCalibDrawerInt':
896  calibDrawer = TileCalibDrawerInt.getInstance(blob)
897  self.log().debug( "typeName = Int " )
898  elif typeName=='TileCalibDrawerBch':
899  calibDrawer = TileCalibDrawerBch.getInstance(blob)
900  self.log().debug( "typeName = Bch " )
901  elif typeName=='TileCalibDrawerOfc':
902  calibDrawer = TileCalibDrawerOfc.getInstance(blob)
903  self.log().debug( "typeName = Ofc " )
904  else:
905  raise Exception( "Invalid blob type requested: %s" % typeName )
906  return calibDrawer
907  except Exception as e:
908  if printError:
909  self.log().error("TileCalibTools.getDrawer(): Fetching of ros=%i, drawer=%i failed with exception %s", ros,drawer,e)
910  return None
911 

◆ getIOVsWithinRange()

def python.TileCalibTools.TileBlobReader.getIOVsWithinRange (   self,
  ros,
  drawer,
  point1inTime = (0,0),
  point2inTime = (2147483647,4294967295),
  printError = True 
)
Returns list of IOVS for the given ROS and drawer, within given validity range -- default: [0-Infty)

Definition at line 998 of file TileCalibTools.py.

998  def getIOVsWithinRange(self, ros, drawer, point1inTime=(0,0), point2inTime=(2147483647,4294967295), printError=True):
999  """
1000  Returns list of IOVS for the given ROS and drawer, within given validity range -- default: [0-Infty)
1001  """
1002  iovs=[]
1003  dbobjs = self.getDBobjsWithinRange(ros,drawer,point1inTime, point2inTime, printError)
1004  if (dbobjs is None):
1005  log.warning( "Warning: can not read IOVs for ros %d drawer %d from input DB file", ros,drawer )
1006  else:
1007  while dbobjs.goToNext():
1008  obj = dbobjs.currentRef()
1009  objsince = obj.since()
1010  sinceRun = objsince >> 32
1011  sinceLum = objsince & 0xFFFFFFFF
1012  since = (sinceRun, sinceLum)
1013  iovs.append(since)
1014  return iovs
1015 

Member Data Documentation

◆ __db

python.TileCalibTools.TileBlobReader.__db
private

Definition at line 772 of file TileCalibTools.py.

◆ __folder

python.TileCalibTools.TileBlobReader.__folder
private

Definition at line 773 of file TileCalibTools.py.

◆ __folderType

python.TileCalibTools.TileBlobReader.__folderType
private

Definition at line 781 of file TileCalibTools.py.

◆ __objDict

python.TileCalibTools.TileBlobReader.__objDict
private

Definition at line 790 of file TileCalibTools.py.

◆ __tag

python.TileCalibTools.TileBlobReader.__tag
private

Definition at line 786 of file TileCalibTools.py.


The documentation for this class was generated from the following file:
TileCalibDrawerBch::getInstance
static const TileCalibDrawerBch * getInstance(const coral::Blob &blob)
Returns a pointer to a const TileCalibDrawerBch.
Definition: TileCalibDrawerBch.cxx:28
TileCalibType::getClassName
static std::string getClassName(TileCalibType::TYPE type)
Returns the class name.
Definition: TileCalibType.cxx:10
TileCalibDrawerInt::getInstance
static const TileCalibDrawerInt * getInstance(const coral::Blob &blob)
Returns a pointer to a const TileCalibDrawerBch.
Definition: TileCalibDrawerInt.cxx:27
TileCalibDrawerFlt::getInstance
static const TileCalibDrawerFlt * getInstance(const coral::Blob &blob)
Returns a pointer to a const TileCalibDrawerFlt.
Definition: TileCalibDrawerFlt.cxx:13
python.TileCalibTools.getAthenaFolderType
def getAthenaFolderType(folderDescr)
Definition: TileCalibTools.py:191
TileCalibUtils::getCommentChannel
static unsigned int getCommentChannel()
Returns the COOL channel number for the comment channel.
Definition: TileCalibUtils.h:82
python.TileCalibTools.getCoolValidityKey
def getCoolValidityKey(pointInTime, isSince=True)
Definition: TileCalibTools.py:334
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
TileCalibDrawerOfc::getInstance
static TileCalibDrawerOfc * getInstance(coral::Blob &blob, uint16_t objVersion, uint32_t nSamples, int32_t nPhases, uint16_t nChans, uint16_t nGains, const std::string &author="", const std::string &comment="", uint64_t timeStamp=0)
Returns a pointer to a non-const TileCalibDrawerOfc.
Definition: TileCalibDrawerOfc.cxx:14
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
TileCalibUtils::getDrawerIdx
static unsigned int getDrawerIdx(unsigned int ros, unsigned int drawer)
Returns a drawer hash.
Definition: TileCalibUtils.cxx:60
error
Definition: IImpactPoint3dEstimator.h:70
description
std::string description
glabal timer - how long have I taken so far?
Definition: hcg.cxx:88