def updateFromFile(self, fileName): """ Updates the internal bad channel cache with the content found in the file. The layout of the file has to follow the TileConditions ASCII file layout. NGO: change this at some point. In a file, not the status word (which depends on the bit pattern version) should be encoded, but the individual problems (enums). For this we need one line per ADC... this requires some modification in the reader. """ parser = TileCalibTools.TileASCIIParser(fileName, 'Bch') dict = parser.getDict() self.log().info("Updating dictionary from file with %i entries" % len(dict)) self.log().info("... filename: %s" % fileName) for key, stat in dict.iteritems(): ros = key[0] mod = key[1] chn = key[2] for adc in xrange(2): status = TileBchStatus() status += self.getAdcStatus(ros, mod, chn, adc) if adc < len(stat): statInt = int(stat[adc]) else: statInt = 0 #=== temporary convention if statInt == 0: pass elif statInt == 1: status += TileBchPrbs.IgnoredInHlt else: status += int(stat[adc]) self.setAdcStatus(ros, mod, chn, adc, status)
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, "")
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)
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)
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)
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)