skyllh.core.utils package
Submodules
skyllh.core.utils.multidimgridpdf module
This module contains utility functions for creating and managing MultiDimGridPDF instances.
- skyllh.core.utils.multidimgridpdf.get_kde_pdf_sig_spatial_norm_factor_func(log10_psi_name='log10_psi')
Returns the standard normalization factor function for the spatial signal MultiDimGridPDF, which is created from KDE PDF values. It can be used for the
norm_factor_func
argument of thecreate_MultiDimGridPDF_from_photosplinetable
andcreate_MultiDimGridPDF_from_kde_pdf
function.- Parameters:
log10_psi_name (str) – The name of the event data field for the log10(psi) values.
- skyllh.core.utils.multidimgridpdf.get_kde_pdf_bkg_norm_factor_func()
Returns the standard normalization factor function for the background MultiDimGridPDF, which is created from KDE PDF values. It can be used for the
norm_factor_func
argument of thecreate_MultiDimGridPDF_from_photosplinetable
andcreate_MultiDimGridPDF_from_kde_pdf
function.
- skyllh.core.utils.multidimgridpdf.create_MultiDimGridPDF_from_photosplinetable(multidimgridpdf_cls, pmm, ds, data, info_key, splinetable_key, kde_pdf_axis_name_map_key='KDE_PDF_axis_name_map', norm_factor_func=None, cache_pd_values=False, tl=None, **kwargs)
Creates a MultiDimGridPDF instance with pdf values taken from a photospline pdf, i.e. a spline interpolation of KDE PDF values stored in a splinetable on disk.
- Parameters:
multidimgridpdf_cls (subclass of MultiDimGridPDF) – The MultiDimGridPDF class, which should be used.
pmm (instance of ParameterModelMapper) – The instance of ParameterModelMapper, which defines the mapping of global parameters to local model parameters.
ds (instance of Dataset) – The instance of Dataset the PDF applies to.
data (instance of DatasetData) – The instance of DatasetData that holds the experimental and monte-carlo data of the dataset.
info_key (str) – The auxiliary data name for the file containing PDF information.
splinetable_key (str) – The auxiliary data name for the name of the file containing the photospline spline table.
kde_pdf_axis_name_map_key (str) – The auxiliary data name for the KDE PDF axis name map.
norm_factor_func (callable | None) – The function that calculates a possible required normalization factor for the PDF value based on the event properties. For more information about this argument see the documentation of the
skyllh.core.pdf.MultiDimGridPDF.__init__()
method.cache_pd_values (bool) – Flag if the probability density values should get cached by the MultiDimGridPDF class.
tl (instance of TimeLord | None) – The optional instance of TimeLord to use for measuring timing information.
- Returns:
pdf (instance of
multidimgridpdf_cls
) – The created PDF instance of MultiDimGridPDF.
- skyllh.core.utils.multidimgridpdf.create_MultiDimGridPDF_from_kde_pdf(multidimgridpdf_cls, pmm, ds, data, numerator_key, denumerator_key=None, kde_pdf_axis_name_map_key='KDE_PDF_axis_name_map', norm_factor_func=None, cache_pd_values=False, tl=None, **kwargs)
Creates a MultiDimGridPDF instance with pdf values taken from KDE PDF values stored in the dataset’s auxiliary data.
- Parameters:
multidimgridpdf_cls (subclass of MultiDimGridPDF) – The MultiDimGridPDF class, which should be used.
pmm (instance of ParameterModelMapper) – The instance of ParameterModelMapper, which defines the mapping of global parameters to local model parameters.
ds (instance of Dataset) – The instance of Dataset the PDF applies to.
data (instance of DatasetData) – The instance of DatasetData that holds the auxiliary data of the dataset.
numerator_key (str) – The auxiliary data name for the PDF numerator array.
denumerator_key (str | None) – The auxiliary data name for the PDF denumerator array. This can be
None
, if no denumerator array is required.kde_pdf_axis_name_map_key (str) – The auxiliary data name for the KDE PDF axis name map.
norm_factor_func (callable | None) – The function that calculates a possible required normalization factor for the PDF value based on the event properties. For more information about this argument see the documentation of the
skyllh.core.pdf.MultiDimGridPDF.__init__()
method.cache_pd_values (bool) – Flag if the probability density values should get cached by the MultiDimGridPDF class.
tl (instance of TimeLord | None) – The optional instance of TimeLord to use for measuring timing information.
- Returns:
pdf (instance of
multidimgridpdf_cls
) – The created PDF instance of MultiDimGridPDF.
skyllh.core.utils.ndphotosplinepdf module
skyllh.core.utils.trials module
This module contains utility functions related analysis trials.
- skyllh.core.utils.trials.create_pseudo_data_file(ana, rss, filename, mean_n_bkg_list=None, mean_n_sig=0, bkg_kwargs=None, sig_kwargs=None, tl=None)
Creates a pickle file that contains the pseudo data for a single trial by generating background and signal events.
- Parameters:
ana (Analysis) – The Analysis instance that should be used to generate the pseudo data.
rss (RandomStateService) – The RandomStateService instance to use for generating random numbers.
filename (str) – The data file name into which the generated pseudo data should get written to.
mean_n_bkg_list (list of float | None) – The mean number of background events that should be generated for each dataset. If set to None (the default), the background generation method needs to obtain this number itself.
mean_n_sig (float) – The mean number of signal events that should be generated for the trial. The actual number of generated events will be drawn from a Poisson distribution with this given signal mean as mean.
bkg_kwargs (dict | None) – Additional keyword arguments for the generate_events method of the background generation method class. An usual keyword argument is poisson.
sig_kwargs (dict | None) – Additional keyword arguments for the generate_signal_events method of the SignalGenerator class. An usual keyword argument is poisson.
tl (TimeLord | None) – The instance of TimeLord that should be used to time individual tasks.
- skyllh.core.utils.trials.load_pseudo_data(filename, tl=None)
Loads the pseudo data for a single trial from the given file name.
- Parameters:
filename (str) – The name of the file that contains the pseudo data.
tl (TimeLord | None) – The instance of TimeLord that should be used to time individual tasks.
- Returns:
mean_n_sig (float) – The mean number of signal events that was used to generate the pseudo data.
n_sig (int) – The actual total number of signal events in the pseudo data.
n_bkg_events_list (list of int) – The total number of background events for each data set of the pseudo data.
n_sig_events_list (list of int) – The total number of signal events for each data set of the pseudo data.
bkg_events_list (list of DataFieldRecordArray instances) – The list of DataFieldRecordArray instances containing the background pseudo data events for each data set.
sig_events_list (list of DataFieldRecordArray instances | None) – The list of DataFieldRecordArray instances containing the signal pseudo data events for each data set. If a particular dataset has no signal events, the entry for that dataset can be None.