Struct rustitude_core::dataset::Dataset
source · pub struct Dataset {
pub events: Arc<RwLock<Vec<Event>>>,
}Expand description
An array of Events with some helpful methods for accessing and parsing the data they
contain.
A Dataset can be loaded from either Parquet and ROOT files using the corresponding
Dataset::from_* methods. Events are stored in an Arc<RwLock<Vec<Event>>>, since we
rarely need to write data to a dataset (splitting/selecting/rejecting events) but often need to
read events from a dataset.
Fields§
§events: Arc<RwLock<Vec<Event>>>Storage for events.
Implementations§
source§impl Dataset
impl Dataset
sourcepub fn split_m(
&self,
range: (f64, f64),
bins: usize,
daughter_indices: Option<Vec<usize>>,
) -> (Vec<Self>, Self, Self)
pub fn split_m( &self, range: (f64, f64), bins: usize, daughter_indices: Option<Vec<usize>>, ) -> (Vec<Self>, Self, Self)
Splits the dataset by the mass of the combination of specified daughter particles in the event. If no daughters are given, the first and second particle are assumed to form the desired combination.
sourcepub fn from_parquet(path: &str) -> Result<Self, RustitudeError>
pub fn from_parquet(path: &str) -> Result<Self, RustitudeError>
sourcepub fn from_parquet_eps_in_beam(path: &str) -> Result<Self, RustitudeError>
pub fn from_parquet_eps_in_beam(path: &str) -> Result<Self, RustitudeError>
Generates a new Dataset from a Parquet file, assuming the EPS vector can be constructed
from the x and y-components of the beam.
§Errors
This method will fail if any individual event is missing all of the required fields, if they have the wrong type, or if the file doesn’t exist/can’t be read for any reason.
sourcepub fn from_parquet_with_eps(
path: &str,
eps: Vec<f64>,
) -> Result<Self, RustitudeError>
pub fn from_parquet_with_eps( path: &str, eps: Vec<f64>, ) -> Result<Self, RustitudeError>
sourcepub fn from_parquet_unpolarized(path: &str) -> Result<Self, RustitudeError>
pub fn from_parquet_unpolarized(path: &str) -> Result<Self, RustitudeError>
sourcepub fn from_root(path: &str) -> Result<Self, RustitudeError>
pub fn from_root(path: &str) -> Result<Self, RustitudeError>
sourcepub fn from_root_eps_in_beam(path: &str) -> Result<Self, RustitudeError>
pub fn from_root_eps_in_beam(path: &str) -> Result<Self, RustitudeError>
Generates a new Dataset from a ROOT file, assuming the EPS vector can be constructed
from the x and y-components of the beam.
§Errors
This method will fail if any individual event is missing all of the required fields, if they have the wrong type, or if the file doesn’t exist/can’t be read for any reason.
sourcepub fn from_root_with_eps(
path: &str,
eps: Vec<f64>,
) -> Result<Self, RustitudeError>
pub fn from_root_with_eps( path: &str, eps: Vec<f64>, ) -> Result<Self, RustitudeError>
sourcepub fn from_root_unpolarized(path: &str) -> Result<Self, RustitudeError>
pub fn from_root_unpolarized(path: &str) -> Result<Self, RustitudeError>
sourcepub fn select(&mut self, query: impl Fn(&Event) -> bool + Sync + Send) -> Self
pub fn select(&mut self, query: impl Fn(&Event) -> bool + Sync + Send) -> Self
Selects events in the dataset using the given query and remove them from the Dataset,
returning them in a new Dataset. The original Dataset will then contain the
“rejected” events, events for which the query returned false.
See also: Dataset::reject
sourcepub fn reject(&mut self, query: impl Fn(&Event) -> bool + Sync + Send) -> Self
pub fn reject(&mut self, query: impl Fn(&Event) -> bool + Sync + Send) -> Self
Removes events from the dataset if the query returns true and returns them in a new
Dataset. The original Dataset will contain events for which the query returned
true.
See also: Dataset::select
sourcepub fn split(
self,
variable: impl Fn(&Event) -> f64 + Sync + Send,
range: (f64, f64),
nbins: usize,
) -> (Vec<Self>, Self, Self)
pub fn split( self, variable: impl Fn(&Event) -> f64 + Sync + Send, range: (f64, f64), nbins: usize, ) -> (Vec<Self>, Self, Self)
Splits the dataset into bins of the specified variable derived from an Event. This
method returns a Vec<Dataset> containing the binned datasets, an underflow Dataset
(events which are below the lower range), and an overflow Dataset (events above the
upper range) in that order.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Dataset
impl !RefUnwindSafe for Dataset
impl Send for Dataset
impl Sync for Dataset
impl Unpin for Dataset
impl !UnwindSafe for Dataset
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moresource§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moresource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.