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 801 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 808 of file TileCalibTools.py.

808  def __init__(self, db, folder, tag=""):
809  """
810  Input:
811  - db : db should be an open database connection
812  - folder: full folder path
813  - tag : The folder tag, e.g. \"000-00\"
814  """
815  #=== initialize base class
816  TileCalibLogger.__init__(self,"TileBlobReader")
817 
818  #=== try to open db
819  try:
820  self.__db = db # CoraCoolDatabase
821  self.__folder = self.__db.getFolder(folder) # CoraCoolFolder
822  except Exception as e:
823  self.log().critical( e )
824  raise
825 
826  #=== determine if "run-lumi" or "time" folder
827  validFolderTypes = ("run-lumi","time")
828  folderDescr = self.__folder.description()
829  self.__folderType = getAthenaFolderType(folderDescr)
830  if self.__folderType not in validFolderTypes:
831  raise Exception("Invalid folder type found: \'%s\'" % self.__folderType)
832 
833  #=== use camelized full folder path only if tag is given
834  self.__tag = tag
835 
836  #=== initialize dictionary to keep reference to DB object of given ros/drawer
837  #=== and timestamp, so they do not go out of scope
838  self.__objDict = {}
839 

Member Function Documentation

◆ folderIsMultiVersion()

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

Definition at line 1131 of file TileCalibTools.py.

1131  def folderIsMultiVersion(self):
1132  """
1133  Returns true if MultiVersion folder is connected
1134  """
1135  if self.__folder.versioningMode()==cool.FolderVersioning.MULTI_VERSION:
1136  return True
1137  else:
1138  return False
1139 
1140 
1141 #======================================================================
1142 #===
1143 #=== TileASCIIParser
1144 #===
1145 #======================================================================
1146 
1147 #
1148 #______________________________________________________________________

◆ 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 1065 of file TileCalibTools.py.

1065  def getBlobsWithinRange(self, ros, drawer, point1inTime=(0,0), point2inTime=(2147483647,4294967295)):
1066  """
1067  Returns all blob objects for the given ROS and drawer, within given validity range -- default: [0-Infty)
1068  Note: the blobs don't contain validity range info. Check method getDBobjsWithinRange()
1069  """
1070 
1071  validityKey1 = getCoolValidityKey(point1inTime,True)
1072  validityKey2 = getCoolValidityKey(point2inTime,False)
1073 
1074  print ("Validity keys range is %s - %s" % (validityKey1, validityKey2))
1075  self.log().debug("Validity key range is %s - %s", validityKey1,validityKey2)
1076 
1077  objs = self.getDBobjsWithinRange(self, ros, drawer, point1inTime, point2inTime)
1078 
1079  #-- Loop over objs to extract blobs
1080  blobs = []
1081  calibDrawer = None
1082  while objs.goToNext():
1083  obj=objs.currentRef()
1084  sinceCool=obj.since()
1085  if sinceCool < validityKey1:
1086  sinceCool = validityKey1
1087  untilCool=obj.until()
1088  blob = obj.payload()[0]
1089  print ("[%d,%d)-[%d,%d) - %s" % ((sinceCool>>32),(sinceCool&0xFFFFFFFF),(untilCool>>32),(untilCool&0xFFFFFFFF),blob))
1090  self.log().debug("blob size: %d", blob.size())
1091 
1092  #=== default policy
1093  while blob.size()==0:
1094  #=== no default at all?
1095  if ros==0 and drawer==0:
1096  raise Exception('No default available')
1097  #=== follow default policy
1098  ros,drawer = self.getDefault(ros,drawer)
1099  chanNum = TileCalibUtils.getDrawerIdx(ros,drawer)
1100  obj = self.__folder.findObject(sinceCool, chanNum, self.__tag)
1101  blob = obj.payload()[0]
1102  self.log().debug("blob size: 0 --> default: %d", blob.size())
1103 
1104  #=== store object in dictionary
1105  self.__objDict[sinceCool] = obj
1106 
1107  #=== create calibDrawer depending on type
1108  calibDrawer = TileCalibDrawerCmt.getInstance(blob)
1109  typeName = TileCalibType.getClassName(calibDrawer.getObjType())
1110  del calibDrawer
1111  if typeName=='TileCalibDrawerFlt':
1112  calibDrawer = TileCalibDrawerFlt.getInstance(blob)
1113  self.log().debug( "typeName = Flt " )
1114  elif typeName=='TileCalibDrawerInt':
1115  calibDrawer = TileCalibDrawerInt.getInstance(blob)
1116  self.log().debug( "typeName = Int " )
1117  elif typeName=='TileCalibDrawerBch':
1118  calibDrawer = TileCalibDrawerBch.getInstance(blob)
1119  self.log().debug( "typeName = Bch " )
1120  elif typeName=='TileCalibDrawerOfc':
1121  calibDrawer = TileCalibDrawerOfc.getInstance(blob)
1122  self.log().debug( "typeName = Ofc " )
1123  else:
1124  raise Exception( "Invalid blob type requested: %s" % typeName )
1125 
1126  blobs.append( calibDrawer )
1127 
1128  return blobs
1129 

◆ getComment()

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

Definition at line 841 of file TileCalibTools.py.

841  def getComment(self, pointInTime, split=False):
842  """
843  Returns the general comment (default if none is set)
844  """
845  validityKey = getCoolValidityKey(pointInTime)
846  try:
848  obj = self.__folder.findObject(validityKey, chanNum, self.__tag)
849  self.log().debug("getComment:Fetching from DB: %s", obj)
850  blob = obj.payload()[0]
852  if split:
853  return (cmt.getAuthor(),cmt.getComment(),cmt.getDate())
854  else:
855  return cmt.getFullComment()
856  except Exception:
857  return "<no comment found>"
858 

◆ 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 1021 of file TileCalibTools.py.

1021  def getDBobjsWithinRange(self, ros, drawer, point1inTime=(0,0), point2inTime=(2147483647,4294967295), printError=True):
1022  """
1023  Returns all DB objects for the given ROS and drawer, within given validity range -- default: [0-Infty)
1024  Check getBlobsWithinRange for an example on how to loop over objects and check validity ranges.
1025  """
1026 
1027  validityKey1 = getCoolValidityKey(point1inTime,True)
1028  validityKey2 = getCoolValidityKey(point2inTime,False)
1029 
1030  #print "Validity keys range is %s - %s" % (validityKey1, validityKey2)
1031  self.log().debug("Validity key range is %s - %s", validityKey1,validityKey2)
1032 
1033  objs = None
1034  try:
1035  dbChanNum = drawer if ros<0 else TileCalibUtils.getDrawerIdx(ros,drawer)
1036  dbChanSel = cool.ChannelSelection(dbChanNum)
1037  #self.log().debug("Fetching blobs from DB: %s" % obj)
1038  objs = self.__folder.browseObjects(validityKey1,validityKey2,dbChanSel,self.__tag)
1039  except Exception as e:
1040  if printError:
1041  self.log().error("TileCalibTools.getDBobjsWithinRange(): Fetching of ros=%i, drawer=%i failed with exception %s", ros,drawer,e)
1042 
1043  return objs
1044 

◆ 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 860 of file TileCalibTools.py.

860  def getDefault(self, ros, drawer):
861  """
862  Returns a default drawer number (among first 20 COOL channels) for any drawer in any partition
863  """
864  if ros==0:
865  if drawer<=4 or drawer==12 or drawer>=20:
866  drawer1=0
867  elif drawer<12:
868  drawer1=4
869  else:
870  drawer1=12
871  elif ros==1 or ros==2:
872  drawer1=4
873  elif ros==3:
874  OffsetEBA = [ 0, 0, 0, 0, 0, 0, 3, 2, #// Merged E+1: EBA07; Outer MBTS: EBA08
875  0, 0, 0, 0, 7, 6, 5, 7, #// D+4: EBA13, EBA16; Special D+4: EBA14; Special D+40: EBA15
876  7, 6, 6, 7, 0, 0, 0, 2, #// D+4: EBA17, EBA20; Special D+4: EBA18, EBA19; Outer MBTS: EBA24
877  3, 0, 0, 0, 0, 0, 0, 0, #// Merged E+1: EBA25
878  0, 0, 0, 0, 0, 0, 1, 1, #// Inner MBTS + special C+10: EBA39, EBA40
879  1, 1, 2, 3, 0, 0, 0, 0, #// Inner MBTS + special C+10: EBA41, EBA42; Outer MBTS: EBA43; Merged E+1: EBA44
880  0, 0, 0, 0, 3, 2, 1, 1, #// Merged E+1: EBA53; Outer MBTS: EBA54; Inner MBTS + special C+10: EBA55, EBA56
881  1, 1, 0, 0, 0, 0, 0, 0] #// Inner MBTS + special C+10: EBA57, EBA58
882  drawer1 = 12 + OffsetEBA[drawer]
883  elif ros==4:
884  OffsetEBC = [ 0, 0, 0, 0, 0, 0, 3, 2, #// Merged E-1: EBC07; Outer MBTS: EBC08
885  0, 0, 0, 0, 7, 6, 6, 7, # // D-4: EBC13, EBC16; Special D-4: EBC14, EBC15;
886  7, 5, 6, 7, 0, 0, 0, 2, #// D-4: EBC17, EBC20; Special D-40 EBC18; Special D-4: EBC19; Outer MBTS: EBC24
887  3, 0, 0, 3, 4, 0, 3, 4, #// Merged E-1: EBC25, EBC28, EBC31; E-4': EBC29, EBC32
888  0, 4, 3, 0, 4, 3, 1, 1, #// E-4': EBC34, EBC37; Merged E-1: EBC35, EBC38; Inner MBTS + special C-10: EBC39, EBC40
889  1, 1, 2, 3, 0, 0, 0, 0, #// Inner MBTS + special C-10: EBC41, EBC42; Outer MBTS: EBC43; Merged E-1: EBC44
890  0, 0, 0, 0, 3, 2, 1, 1, #// Merged E-1: EBC53; Outer MBTS: EBC54; Inner MBTS + special C-10: EBC55, EBC56
891  1, 1, 0, 0, 0, 0, 0, 0] #// Inner MBTS + special C-10: EBC57, EBC58
892  drawer1 = 12 + OffsetEBC[drawer]
893  else:
894  drawer1=0
895 
896  return (0,drawer1)
897 

◆ 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 961 of file TileCalibTools.py.

961  def getDefaultDrawer(self, ros, drawer, pointInTime, printError=True):
962  """
963  Returns a TileCalibDrawer object for the given ROS and drawer.
964  """
965 
966  validityKey = getCoolValidityKey(pointInTime)
967  self.log().debug("Validity key is %s", validityKey)
968  try:
969  calibDrawer = None
970  #=== Have we retrieved data previously?
971  key = (ros,drawer,validityKey)
972  obj = self.__objDict.get(key)
973  #=== ... if not, get it from DB
974  if not obj:
975  chanNum = TileCalibUtils.getDrawerIdx(ros,drawer)
976  obj = self.__folder.findObject(validityKey, chanNum, self.__tag)
977  self.log().debug("Fetching from DB: %s", obj)
978  blob = obj.payload()[0]
979  self.log().debug("blob size: %d", blob.size())
980  #=== default policy
981  while blob.size()==0:
982  #=== no default at all?
983  if ros==0 and drawer==0:
984  raise Exception('No default available')
985  #=== follow default policy
986  ros,drawer = self.getDefault(ros,drawer)
987  chanNum = TileCalibUtils.getDrawerIdx(ros,drawer)
988  obj = self.__folder.findObject(validityKey, chanNum, self.__tag)
989  blob = obj.payload()[0]
990  #=== store object in dictionary
991  self.__objDict[key] = obj
992  #=== get blob
993  blob = obj.payload()[0]
994  self.log().debug("blob size: %d", blob.size())
995 
996  #=== create calibDrawer depending on type
997  calibDrawer = TileCalibDrawerCmt.getInstance(blob)
998  typeName = TileCalibType.getClassName(calibDrawer.getObjType())
999  del calibDrawer
1000  if typeName=='TileCalibDrawerFlt':
1001  calibDrawer = TileCalibDrawerFlt.getInstance(blob)
1002  self.log().debug( "typeName = Flt " )
1003  elif typeName=='TileCalibDrawerInt':
1004  calibDrawer = TileCalibDrawerInt.getInstance(blob)
1005  self.log().debug( "typeName = Int " )
1006  elif typeName=='TileCalibDrawerBch':
1007  calibDrawer = TileCalibDrawerBch.getInstance(blob)
1008  self.log().debug( "typeName = Bch " )
1009  elif typeName=='TileCalibDrawerOfc':
1010  calibDrawer = TileCalibDrawerOfc.getInstance(blob)
1011  self.log().debug( "typeName = Ofc " )
1012  else:
1013  raise Exception( "Invalid blob type requested: %s" % typeName )
1014  return calibDrawer
1015  except Exception as e:
1016  if printError:
1017  self.log().error("TileCalibTools.getDefaultDrawer(): Fetching of ros=%i, drawer=%i failed with exception %s", ros,drawer,e)
1018  return None
1019 

◆ 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 899 of file TileCalibTools.py.

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

◆ 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 1046 of file TileCalibTools.py.

1046  def getIOVsWithinRange(self, ros, drawer, point1inTime=(0,0), point2inTime=(2147483647,4294967295), printError=True):
1047  """
1048  Returns list of IOVS for the given ROS and drawer, within given validity range -- default: [0-Infty)
1049  """
1050  iovs=[]
1051  dbobjs = self.getDBobjsWithinRange(ros,drawer,point1inTime, point2inTime, printError)
1052  if (dbobjs is None):
1053  log.warning( "Warning: can not read IOVs for ros %d drawer %d from input DB file", ros,drawer )
1054  else:
1055  while dbobjs.goToNext():
1056  obj = dbobjs.currentRef()
1057  objsince = obj.since()
1058  sinceRun = objsince >> 32
1059  sinceLum = objsince & 0xFFFFFFFF
1060  since = (sinceRun, sinceLum)
1061  iovs.append(since)
1062  return iovs
1063 

Member Data Documentation

◆ __db

python.TileCalibTools.TileBlobReader.__db
private

Definition at line 820 of file TileCalibTools.py.

◆ __folder

python.TileCalibTools.TileBlobReader.__folder
private

Definition at line 821 of file TileCalibTools.py.

◆ __folderType

python.TileCalibTools.TileBlobReader.__folderType
private

Definition at line 829 of file TileCalibTools.py.

◆ __objDict

python.TileCalibTools.TileBlobReader.__objDict
private

Definition at line 838 of file TileCalibTools.py.

◆ __tag

python.TileCalibTools.TileBlobReader.__tag
private

Definition at line 834 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
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
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:360
debug
const bool debug
Definition: MakeUncertaintyPlots.cxx:53
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:130
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:91