diff --git a/tjmonopix2/analysis/corryvreckan_converter.py b/tjmonopix2/analysis/corryvreckan_converter.py new file mode 100644 index 0000000..c15675f --- /dev/null +++ b/tjmonopix2/analysis/corryvreckan_converter.py @@ -0,0 +1,94 @@ +# +# ------------------------------------------------------------ +# Copyright (c) All rights reserved +# SiLab, Institute of Physics, University of Bonn +# ------------------------------------------------------------ +# + +from pathlib import Path + +import numpy as np +import tables as tb + +from tjmonopix2.analysis import analysis + + +def format_dut(input_filename: str | Path, output_filename: str | Path = None, trigger_mode: str = "AIDA") -> None: + """Format hit table to be compatible with corryvreckan EventLoaderHDF5 as of commit 149e937f + + Parameters + ---------- + input_filename : str | Path + Interpreted hit file with Hit and/or Event data depending on trigger_mode + output_filename : str | Path, optional + Output file name. If None, defaults to input_filename with suffix '_converted', by default None + trigger_mode : str, optional + Trigger mode during data taking. EUDET mode (with trigger handshake) and AIDA, mode (without + handshake only) are supported. In general, use `DATA_FORMAT=1` in `testbench.yaml` for data + taking. By default "AIDA" + + Raises + ------ + RuntimeError + Invalid trigger mode selected + """ + hit_dtype_converted = np.dtype( + [("column", "