Exemple #1
0
def prepare_singleQuad_xml_files(type_name, type_setting, modules=modulelist):
    for module in modules:
        xmlfilename = os.path.join(
            xmlfolder, 'CMSIT_singleQuad_%s_%s.xml' % (module, type_name))
        xmlobject = XMLInfo(xmlfilename)
        for setting in daqsettings_per_xmltype[type_setting]:
            xmlobject.set_daq_settings(
                setting, daqsettings_per_xmltype[type_setting][setting])
        for chip in chiplist:
            xmlobject.set_chip_attribute_by_moduleid(1, chip, 'Lane', str(
                chip))  # the lane corresponds to the chip ID on the single AB
            xmlobject.set_chip_attribute_by_moduleid(
                1, chip, 'configfile',
                'CMSIT_RD53_%s_chip%i_default.txt' % (module, chip))

        chip_settings_thismodule = chip_settings[module]
        keepchips = []
        for chip in chip_settings_thismodule:
            settings = chip_settings_thismodule[chip]
            for setting in settings:
                xmlobject.set_chip_setting_by_modulename(
                    module, chip, setting, settings[setting])
        xmlobject.keep_only_chips_by_modulename(
            module, chip_settings_thismodule.keys())
        xmlobject.save_xml_as(xmlfilename)
Exemple #2
0
def run_ber_scan(modules,
                 chips_per_module,
                 ring,
                 positions,
                 tap_settings=[],
                 mode='time',
                 value=10):

    # first, enable TAP1, TAP2

    for moduleidx, module in enumerate(modules):
        for chip in chips_per_module[module]:

            if ring == 'singleQuad':
                if not len(modules) == 1:
                    raise AttributeError(
                        'Trying to run BER in singleQuad mode with mode than one module'
                    )
                module = modules[0]
                xmlfile_for_ber = os.path.join(
                    xmlfolder, 'CMSIT_%s_%s_%s.xml' % (ring, module, 'ber'))
                reset_singleQuad_xml_files(type='ber',
                                           modules=modules,
                                           chips=chips)
                prepare_singleQuad_xml_files(type_name='ber',
                                             type_setting='scurve',
                                             modules=modules)
            elif ring == 'R1':
                xmlfile_for_ber = os.path.join(
                    xmlfolder, 'CMSIT_disk%s_%s.xml' % (ring, 'ber'))
                reset_and_prepare_Ring_xml_file('ber', 'scurve',
                                                ids_and_chips_per_module_R1,
                                                ring)
            elif ring == 'R3':
                xmlfile_for_ber = os.path.join(
                    xmlfolder, 'CMSIT_disk%s_%s.xml' % (ring, 'ber'))
            xmlobject = XMLInfo(xmlfile_for_ber)
            print module, chip
            xmlobject.keep_only_modules_by_modulename([module])
            xmlobject.keep_only_chips_by_modulename(module, [chip])
            xmlobject.set_chip_setting_by_modulename(module, chip,
                                                     'CML_CONFIG', '127')

            # now, in a loop, set TAP values to scan through
            for tap0, tap1, tap2 in tap_settings:
                print(tap0, tap1, tap2)
                xmlobject.set_chip_setting_by_modulename(
                    module, chip, 'CML_TAP0_BIAS', str(tap0))
                xmlobject.set_chip_setting_by_modulename(
                    module, chip, 'CML_TAP1_BIAS', str(tap1))
                xmlobject.set_chip_setting_by_modulename(
                    module, chip, 'CML_TAP2_BIAS', str(tap2))
                xmlobject.save_xml_as(xmlfile_for_ber)

                # assemble the OS command
                if mode is 'time': tuningstepname = 'prbstime'
                elif mode is 'frames': tuningstepname = 'prbsframes'
                else:
                    raise AttributeError(
                        'Function \'run_ber_scan()\' received invalid argument for \'mode\': %s. Must be \'time\' or \'frames\''
                        % mode)
                command_p = 'CMSITminiDAQ -f %s p' % (xmlfile_for_ber)
                command_ber = 'CMSITminiDAQ -f %s -c %s %i BE-FE 2>&1 | tee %s' % (
                    xmlfile_for_ber, tuningstepname, value,
                    os.path.join(
                        logfolder, 'ber_%s_%s_chip%i_pos%s_%i_%i_%i.log' %
                        (ring, module, chip, str(
                            positions[moduleidx]), tap0, tap1, tap2)))

                # execute the OS command
                print(command_p)
                os.system(command_p)
                time.sleep(1)
                print(command_ber)
                os.system(command_ber)
                time.sleep(2)