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

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

Member Function Documentation

◆ folderIsMultiVersion()

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

Definition at line 1200 of file TileCalibTools.py.

1200 def folderIsMultiVersion(self):
1201 """
1202 Returns true if MultiVersion folder is connected
1203 """
1204 if self.__folder.versioningMode()==cool.FolderVersioning.MULTI_VERSION:
1205 return True
1206 else:
1207 return False
1208
1209
1210#======================================================================
1211#===
1212#=== TileASCIIParser
1213#===
1214#======================================================================
1215
1216#
1217#______________________________________________________________________

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

1134 def getBlobsWithinRange(self, ros, drawer, point1inTime=(0,0), point2inTime=(2147483647,4294967295)):
1135 """
1136 Returns all blob objects for the given ROS and drawer, within given validity range -- default: [0-Infty)
1137 Note: the blobs don't contain validity range info. Check method getDBobjsWithinRange()
1138 """
1139
1140 validityKey1 = getCoolValidityKey(point1inTime,True)
1141 validityKey2 = getCoolValidityKey(point2inTime,False)
1142
1143 print ("Validity keys range is %s - %s" % (validityKey1, validityKey2))
1144 self.log().debug("Validity key range is %s - %s", validityKey1,validityKey2)
1145
1146 objs = self.getDBobjsWithinRange(self, ros, drawer, point1inTime, point2inTime)
1147
1148 #-- Loop over objs to extract blobs
1149 blobs = []
1150 calibDrawer = None
1151 while objs.goToNext():
1152 obj=objs.currentRef()
1153 sinceCool=obj.since()
1154 if sinceCool < validityKey1:
1155 sinceCool = validityKey1
1156 untilCool=obj.until()
1157 blob = obj.payload()[0]
1158 print ("[%d,%d)-[%d,%d) - %s" % ((sinceCool>>32),(sinceCool&0xFFFFFFFF),(untilCool>>32),(untilCool&0xFFFFFFFF),blob))
1159 self.log().debug("blob size: %d", blob.size())
1160
1161 #=== default policy
1162 while blob.size()==0:
1163 #=== no default at all?
1164 if ros==0 and drawer==0:
1165 raise Exception('No default available')
1166 #=== follow default policy
1167 ros,drawer = self.getDefault(ros,drawer)
1168 chanNum = TileCalibUtils.getDrawerIdx(ros,drawer)
1169 obj = self.__folder.findObject(sinceCool, chanNum, self.__tag)
1170 blob = obj.payload()[0]
1171 self.log().debug("blob size: 0 --> default: %d", blob.size())
1172
1173 #=== store object in dictionary
1174 self.__objDict[sinceCool] = obj
1175
1176 #=== create calibDrawer depending on type
1177 calibDrawer = TileCalibDrawerCmt.getInstance(blob)
1178 typeName = TileCalibType.getClassName(calibDrawer.getObjType())
1179 del calibDrawer
1180 if typeName=='TileCalibDrawerFlt':
1181 calibDrawer = TileCalibDrawerFlt.getInstance(blob)
1182 self.log().debug( "typeName = Flt " )
1183 elif typeName=='TileCalibDrawerInt':
1184 calibDrawer = TileCalibDrawerInt.getInstance(blob)
1185 self.log().debug( "typeName = Int " )
1186 elif typeName=='TileCalibDrawerBch':
1187 calibDrawer = TileCalibDrawerBch.getInstance(blob)
1188 self.log().debug( "typeName = Bch " )
1189 elif typeName=='TileCalibDrawerOfc':
1190 calibDrawer = TileCalibDrawerOfc.getInstance(blob)
1191 self.log().debug( "typeName = Ofc " )
1192 else:
1193 raise Exception( "Invalid blob type requested: %s" % typeName )
1194
1195 blobs.append( calibDrawer )
1196
1197 return blobs
1198
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, const std::string &author="", const std::string &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 910 of file TileCalibTools.py.

910 def getComment(self, pointInTime, split=False):
911 """
912 Returns the general comment (default if none is set)
913 """
914 validityKey = getCoolValidityKey(pointInTime)
915 try:
917 obj = self.__folder.findObject(validityKey, chanNum, self.__tag)
918 self.log().debug("getComment:Fetching from DB: %s", obj)
919 blob = obj.payload()[0]
921 if split:
922 return (cmt.getAuthor(),cmt.getComment(),cmt.getDate())
923 else:
924 return cmt.getFullComment()
925 except Exception:
926 return "<no comment found>"
927
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 1090 of file TileCalibTools.py.

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

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

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

◆ getDefaultDrawer()

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

Definition at line 1030 of file TileCalibTools.py.

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

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

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

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

1115 def getIOVsWithinRange(self, ros, drawer, point1inTime=(0,0), point2inTime=(2147483647,4294967295), printError=True):
1116 """
1117 Returns list of IOVS for the given ROS and drawer, within given validity range -- default: [0-Infty)
1118 """
1119 iovs=[]
1120 dbobjs = self.getDBobjsWithinRange(ros,drawer,point1inTime, point2inTime, printError)
1121 if (dbobjs is None):
1122 log.warning( "Warning: can not read IOVs for ros %d drawer %d from input DB file", ros,drawer )
1123 else:
1124 while dbobjs.goToNext():
1125 obj = dbobjs.currentRef()
1126 objsince = obj.since()
1127 sinceRun = objsince >> 32
1128 sinceLum = objsince & 0xFFFFFFFF
1129 since = (sinceRun, sinceLum)
1130 iovs.append(since)
1131 return iovs
1132

Member Data Documentation

◆ __db

python.TileCalibTools.TileBlobReader.__db = db
private

Definition at line 889 of file TileCalibTools.py.

◆ __folder

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

Definition at line 890 of file TileCalibTools.py.

◆ __folderType

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

Definition at line 898 of file TileCalibTools.py.

◆ __objDict

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

Definition at line 907 of file TileCalibTools.py.

◆ __tag

python.TileCalibTools.TileBlobReader.__tag = tag
private

Definition at line 903 of file TileCalibTools.py.


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