Exemple #1
0
 def listBadAdcs(self, rosBeg=0, modBeg=0, rosEnd=5, modEnd=64):
     """
     Print a formatted list of all ADCs with problems.
     """
     self.log().info(
         "==============================================================")
     self.log().info(
         "                 Current list of affected ADCs               ")
     self.log().info(
         "==============================================================")
     for ros in range(rosBeg, rosEnd):
         for mod in range(modBeg,
                          min(modEnd, TileCalibUtils.getMaxDrawer(ros))):
             modName = TileCalibUtils.getDrawerString(ros, mod)
             for chn in range(TileCalibUtils.max_chan()):
                 chnName = "channel %2i" % chn
                 for adc in range(TileCalibUtils.max_gain()):
                     gainName = "LG:"
                     if adc:
                         gainName = "HG:"
                     prbs = self.getAdcProblems(ros, mod, chn, adc)
                     for prbCode in sorted(prbs.keys()):
                         prbDesc = prbs[prbCode]
                         msg = "%s %s %s %2i (%s)" % (
                             modName, chnName, gainName, prbCode, prbDesc)
                         self.log().info(msg)
                         modName = " " * 5
                         chnName = " " * 10
                         gainName = " " * 3
     self.log().info(
         "==============================================================")
Exemple #2
0
def decode_status(chan, calib_blob):
    """
    Given a module number `chan` and a `calib_blob` string, return the number
    of bad, good and affected channels in this module.
    
    It also returns a dictionary `prob` containing as keys the problem identifier
    and values the number of channels affected by that problem.
    """

    if chan == 1000 or len(calib_blob) <= 24:
        # chan 1000 is a comment, and calib_blobs less than 24 in length cause
        # a crash.
        return None

    # Decode a Coral BLOB into a string
    b = make_blob(calib_blob)
    bch = TileCalibDrawerBch.getInstance(b)

    bad, good, affected = [], [], []

    probs = {}

    decoder = TileBchDecoder(bch.getBitPatternVersion())
    chn_adcs = product(xrange(TileCalibUtils.max_chan()),
                       xrange(TileCalibUtils.max_gain()))
    # Stolen from near
    # http://alxr.usatlas.bnl.gov/lxr/source/atlas/TileCalorimeter/TileCalib/
    #     TileCalibBlobPython/python/TileBchTools.py#072
    for chn, adc in chn_adcs:
        adcBits, chnBits = bch.getData(chn, adc, 0), bch.getData(chn, 2, 0)
        status = TileBchStatus(decoder.decode(chnBits, adcBits))
        if status.isBad(): bad.append((chn, adc))
        if status.isGood(): good.append((chn, adc))
        if status.isAffected(): affected.append((chn, adc))

        if not status.isGood():
            prbs = status.getPrbs()
            # Build a dictionary
            for prb in prbs:
                key = prb, TileBchPrbs.getDescription(prb)
                probs[key] = probs.get(key, 0) + 1

    return len(bad), len(good), len(affected), probs
Exemple #3
0
 def checkModuleForChanges(self, ros, drawer):
     """
     Returns:
     - if nothing changed                                    :  0
     - if something changed and complete drawer is now good  : -1
     - if something changed but drawer is not completely good: >0
     """
     diffCnt = 0
     allGood = True
     for chn in range(TileCalibUtils.max_chan()):
         for adc in range(TileCalibUtils.max_gain()):
             idx = self.__getAdcIdx(ros, drawer, chn, adc)
             newStatus = self.__newStat[idx]
             #=== count differences between old and new
             if newStatus != self.__oldStat[idx]:
                 diffCnt += 1
             #=== invalidate allGood if one ADC is not good
             if not newStatus.isGood():
                 allGood = False
     if diffCnt > 0 and allGood:
         return -1
     return diffCnt
Exemple #4
0
 else:
     modSpec = modName
 newDrawer = True
 flt1 = blobReader.getDrawer(ros, mod, since, False, False)
 if flt1:
     oldNchan = flt1.getNChans()
     oldNgain = flt1.getNGains()
     oldVsize = flt1.getObjSizeUint32()
 else:
     oldNchan = 0
     oldNgain = 0
     oldVsize = 0
 nchan = nchanDef if nchanDef > 0 else (
     flt1.getNChans() if flt1 else TileCalibUtils.max_chan())
 ngain = ngainDef if ngainDef > 0 else (
     flt1.getNGains() if flt1 else TileCalibUtils.max_gain())
 for chn in range(nchan):
     #=== loop over gains
     for adc in range(ngain):
         data = blobParser.getData(ros, mod, chn, adc, since)
         if not len(data) and allzero:
             continue
         if not len(data) and (not all or
                               (not flt1 and not rosmin)):
             if not rosmin:
                 log.warning(
                     "%i/%2i/%2i/%i: No value found in file",
                     ros, mod, chn, adc)
             continue
         #=== need to invalidate previous blob in DB when reading from ASCII file
         if newDrawer:
Exemple #5
0
    modmax = mod + 1
elif mod < -1:
    modmax = modmin

if chan_n >= 0 and chan_n < TileCalibUtils.max_chan():
    chanmin = chan_n
    chanmax = chan_n + 1
else:
    if chanmin < 0:
        chanmin = 0
    if chanmax < 0:
        chanmax = TileCalibUtils.max_chan()
    else:
        chanmax += 1

if gain_n >= 0 and gain_n < TileCalibUtils.max_gain():
    gainmin = gain_n
    gainmax = gain_n + 1
else:
    gainmin = 0
    gainmax = TileCalibUtils.max_gain()

#=== Filling the iovList
iovList = []
if iov:
    if mod >= 0:
        COOL_part = ros
        COOL_chan = mod
    else:
        COOL_part = -1
        COOL_chan = 1000
Exemple #6
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
Exemple #7
0
                        #nc = flt.getNChans()
                        #ng = flt.getNGains()

                        if (typelo != typehi):
                            log.error("Object types %s %s are different",
                                      typelo, typehi)
                            sys.exit()

                        #=== get all problems of this module
                        #showAdcProblems(mgr,ros,mod)

                        #.. check for identical conditions
                        for chn in range(TileCalibUtils.max_chan()):
                            #  chnName = " %2i" % chn
                            #if identical:
                            for adc in range(TileCalibUtils.max_gain()):
                                #if identical:
                                for ind in range(
                                        1):  # 4 values per channel/adc

                                    #=== build status from both adc and channel bits
                                    adcBits = calibDrawer.getData(
                                        chn, adc, ind)
                                    chnBits = calibDrawer.getData(chn, 2, ind)
                                    status = TileBchStatus(
                                        bchDecoder.decode(chnBits, adcBits))

                                    adcBits = calibDrawerPrev.getData(
                                        chn, adc, ind)
                                    chnBits = calibDrawerPrev.getData(
                                        chn, 2, ind)
Exemple #8
0
folderTag = TileCalibTools.getFolderTag(
    schema if 'COMP200' in schema or 'OFLP200' in schema else db, folderPath,
    tag)
log.info("Initializing folder %s with tag %s", folderPath, folderTag)

#=== initialize blob reader
blobReader = TileCalibTools.TileBlobReader(db, folderPath, folderTag)
#blobReader.log().setLevel(logging.DEBUG)

#=== get drawer with status at given run
log.info("Initializing for run %d, lumiblock %d", run, lumi)
flt = None
r = 5
d = 0
nchan = TileCalibUtils.max_chan()
ngain = TileCalibUtils.max_gain()
while not flt:
    d -= 1
    if d < 0:
        r -= 1
        if r < 0:
            break
        d = TileCalibUtils.getMaxDrawer(r) - 1
    flt = blobReader.getDrawer(r, d, (run, lumi), False, False)
if flt:
    blobT = flt.getObjType()
    blobV = flt.getObjVersion()
    mchan = flt.getNChans()
    mgain = flt.getNGains()
    mval = flt.getObjSizeUint32()
    log.info("Blob type: %d  Version: %d  Nchannels: %d  Ngains: %d  Nval: %d",