Source code for km3dq_common.lw_db_library

#! /usr/bin/env python
###############################################################################
from km3dq_common.config_library import configure_defect

###############################################################################
[docs] def decode_defect_diag_byte(value, def_type0): """ Decodes the assigned defect (integer) for a given type and returns a single string. === Arguments === - value : diagnosis value for a given type - [integer] - def_type: defect type ("daq", "operation"...) - [string] === Output === - Single string contained all the corresponding defects separated by a slash Ex: 'missing_data_dst / jmergefitfailure /' """ defects0 = configure_defect() result = "" def_type1 = def_type0.replace("def_", "") for i_bit in defects0['bit'][def_type1]: if (int(value) >> defects0['bit'][def_type1][i_bit]) & 1: result += f"{i_bit} / " return result
###############################################################################
[docs] def decode_defect_file(defect_file_dict, run_nb): """ Decode the defect file and returns === Arguments === - defect_file_dict: defect dictionnary produced by the read_defect_file function - [dictionnary] - run_nb : run number - [integer] === Output === - Defects assigned to this run. Both a dict and string (to be used in html - See qaqcprocessing/dst-process.py) are returned. Ex: {'str': '<b> def_data_processing </b>: missing_data_dst / ', 'dict': {'def_data_processing': 'missing_data_dst / '}} """ run_defect_str = {"str": "", "dict": {}} for i_def_type in defect_file_dict.keys(): if run_nb not in defect_file_dict[i_def_type]: continue diag = decode_defect_diag_byte(defect_file_dict[i_def_type][run_nb], i_def_type) run_defect_str['str'] += (f"<b> {i_def_type} </b>: {diag}") run_defect_str['dict'][i_def_type] = diag return run_defect_str