def run_scan(scan, run_conf=None): run_manager = RunManager(_configuration_folder) run_manager.run_run(scan, run_conf=run_conf) error_msg = '' try: error_msg = str(run_manager.current_run.err_queue.get(timeout=1)[1]) except Empty: pass return run_manager.current_run._run_status == 'FINISHED', error_msg, run_manager.current_run.output_filename, run_manager.current_run._default_run_conf, run_manager.current_run.__class__.__name__
def run_scan(scan, run_conf=None): run_manager = RunManager(_configuration_folder) run_manager.run_run(scan, run_conf=run_conf) error_msg = '' try: error_msg = str(run_manager._current_run.err_queue.get(timeout=1)[1]) except Empty: pass return run_manager._current_run._run_status == 'FINISHED', error_msg, run_manager._current_run.output_filename, run_manager._current_run._default_run_conf, run_manager._current_run.__class__.__name__
def test_global_register(self, mock_send_commands, mock_configure_pixel): run_manager = RunManager('test_interface/configuration.yaml') run_manager.run_run(RegisterTest, run_conf={'test_pixel': False}) error_msg = 'Global register test failed. ' try: error_msg += str(run_manager.current_run.err_queue.get(timeout=1)[1]) except Empty: pass ok = (run_manager.current_run._run_status == 'FINISHED') self.assertTrue(ok, msg=error_msg)
def test_global_register(self, mock_configure_pixel, mock_send_commands): run_manager = RunManager('test_interface/configuration.yaml') run_manager.run_run(RegisterTest, run_conf={'test_pixel': False}) error_msg = 'Global register test failed. ' try: error_msg += str( run_manager._current_run.err_queue.get(timeout=1)[1]) except Empty: pass ok = (run_manager._current_run._run_status == 'FINISHED') self.assertTrue(ok, msg=error_msg)
# run_conf[item] = pp.GetConfigParameter(item) # except: # pass rmngr = RunManager( '../configuration.yaml') # TODO: get conf from EUDAQ pp.Configuring = True # check for start of run cmd from RunControl while not pp.StartingRun and not pp.Terminating: if pp.Configuring: break sleep(1) # check if we are starting: if pp.StartingRun: print "Starting run..." # join = rmngr.run_run(EudaqExtTriggerScan, run_conf=run_conf, use_thread=True) join = rmngr.run_run(EudaqExtTriggerScan, use_thread=True) sleep(5) pp.StartingRun = True # set status and send BORE # starting to run while join(timeout=1) is None: if pp.Error or pp.Terminating: rmngr.abort_current_run() if pp.StoppingRun: rmngr.stop_current_run() status = join() # abort conditions if status is not run_status.finished or pp.Error or pp.Terminating: pp.StoppingRun = False # set status and send EORE # check if the run is stopping regularly if pp.StoppingRun: pp.StoppingRun = True # set status and send EORE
from pybar.run_manager import RunManager # importing run manager from pybar.scans.scan_analog import AnalogScan from pybar.scans.scan_ext_trigger_gdac import ExtTriggerGdacScan from pybar.run_manager import run_status if __name__ == "__main__": runmngr = RunManager('../../pybar/configuration.yaml') # loading configuration file, specifying hardware configuration and module configuration. # # Running primlist: runmngr.run_primlist('example_run_manager.plst', skip_remaining=True) # executing primlist.plst file, specific scan parameters are set inside the primlist file, skip remaining scans on error # Each scan has a default configuration, which is defined inside the corresponding scan file in /host/pybar/scans/. It is not necessary to define scan parameters inside primlist file. # # Running single scan and changing scan parameters: join = runmngr.run_run(run=AnalogScan, run_conf={"scan_parameters": [('PlsrDAC', 500)], "n_injections": 1000}, use_thread=True) # run_run returns a function object when use_thread is True status = join() print 'Status:', status # will wait for scan to be finished and returns run status # # Or use a run configuration file: status = runmngr.run_run(run=AnalogScan, run_conf="run_configuration.txt") # using no thread print 'Status:', status # # Example for a loop: for gdac in range(50, 200, 10): join = runmngr.run_run(ExtTriggerGdacScan, run_conf={'scan_parameters': {'GDAC': gdac}}, use_thread=True) # use thread print 'Status:', join(timeout=5) # join has a timeout, return None if run has not yet finished runmngr.abort_current_run() # stopping/aborting run from outside if join() != run_status.finished: # status OK? print 'ERROR!' break # jump out # # After finishing the primlist/run: you will find the module data relative to the configuration.yaml file.
charge_calibration[column, row, :, 1])) and np.all( np.isfinite(charge_calibration[column, row, :, 3])): mean_signal_to_noise += ( charge_calibration[column, row, :, 1] / charge_calibration[column, row, :, 3]) mean_signal_to_noise /= valid_pixel[0].shape[0] return mean_signal_to_noise if __name__ == "__main__": plsr_dacs = [40, 50, 60, 80, 130, 180, 230, 280, 340, 440, 540, 640, 740] # PlsrDAC setting for hit OR calibration scan runmngr = RunManager(r'../../pybar/configuration.yaml') runmngr.run_run(run=FastThresholdScan) # initial threshold check actual_vthin_alt_fine = runmngr.current_run.register.get_global_register_value( "Vthin_AltFine") sns = [] # SN values # Take data for dis_vbn in [ 40, ]: # analog discriminator bias loop for vthin_alt_fine in range(actual_vthin_alt_fine, 256, 100): # threshold loop for prmp_vbpf in range(0, 256, 32): # feedback current loop runmngr.current_run.register.set_global_register_value( "PrmpVbpf", prmp_vbpf) runmngr.current_run.register.set_global_register_value( "Vthin_AltFine", vthin_alt_fine)
# # (from configuration.yaml) # fe_configuration: 1 # ... # # This will retain the configuration for the following scans. # Please note: no configuration file exists at this stage because no run was executed so far. # # Executing runs defined by a primlist: runmngr.run_primlist('example_run_manager.plst', skip_remaining=True) # executing primlist.plst file, specific run configuration are set inside the primlist file, skip remaining scans on error # press Ctrl-C to abort the run at any time # Each scan has a default run configuration, which is defined inside the corresponding scan file in /host/pybar/scans/. # It is not necessary to add run parameters to the primlist file. If not given they are taken from the default run configuration (_default_run_conf). # # Running a single scan and changing default run configuration (_default_run_conf): join = runmngr.run_run(run=AnalogScan, run_conf={"scan_parameters": [('PlsrDAC', 500)], "n_injections": 1000}, use_thread=True) # run_run returns a function object when use_thread is True status = join() # waiting here for finishing the run, press Ctrl-C to abort the run at any time print 'Status:', status # will wait for run to be finished and returns run status # # Or use a run configuration file: status = runmngr.run_run(run=AnalogScan, run_conf="example_run_manager_run_config.txt") # using no thread print 'Status:', status # # Example for a loop of runs, which is failing: for delay in range(14, 50, 16): join = runmngr.run_run(ExtTriggerScan, run_conf={"trigger_delay": delay, "no_data_timeout": 60}, use_thread=True) # use thread print 'Status:', join(timeout=5) # join has a timeout, return None if run has not yet finished runmngr.abort_current_run("Calling abort_current_run(). This scan was aborted by intention") # stopping/aborting run from outside (same effect has Ctrl-C) if join() != run_status.finished: # status OK? print 'ERROR! This error was made by intention!' break # jump out
from pybar.scans.scan_digital import DigitalScan from pybar.scans.scan_analog import AnalogScan from pybar.scans.scan_threshold import ThresholdScan from pybar.scans.tune_fei4 import Fei4Tuning from pybar.scans.tune_stuck_pixel import StuckPixelScan from pybar.scans.tune_noise_occupancy import NoiseOccupancyScan from pybar.scans.tune_merged_pixels import MergedPixelsTuning # additional run configuration (optinal) run_conf = None # use path to YAML file, or dict if __name__ == "__main__": runmngr = RunManager('../../pybar/configuration.yaml') # configuration YAML file, open it for more details, it may contain run configuration # pre tuning status = runmngr.run_run(run=DigitalScan, run_conf=run_conf) print 'Status:', status status = runmngr.run_run(run=ThresholdScan, run_conf=run_conf) print 'Status:', status status = runmngr.run_run(run=AnalogScan, run_conf=run_conf) print 'Status:', status # tuning status = runmngr.run_run(run=Fei4Tuning, run_conf=run_conf) print 'Status:', status # post tuning status = runmngr.run_run(run=ThresholdScan, run_conf=run_conf) print 'Status:', status
# try: # run_conf[item] = pp.GetConfigParameter(item) # except: # pass rmngr = RunManager("../configuration.yaml") # TODO: get conf from EUDAQ pp.Configuring = True # check for start of run cmd from RunControl while not pp.StartingRun and not pp.Terminating: if pp.Configuring: break sleep(1) # check if we are starting: if pp.StartingRun: print "Starting run..." # join = rmngr.run_run(EudaqExtTriggerScan, run_conf=run_conf, use_thread=True) join = rmngr.run_run(EudaqExtTriggerScan, use_thread=True) sleep(5) pp.StartingRun = True # set status and send BORE # starting to run while join(timeout=1) is None: if pp.Error or pp.Terminating: rmngr.abort_current_run() if pp.StoppingRun: rmngr.stop_current_run() status = join() # abort conditions if status is not run_status.finished or pp.Error or pp.Terminating: pp.StoppingRun = False # set status and send EORE # check if the run is stopping regularly if pp.StoppingRun: pp.StoppingRun = True # set status and send EORE
# except Exception: # pass if runmngr: runmngr.close() runmngr = None runmngr = RunManager( 'configuration.yaml') # TODO: get conf from EUDAQ pp.Configuring = True # check if we are starting: if pp.StartingRun: run_number = pp.GetRunNumber() logging.info("Starting run EUDAQ run %d..." % run_number) # join = runmngr.run_run(EudaqExtTriggerScan, run_conf=run_conf, use_thread=True) join = runmngr.run_run( EudaqExtTriggerScan, use_thread=True, run_conf={"comment": "EUDAQ run %d" % run_number}) # sleep(5) # pp.StartingRun = True # set status and send BORE # starting run while join(timeout=1) == run_status.running: if pp.Error or pp.Terminating: logging.error("EUDAQ run %d forcibly stopped" % run_number) runmngr.cancel_current_run(msg="Run stopped by RunControl") status = join() logging.info("Run status: %s" % status) # abort conditions if pp.StoppingRun: pp.StoppingRun = True # set status and send EORE if runmngr is not None: runmngr.close()
# Tuning cref = 12 target_threshold = 34 target_charge = 300 target_tot = 9 # TDC measurements plsr_dacs = [target_threshold, 40, 50, 60, 80, 100, 120, 150, 200, 250, 300, 350, 400, 500, 600, 700, 800] # PlsrDAC range for TDC calibration, should start at threshold col_span = [55, 75]#[50, 78] # pixel column range to use in TDC scans row_span = [125, 225]#[20, 315] # pixel row range to use in TDC scans tdc_pixel = make_box_pixel_mask_from_col_row(column=[col_span[0], col_span[1]], row=[row_span[0], row_span[1]]) # edge pixel are not used in analysis runmngr = RunManager('configuration.yaml') # IV scan runmngr.run_run(run=IVScan, run_conf={"voltages": np.arange(-1, max_iv_voltage - 1, -1), "max_voltage": max_iv_voltage, "bias_voltage": bias_voltage, "minimum_delay": 0.5}) # FE check and complete tuning runmngr.run_run(run=RegisterTest) runmngr.run_run(run=DigitalScan) # digital scan with std. settings if runmngr.current_run.register.flavor == 'fei4a': # FEI4 A related config changes, Deactivate noisy edge columns if FE-I4A runmngr.current_run.register.set_global_register_value("DisableColumnCnfg", 549755813891) # Disable noisy columns runmngr.current_run.register.set_global_register_value("Cref", cref) # Set correct cref runmngr.current_run.register.save_configuration(runmngr.current_run.register.configuration_file) runmngr.run_run(run=DigitalScan) # repeat digital scan with specific settings runmngr.run_run(run=Fei4Tuning, run_conf={'target_threshold': target_threshold, 'target_tot': target_tot, 'target_charge': target_charge}, catch_exception=False) runmngr.run_run(run=AnalogScan, run_conf={'scan_parameters': [('PlsrDAC', target_charge)]}) runmngr.run_run(run=FastThresholdScan) runmngr.run_run(run=StuckPixelScan)
# This will retain the configuration for the following scans. # Please note: no configuration file exists at this stage because no run was executed so far. # # Executing runs defined by a primlist: runmngr.run_primlist( 'example_run_manager.plst', skip_remaining=True ) # executing primlist.plst file, specific run configuration are set inside the primlist file, skip remaining scans on error # press Ctrl-C to abort the run at any time # Each scan has a default run configuration, which is defined inside the corresponding scan file in /host/pybar/scans/. # It is not necessary to add run parameters to the primlist file. If not given they are taken from the default run configuration (_default_run_conf). # # Running a single scan and changing default run configuration (_default_run_conf): join = runmngr.run_run( run=AnalogScan, run_conf={ "scan_parameters": [('PlsrDAC', 500)], "n_injections": 1000 }, use_thread=True ) # run_run returns a function object when use_thread is True status = join( ) # waiting here for finishing the run, press Ctrl-C to abort the run at any time print 'Status:', status # will wait for run to be finished and returns run status # # Or use a run configuration file: status = runmngr.run_run( run=AnalogScan, run_conf="example_run_manager_run_config.txt") # using no thread print 'Status:', status # # Example for a loop of runs, which is failing: for delay in range(14, 50, 16):
target_threshold, 40, 50, 60, 80, 100, 120, 150, 200, 250, 300, 350, 400, 500, 600, 700, 800 ] # PlsrDAC range for TDC calibration, should start at threshold col_span = [55, 75] # [50, 78] # pixel column range to use in TDC scans row_span = [125, 225] # [20, 315] # pixel row range to use in TDC scans tdc_pixel = make_box_pixel_mask_from_col_row( column=[col_span[0], col_span[1]], row=[row_span[0], row_span[1]]) # edge pixel are not used in analysis runmngr = RunManager('configuration.yaml') # IV scan runmngr.run_run(run=IVScan, run_conf={ "voltages": np.arange(-1, max_iv_voltage - 1, -1), "max_voltage": max_iv_voltage, "bias_voltage": bias_voltage, "minimum_delay": 0.5 }) # FE check and complete tuning runmngr.run_run(run=RegisterTest) runmngr.run_run(run=DigitalScan) # digital scan with std. settings if runmngr.current_run.register.flavor == 'fei4a': # FEI4 A related config changes, Deactivate noisy edge columns if FE-I4A runmngr.current_run.register.set_global_register_value( "DisableColumnCnfg", 549755813891) # Disable noisy columns runmngr.current_run.register.set_global_register_value( "Cref", cref) # Set correct cref runmngr.current_run.register.save_configuration( runmngr.current_run.register.configuration_file)
charge_calibration = in_file_h5.root.HitOrCalibration[:] plsr_dacs = in_file_h5.root.HitOrCalibration._v_attrs.scan_parameter_values valid_pixel = np.where(charge_calibration.sum(axis=(2, 3)) > 0) # valid pixel have data and a calibration (that is any charge(TDC) calibration != 0) mean_signal_to_noise = np.zeros(len(plsr_dacs)) for (column, row) in np.column_stack(valid_pixel): if np.all(np.isfinite(charge_calibration[column, row, :, 1])) and np.all(np.isfinite(charge_calibration[column, row, :, 3])): mean_signal_to_noise += (charge_calibration[column, row, :, 1] / charge_calibration[column, row, :, 3]) mean_signal_to_noise /= valid_pixel[0].shape[0] return mean_signal_to_noise if __name__ == "__main__": plsr_dacs = [40, 50, 60, 80, 130, 180, 230, 280, 340, 440, 540, 640, 740] runmngr = RunManager(r'../../pybar/configuration.yaml') runmngr.run_run(run=FastThresholdScan) sns = [] actual_vthin_alt_fine = runmngr.current_run.register.get_global_register_value("Vthin_AltFine") for dis_vbn in [40, ]: for vthin_alt_fine in range(actual_vthin_alt_fine, 256, 100): for prmp_vbpf in range(0, 256, 32): runmngr.current_run.register.set_global_register_value("PrmpVbpf", prmp_vbpf) runmngr.current_run.register.set_global_register_value("Vthin_AltFine", vthin_alt_fine) runmngr.current_run.register.set_global_register_value("DisVbn", dis_vbn) runmngr.run_run(run=HitOrCalibration, run_conf={ 'reset_rx_on_error': True, "pixels": ((10, 10), (30, 100), (50, 200), (70, 300)), "scan_parameters": [('column', None),
from pybar.scans.scan_threshold import ThresholdScan from pybar.scans.tune_fei4 import Fei4Tuning from pybar.scans.tune_stuck_pixel import StuckPixelScan from pybar.scans.tune_noise_occupancy import NoiseOccupancyScan from pybar.scans.tune_merged_pixels import MergedPixelsTuning # additional run configuration (optinal) run_conf = None # use path to YAML file, or dict if __name__ == "__main__": runmngr = RunManager( '../../pybar/configuration.yaml' ) # configuration YAML file, open it for more details, it may contain run configuration # pre tuning status = runmngr.run_run(run=DigitalScan, run_conf=run_conf) print 'Status:', status status = runmngr.run_run(run=ThresholdScan, run_conf=run_conf) print 'Status:', status status = runmngr.run_run(run=AnalogScan, run_conf=run_conf) print 'Status:', status # tuning status = runmngr.run_run(run=Fei4Tuning, run_conf=run_conf) print 'Status:', status # post tuning status = runmngr.run_run(run=ThresholdScan, run_conf=run_conf) print 'Status:', status