def scan(self): '''Metascript that calls other scripts to tune the FE. Parameters ---------- cfg_name : string Name of the config to be created. This config holds the tuning results. target_threshold : int The target threshold value in PlsrDAC. target_charge : int The target charge in PlsrDAC value to tune to. target_tot : int The target tot value to tune to. global_iterations : int Defines how often global threshold/global feedback current tuning is repeated. -1: the global tuning is disabled 0: the global tuning consists of the global threshold tuning only 1: global threshold/global feedback current/global threshold tuning 2: global threshold/global feedback current/global threshold tuning/global feedback current/global threshold tuning ... local_iterations : int Defines how often local threshold (TDAC) / feedback current (FDAC) tuning is repeated. -1: the local tuning is disabled 0: the local tuning consists of the local threshold tuning only (TDAC) 1: TDAC/FDAC/TDAC 2: TDAC/FDAC/TDAC/FDAC/TDAC ... ''' if self.global_iterations < 0: self.global_iterations = 0 if self.local_iterations < 0: self.local_iterations = 0 difference_bit = 1 if self.make_plots: self.plots_filename = PdfPages(self.output_filename + '.pdf') else: self.plots_filename = None start_bit = 7 for iteration in range(0, self.global_iterations): # tune iteratively with decreasing range to save time logging.info("Global tuning step %d / %d" % (iteration + 1, self.global_iterations)) start_bit = 7 # - difference_bit * iteration self.set_scan_parameters(global_step=self.scan_parameters.global_step + 1) self.gdac_tune_bits = range(start_bit, -1, -1) GdacTuning.scan(self) self.set_scan_parameters(global_step=self.scan_parameters.global_step + 1) self.feedback_tune_bits = range(start_bit, -1, -1) FeedbackTuning.scan(self) if self.global_iterations >= 0: self.set_scan_parameters(global_step=self.scan_parameters.global_step + 1) self.gdac_tune_bits = range(start_bit, -1, -1) GdacTuning.scan(self) Vthin_AC = self.register.get_global_register_value("Vthin_AltCoarse") Vthin_AF = self.register.get_global_register_value("Vthin_AltFine") PrmpVbpf = self.register.get_global_register_value("PrmpVbpf") logging.info("Results of global threshold tuning: Vthin_AltCoarse / Vthin_AltFine = %d / %d" % (Vthin_AC, Vthin_AF)) logging.info("Results of global feedback tuning: PrmpVbpf = %d" % (PrmpVbpf,)) difference_bit = int(5 / (self.local_iterations if self.local_iterations > 0 else 1)) start_bit = 4 for iteration in range(0, self.local_iterations): logging.info("Local tuning step %d / %d" % (iteration + 1, self.local_iterations)) start_bit = 4 # - difference_bit * iteration self.tdac_tune_bits = range(start_bit, -1, -1) TdacTuning.scan(self) self.fdac_tune_bits = range(start_bit - 1, -1, -1) FdacTuning.scan(self) if self.local_iterations >= 0: self.tdac_tune_bits = range(start_bit, -1, -1) TdacTuning.scan(self)
def scan(self): '''Metascript that calls other scripts to tune the FE. Parameters ---------- cfg_name : string Name of the config to be created. This config holds the tuning results. target_threshold : int The target threshold value in PlsrDAC. target_charge : int The target charge in PlsrDAC value to tune to. target_tot : float The target tot value to tune to. global_iterations : int Defines how often global threshold (GDAC) / global feedback (PrmpVbpf) current tuning is repeated. -1 or None: Global tuning is disabled 0: Only global threshold tuning 1: GDAC -> PrmpVbpf -> GDAC 2: GDAC -> PrmpVbpf -> GDAC -> PrmpVbpf -> GDAC ... local_iterations : int Defines how often local threshold (TDAC) / feedback current (FDAC) tuning is repeated. -1 or None: Local tuning is disabled 0: Only local threshold tuning 1: TDAC -> FDAC -> TDAC 2: TDAC -> FDAC -> TDAC -> FDAC -> TDAC ... ''' if self.global_iterations is None: self.global_iterations = -1 if self.local_iterations is None: self.local_iterations = -1 if self.make_plots: self.plots_filename = PdfPages(self.output_filename + '.pdf') else: self.plots_filename = None for iteration in range(0, self.global_iterations): # tune iteratively with decreasing range to save time logging.info("Global tuning step %d / %d", iteration + 1, self.global_iterations) self.set_scan_parameters(global_step=self.scan_parameters.global_step + 1) GdacTuning.scan(self) self.set_scan_parameters(global_step=self.scan_parameters.global_step + 1) FeedbackTuning.scan(self) if self.global_iterations >= 0: self.set_scan_parameters(global_step=self.scan_parameters.global_step + 1) GdacTuning.scan(self) Vthin_AC = self.register.get_global_register_value("Vthin_AltCoarse") Vthin_AF = self.register.get_global_register_value("Vthin_AltFine") PrmpVbpf = self.register.get_global_register_value("PrmpVbpf") logging.info("Results of global threshold tuning: Vthin_AltCoarse / Vthin_AltFine = %d / %d", Vthin_AC, Vthin_AF) logging.info("Results of global feedback tuning: PrmpVbpf = %d", PrmpVbpf) for iteration in range(0, self.local_iterations): logging.info("Local tuning step %d / %d", iteration + 1, self.local_iterations) self.set_scan_parameters(local_step=self.scan_parameters.local_step + 1) TdacTuning.scan(self) self.set_scan_parameters(local_step=self.scan_parameters.local_step + 1) FdacTuning.scan(self) if self.local_iterations >= 0: self.set_scan_parameters(local_step=self.scan_parameters.local_step + 1) TdacTuning.scan(self)
def scan(self): '''Metascript that calls other scripts to tune the FE. Parameters ---------- cfg_name : string Name of the config to be created. This config holds the tuning results. target_threshold : int The target threshold value in PlsrDAC. target_charge : int The target charge in PlsrDAC value to tune to. target_tot : float The target tot value to tune to. global_iterations : int Defines how often global threshold/global feedback current tuning is repeated. -1: the global tuning is disabled 0: the global tuning consists of the global threshold tuning only 1: global threshold/global feedback current/global threshold tuning 2: global threshold/global feedback current/global threshold tuning/global feedback current/global threshold tuning ... local_iterations : int Defines how often local threshold (TDAC) / feedback current (FDAC) tuning is repeated. -1: the local tuning is disabled 0: the local tuning consists of the local threshold tuning only (TDAC) 1: TDAC/FDAC/TDAC 2: TDAC/FDAC/TDAC/FDAC/TDAC ... ''' if self.global_iterations < 0: self.global_iterations = 0 if self.local_iterations < 0: self.local_iterations = 0 # difference_bit = 1 if self.make_plots: self.plots_filename = PdfPages(self.output_filename + '.pdf') else: self.plots_filename = None start_bit = 7 for iteration in range(0, self.global_iterations): # tune iteratively with decreasing range to save time logging.info("Global tuning step %d / %d", iteration + 1, self.global_iterations) start_bit = 7 # - difference_bit * iteration self.set_scan_parameters(global_step=self.scan_parameters.global_step + 1) self.gdac_tune_bits = range(start_bit, -1, -1) GdacTuning.scan(self) self.set_scan_parameters(global_step=self.scan_parameters.global_step + 1) self.feedback_tune_bits = range(start_bit, -1, -1) FeedbackTuning.scan(self) if self.global_iterations >= 0: self.set_scan_parameters(global_step=self.scan_parameters.global_step + 1) self.gdac_tune_bits = range(start_bit, -1, -1) GdacTuning.scan(self) Vthin_AC = self.register.get_global_register_value("Vthin_AltCoarse") Vthin_AF = self.register.get_global_register_value("Vthin_AltFine") PrmpVbpf = self.register.get_global_register_value("PrmpVbpf") logging.info("Results of global threshold tuning: Vthin_AltCoarse / Vthin_AltFine = %d / %d", Vthin_AC, Vthin_AF) logging.info("Results of global feedback tuning: PrmpVbpf = %d", PrmpVbpf) # difference_bit = int(5 / (self.local_iterations if self.local_iterations > 0 else 1)) start_bit = 4 for iteration in range(0, self.local_iterations): logging.info("Local tuning step %d / %d", iteration + 1, self.local_iterations) start_bit = 4 # - difference_bit * iteration self.tdac_tune_bits = range(start_bit, -1, -1) TdacTuning.scan(self) self.fdac_tune_bits = range(start_bit - 1, -1, -1) FdacTuning.scan(self) if self.local_iterations >= 0: self.tdac_tune_bits = range(start_bit, -1, -1) TdacTuning.scan(self)
def scan(self): '''Metascript that calls other scripts to tune the FE. Parameters ---------- cfg_name : string Name of the config to be created. This config holds the tuning results. target_threshold : int The target threshold value in PlsrDAC. target_charge : int The target charge in PlsrDAC value to tune to. target_tot : float The target tot value to tune to. global_iterations : int Defines how often global threshold (GDAC) / global feedback (PrmpVbpf) current tuning is repeated. -1 or None: Global tuning is disabled 0: Only global threshold tuning 1: GDAC -> PrmpVbpf -> GDAC 2: GDAC -> PrmpVbpf -> GDAC -> PrmpVbpf -> GDAC ... local_iterations : int Defines how often local threshold (TDAC) / feedback current (FDAC) tuning is repeated. -1 or None: Local tuning is disabled 0: Only local threshold tuning 1: TDAC -> FDAC -> TDAC 2: TDAC -> FDAC -> TDAC -> FDAC -> TDAC ... ''' for iteration in range(0, self.global_iterations): # tune iteratively with decreasing range to save time if self.stop_run.is_set(): break logging.info("Global tuning step %d / %d", iteration + 1, self.global_iterations) self.set_scan_parameters(global_step=self.scan_parameters.global_step + 1) GdacTuning.scan(self) commands = [] commands.extend(self.register.get_commands("ConfMode")) commands.extend(self.register.get_commands("WrRegister", name=["Vthin_AltCoarse", "Vthin_AltFine"])) commands.extend(self.register.get_commands("RunMode")) self.register_utils.send_commands(commands) if self.stop_run.is_set(): break self.set_scan_parameters(global_step=self.scan_parameters.global_step + 1) FeedbackTuning.scan(self) commands = [] commands.extend(self.register.get_commands("ConfMode")) commands.extend(self.register.get_commands("WrRegister", name=["PrmpVbpf"])) commands.extend(self.register.get_commands("RunMode")) self.register_utils.send_commands(commands) if self.global_iterations >= 0 and not self.stop_run.is_set(): self.set_scan_parameters(global_step=self.scan_parameters.global_step + 1) GdacTuning.scan(self) commands = [] commands.extend(self.register.get_commands("ConfMode")) commands.extend(self.register.get_commands("WrRegister", name=["Vthin_AltCoarse", "Vthin_AltFine"])) commands.extend(self.register.get_commands("RunMode")) self.register_utils.send_commands(commands) Vthin_AC = self.register.get_global_register_value("Vthin_AltCoarse") Vthin_AF = self.register.get_global_register_value("Vthin_AltFine") PrmpVbpf = self.register.get_global_register_value("PrmpVbpf") logging.info("Results of global threshold tuning: Vthin_AltCoarse / Vthin_AltFine = %d / %d", Vthin_AC, Vthin_AF) logging.info("Results of global feedback tuning: PrmpVbpf = %d", PrmpVbpf) for iteration in range(0, self.local_iterations): if self.stop_run.is_set(): break logging.info("Local tuning step %d / %d", iteration + 1, self.local_iterations) self.set_scan_parameters(local_step=self.scan_parameters.local_step + 1) TdacTuning.scan(self) commands = [] commands.extend(self.register.get_commands("ConfMode")) commands.extend(self.register.get_commands("WrFrontEnd", same_mask_for_all_dc=False, name="TDAC")) commands.extend(self.register.get_commands("RunMode")) self.register_utils.send_commands(commands) if self.stop_run.is_set(): break self.set_scan_parameters(local_step=self.scan_parameters.local_step + 1) FdacTuning.scan(self) commands = [] commands.extend(self.register.get_commands("ConfMode")) commands.extend(self.register.get_commands("WrFrontEnd", same_mask_for_all_dc=False, name="FDAC")) commands.extend(self.register.get_commands("RunMode")) self.register_utils.send_commands(commands) if self.local_iterations >= 0 and not self.stop_run.is_set(): self.set_scan_parameters(local_step=self.scan_parameters.local_step + 1) TdacTuning.scan(self) commands = [] commands.extend(self.register.get_commands("ConfMode")) commands.extend(self.register.get_commands("WrFrontEnd", same_mask_for_all_dc=False, name="TDAC")) commands.extend(self.register.get_commands("RunMode")) self.register_utils.send_commands(commands)