def __init__(self, fname, vhdl_dict, writer_t): super(PatternDumper, self).__init__() self.fname = fname # file that is dumped to self.frame_dict = {} # dict for easy access of words self.vhdl_dict = vhdl_dict # vhdl-dict as returned by ../../tools/vhdl.VHDLConfigParser self._log = log.init_logging(self.__class__.__name__) self._writer = writer_t() # which writer should be used for dumping? self._bxCounter = 0
def __init__(self, fname, vhdl_dict, fobj=None): super(BufferParser, self).__init__() self.fname = fname # file that is parsed self.fobj = fobj # if file-content is already available provide it self.frame_dict = {} # dict for easy access of words (see init) self.initialized = False # saves if frame_dict is initialized self.vhdl_dict = vhdl_dict # vhdl-dict as returned by ../../tools/vhdl.VHDLConfigParser self.max_frame = 0 # uppermost frame number containing muons self.valid_frames = -1 # total number of frames containing muons self._log = log.init_logging(self.__class__.__name__)
def main(): _log = log.init_logging("main") vhdl_dict = VHDLConstantsParser.parse_vhdl_file("data/ugmt_constants.vhd") basedir_testbench = "data/patterns/emu/" rankLUT = l1t.MicroGMTRankPtQualLUT() options = parse_options() file_dict = discover_files(options) for pattern, fnames in file_dict.iteritems(): _log.info("{patt:+^90}".format(patt=pattern)) _log.info("{info:>90}".format(info="HW PARSING")) # Reading and processing the hardware data input_parser = InputBufferParser(fnames["rx"], vhdl_dict) in_muons = input_parser.get_input_muons() input_testbench = PatternDumper(basedir_testbench + pattern + ".txt", vhdl_dict, TestbenchWriter) offset = 36 fwdp_range = range(offset + vhdl_dict["FWD_POS_LOW"], offset + vhdl_dict["FWD_POS_HIGH"]) fwdn_range = range(offset + vhdl_dict["FWD_NEG_LOW"], offset + vhdl_dict["FWD_NEG_HIGH"]) bar_range = range(offset + vhdl_dict["BARREL_LOW"], offset + vhdl_dict["BARREL_HIGH"]) ovlp_range = range(offset + vhdl_dict["OVL_POS_LOW"], offset + vhdl_dict["OVL_POS_HIGH"]) ovln_range = range(offset + vhdl_dict["OVL_NEG_LOW"], offset + vhdl_dict["OVL_NEG_HIGH"]) while len(in_muons) > 0: bar_muons = [] ovlp_muons = [] ovln_muons = [] fwdp_muons = [] fwdn_muons = [] for i in range(108): mu = in_muons[0] if mu.link in fwdp_range: fwdp_muons.append(mu) if mu.link in fwdn_range: fwdn_muons.append(mu) if mu.link in ovlp_range: ovlp_muons.append(mu) if mu.link in ovln_range: ovln_muons.append(mu) if mu.link in bar_range: bar_muons.append(mu) del in_muons[0] input_testbench.writeMuonBasedInputBX(bar_muons, fwdp_muons, fwdn_muons, ovlp_muons, ovln_muons, [], rankLUT, False, True) input_testbench.dump()
instance_string = 'INST "algo/deserialize' if serdes_type == "CALO": instance_string = instance_string + '_energies' elif serdes_type == "MU": instance_string = instance_string + '_muons' else: instance_string = instance_string + '_ERROR' instance_string = instance_string + '/deserialize_' instance_string = instance_string + str(instance_num) instance_string = instance_string + '" AREA_GROUP=quad_' instance_string = instance_string + str(area_group) instance_string = instance_string + ';' return instance_string _log = log.init_logging("ucf_serdes_constraints_generator") if __name__ == "__main__": # initialize command line input opts, args = parse_options() # set verbosity according to option log.set_level(opts.verbosity) _log.debug("*" * 40) _log.info(" UCF Serdes constraints generator") _log.info("*" * 40) _log.info("Paste the following into your ucf file:") config_dict = VHDLConstantsParser.parse_vhdl_file(opts.files[0]) quad_dict = get_quad_areagroup_mapping(opts.files[1]) for key in sorted(config_dict):
TH1.AddDirectory(False) pi = math.pi gROOT.SetBatch() # gStyle.SetOptStat("ne") gStyle.SetHistMinimumZero() gStyle.SetPalette(1) canvas = TCanvas("canvas_of_plots","comparisons") canvas.SetFillStyle(0) vhdl_dict = VHDLConstantsParser.parse_vhdl_file("data/ugmt_constants.vhd") options = parse_options() _log = None if options.verbose: _log = log.init_logging("BufferAnalyzer") else: _log = log.init_logging("BufferAnalyzer", INFO) file_dict = discover_files(options) ##### if the physical properties should be calculated, then the functions phi, eta and pt just have to be discommented. Doing this, the following parameters are their input. ##### They dont have any other use eta_unit = 0.01 eta_low = -240 eta_high = 239 phi_unit = 2*pi/576 phi_low = 0 phi_high = 57 pt_unit = 0.5 pt_low = 0
rects.append(Rect(xb, yb, xe-xb, ye-yb, typ, name, modifier)) return rects def test_rect_list(rect_list): found_overlap = False for i, rect1 in enumerate(rect_list): # the overlap is symmetric, only have to check once for j, rect2 in enumerate(rect_list[i:]): if i == j: continue overlap = Rect.test_overlap(rect1, rect2) if overlap: _log.info("{rect1} and {rect2}".format(rect1=rect1, rect2=rect2)) found_overlap = True return found_overlap _log = log.init_logging("ucf-test") if __name__ == "__main__": # initialize command line input opts, args = parse_options() # set verbosity according to option log.set_level(opts.verbosity) _log.debug ("*"*40) _log.info (" UCF Overlap Tester") _log.info ("*"*40) ram_rects = [] slice_rects = [] for fname in opts.files: f = open(fname, 'r') for line_no, line in enumerate(f):
instance_string = 'INST "algo/deserialize' if serdes_type == "CALO": instance_string = instance_string + '_energies' elif serdes_type == "MU": instance_string = instance_string + '_muons' else: instance_string = instance_string + '_ERROR' instance_string = instance_string + '/deserialize_' instance_string = instance_string + str(instance_num) instance_string = instance_string + '" AREA_GROUP=quad_' instance_string = instance_string + str(area_group) instance_string = instance_string + ';' return instance_string _log = log.init_logging("ucf_serdes_constraints_generator") if __name__ == "__main__": # initialize command line input opts, args = parse_options() # set verbosity according to option log.set_level(opts.verbosity) _log.debug ("*"*40) _log.info (" UCF Serdes constraints generator") _log.info ("*"*40) _log.info ("Paste the following into your ucf file:") config_dict = VHDLConstantsParser.parse_vhdl_file(opts.files[0]) quad_dict = get_quad_areagroup_mapping(opts.files[1]) for key in sorted(config_dict):
from tools.vhdl import VHDLConstantsParser from tools.TDRStyle import TDRStyle from tools.muon_helpers import non_zero, print_out_word, print_in_word from tools.logger import log from gt_dump_analyser import get_gt_muons def append_non_zero(non_zero_mus, all_mus): for mu in all_mus: mu_tmp = Muon(vhdl_dict, mu_type="IN", obj=mu) if mu_tmp.bitword != 0: non_zero_mus.append(mu_tmp) if __name__ == "__main__": _log = log.init_logging("main") TDRStyle.initialize() TH1.AddDirectory(False) pi = math.pi gROOT.SetBatch() # gStyle.SetOptStat("ne") gStyle.SetHistMinimumZero() gStyle.SetPalette(1) canvas = TCanvas("canvas_of_plots","comparisons") canvas.SetFillStyle(0) vhdl_dict = VHDLConstantsParser.parse_vhdl_file("data/ugmt_constants.vhd") options = parse_options() file_dict = discover_files(options) ##### if the physical properties should be calculated, then the functions phi, eta and pt just have to be discommented. Doing this, the following parameters are their input.
TH1.AddDirectory(False) pi = math.pi gROOT.SetBatch() # gStyle.SetOptStat("ne") gStyle.SetHistMinimumZero() gStyle.SetPalette(1) canvas = TCanvas("canvas_of_plots", "comparisons") canvas.SetFillStyle(0) vhdl_dict = VHDLConstantsParser.parse_vhdl_file("data/ugmt_constants.vhd") options = parse_options() _log = None if options.verbose: _log = log.init_logging("BufferAnalyzer") else: _log = log.init_logging("BufferAnalyzer", INFO) file_dict = discover_files(options) ##### if the physical properties should be calculated, then the functions phi, eta and pt just have to be discommented. Doing this, the following parameters are their input. ##### They dont have any other use eta_unit = 0.01 eta_low = -240 eta_high = 239 phi_unit = 2 * pi / 576 phi_low = 0 phi_high = 57 pt_unit = 0.5 pt_low = 0
for varname, hist_property in namesdict.iteritems(): hist[varname] = ROOT.TH1D(varname + "{title}".format(title=title), "", hist_property[1], hist_property[2], hist_property[3]) hist[varname].SetXTitle(hist_property[0]) if __name__ == "__main__": ROOT.TH1.AddDirectory(False) ROOT.gROOT.SetBatch() ROOT.gStyle.SetOptStat("ne") ROOT.gStyle.SetHistMinimumZero() ROOT.gStyle.SetPalette(1) canvas = ROOT.TCanvas("canvas_of_plots", "comparisons") canvas.SetFillStyle(0) _log = log.init_logging("main") vhdl_dict = VHDLConstantsParser.parse_vhdl_file("data/ugmt_constants.vhd") options = parse_options() file_dict = discover_files(options) # binning of plots: hist_parameters = { "qualityBits": ["qualityBits", 16, 0, 16], "ptBits": ["ptBits", 128, 0, 512], #(pt_high-pt_low)/pt_unit, pt_low, pt_high], "phiBits": ["phiBits", 256, 0, 1024], #(phi_high-phi_low)/phi_unit, phi_low, phi_high], "etaBits": ["etaBits", 256, -512,
def test_rect_list(rect_list): found_overlap = False for i, rect1 in enumerate(rect_list): # the overlap is symmetric, only have to check once for j, rect2 in enumerate(rect_list[i:]): if i == j: continue overlap = Rect.test_overlap(rect1, rect2) if overlap: _log.info("{rect1} and {rect2}".format(rect1=rect1, rect2=rect2)) found_overlap = True return found_overlap _log = log.init_logging("ucf-test") if __name__ == "__main__": # initialize command line input opts, args = parse_options() # set verbosity according to option log.set_level(opts.verbosity) _log.debug("*" * 40) _log.info(" UCF Overlap Tester") _log.info("*" * 40) ram_rects = [] slice_rects = [] for fname in opts.files: f = open(fname, 'r') for line_no, line in enumerate(f):