Ejemplo n.º 1
0
    def TD_scan(self, GEMROC_num, to_all=False):
        if to_all:
            process_list = []
            pipe_list = []
            test_r_array = []
            for number, GEMROC_num in self.GEMROC_reading_dict.items():

                pipe_in, pipe_out = Pipe()
                p = Process(target=self.TD_scan_process,
                            args=(number, pipe_in))

                process_list.append(p)
                pipe_list.append(pipe_out)
                p.start()

            for process, pipe_out in zip(process_list, pipe_list):
                process.join()
                value, key = pipe_out.recv()
                process.terminate()
                self.TD_scan_result["GEMROC {}".format(key)] = value
            GEMROC_num = -1

        else:
            GEMROC = self.GEMROC_reading_dict["GEMROC {}".format(GEMROC_num)]
            GEM_COM = GEMROC.GEM_COM
            c_inst = GEMROC.c_inst
            g_inst = GEMROC.g_inst
            test_r = (AN_CLASS.analisys_conf(GEM_COM, c_inst, g_inst))
            safe_delays = test_r.TIGER_delay_tuning()
            self.TD_scan_result["GEMROC {}".format(GEMROC_num)] = safe_delays
        self.save_values(GEMROC_num)
Ejemplo n.º 2
0
 def TD_scan_process(self,number,pipe_in):
     GEMROC=self.GEMROC_reading_dict[number]
     GEM_COM = GEMROC.GEM_COM
     c_inst = GEMROC.c_inst
     g_inst = GEMROC.g_inst
     test_r = (AN_CLASS.analisys_conf(GEM_COM, c_inst, g_inst))
     safe_delays = test_r.TIGER_delay_tuning()
     pipe_in.send((safe_delays,test_r.GEMROC_ID))
     pipe_in.close()
     test_r.__del__()
Ejemplo n.º 3
0
 def procedural_scan(self,
                     des_rate=3500,
                     number_of_cycle=2,
                     square_size=5,
                     acq_time=0.1):
     """
     Scan in a square around the current thr, then set the threshold to the value more near to the desidered value
     :param des_rate:
     :param number_of_cycle:
     :param square_size:
     :return:
     """
     for cycle in range(number_of_cycle):
         for key, GEMROC in self.GEMROC_reading_dic.items():
             GEM_COM = GEMROC.GEM_COM
             for T in range(0, 8):
                 for ch in range(0, 64):
                     vt1_current = GEMROC.c_inst.Channel_cfg_list[T][ch][
                         'Vth_T1']
                     vt2_current = GEMROC.c_inst.Channel_cfg_list[T][ch][
                         'Vth_T2']
                     c_inst = GEMROC.c_inst
                     g_inst = GEMROC.g_inst
                     test_c = AN_CLASS.analisys_conf(
                         GEM_COM, c_inst, g_inst)
                     scan_matrix = test_c.both_vth_scan(
                         T,
                         ch,
                         extreme_t=(vt1_current - (square_size - 1) / 2,
                                    vt1_current + (square_size - 1) / 2),
                         extreme_e=((vt2_current - (square_size - 1) / 2,
                                     vt2_current + (square_size - 1) / 2)),
                         acq_time=acq_time)
                     scan_matrix = scan_matrix * (1 / (acq_time))
                     diff_matrix = abs(scan_matrix - des_rate)
                     vt1, vt2 = (np.argmin(diff_matrix) // 64,
                                 np.argmin(diff_matrix) % 64)
                     print("Ch {} -set vth1 {}, set vth 2 {}".format(
                         ch, vt1, vt2))
                     GEMROC.c_inst.Channel_cfg_list[T][ch]['Vth_T1'] = vt1
                     GEMROC.c_inst.Channel_cfg_list[T][ch]['Vth_T2'] = vt2
                     GEMROC.GEM_COM.WriteTgtGEMROC_TIGER_ChCfgReg(
                         c_inst, T, ch)
Ejemplo n.º 4
0
    def procedural_scan_process(self,
                                GEMROC,
                                pipeout,
                                des_rate=3500,
                                number_of_cycle=2,
                                square_size=5,
                                acq_time=0.1,
                                conditional=False,
                                tollerance=0.5):
        """
        Procedural scan with multiprocess
        :param GEMROC:
        :param pipeout:
        :param des_rate:
        :param des_rate:
        :param number_of_cycle:
        :param square_size:
        :param acq_time:
        :return:
        """
        GEM_COM = GEMROC.GEM_COM

        if debug:
            with open(
                    "./log_folder/auto_thr_setting_log_GEMROC{}.txt".format(
                        GEM_COM.GEMROC_ID), "w+") as logfile:
                logfile.write(
                    "Aiming at {}, {} cycles, conditional = {}".format(
                        des_rate, number_of_cycle, conditional))
            print("Starting")
        for cycle in range(number_of_cycle):
            # maximum_matrix = GEM_COM.load_thr_max_from_file()
            for T in range(0, 8):
                for ch in range(0, 64):
                    if debug:
                        with open(
                                "./log_folder/auto_thr_setting_log_GEMROC{}.txt"
                                .format(GEM_COM.GEMROC_ID), "a+") as logfile:
                            logfile.write("T {} ch{}\n".format(T, ch))
                    vt1_current = GEMROC.c_inst.Channel_cfg_list[T][ch][
                        'Vth_T1']
                    vt2_current = GEMROC.c_inst.Channel_cfg_list[T][ch][
                        'Vth_T2']
                    c_inst = GEMROC.c_inst
                    g_inst = GEMROC.g_inst
                    if debug:
                        with open(
                                "./log_folder/auto_thr_setting_log_GEMROC{}.txt"
                                .format(GEM_COM.GEMROC_ID), "a+") as logfile:
                            logfile.write("Current VT1-{} VT2-{}\n".format(
                                vt1_current, vt2_current))
                    test_c = AN_CLASS.analisys_conf(GEM_COM, c_inst, g_inst)

                    if conditional:
                        scan_matrix = test_c.both_vth_scan(
                            T,
                            ch,
                            extreme_t=(vt1_current, vt1_current),
                            extreme_e=(vt2_current, vt2_current),
                            acq_time=acq_time)
                        scan_matrix = scan_matrix * (1 / (acq_time))
                        if scan_matrix[vt1_current][vt2_current] < des_rate * (
                                1 + tollerance) and scan_matrix[vt1_current][
                                    vt2_current] > des_rate * (1 - tollerance):
                            if debug:
                                with open(
                                        "./log_folder/auto_thr_setting_log_GEMROC{}.txt"
                                        .format(GEM_COM.GEMROC_ID),
                                        "a+") as logfile:
                                    logfile.write(
                                        "No need to change gemroc {}, TIGER {}, channel{}\n"
                                        .format(GEMROC.GEMROC_ID, T, ch))
                            pipeout.send(GEM_COM.GEMROC_ID)
                            pipeout.send(T)
                            pipeout.send(ch)
                            pipeout.send(vt1_current)
                            pipeout.send(vt2_current)
                            continue
                        elif debug:
                            with open(
                                    "./log_folder/auto_thr_setting_log_GEMROC{}.txt"
                                    .format(GEM_COM.GEMROC_ID),
                                    "a+") as logfile:
                                logfile.write(
                                    "Tollerated rate {}-{}, acquired rate: {}\n"
                                    .format(
                                        des_rate * (1 + tollerance),
                                        des_rate * (1 - tollerance),
                                        scan_matrix[vt1_current][vt2_current]))
                    scan_matrix = test_c.both_vth_scan(
                        T,
                        ch,
                        extreme_t=(vt1_current - (square_size - 1) / 2,
                                   vt1_current + (square_size - 1) / 2),
                        extreme_e=((vt2_current - (square_size - 1) / 2,
                                    vt2_current + (square_size - 1) / 2)),
                        acq_time=acq_time)
                    scan_matrix = scan_matrix * (1 / (acq_time))
                    diff_matrix = abs(scan_matrix - des_rate)
                    vt1, vt2 = (np.argmin(diff_matrix) // 64,
                                np.argmin(diff_matrix) % 64)
                    # print "T {} Ch {} -set vth1 {}, set vth 2 {}".format(T,ch,vt1,vt2)
                    GEMROC.c_inst.Channel_cfg_list[T][ch]['Vth_T1'] = vt1
                    GEMROC.c_inst.Channel_cfg_list[T][ch]['Vth_T2'] = vt2
                    if debug:
                        with open(
                                "./log_folder/auto_thr_setting_log_GEMROC{}.txt"
                                .format(GEM_COM.GEMROC_ID), "a+") as logfile:
                            logfile.write("VT1 = {}, VT2 = {}\n".format(
                                vt1, vt2))
                    GEM_COM.WriteTgtGEMROC_TIGER_ChCfgReg(c_inst, T, ch)
                    pipeout.send(GEM_COM.GEMROC_ID)
                    pipeout.send(T)
                    pipeout.send(ch)
                    pipeout.send(vt1)
                    pipeout.send(vt2)
                print("T {} done".format(T))

        pipeout.send(65)
        return
Ejemplo n.º 5
0
g_inst_list = []
c_inst_list = []
GEM_AN_list = []
configuration_error_list = []

for G in range(first, last):
    GEM_COM_list.append(COM_class.communication(G, FEB_PWR_EN_pattern))
    default_g_inst_settigs_filename = GEM_COM_list[
        G - first].conf_folder + sep + "TIGER_def_g_cfg_2018.txt"
    default_c_inst_settigs_filename = GEM_COM_list[
        G - first].conf_folder + sep + "TIGER_def_ch_cfg_2018.txt"

    g_inst_list.append(
        GEM_CONF.g_reg_settings(G, default_g_inst_settigs_filename))
    c_inst_list.append(
        GEM_CONF.ch_reg_settings(G, default_c_inst_settigs_filename))

    GEM_AN_list.append(
        AN_CLASS.analisys_conf(GEM_COM_list[G - first], c_inst_list[G - first],
                               g_inst_list[G - first]))

for G in range(first, last):
    print "Turning ON FEBs on GEMROC {}".format(G)
    GEM_COM_list[G - first].FEBPwrEnPattern_set(int(0xff))
    GEM_AN_list[G - first].TIGER_config_test()  #Configuration test
    GEM_AN_list[G - first].TIGER_TP_test()  #Test pulse reception test
    GEM_AN_list[
        G - first].TIGER_GEMROC_sync_test()  #Test the GEMROC syncronous reset
    print "Turning OFF febs on GEMROC {}".format(G)
    GEM_COM_list[G - first].FEBPwrEnPattern_set(int(0x0))