BinMixin
- class cait.mixins.BinMixin[source]
Bases:
objectA Mixin Class to the DataHandler Class with methods for the triggering of *.bin files.
- include_bin_triggers(path: str, dtype: numpy.dtype, keys: list, header_size: int, thresholds: list, adc_bits=16, trigger_block: Optional[int] = None, take_samples: Optional[int] = None, of: Optional[list] = None, down: int = 1, window: bool = True, overlap: Optional[float] = None, read_triggerstamps: bool = False)[source]
Trigger the *.bin file of a detector module and include them in the HDF5 set.
The trigger time stamps of all channels get aligned, by applying a trigger block to channels that belong to the same module.
- Parameters
path (str) – The full path for the BIN file.
dtype (numpy data type) – The data type with which we read the *.bin file.
key (str) – The key of the dtype, corresponding to the channel that we want to read.
header_size (int) – The size of the file header of the bin file, in bytes.
thresholds (list of floats) – The trigger tresholds for all channels in Volt.
adc_bits (int) – The precision of the digitizer.
trigger_block (int or None) – The number of samples for that the trigger is blocked after a trigger. If None, it is the length of a record window.
take_samples (int or None) – The number of samples that we trigger from the stream file. Standard argument is None, which means all samples are triggered.
of (list of arrays) – The optimum filter transfer functions for all channels.
down (int) – The downsampling factor for triggering.
window (bool) – If true, the trigger window is multiplied with a window function before the filtering. This is strongly recommended! Otherwise some artifacts from major differences in the left and right baseline level can appear somewhere in the middle of the record window.
overlap (float) – A value between 0 and 1 that defines the part of the record window that overlaps with the previous/next one. Standard value is 1/4 - it is recommended to use this value!
read_triggerstamps (bool) – In case there is already a trigger_hours data set in the HDF5 stream group, we can read it instead of doing the triggering again. For this, set this argument to True.
- include_dac_triggers(path: str, dtype, keys, header_size, thresholds: list, dac_bits=16, trigger_block: Optional[int] = None, take_samples: Optional[int] = None, down: int = 1, window: bool = True, overlap: Optional[float] = None)[source]
Trigger the DAC channels of a *.bin file of a detector module and include them in the HDF5 set.
The trigger time stamps of all channels get aligned, by applying a trigger block to channels that belong to the same module.
- Parameters
path (str) – The full paths for the bin file.
dtype (numpy data type) – The data type with which we read the *.bin file.
keys (list of str) – The keys of the dtype, corresponding to the channels that we want to read.
header_size (int) – The size of the file header of the bin file, in bytes.
thresholds (list of floats) – The trigger tresholds for all channels in Volt.
adc_bits (int) – The precision of the digitizer.
trigger_block (int or None) – The number of samples for that the trigger is blocked after a trigger. If None, it is the length of a record window.
take_samples (int or None) – The number of samples that we trigger from the stream file. Standard argument is None, which means all samples are triggered.
down (int) – The downsampling factor for triggering.
window (bool) – If true, the trigger window is multiplied with a window function before the filtering. This is strongly recommended! Otherwise some artifacts from major differences in the left and right baseline level can appear somewhere in the middle of the record window.
overlap (float) – A value between 0 and 1 that defines the part of the record window that overlaps with the previous/next one. Standard value is 1/4 - it is recommended to use this value!
- include_noise_events_vdaq(path, dtype, keys, header_size, adc_bits=16, datatype='float32', origin=None, down=1)[source]
Include the events corresponding to chosen noise triggers from the *.bin file.
- Parameters
path (str) – The full path to the *.bin file.
dtype (numpy data type) – The data type with which we read the *.bin file.
keys (str) – The keys of the dtype, corresponding to the ADC channels that we want to include.
header_size (int) – The size of the file header of the bin file, in bytes.
adc_bits (int) – The precision of the digitizer.
datatype (string) – The datatype of the stored events.
origin (string) – This is needed in case you want to include events to a dataset that itself is a merge of other datasets. Then typically a set of origin strings is included in the set, which specify the origin of the individual events within the merged set. By putting a origin string here, the events get included in the event data set exactly at the positions where the origin attribute is the same as the handed origin string.
down (int) – The factor by which we want to downsample the included events.
- include_test_stamps_vdaq(triggers: list, tpas: list, name_appendix: str = '', trigger_block: Optional[int] = None, file_start: Optional[float] = None)[source]
Include the time stamps and TPA from the test pulses on the *.bin file’s DAC channels.
- Parameters
triggers (list of nmbr_channels 1D numpy arrays) – A list of the triggers, corresponding to all channels, in seconds from start of file.
tpas (list of nmbr_channels 1D numpy arrays) – The test pulse amplitudes corresponding to the triggers.
name_appendix (str) – This is appended to the name of the trigger data set in the HDF5 file.
trigger_block (int) – The number of samples for which the trigger is blocked, after a previous trigger.
file_start (float) – This value is added to all triggers, in seconds. Can e.g. be the absolut linux time stamp of the file start.
- include_triggered_events_vdaq(path, dtype, keys, header_size, adc_bits=16, max_time_diff=0.5, exclude_tp=True, sample_duration=None, name_appendix='', datatype='float32', min_tpa=None, min_cpa=None, down=1, origin=None)[source]
Include the triggered events from the BIN file.
It is recommended to exclude the testpulses. This means, we exclude them from the events group and put them separately in the testpulses and control pulses groups.
- Parameters
path (str) – The full path to the *.bin file.
dtype (numpy data type) – The data type with which we read the *.bin file.
keys (str) – The keys of the dtype, corresponding to the ADC channels that we want to include.
header_size (int) – The size of the file header of the bin file, in bytes.
adc_bits (int) – The precision of the digitizer.
max_time_diff (float) – The maximal time difference between a trigger and a test pulse time stamp such that the trigger is still counted as test pulse, in seconds.
exclude_tp (bool) – If true, we separate the test pulses from the triggered events and put them in individual groups.
sample_duration (float) – The duration of a sample in seconds. If None, the inverse of the sample frequency is taken.
name_appendix (string) – The name appendix of the data sets trigger_hours, trigger_time_s and trigger_time_mus in the HDF5 file. This is typically needed, when we want to include the events corresponding to time stamps that were triggered with the CAT CTrigger and then included in the HDF5 set.
datatype (string) – The datatype of the stored events.
min_tpa (float) – TPA values below this are not counted as testpulses.
min_cpa (float) – TPA values above this are counted as control pulses.
down (int) – The events get stored downsampled by this factor.
origin (str) – The name of the bin file from which we read, e.g. bck_xxx
- include_vtrigger_stamps(triggers: list, name_appendix: str = '', trigger_block: Optional[int] = None, file_start: Optional[float] = None)[source]
Include trigger time stamps corresponding to a *.bin file. This function does not do the triggering itself, has to be done previously, with third-party software, e.g. https://github.com/fewagner/trigger.
- Parameters
triggers (list of nmbr_channels 1D numpy arrays) – A list of the triggers, corresponding to all channels, in seconds from start of file.
name_appendix (str) – This is appended to the name of the trigger data set in the HDF5 file.
trigger_block (int) – The number of samples for which the trigger is blocked, after a previous trigger.
file_start (float) – This value is added to all triggers, in seconds. Can e.g. be the absolut linux time stamp of the file start.