FitMixin

class cait.mixins.FitMixin[source]

Bases: object

A Mixin Class to the DataHandler Class with methods for the calculation of fits.

apply_array_fit(type='events', only_channels=None, sample_length=None, max_shift=20, truncation_level=None, processes=4, name_appendix='', group_name_appendix='', first_channel_dominant=False, use_this_array=None, blcomp=4, no_bl_when_sat=True)[source]

Calculates the array fit for all events of type (events or tp) and stores in HDF5 file.

The stored parameters are (pulse_height, onset_in_ms, bl_offset, bl_linear_coeffiient, quadratic, cubic). This method is different to apply_sev_fit, because we can use an arbitrary numerical array as standard event fit component, not only one described by the parameters of the pulse shape model. Per default, the numerical sev is used as sev component. Furthermore, the fit is split into a linear and nonlinear regression part, which provides significant speedup. Only the t0 parameter is subject to a nonlinear optimization problem, while the others are calculated by matrix inversion.

Parameters
  • type (string) – Name of the group in the HDF5 set, either events or testpulses.

  • only_channels (list of ints) – Only these channels are fitted, the others are left as is or filled with zeros.

  • sample_length (float) – The length of a sample in milliseconds. If None, this is calculated from the sample frequency.

  • max_shift (float) – The maximal shift in ms allowed for the t0 value.

  • truncation_level (list of nmbr_channel floats) – The pulse height Volt value at that the detector saturation starts.

  • processes (int) – The number of workers for the fit.

  • name_appendix (string) – This gets appendend to the dataset name in the HDF5 set.

  • group_name_appendix (string) – This is appendend to the group name of the stdevent in the HDF5 set.

  • first_channel_dominant (bool) – Take the peak position from the first channel and evaluate the others at the same position.

  • use_this_array (2D numpy array) – List of the standardevents/array that are used for the fit. Shape: (nmbr_channels, record_length).

  • blcomp (int) – Either 1,2,3 or 4 - number of the baseline components, i.e. order + 1 of the polynomial assumed for baseline.

apply_sev_fit(type='events', only_channels=None, sample_length=None, down=1, order_bl_polynomial=3, t0_bounds=(- 20, 20), truncation_level=None, interval_restriction_factor=None, verb=False, processes=4, name_appendix='', group_name_appendix='', first_channel_dominant=False, use_saturation=False)[source]

Calculates the SEV fit for all events of type (events or tp) and stores in HDF5 file. The stored parameters are (pulse_height, onset_in_ms, bl_offset, bl_linear_coeffiient, quadratic, cubic).

Attention! Since v11.1 it is recommended to use apply_array_fit instead, which provides a more stable fit implementation.

This method was described in “F. Reindl, Exploring Light Dark Matter With CRESST-II Low-Threshold Detector”, available via http://mediatum.ub.tum.de/?id=1294132 (accessed on the 9.7.2021).

Parameters
  • type (string) – Name of the group in the HDF5 set, either events or testpulses.

  • only_channels (list of ints) – Only these channels are fitted, the others are left as is or filled with zeros.

  • order_bl_polynomial (int) – Either 0,1,2 or 3 - the order of the polynomial assumed for baseline.

  • sample_length (float) – The length of a sample in milliseconds. If None, this is calculated from the sample frequency.

  • down (int) – The downsample factor for the fit, has to be a power of 2.

  • t0_bounds (2-tuple of ints) – The lower and upper bounds in milliseconds for the onset position.

  • truncation_level (list of nmbr_channel floats) – The pulse height Volt value at that the detector saturation starts.

  • interval_restriction_factor (2-tuple of ints) – Value between 0 and 1, the inverval of the event is restricted around 1/4 by this factor.

  • verb (bool) – Verbal feedback about the progress.

  • processes (int) – The number of workers for the fit.

  • name_appendix (string) – This gets appendend to the dataset name in the HDF5 set.

  • group_name_appendix (string) – This is appendend to the group name of the stdevent in the HDF5 set.

  • first_channel_dominant (bool) – Take the peak position from the first channel and evaluate the others at the same position.

calc_bl_coefficients(type='noise', down=1)[source]

Calcualted the fit coefficients with a cubic polynomial on the noise baselines.

Parameters
  • type (string) – The group name in the HDF5 set, should be noise.

  • down (int) – The baselines are downsampled by this factor before the fit.

calc_parametric_fit(path_h5=None, type='events', processes=4)[source]

Calculate the Parameteric Fit for the Events in an HDF5 File.

This methods was described in “(1995) F. Pröbst et. al., Model for cryogenic particle detectors with superconducting phase transition thermometers.”

Parameters
  • path_h5 (string) – Optional, the full path to the hdf5 file, e.g. “data/bck_001.h5”.

  • type (string) – Either events or testpulses.

  • processes (int) – The number of processes to use for the calculation.

calc_saturation(channel=0, only_idx=None)[source]

Fit a logistics curve to the testpulse amplitudes vs their pulse heights.

This method was used to describe the detector saturation in “M. Stahlberg, Probing low-mass dark matter with CRESST-III : data analysis and first results”, available via https://doi.org/10.34726/hss.2021.45935 (accessed on the 9.7.2021).

Parameters
  • channel (int) – The channel for that we calculate the saturation.

  • only_idx (list of ints) – Only these indices are used in the fit of the saturation.

estimate_trigger_threshold(channel, detector_mass, allowed_noise_triggers=1, sigma_x0=2, method='of', bins=200, yran=None, xran=None, xran_hist=None, ul=30, ll=0, cut_flag=None, plot=True, title=None, sample_length=None, record_length=None, interval_restriction=0.75, binned_fit=False, model='gauss', ylog=False, save_path=None)[source]

Estimate the trigger threshold to obtain a given number of noise triggers per exposure.

The method assumes a Gaussian sample distribution of the noise, following “A method to define the energy threshold depending on noise level for rare event searches” (arXiv:1711.11459). There are multiple extensions implemented, that descibe additional Gaussian mixture or non-Gaussian components. A more extensive description can be found in the corresponding tutorial.

Parameters
  • channel (int) – The number of the channel for that we estimate the noise trigger threshold.

  • detector_mass (float) – The mass of the detector in kg.

  • allowed_noise_triggers (float) – The number of noise triggers that are allowed per kg day exposure.

  • sigma_x0 (float) – A start value for the baseline resolution. Is only used for the unbinned fit.

  • method (string) – Either ‘of’ for estimating the noise triggers after optimal filtering or ‘ph’ for taking the maximum value of the raw data.

  • bins (int) – The number of bins for the histogram plots.

  • yran (tuple of two floats) – The range of the y axis on both plots.

  • xran (tuple of two floats) – The range of the x axis on the noise trigger estimation plot.

  • xran_hist (tuple of two floats) – The range of the x axis on the histogram plot.

  • ul (float) – The upper limit of the interval that is used to search a threshold, in mV.

  • ll (float) – The lower limit of the interval that is used to search a threshold, in mV.

  • cut_flag (list of bool) – A list of boolean values that determine which events are excluded from the calculation.

  • plot (bool) – If True, a plot of the fit and the noise trigger estimation are shown.

  • title (string) – A title for both plots.

  • sample_length (float) – The length of a sample in seconds. If None, it is calculated from the sample frequency.

  • record_length (int) – The number of samples within a record window.

  • interval_restriction

  • binned_fit (bool) – Not recommended. If chosen, the model is fit with least squared to the histogram. Otherwise an unbinned likelihood fit is performed.

  • model (string) – Determine which model is fit to the noise. - ‘gauss’: Model of purely Gaussian noise. - ‘pollution_exponential’: Model of Gaussian noise with one exponentially distributed sample on each baseline. - ‘fraction_exponential’: Mixture model of Gaussian and exponentially distributed noise. - ‘pollution_gauss’: Model of Gaussian noise and one sample in each baseline that follows another, also Gaussian distribution. - ‘fraction_gauss’: Mixture model of two Gaussian noise components.

  • ylog (bool) – If set, the y axis is plotted logarithmically on the histogram plot.

  • save_path (string) – A path to save the plots.