ATLAS Offline Software
Loading...
Searching...
No Matches
python.TileCalibTools.TileBlobReader Class Reference
Inheritance diagram for python.TileCalibTools.TileBlobReader:
Collaboration diagram for python.TileCalibTools.TileBlobReader:

Public Member Functions

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

Private Attributes

 __db = db
 __folder = self.__db.getFolder(folder)
 __folderType = getAthenaFolderType(folderDescr)
 __tag = tag
dict __objDict = {}

Detailed Description

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

Definition at line 882 of file TileCalibTools.py.

Constructor & Destructor Documentation

◆ __init__()

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

889 def __init__(self, db, folder, tag=""):
890 """
891 Input:
892 - db : db should be an open database connection
893 - folder: full folder path
894 - tag : The folder tag, e.g. \"000-00\"
895 """
896 #=== initialize base class
897 TileCalibLogger.__init__(self,"TileBlobReader")
898
899 #=== try to open db
900 try:
901 self.__db = db # CoraCoolDatabase
902 self.__folder = self.__db.getFolder(folder) # CoraCoolFolder
903 except Exception as e:
904 self.log().critical( e )
905 raise
906
907 #=== determine if "run-lumi" or "time" folder
908 validFolderTypes = ("run-lumi","time")
909 folderDescr = self.__folder.description()
910 self.__folderType = getAthenaFolderType(folderDescr)
911 if self.__folderType not in validFolderTypes:
912 raise Exception("Invalid folder type found: \'%s\'" % self.__folderType)
913
914 #=== use camelized full folder path only if tag is given
915 self.__tag = tag
916
917 #=== initialize dictionary to keep reference to DB object of given ros/drawer
918 #=== and timestamp, so they do not go out of scope
919 self.__objDict = {}
920
std::string description
glabal timer - how long have I taken so far?
Definition hcg.cxx:93

Member Function Documentation

◆ folderIsMultiVersion()

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

Definition at line 1212 of file TileCalibTools.py.

1212 def folderIsMultiVersion(self):
1213 """
1214 Returns true if MultiVersion folder is connected
1215 """
1216 if self.__folder.versioningMode()==cool.FolderVersioning.MULTI_VERSION:
1217 return True
1218 else:
1219 return False
1220
1221
1222#======================================================================
1223#===
1224#=== TileASCIIParser
1225#===
1226#======================================================================
1227
1228#
1229#______________________________________________________________________

◆ getBlobsWithinRange()

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

1146 def getBlobsWithinRange(self, ros, drawer, point1inTime=(0,0), point2inTime=(2147483647,4294967295)):
1147 """
1148 Returns all blob objects for the given ROS and drawer, within given validity range -- default: [0-Infty)
1149 Note: the blobs don't contain validity range info. Check method getDBobjsWithinRange()
1150 """
1151
1152 validityKey1 = getCoolValidityKey(point1inTime,True)
1153 validityKey2 = getCoolValidityKey(point2inTime,False)
1154
1155 print ("Validity keys range is %s - %s" % (validityKey1, validityKey2))
1156 self.log().debug("Validity key range is %s - %s", validityKey1,validityKey2)
1157
1158 objs = self.getDBobjsWithinRange(self, ros, drawer, point1inTime, point2inTime)
1159
1160 #-- Loop over objs to extract blobs
1161 blobs = []
1162 calibDrawer = None
1163 while objs.goToNext():
1164 obj=objs.currentRef()
1165 sinceCool=obj.since()
1166 if sinceCool < validityKey1:
1167 sinceCool = validityKey1
1168 untilCool=obj.until()
1169 blob = obj.payload()[0]
1170 print ("[%d,%d)-[%d,%d) - %s" % ((sinceCool>>32),(sinceCool&0xFFFFFFFF),(untilCool>>32),(untilCool&0xFFFFFFFF),blob))
1171 self.log().debug("blob size: %d", blob.size())
1172
1173 #=== default policy
1174 while blob.size()==0:
1175 #=== no default at all?
1176 if ros==0 and drawer==0:
1177 raise Exception('No default available')
1178 #=== follow default policy
1179 ros,drawer = self.getDefault(ros,drawer)
1180 chanNum = TileCalibUtils.getDrawerIdx(ros,drawer)
1181 obj = self.__folder.findObject(sinceCool, chanNum, self.__tag)
1182 blob = obj.payload()[0]
1183 self.log().debug("blob size: 0 --> default: %d", blob.size())
1184
1185 #=== store object in dictionary
1186 self.__objDict[sinceCool] = obj
1187
1188 #=== create calibDrawer depending on type
1189 calibDrawer = TileCalibDrawerCmt.getInstance(blob)
1190 typeName = TileCalibType.getClassName(calibDrawer.getObjType())
1191 del calibDrawer
1192 if typeName=='TileCalibDrawerFlt':
1193 calibDrawer = TileCalibDrawerFlt.getInstance(blob)
1194 self.log().debug( "typeName = Flt " )
1195 elif typeName=='TileCalibDrawerInt':
1196 calibDrawer = TileCalibDrawerInt.getInstance(blob)
1197 self.log().debug( "typeName = Int " )
1198 elif typeName=='TileCalibDrawerBch':
1199 calibDrawer = TileCalibDrawerBch.getInstance(blob)
1200 self.log().debug( "typeName = Bch " )
1201 elif typeName=='TileCalibDrawerOfc':
1202 calibDrawer = TileCalibDrawerOfc.getInstance(blob)
1203 self.log().debug( "typeName = Ofc " )
1204 else:
1205 raise Exception( "Invalid blob type requested: %s" % typeName )
1206
1207 blobs.append( calibDrawer )
1208
1209 return blobs
1210
const bool debug
static const TileCalibDrawerBch * getInstance(const coral::Blob &blob)
Returns a pointer to a const TileCalibDrawerBch.
static const TileCalibDrawerCmt * getInstance(const coral::Blob &blob)
Returns a pointer to a const TileCalibDrawerCmt.
static const TileCalibDrawerFlt * getInstance(const coral::Blob &blob)
Returns a pointer to a const TileCalibDrawerFlt.
static const TileCalibDrawerInt * getInstance(const coral::Blob &blob)
Returns a pointer to a const TileCalibDrawerBch.
static TileCalibDrawerOfc * getInstance(coral::Blob &blob, uint16_t objVersion, uint32_t nSamples, int32_t nPhases, uint16_t nChans, uint16_t nGains, std::string_view author="", std::string_view comment="", uint64_t timeStamp=0)
Returns a pointer to a non-const TileCalibDrawerOfc.
static std::string getClassName(TileCalibType::TYPE type)
Returns the class name.
static unsigned int getDrawerIdx(unsigned int ros, unsigned int drawer)
Returns a drawer hash.

◆ getComment()

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

Definition at line 922 of file TileCalibTools.py.

922 def getComment(self, pointInTime, split=False):
923 """
924 Returns the general comment (default if none is set)
925 """
926 validityKey = getCoolValidityKey(pointInTime)
927 try:
929 obj = self.__folder.findObject(validityKey, chanNum, self.__tag)
930 self.log().debug("getComment:Fetching from DB: %s", obj)
931 blob = obj.payload()[0]
933 if split:
934 return (cmt.getAuthor(),cmt.getComment(),cmt.getDate())
935 else:
936 return cmt.getFullComment()
937 except Exception:
938 return "<no comment found>"
939
static unsigned int getCommentChannel()
Returns the COOL channel number for the comment channel.

◆ getDBobjsWithinRange()

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

1102 def getDBobjsWithinRange(self, ros, drawer, point1inTime=(0,0), point2inTime=(2147483647,4294967295), printError=True):
1103 """
1104 Returns all DB objects for the given ROS and drawer, within given validity range -- default: [0-Infty)
1105 Check getBlobsWithinRange for an example on how to loop over objects and check validity ranges.
1106 """
1107
1108 validityKey1 = getCoolValidityKey(point1inTime,True)
1109 validityKey2 = getCoolValidityKey(point2inTime,False)
1110
1111 #print "Validity keys range is %s - %s" % (validityKey1, validityKey2)
1112 self.log().debug("Validity key range is %s - %s", validityKey1,validityKey2)
1113
1114 objs = None
1115 try:
1116 dbChanNum = drawer if ros<0 else TileCalibUtils.getDrawerIdx(ros,drawer)
1117 dbChanSel = cool.ChannelSelection(dbChanNum)
1118 #self.log().debug("Fetching blobs from DB: %s" % obj)
1119 objs = self.__folder.browseObjects(validityKey1,validityKey2,dbChanSel,self.__tag)
1120 except Exception as e:
1121 if printError:
1122 self.log().error("TileCalibTools.getDBobjsWithinRange(): Fetching of ros=%i, drawer=%i failed with exception %s", ros,drawer,e)
1123
1124 return objs
1125

◆ getDefault()

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

941 def getDefault(self, ros, drawer):
942 """
943 Returns a default drawer number (among first 20 COOL channels) for any drawer in any partition
944 """
945 if ros==0:
946 if drawer<=4 or drawer==12 or drawer>=20:
947 drawer1=0
948 elif drawer<12:
949 drawer1=4
950 else:
951 drawer1=12
952 elif ros==1 or ros==2:
953 drawer1=4
954 elif ros==3:
955 OffsetEBA = [ 0, 0, 0, 0, 0, 0, 3, 2, #// Merged E+1: EBA07; Outer MBTS: EBA08
956 0, 0, 0, 0, 7, 6, 5, 7, #// D+4: EBA13, EBA16; Special D+4: EBA14; Special D+40: EBA15
957 7, 6, 6, 7, 0, 0, 0, 2, #// D+4: EBA17, EBA20; Special D+4: EBA18, EBA19; Outer MBTS: EBA24
958 3, 0, 0, 0, 0, 0, 0, 0, #// Merged E+1: EBA25
959 0, 0, 0, 0, 0, 0, 1, 1, #// Inner MBTS + special C+10: EBA39, EBA40
960 1, 1, 2, 3, 0, 0, 0, 0, #// Inner MBTS + special C+10: EBA41, EBA42; Outer MBTS: EBA43; Merged E+1: EBA44
961 0, 0, 0, 0, 3, 2, 1, 1, #// Merged E+1: EBA53; Outer MBTS: EBA54; Inner MBTS + special C+10: EBA55, EBA56
962 1, 1, 0, 0, 0, 0, 0, 0] #// Inner MBTS + special C+10: EBA57, EBA58
963 drawer1 = 12 + OffsetEBA[drawer]
964 elif ros==4:
965 OffsetEBC = [ 0, 0, 0, 0, 0, 0, 3, 2, #// Merged E-1: EBC07; Outer MBTS: EBC08
966 0, 0, 0, 0, 7, 6, 6, 7, # // D-4: EBC13, EBC16; Special D-4: EBC14, EBC15;
967 7, 5, 6, 7, 0, 0, 0, 2, #// D-4: EBC17, EBC20; Special D-40 EBC18; Special D-4: EBC19; Outer MBTS: EBC24
968 3, 0, 0, 3, 4, 0, 3, 4, #// Merged E-1: EBC25, EBC28, EBC31; E-4': EBC29, EBC32
969 0, 4, 3, 0, 4, 3, 1, 1, #// E-4': EBC34, EBC37; Merged E-1: EBC35, EBC38; Inner MBTS + special C-10: EBC39, EBC40
970 1, 1, 2, 3, 0, 0, 0, 0, #// Inner MBTS + special C-10: EBC41, EBC42; Outer MBTS: EBC43; Merged E-1: EBC44
971 0, 0, 0, 0, 3, 2, 1, 1, #// Merged E-1: EBC53; Outer MBTS: EBC54; Inner MBTS + special C-10: EBC55, EBC56
972 1, 1, 0, 0, 0, 0, 0, 0] #// Inner MBTS + special C-10: EBC57, EBC58
973 drawer1 = 12 + OffsetEBC[drawer]
974 else:
975 drawer1=0
976
977 return (0,drawer1)
978

◆ getDefaultDrawer()

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

Definition at line 1042 of file TileCalibTools.py.

1042 def getDefaultDrawer(self, ros, drawer, pointInTime, printError=True):
1043 """
1044 Returns a TileCalibDrawer object for the given ROS and drawer.
1045 """
1046
1047 validityKey = getCoolValidityKey(pointInTime)
1048 self.log().debug("Validity key is %s", validityKey)
1049 try:
1050 calibDrawer = None
1051 #=== Have we retrieved data previously?
1052 key = (ros,drawer,validityKey)
1053 obj = self.__objDict.get(key)
1054 #=== ... if not, get it from DB
1055 if not obj:
1056 chanNum = TileCalibUtils.getDrawerIdx(ros,drawer)
1057 obj = self.__folder.findObject(validityKey, chanNum, self.__tag)
1058 self.log().debug("Fetching from DB: %s", obj)
1059 blob = obj.payload()[0]
1060 self.log().debug("blob size: %d", blob.size())
1061 #=== default policy
1062 while blob.size()==0:
1063 #=== no default at all?
1064 if ros==0 and drawer==0:
1065 raise Exception('No default available')
1066 #=== follow default policy
1067 ros,drawer = self.getDefault(ros,drawer)
1068 chanNum = TileCalibUtils.getDrawerIdx(ros,drawer)
1069 obj = self.__folder.findObject(validityKey, chanNum, self.__tag)
1070 blob = obj.payload()[0]
1071 #=== store object in dictionary
1072 self.__objDict[key] = obj
1073 #=== get blob
1074 blob = obj.payload()[0]
1075 self.log().debug("blob size: %d", blob.size())
1076
1077 #=== create calibDrawer depending on type
1078 calibDrawer = TileCalibDrawerCmt.getInstance(blob)
1079 typeName = TileCalibType.getClassName(calibDrawer.getObjType())
1080 del calibDrawer
1081 if typeName=='TileCalibDrawerFlt':
1082 calibDrawer = TileCalibDrawerFlt.getInstance(blob)
1083 self.log().debug( "typeName = Flt " )
1084 elif typeName=='TileCalibDrawerInt':
1085 calibDrawer = TileCalibDrawerInt.getInstance(blob)
1086 self.log().debug( "typeName = Int " )
1087 elif typeName=='TileCalibDrawerBch':
1088 calibDrawer = TileCalibDrawerBch.getInstance(blob)
1089 self.log().debug( "typeName = Bch " )
1090 elif typeName=='TileCalibDrawerOfc':
1091 calibDrawer = TileCalibDrawerOfc.getInstance(blob)
1092 self.log().debug( "typeName = Ofc " )
1093 else:
1094 raise Exception( "Invalid blob type requested: %s" % typeName )
1095 return calibDrawer
1096 except Exception as e:
1097 if printError:
1098 self.log().error("TileCalibTools.getDefaultDrawer(): Fetching of ros=%i, drawer=%i failed with exception %s", ros,drawer,e)
1099 return None
1100
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:132

◆ getDrawer()

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

980 def getDrawer(self, ros, drawer, pointInTime, printError=True, useDefault=True):
981 """
982 Returns a TileCalibDrawer object for the given ROS and drawer.
983 """
984
985 validityKey = getCoolValidityKey(pointInTime)
986 self.log().debug("Validity key is %s", validityKey)
987 try:
988 calibDrawer = None
989 #=== Have we retrieved data previously?
990 key = (ros,drawer,validityKey)
991 obj = self.__objDict.get(key)
992 #=== ... if not, get it from DB
993 if not obj:
994 chanNum = TileCalibUtils.getDrawerIdx(ros,drawer)
995 obj = self.__folder.findObject(validityKey, chanNum, self.__tag)
996 self.log().debug("Fetching from DB: %s", obj)
997 blob = obj.payload()[0]
998 self.log().debug("blob size: %d", blob.size())
999 #=== default policy
1000 if not useDefault and blob.size()==0:
1001 return 0
1002 while blob.size()==0:
1003 #=== no default at all?
1004 if ros==0 and drawer==0:
1005 raise Exception('No default available')
1006 #=== follow default policy
1007 ros,drawer = self.getDefault(ros,drawer)
1008 chanNum = TileCalibUtils.getDrawerIdx(ros,drawer)
1009 obj = self.__folder.findObject(validityKey, chanNum, self.__tag)
1010 blob = obj.payload()[0]
1011 #=== store object in dictionary
1012 self.__objDict[key] = obj
1013 #=== get blob
1014 blob = obj.payload()[0]
1015 self.log().debug("blob size: %d", blob.size())
1016
1017 #=== create calibDrawer depending on type
1018 calibDrawer = TileCalibDrawerCmt.getInstance(blob)
1019 typeName = TileCalibType.getClassName(calibDrawer.getObjType())
1020 del calibDrawer
1021 if typeName=='TileCalibDrawerFlt':
1022 calibDrawer = TileCalibDrawerFlt.getInstance(blob)
1023 self.log().debug( "typeName = Flt " )
1024 elif typeName=='TileCalibDrawerInt':
1025 calibDrawer = TileCalibDrawerInt.getInstance(blob)
1026 self.log().debug( "typeName = Int " )
1027 elif typeName=='TileCalibDrawerBch':
1028 calibDrawer = TileCalibDrawerBch.getInstance(blob)
1029 self.log().debug( "typeName = Bch " )
1030 elif typeName=='TileCalibDrawerOfc':
1031 calibDrawer = TileCalibDrawerOfc.getInstance(blob)
1032 self.log().debug( "typeName = Ofc " )
1033 else:
1034 raise Exception( "Invalid blob type requested: %s" % typeName )
1035 return calibDrawer
1036 except Exception as e:
1037 if printError:
1038 self.log().error("TileCalibTools.getDrawer(): Fetching of ros=%i, drawer=%i failed with exception %s", ros,drawer,e)
1039 return None
1040

◆ getIOVsWithinRange()

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

1127 def getIOVsWithinRange(self, ros, drawer, point1inTime=(0,0), point2inTime=(2147483647,4294967295), printError=True):
1128 """
1129 Returns list of IOVS for the given ROS and drawer, within given validity range -- default: [0-Infty)
1130 """
1131 iovs=[]
1132 dbobjs = self.getDBobjsWithinRange(ros,drawer,point1inTime, point2inTime, printError)
1133 if (dbobjs is None):
1134 log.warning( "Warning: can not read IOVs for ros %d drawer %d from input DB file", ros,drawer )
1135 else:
1136 while dbobjs.goToNext():
1137 obj = dbobjs.currentRef()
1138 objsince = obj.since()
1139 sinceRun = objsince >> 32
1140 sinceLum = objsince & 0xFFFFFFFF
1141 since = (sinceRun, sinceLum)
1142 iovs.append(since)
1143 return iovs
1144

Member Data Documentation

◆ __db

python.TileCalibTools.TileBlobReader.__db = db
private

Definition at line 901 of file TileCalibTools.py.

◆ __folder

python.TileCalibTools.TileBlobReader.__folder = self.__db.getFolder(folder)
private

Definition at line 902 of file TileCalibTools.py.

◆ __folderType

python.TileCalibTools.TileBlobReader.__folderType = getAthenaFolderType(folderDescr)
private

Definition at line 910 of file TileCalibTools.py.

◆ __objDict

dict python.TileCalibTools.TileBlobReader.__objDict = {}
private

Definition at line 919 of file TileCalibTools.py.

◆ __tag

python.TileCalibTools.TileBlobReader.__tag = tag
private

Definition at line 915 of file TileCalibTools.py.


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