示例#1
0
    def __updateFromDb(self,
                       db,
                       folderPath,
                       tag,
                       runLumi,
                       fillTable=1,
                       ros=-1,
                       module=-1):
        """
        Updates the internal bad channel cache with the content
        found in the database. An open database instance (db) has to
        be provided. Tag and runNum are used to locate the set of
        bad channels to be read from the database.
        """

        #=== try to open the db
        try:
            if not db.isOpen():
                raise Exception("DB not open: ", db.databaseId())
        except Exception as e:
            self.log().critical(e)
            return

        #=== print status information
        reader = TileCalibTools.TileBlobReader(db, folderPath, tag)
        if ros == -2:
            ros = 0
            module = TileCalibUtils.definitions_draweridx()
            self.log().info("Updating dictionary from \'%s\'",
                            db.databaseName())
            self.log().info("... using tag \'%s\', run-lumi=%s", tag, runLumi)
            self.__multiVersion = reader.folderIsMultiVersion()
            self.__comment = reader.getComment(runLumi)
            self.log().info("... comment: %s", self.__comment)

        #=== loop over the whole detector
        rosmin = ros if ros >= 0 else 0
        rosmax = ros + 1 if ros >= 0 else TileCalibUtils.max_ros()
        for ros in range(rosmin, rosmax):
            modmin = module if module >= 0 else 0
            modmax = module + 1 if module >= 0 else TileCalibUtils.getMaxDrawer(
                ros)
            for mod in range(modmin, modmax):
                bch = reader.getDrawer(ros, mod, runLumi, False)
                if bch is None:
                    if fillTable >= 0:
                        self.log().warning(
                            "Missing IOV in condDB: ros=%i mod=%i runLumi=%s",
                            ros, mod, runLumi)
                    continue
                bchDecoder = TileBchDecoder(bch.getBitPatternVersion())
                for chn in range(TileCalibUtils.max_chan()):
                    for adc in range(TileCalibUtils.max_gain()):
                        #=== adc bits
                        adcBits = bch.getData(chn, adc, 0)
                        #=== channel bits (works always due to default policy)
                        chnBits = bch.getData(chn, 2, 0)
                        #=== build status from both adc and channel bits
                        status = TileBchStatus(
                            bchDecoder.decode(chnBits, adcBits))
                        if fillTable == 0:
                            self.__oldStat[self.__getAdcIdx(
                                ros, mod, chn, adc)] = status
                        elif fillTable == 1 or fillTable == -1:
                            self.__newStat[self.__getAdcIdx(
                                ros, mod, chn, adc)] = status
                        elif fillTable == 2 or fillTable == -2:
                            self.__oldStat[self.__getAdcIdx(
                                ros, mod, chn, adc)] = status
                            self.__newStat[self.__getAdcIdx(
                                ros, mod, chn, adc)] = status
                        else:
                            self.__newStat[self.__getAdcIdx(
                                ros, mod, chn, adc)] = status
                            status1 = TileBchStatus(
                                bchDecoder.decode(chnBits, adcBits))
                            self.__oldStat[self.__getAdcIdx(
                                ros, mod, chn, adc)] = status1
示例#2
0
#=== set database
db = TileCalibTools.openDbConn(schema, 'READONLY')
folderTag = TileCalibTools.getFolderTag(db if 'CONDBR2' in schema else schema,
                                        folderPath, tag)
log.info("Initializing folder %s with tag %s", folderPath, folderTag)

#=== create bad channel manager
mgr = TileBchTools.TileBchMgr()
mgr.setLogLvl(logLevel)
mgr.initialize(db, folderPath, folderTag, (run, lumi), warn, -2)
if iov or comment or warn < 0:
    blobReader = TileCalibTools.TileBlobReader(db, folderPath, folderTag)

#=== Dump the current isBad definition
isBadDef = mgr.getAdcProblems(0, TileCalibUtils.definitions_draweridx(),
                              TileCalibUtils.bad_definition_chan(), 0)
if len(list(isBadDef.keys())):
    log.info("isBad Definition: ")
    for prbCode in sorted(isBadDef.keys()):
        prbDesc = isBadDef[prbCode]
        msg = "- %2i (%s)" % (prbCode, prbDesc)
        log.info(msg)
#=== Dump the current isBadTiming definition
isBadTimingDef = mgr.getAdcProblems(0, TileCalibUtils.definitions_draweridx(),
                                    TileCalibUtils.badtiming_definition_chan(),
                                    0)
if len(list(isBadTimingDef.keys())):
    log.info("isBadTiming Definition: ")
    for prbCode in sorted(isBadTimingDef.keys()):
        prbDesc = isBadTimingDef[prbCode]
示例#3
0
 def getBadTimingDefinition(self):
     """
     Returns bad time status definition
     """
     return self.getAdcStatus(0, TileCalibUtils.definitions_draweridx(),
                              TileCalibUtils.badtiming_definition_chan(), 0)