Observables Module
Provides functions to calculate various observables from shower data and to add them to shower data files. This can be useful for analyzing the fidelity of generative shower models or for training two-stage models (e.g. layer-wise properties first, then point clouds).
- showerdata.observables.compute_threshold_mask(showers, detector_config=None)[source]
Compute a mask for the shower points based on detector thresholds.
- Parameters:
showers (Showers) – The showers to compute the mask for.
detector_config (DetectorGeometry) – The detector configuration.
- Returns:
A boolean mask indicating which points pass the thresholds.
- Return type:
NDArray
- showerdata.observables.calc_num_points_per_layer(showers, num_layers=-1, detector_config=None)[source]
Calculate the number of points per layer for each shower.
- Parameters:
- Returns:
A 2D array of shape (num_showers, num_layers) containing the number of points per layer for each shower.
- Return type:
NDArray
- showerdata.observables.calc_energy_per_layer(showers, num_layers=-1, detector_config=None)[source]
Calculate the total energy per layer for each shower.
- Parameters:
showers (Showers) – The showers to calculate the total energy per layer for.
- Returns:
A 2D array of shape (num_showers, num_layers) containing the total energy per layer for each shower.
- Return type:
NDArray
- showerdata.observables.calc_energy_per_radial_bin(showers, bin_edges=None, detector_config=None)[source]
Calculate the total energy per radial bin for each shower.
- Parameters:
showers (Showers) – The showers to calculate the total energy per radial bin for.
bin_edges (ArrayLike, optional) – The edges of the radial bins. If None, defaults to 200 bins from 0 to 400 mm.
- Returns:
A 2D array of shape (num_showers, num_bins) containing the total energy per radial bin for each shower.
- Return type:
NDArray
- showerdata.observables.calc_center_of_energy(showers, detector_config=None)[source]
Calculate the center of energy for each shower.
- Parameters:
showers (Showers) – The showers to calculate the center of energy for.
- Returns:
A 2D array of shape (num_showers, 3) containing the center of energy (x, y, z) for each shower.
- Return type:
NDArray
- class showerdata.observables.ObservableInfo(key, shape, dtype, function)[source]
Bases:
object- dtype: DTypeLike
- showerdata.observables.add_observables_to_file(path, batch_size=1000, overwrite=False, detector_config=None)[source]
Calculate and add observables to an existing HDF5 file containing shower data.
- showerdata.observables.save_observables_to_file(path, observables, overwrite=False)[source]
Save observables to an HDF5 file.
- showerdata.observables.read_observables_from_file(path, observables=None, start=0, stop=None)[source]
Read observables from an HDF5 file. The default observables are:
num_points_per_layer
energy_per_layer
energy_per_radial_bin
center_of_energy
total_energy
total_num_points
incident_energies
incident_pdg
incident_directions
shower_ids
- Parameters:
file (str) – The HDF5 file to read from.
observables (list[str], optional) – The list of observables to read.
start (int, optional) – The starting index of the showers to read. Defaults to 0.
stop (int, optional) – The stopping index of the showers to read. If None, reads until the end. Defaults to None.
- Returns:
A dictionary containing the observables.
- Return type: