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 748 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 755 of file TileCalibTools.py.

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

Member Function Documentation

◆ folderIsMultiVersion()

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

Definition at line 1078 of file TileCalibTools.py.

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

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

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

◆ getComment()

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

Definition at line 788 of file TileCalibTools.py.

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

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

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

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

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

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

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

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

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

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

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

Member Data Documentation

◆ __db

python.TileCalibTools.TileBlobReader.__db
private

Definition at line 767 of file TileCalibTools.py.

◆ __folder

python.TileCalibTools.TileBlobReader.__folder
private

Definition at line 768 of file TileCalibTools.py.

◆ __folderType

python.TileCalibTools.TileBlobReader.__folderType
private

Definition at line 776 of file TileCalibTools.py.

◆ __objDict

python.TileCalibTools.TileBlobReader.__objDict
private

Definition at line 785 of file TileCalibTools.py.

◆ __tag

python.TileCalibTools.TileBlobReader.__tag
private

Definition at line 781 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:192
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:335
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