Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 754 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 761 of file TileCalibTools.py.

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

Member Function Documentation

◆ folderIsMultiVersion()

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

Definition at line 1084 of file TileCalibTools.py.

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

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

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

◆ getComment()

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

Definition at line 794 of file TileCalibTools.py.

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

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

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

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

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

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

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

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

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

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

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

Member Data Documentation

◆ __db

python.TileCalibTools.TileBlobReader.__db
private

Definition at line 773 of file TileCalibTools.py.

◆ __folder

python.TileCalibTools.TileBlobReader.__folder
private

Definition at line 774 of file TileCalibTools.py.

◆ __folderType

python.TileCalibTools.TileBlobReader.__folderType
private

Definition at line 782 of file TileCalibTools.py.

◆ __objDict

python.TileCalibTools.TileBlobReader.__objDict
private

Definition at line 791 of file TileCalibTools.py.

◆ __tag

python.TileCalibTools.TileBlobReader.__tag
private

Definition at line 787 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