Exemple #1
0
def fillTileMuId(file, since,
               until=(TileCalibTools.MAXRUN, TileCalibTools.MAXLBK)):
    
    #=== construct folder path
    folder = TileCalibTools.getTilePrefix(False)+"MUID"

    #=== common TileMuId defaults
    default = cppyy.gbl.std.vector('float')()
    for i in xrange(20):
        default.push_back(150.)
        default.push_back(5000.)
    defVec = cppyy.gbl.std.vector('std::vector<float>')()
    defVec.push_back(default)
    defVec.push_back(default)    
    
    #=====================================================
    #=== fill 
    #=====================================================
    writer = TileCalibTools.TileBlobWriter(db,folder,'Flt',False)
    writer.setComment(os.getlogin(),"Arantxa's values, april 2009.")
    parser = TileCalibTools.TileASCIIParser(file,"TileMuId");

    #=== initialize all channels and write global default
    util = cppyy.gbl.TileCalibUtils()
    for ros in xrange(util.max_ros()):
        for drawer in xrange(util.getMaxDrawer(ros)):
            flt = writer.zeroBlob(ros,drawer)
    calibDrawer = writer.getDrawer(0,0)
    calibDrawer.init(defVec,1,1)

    #=== loop over whole detector
    for ros in xrange(1,5):
        for mod in xrange(64):
            #=== need to invalidate previous blob in DB when reading from ASCII file
            writer.zeroBlob(ros,mod)
            #=== we write 40 numbers (thresholds for 20 cells) only to channel 0 in each drawer
            chn = 0
            values = parser.getData(ros,mod,chn)
            if not len(values):
                log.warning("%i/%2i/%2i/x: No value found in file" % (ros,mod,chn))
                continue
            #=== init drawer with defaults for first entry
            calibDrawer = writer.getDrawer(ros,mod)
            if not calibDrawer.getNObjs():
                log.info("Initializing drawer %i/%2i\t%i" % (ros,mod,calibDrawer.getNObjs()))
                calibDrawer.init(defVec,48,1)
            #=== fill in realistic values (just for the low gain index, store 40 values)
            adc = 0
            line = "%i/%2i/%2i/%i: " % (ros,mod,chn,adc)            
            for i in xrange(40):
                value = float(values[i])
                calibDrawer.setData(chn,adc,i,value)
                line += "%f " % (value,)

            log.debug(line)

    #=== register in DB
    writer.register(since, until, "")
Exemple #2
0
def fillTimingTc(fileTclas, tag, since,
               until=(TileCalibTools.MAXRUN, TileCalibTools.MAXLBK)):

    #=== construct folder path
    folderTclas = TileCalibTools.getTilePrefix(True,True)+"TIME/CHANNELOFFSET/LAS"

    #=== create default: one number
    #--- per ADC    for Tclas
    default = cppyy.gbl.std.vector('float')()
    default.push_back(0.)

    #=====================================================
    #=== fill Tclas
    #=====================================================
    tclasWriter = TileCalibTools.TileBlobWriter(db,folderTclas,'Flt')
    tclasWriter.setComment(os.getlogin(),fileTclas)
    parserTclas = TileCalibTools.TileASCIIParser(fileTclas,"Tclas");
    defTclas = cppyy.gbl.std.vector('std::vector<float>')()
    defTclas.push_back(default) # low  gain
    defTclas.push_back(default) # high gain
    #=== initialize defaults
    ros = 0
    for mod in xrange(20):
        flt = tclasWriter.zeroBlob(ros,mod)
    flt = tclasWriter.getDrawer(0, 0)
    flt.init(defTclas,1,0)        
    #=== loop over whole detector
    for ros in xrange(1,5):
        for mod in xrange(64):
            #=== need to invalidate previous blob in DB when reading from ASCII file
            tclasWriter.zeroBlob(ros,mod)
            for chn in xrange(48):
                tclas = parserTclas.getData(ros,mod,chn)
                if not len(tclas):
                    log.warning("%i/%2i/%2i/x: No value found in file" % (ros,mod,chn))
                    continue
                #=== init drawer for first entry
                calibDrawer = tclasWriter.getDrawer(ros,mod)
                if not calibDrawer.getNObjs():
                    log.info("Initializing drawer %i/%2i\t%i" % (ros,mod,calibDrawer.getNObjs()))
                    calibDrawer.init(defTclas,48,0)
                #=== loop over gainsa
                for adc in xrange(2):
                    val = float(tclas[adc])
                    log.debug("%i/%2i/%2i/%i: tclas = %f" % (ros,mod,chn,adc, val))
                    calibDrawer.setData(chn,adc,0,val)

    folderTag = TileCalibUtils.getFullTag(folderTclas, tag)
    tclasWriter.setComment(os.getlogin(),"Timing update for all partitions")
    tclasWriter.register(since, until, folderTag)
Exemple #3
0
def fillTripsProbs(fileTrips,
                   folderPath,
                   tag,
                   since,
                   until=(TileCalibTools.MAXRUN, TileCalibTools.MAXLBK)):

    #=== get full folder tag
    folderTag = TileCalibUtils.getFullTag(folderPath, tag)

    util = cppyy.gbl.TileCalibUtils()

    default = cppyy.gbl.std.vector('unsigned int')()
    for i in xrange(util.max_drawer() + 1):
        default.push_back(0)

    defVec = cppyy.gbl.std.vector('std::vector<unsigned int>')()
    defVec.push_back(default)

    #=====================================================
    #=== fill
    #=====================================================
    writer = TileCalibTools.TileBlobWriter(db, folderPath, 'Bch')

    precisions = [[0 for drawer in xrange(util.max_drawer())]
                  for ros in xrange(util.max_ros())]
    trips = [[0 for drawer in xrange(util.max_drawer())]
             for ros in xrange(util.max_ros())]

    parser = TileCalibTools.TileASCIIParser3(fileTrips, "Trip")
    dict = parser.getDict()
    log.info("Updating dictionary from file with %i entries" % len(dict))
    log.info("... filename: %s" % fileTrips)
    for key, trip in dict.iteritems():
        ros = key[0]
        mod = key[1]
        precisions[ros][mod] = len(trip[0]) - 2
        trips[ros][mod] = float(trip[0])

    tripsCalibDrawer = writer.getDrawer(util.trips_ros(), util.trips_drawer())
    tripsCalibDrawer.init(defVec, util.max_ros(), 1)

    for ros in xrange(util.max_ros()):
        denominator = 10**max(precisions[ros])
        for mod in xrange(util.max_drawer()):
            trip = int(trips[ros][mod] * denominator)
            tripsCalibDrawer.setData(ros, 0, mod, trip)
        tripsCalibDrawer.setData(ros, 0, util.max_drawer(), denominator)

    #=== register in DB
    writer.register(since, until, folderTag)
Exemple #4
0
def fillTimingTd(fileTdlas, tag, since,
               until=(TileCalibTools.MAXRUN, TileCalibTools.MAXLBK)):

    #=== construct folder path
    folderTdlas = TileCalibTools.getTilePrefix(True,True)+"TIME/DRAWEROFFSET/LAS"

    #=== create default: one number
    #--- per drawer for Tdlas
    default = cppyy.gbl.std.vector('float')()
    default.push_back(0.)

    #=====================================================
    #=== fill Tdlas
    #=====================================================
    tdlasWriter = TileCalibTools.TileBlobWriter(db,folderTdlas,'Flt')
    tdlasWriter.setComment(os.getlogin(),fileTdlas)
    parserTdlas = TileCalibTools.TileASCIIParser(fileTdlas,"Tdlas");
    defTdlas = cppyy.gbl.std.vector('std::vector<float>')()
    defTdlas.push_back(default)
    #=== initialize defaults
    ros = 0
    for mod in xrange(20):
        flt = tdlasWriter.zeroBlob(ros,mod)
    flt = tdlasWriter.getDrawer(0, 0)
    flt.init(defTdlas,1,0)    
    #=== loop over whole detector
    for ros in xrange(1,5):
        for mod in xrange(64):
            #=== need to invalidate previous blob in DB when reading from ASCII file
            tdlasWriter.zeroBlob(ros,mod)
            tdlas = parserTdlas.getData(ros,mod,0)
            if not len(tdlas):
                log.warning("(ros,mod)=(%i,%2i): No value found in file" % (ros,mod))
                continue
            defTdlas[0][0] = float(tdlas[0])
            log.debug("(ros,mod)=(%i,%2i): tdlas = %f" % (ros,mod,defTdlas[0][0]))
            calibDrawer = tdlasWriter.getDrawer(ros,mod)
            calibDrawer.init(defTdlas,1,0)

    folderTag = TileCalibUtils.getFullTag(folderTdlas, tag)
    tdlasWriter.setComment(os.getlogin(),"Timing update for all partitions")
    tdlasWriter.register(since, until, folderTag)
Exemple #5
0
def fillPed(filePed,
            tag,
            comment,
            since,
            until=(TileCalibTools.MAXRUN, TileCalibTools.MAXLBK)):

    #=== construct folder path
    folder = TileCalibTools.getTilePrefix(True, True) + "NOISE/SAMPLE"

    #=== get full folder tag
    folderTag = TileCalibUtils.getFullTag(folder, tag)

    #=== create default (ADC counts)
    pedDef = [30., 50.]
    loGainDef = 0.8
    hiGainDef = 1.6
    defaultLo = cppyy.gbl.std.vector('float')()
    defaultLo.push_back(pedDef[0])  # pedestal mean value
    defaultLo.push_back(loGainDef)  # pedestal rms
    defaultLo.push_back(0.0)  # pedestal low frequency noise
    defaultLo.push_back(loGainDef)  # pedestal HFN1
    defaultLo.push_back(0.0)  # pedestal HFN2
    defaultLo.push_back(0.0)  # pedestal HFN2/HFN1 ratio
    defaultHi = cppyy.gbl.std.vector('float')()
    defaultHi.push_back(pedDef[1])  # pedestal mean value
    defaultHi.push_back(hiGainDef)  # pedestal rms
    defaultHi.push_back(0.0)  # pedestal low frequency noise
    defaultHi.push_back(hiGainDef)  # pedestal HFN1
    defaultHi.push_back(0.0)  # pedestal HFN2
    defaultHi.push_back(0.0)  # pedestal HFN2/HFN1 ratio
    defVec = cppyy.gbl.std.vector('std::vector<float>')()
    defVec.push_back(defaultLo)
    defVec.push_back(defaultHi)

    #=====================================================
    #=== fill
    #=====================================================
    writer = TileCalibTools.TileBlobWriter(db, folder, 'Flt')
    writer.setComment(os.getlogin(), comment)
    parser = TileCalibTools.TileASCIIParser2(filePed, "")
    #=== loop over whole detector
    for ros in xrange(0, 5):
        #for mod in xrange(64):
        for mod in xrange(0, min(64, TileCalibUtils.getMaxDrawer(ros))):
            #=== need to invalidate previous blob in DB when reading from ASCII file
            writer.zeroBlob(ros, mod)
            #=== init drawer with defaults for first entry
            calibDrawer = writer.getDrawer(ros, mod)
            if not calibDrawer.getNObjs():
                log.info("Initializing drawer %i/%2i\t%i" %
                         (ros, mod, calibDrawer.getNObjs()))
                calibDrawer.init(defVec, 48, 0)
            for chn in xrange(48):
                #=== loop over gains
                for adc in xrange(2):
                    calibDrawer.setData(chn, adc, 0,
                                        pedDef[adc] + (chn + 1) / 48.)
                    values = parser.getData(ros, mod, chn, adc)
                    if not len(values):
                        log.warning("%i/%2i/%2i/%i: No value found in file" %
                                    (ros, mod, chn, adc))
                        values = parser.getData(0, ros * 4, chn, adc)
                        if not len(values):
                            log.warning("No default per partition available")
                            values = parser.getData(0, 0, chn, adc)
                            if not len(values):
                                log.warning(
                                    "No global default available - give up")
                                continue
                            else:
                                log.warning("Using global default")
                        else:
                            log.warning("Using default per partition")
                    #=== the order of columns in the ASCII file is different to the order in DB
                    lvl = float(values[0])  # pedestal level
                    hfn = float(values[1])  # high frequency noise
                    lfn = float(values[2])  # low frequency noise
                    hfn1 = float(values[3])  # hfn1
                    hfn2 = float(values[4])  # hfn2
                    norm = float(values[5])  # hfn2/hfn1
                    log.debug(
                        "%i/%2i/%2i/%i: pedLvl=%f\thfn=%f\tlfn=%f\thfn1=%f\thfn2=%f\tnorm=%f"
                        %
                        (ros, mod, chn, adc, lvl, hfn, lfn, hfn1, hfn2, norm))
                    calibDrawer.setData(chn, adc, 0, lvl)
                    calibDrawer.setData(chn, adc, 1, hfn)
                    calibDrawer.setData(chn, adc, 2, lfn)
                    calibDrawer.setData(chn, adc, 3, hfn1)
                    calibDrawer.setData(chn, adc, 4, hfn2)
                    calibDrawer.setData(chn, adc, 5, norm)
    #=== register in DB
    writer.register(since, until, folderTag)
Exemple #6
0
def fillIntegrator(fileInt,
                   tag,
                   since,
                   until=(TileCalibTools.MAXRUN, TileCalibTools.MAXLBK)):

    #=== construct folder path
    folder = TileCalibTools.getTilePrefix(True, True) + "INTEGRATOR"

    #=== get full folder tag
    folderTag = TileCalibUtils.getFullTag(folder, tag)

    #=== create default values for each of the six gains 1 to 6
    # for each gain there is:
    # gain, error of the gain, chi2 of the fit, pedestal
    # DAC for pedestal, sigma of pedestal distribution
    # RMS of pedestal distribution, sigma of the RMS

    dv = []
    dv.append((2.814, 0.023, -1, -1, 80, -1, -1, -1))
    dv.append((26.010, 0.230, -1, -1, 80, -1, -1, -1))
    dv.append((28.810, 0.240, -1, -1, 80, -1, -1, -1))
    dv.append((54.810, 0.480, -1, -1, 70, -1, -1, -1))
    dv.append((75.790, 0.677, -1, -1, 70, -1, -1, -1))
    dv.append((101.800, 0.900, -1, -1, 70, -1, -1, -1))

    #=== number of integrator gains and value per gain
    ngain = 6
    nperg = 8

    defVec = cppyy.gbl.std.vector('std::vector<float>')()

    for i in range(ngain):
        defaultGain = cppyy.gbl.std.vector('float')()
        for v in dv[i]:
            defaultGain.push_back(v)
        defVec.push_back(defaultGain)

    #=====================================================
    #=== fill
    #=====================================================
    writer = TileCalibTools.TileBlobWriter(db, folder, 'Flt')
    writer.setComment(os.getlogin(),
                      "Jalal's values with non-zero defaults, 2008-12-05")
    parser = TileCalibTools.TileASCIIParser(fileInt, "IntGain")
    #=== initialize all channels and write global default
    util = cppyy.gbl.TileCalibUtils()
    for ros in range(util.max_ros()):
        for drawer in range(util.getMaxDrawer(ros)):
            writer.zeroBlob(ros, drawer)
    calibDrawer = writer.getDrawer(0, 0)
    calibDrawer.init(defVec, 1, 1)
    #=== loop over whole detector
    for ros in range(1, 5):
        for mod in range(64):
            #=== need to invalidate previous blob in DB when reading from ASCII file
            writer.zeroBlob(ros, mod)
            for chn in range(48):
                values = parser.getData(ros, mod, chn)
                if not len(values):
                    log.warning("%i/%2i/%2i/x: No value found in file", ros,
                                mod, chn)
                    continue
                #=== init drawer with defaults for first entry
                calibDrawer = writer.getDrawer(ros, mod)
                if not calibDrawer.getNObjs():
                    log.info("Initializing drawer %i/%2i\t%i", ros, mod,
                             calibDrawer.getNObjs())
                    calibDrawer.init(defVec, 48, 1)

                #=== loop over gains
                for adc in range(ngain):
                    line = "%i/%2i/%2i/%i: " % (ros, mod, chn, adc)
                    for v in range(nperg):
                        value = float(values[adc * nperg + v])
                        calibDrawer.setData(chn, adc, v, value)
                        line += "%f " % (value, )

                    log.debug(line)

    #=== register in DB
    writer.register(since, until, folderTag)
Exemple #7
0
                run)
        if run < 0:
            log.error("Bad run number")
            sys.exit(2)

    since = (run, lumi)
    iovList = [since]
    iovUntil = [until]
    iovUntilCMT = [until]
    if "begin" not in dir():
        begin = since
    if run2 < 0:
        run2 = begin[0]
    if run2 > begin[0] or (run2 == begin[0] and lumi2 > begin[1]):
        undo = True
        blobWriter2 = TileCalibTools.TileBlobWriter(
            dbw, outfolderPath, 'Flt', (True if len(outtag) else False))
    else:
        undo = False

    log.info("Initializing for run %d, lumiblock %d", run, lumi)

flt = None
r = 5
d = 0
while not flt:
    d -= 1
    if d < 0:
        r -= 1
        if r < 0:
            break
        d = TileCalibUtils.getMaxDrawer(r) - 1
Exemple #8
0
        #=== default for drawer initialization
        loGainDefVec = cppyy.gbl.std.vector('unsigned int')()
        loGainDefVec.push_back(0)
        hiGainDefVec = cppyy.gbl.std.vector('unsigned int')()
        hiGainDefVec.push_back(0)
        comChnDefVec = cppyy.gbl.std.vector('unsigned int')()
        comChnDefVec.push_back(0)
        cppyy.makeClass('std::vector<unsigned int>')
        defVec = cppyy.gbl.std.vector('std::vector<unsigned int>')()
        defVec.push_back(loGainDefVec)
        defVec.push_back(hiGainDefVec)
        defVec.push_back(comChnDefVec)

        #=== loop over the whole detector
        writer = TileCalibTools.TileBlobWriter(db, folderPath, 'Bch',
                                               multiVersion)
        if len(comment): writer.setComment(author, comment)
        bchDecoder = TileBchDecoder(bitPatVer)
        nUpdates = 0
        goodComment = True
        for ros in xrange(0, TileCalibUtils.max_ros()):
            for mod in xrange(TileCalibUtils.getMaxDrawer(ros)):
                modName = TileCalibUtils.getDrawerString(ros, mod)
                nChange = self.checkModuleForChanges(ros, mod)
                if nChange == 0:
                    #=== do nothing if nothing changed
                    continue
                if nChange == -1:
                    nUpdates += 1
                    self.log().info("Drawer %s reset to GOOD" % (modName))
                    if modName not in comment:
Exemple #9
0
def fillAutoCr(filePed,
               tag,
               since,
               until=(TileCalibTools.MAXRUN, TileCalibTools.MAXLBK)):

    #=== construct folder path
    folder = TileCalibTools.getTilePrefix(True, True) + "NOISE/AUTOCR"

    #=== get full folder tag
    folderTag = TileCalibUtils.getFullTag(folder, tag)

    #=== common noise autocr defaults (no correlation)
    default = cppyy.gbl.std.vector('float')()
    for i in range(6):
        default.push_back(0.)
    defVec = cppyy.gbl.std.vector('std::vector<float>')()
    defVec.push_back(default)
    defVec.push_back(default)

    #=====================================================
    #=== fill
    #=====================================================
    writer = TileCalibTools.TileBlobWriter(db, folder, 'Flt')
    writer.setComment(os.getlogin(),
                      "Giulio's file for LBC test n.0, 2009-02-27")
    parser = TileCalibTools.TileASCIIParser(filePed, "AutoCr")

    #=== initialize all channels and write global default
    util = cppyy.gbl.TileCalibUtils()
    for ros in range(util.max_ros()):
        for drawer in range(util.getMaxDrawer(ros)):
            writer.zeroBlob(ros, drawer)
    calibDrawer = writer.getDrawer(0, 0)
    calibDrawer.init(defVec, 1, 1)

    #=== loop over whole detector
    for ros in range(1, 5):
        for mod in range(64):
            #=== need to invalidate previous blob in DB when reading from ASCII file
            writer.zeroBlob(ros, mod)
            for chn in range(48):
                values = parser.getData(ros, mod, chn)
                if not len(values):
                    log.warning("%i/%2i/%2i/x: No value found in file", ros,
                                mod, chn)
                    continue
                #=== init drawer with defaults for first entry
                calibDrawer = writer.getDrawer(ros, mod)
                if not calibDrawer.getNObjs():
                    log.info("Initializing drawer %i/%2i\t%i", ros, mod,
                             calibDrawer.getNObjs())
                    calibDrawer.init(defVec, 48, 1)
                #=== fill in realistic values
                for adc in range(2):
                    line = "%i/%2i/%2i/%i: " % (ros, mod, chn, adc)
                    for i in range(6):
                        value = float(values[adc * 6 + i])
                        calibDrawer.setData(chn, adc, i, value)
                        line += "%f " % (value, )

                    log.debug(line)
    #=== register in DB
    writer.register(since, until, folderTag)
Exemple #10
0
    def commitToDb(self,
                   db,
                   folderPath,
                   tag,
                   bitPatVer,
                   author,
                   comment,
                   since,
                   until=(MAXRUN, MAXLBK),
                   untilCmt=None,
                   moduleList=[]):
        """
        Commits the differences compared to the set of bad channels read in with the
        initialze function to the provided database.
        - author  : author name (string)
        - comment : a comment (string)
        - sinceRun, sinceLbk : start of IOV for which bad channels are valid
        - untilRun, untilLbk : end   of IOV for which bad channels are valid
        """
        #=== check db status
        try:
            if not db.isOpen():
                raise Exception("DB not open: ", db.databaseId())
        except Exception as e:
            raise (e)

        multiVersion = self.__multiVersion
        writer = TileCalibTools.TileBlobWriter(db, folderPath, 'Bch',
                                               multiVersion)
        if len(comment) or isinstance(author, tuple):
            writer.setComment(author, comment)
        nUpdates = 0
        goodComment = True
        #=== get latest state from db
        if moduleList != ['CMT']:
            if since != (MINRUN, MINLBK):
                justBefore = list(since)
                if justBefore[1] > MINLBK:
                    justBefore[1] = justBefore[1] - 1
                else:
                    justBefore[0] = justBefore[0] - 1
                    justBefore[1] = MAXLBK
                justBefore = tuple(justBefore)
                if self.__mode != 2:
                    self.log().info(
                        "Reading db state just before %s, i.e. at %s", since,
                        justBefore)
                    self.__updateFromDb(db, folderPath, tag, justBefore, 0)
                else:
                    self.log().info(
                        "Using previous bad channel list from input DB")
                self.log().info(
                    "And comparing it with new list of bad channels")
            else:
                if self.__mode != 2:
                    reader = TileCalibTools.TileBlobReader(db, folderPath, tag)
                    multiVersion = reader.folderIsMultiVersion()
                self.log().info(
                    "Filling db from %s, resetting old status cache",
                    list(since))
                self.__oldStat = len(self.__oldStat) * [TileBchStatus()]

            #=== print status information
            self.log().info("Committing changes to DB \'%s\'", db.databaseId())
            self.log().info(
                "... using tag \'%s\' and [run,lumi] range: [%i,%i] - [%i,%i]",
                tag, since[0], since[1], until[0], until[1])
            if isinstance(author, tuple) and len(author) == 3:
                self.log().info("... author : \'%s\'", author[0])
                self.log().info("... comment: \'%s\'", author[1])
            else:
                self.log().info("... author : \'%s\'", author)
                self.log().info("... comment: \'%s\'", comment)

            #=== default for drawer initialization
            loGainDefVec = cppyy.gbl.std.vector('unsigned int')()
            loGainDefVec.push_back(0)
            hiGainDefVec = cppyy.gbl.std.vector('unsigned int')()
            hiGainDefVec.push_back(0)
            comChnDefVec = cppyy.gbl.std.vector('unsigned int')()
            comChnDefVec.push_back(0)
            cppyy.makeClass('std::vector<unsigned int>')
            defVec = cppyy.gbl.std.vector('std::vector<unsigned int>')()
            defVec.push_back(loGainDefVec)
            defVec.push_back(hiGainDefVec)
            defVec.push_back(comChnDefVec)

            #=== loop over the whole detector
            bchDecoder = TileBchDecoder(bitPatVer)
            for ros in range(0, TileCalibUtils.max_ros()):
                for mod in range(TileCalibUtils.getMaxDrawer(ros)):
                    modName = TileCalibUtils.getDrawerString(ros, mod)
                    nChange = self.checkModuleForChanges(ros, mod)
                    if nChange == 0 and (len(moduleList) == 0
                                         or modName not in moduleList
                                         or 'ALL' not in moduleList):
                        #=== do nothing if nothing changed
                        continue
                    if nChange == -1:
                        nUpdates += 1
                        self.log().info("Drawer %s reset to GOOD", modName)
                        if modName not in comment and not (
                                "ONL" not in folderPath
                                or "syncALL" not in comment):
                            goodComment = False
                            self.log().error(
                                "Comment string - '%s' - doesn't contain drawer %s",
                                comment, modName)
                        writer.zeroBlob(ros, mod)
                    else:
                        nUpdates += 1
                        self.log().info("Applying %2i changes to drawer %s",
                                        nChange, modName)
                        if modName not in comment and ("ONL" not in folderPath
                                                       or "syncALL"
                                                       not in comment):
                            goodComment = False
                            self.log().error(
                                "Comment string - '%s' - doesn't contain drawer %s",
                                comment, modName)
                        drawer = writer.getDrawer(ros, mod)
                        drawer.init(defVec, TileCalibUtils.max_chan(),
                                    bitPatVer)
                        for chn in range(TileCalibUtils.max_chan()):
                            #=== get low gain bit words
                            wordsLo = bchDecoder.encode(
                                self.getAdcStatus(ros, mod, chn, 0))
                            chBits = wordsLo[0]
                            loBits = wordsLo[1]
                            #=== get high gain bit words
                            wordsHi = bchDecoder.encode(
                                self.getAdcStatus(ros, mod, chn, 1))
                            chBits = wordsHi[0] | chBits
                            hiBits = wordsHi[1]
                            #=== set low, high and common channel word in calibDrawer
                            drawer.setData(chn, 0, 0, loBits)
                            drawer.setData(chn, 1, 0, hiBits)
                            drawer.setData(chn, 2, 0, chBits)
                            #=== synchronizing channel status in low and high gain
                            if wordsLo[0] != chBits:
                                self.log().info(
                                    "Drawer %s ch %2d - sync LG status with HG ",
                                    modName, chn)
                                status = TileBchStatus(
                                    bchDecoder.decode(chBits, loBits))
                                self.setAdcStatus(ros, mod, chn, 0, status)
                            if wordsHi[0] != chBits:
                                self.log().info(
                                    "Drawer %s ch %2d - sync HG status with LG ",
                                    modName, chn)
                                status = TileBchStatus(
                                    bchDecoder.decode(chBits, hiBits))
                                self.setAdcStatus(ros, mod, chn, 1, status)

        #=== register
        if nUpdates > 0 or moduleList == ['CMT']:
            if goodComment:
                self.log().info(
                    "Attempting to register %i modified drawers...", nUpdates)
                if untilCmt is not None and untilCmt != until:
                    if moduleList != ['CMT'] and until > since:
                        writer.register(since, until, tag, 1)
                    if untilCmt > since:
                        writer.register(since, untilCmt, tag, -1)
                else:
                    writer.register(since, until, tag)
            else:
                self.log().error(
                    "Aborting update due to errors in comment string")
        else:
            self.log().warning(
                "No drawer modifications detected, ignoring commit request")
Exemple #11
0
        regFrom = sys.argv.pop(0)
    else:
        #=== check if file exists
        if os.path.exists(arg):
            fileList.append(arg)
        else:
            log.error("File \"%s\" does not exist, ignoring input!", arg)

import cppyy
from TileCalibBlobPython import TileCalibTools

#=== open the database
db = TileCalibTools.openDb('SQLITE', 'CONDBR2', 'UPDATE')

#=== get a blob writer
blobWriter = TileCalibTools.TileBlobWriter(db, "/TILE/ONL01/INTEGRATOR", True,
                                           False)

#=== declare default vector
default = cppyy.gbl.std.vector('float')()
default.push_back(0.)  # gain            0
default.push_back(0.)  # sigma(gain)     1
default.push_back(0.)  # chi2            2
default.push_back(0.)  # DAC             3
default.push_back(0.)  # pedestal        4
default.push_back(0.)  # sigma(pedestal) 5
default.push_back(0.)  # rms             6
default.push_back(0.)  # sigma(rms)      7
defVec = cppyy.gbl.std.vector('std::vector<float>')()
defVec.push_back(default)  # gain 1
defVec.push_back(default)  # gain 2
defVec.push_back(default)  # gain 3