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

source

pub fn weights(&self) -> Vec<f64>

Retrieves the weights from the events in the dataset

source

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.

source

pub fn from_parquet(path: &str) -> Result<Self, RustitudeError>

Generates a new Dataset from a Parquet file.

§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.

source

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.

source

pub fn from_parquet_with_eps( path: &str, eps: Vec<f64>, ) -> Result<Self, RustitudeError>

Generates a new Dataset from a Parquet file with a given EPS polarization vector.

§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.

source

pub fn from_parquet_unpolarized(path: &str) -> Result<Self, RustitudeError>

Generates a new Dataset from a Parquet file with EPS = [0, 0, 0].

§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.

source

pub fn from_root(path: &str) -> Result<Self, RustitudeError>

Generates a new Dataset from a ROOT file.

§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.

source

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.

source

pub fn from_root_with_eps( path: &str, eps: Vec<f64>, ) -> Result<Self, RustitudeError>

Generates a new Dataset from a Parquet file with a given EPS polarization vector.

§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.

source

pub fn from_root_unpolarized(path: &str) -> Result<Self, RustitudeError>

Generates a new Dataset from a Parquet file with EPS = [0, 0, 0].

§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.

source

pub fn new(events: Vec<Event>) -> Self

Generate a new Dataset from a Vec<Event>.

source

pub fn is_empty(&self) -> bool

Checks if the dataset is empty.

source

pub fn len(&self) -> usize

Returns the number of events in the dataset.

source

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

source

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

source

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§

source§

impl Clone for Dataset

source§

fn clone(&self) -> Dataset

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Dataset

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Dataset

source§

fn default() -> Dataset

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Any for T
where T: Any,

source§

fn into_any(self: Box<T>) -> Box<dyn Any>

source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

source§

fn type_name(&self) -> &'static str

source§

impl<T> AnySync for T
where T: Any + Send + Sync,

source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> DynClone for T
where T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> Ungil for T
where T: Send,