Struct Grid

Source
pub struct Grid { /* private fields */ }
Expand description

Main data structure of PineAPPL. This structure contains a Subgrid for each LumiEntry, bin, and coupling order it was created with.

Implementations§

Source§

impl Grid

Source

pub fn new( channels: Vec<Channel>, orders: Vec<Order>, bin_limits: Vec<f64>, subgrid_params: SubgridParams, ) -> Self

Constructor.

Source

pub fn with_subgrid_type( channels: Vec<Channel>, orders: Vec<Order>, bin_limits: Vec<f64>, subgrid_params: SubgridParams, extra: ExtraSubgridParams, subgrid_type: &str, ) -> Result<Self, GridError>

Constructor. This function can be used like new, but the additional parameter subgrid_type selects the underlying Subgrid type. Supported values are:

  • LagrangeSubgrid
  • LagrangeSparseSubgrid
  • NtupleSubgrid
§Errors

If subgrid_type is none of the values listed above, an error is returned.

Source

pub fn pid_basis(&self) -> PidBasis

Return by which convention the particle IDs are encoded.

Source

pub fn set_pid_basis(&mut self, pid_basis: PidBasis)

Set the convention by which PIDs of channels are interpreted.

Source

pub fn convolve( &self, lumi_cache: &mut LumiCache<'_>, order_mask: &[bool], bin_indices: &[usize], channel_mask: &[bool], xi: &[(f64, f64)], ) -> Vec<f64>

Perform a convolution using the PDFs and strong coupling in lumi_cache, and only selecting only the orders, bins and channels corresponding to order_mask, bin_indices and channel_mask. A variation of the scales is performed using the factors in xi; the first factor varies the renormalization scale, the second the factorization scale. Note that for the variation to be trusted all non-zero log-grids must be contained.

§Panics

TODO

Source

pub fn convolve_subgrid( &self, lumi_cache: &mut LumiCache<'_>, ord: usize, bin: usize, channel: usize, xir: f64, xif: f64, ) -> Array3<f64>

Convolutes a single subgrid (order, bin, channel) with the PDFs strong coupling given by xfx1, xfx2 and alphas. The convolution result is fully differentially, such that the axes of the result correspond to the values given by the subgrid q2, x1 and x2 grid values.

§Panics

TODO

Source

pub fn fill( &mut self, order: usize, observable: f64, channel: usize, ntuple: &Ntuple<f64>, )

Fills the grid with an ntuple for the given order, observable, and channel.

§Panics

TODO

Source

pub fn read(reader: impl Read) -> Result<Self, GridError>

Construct a Grid by deserializing it from reader. Reading is buffered.

§Errors

If reading from the compressed or uncompressed stream fails an error is returned.

Source

pub fn write(&self, writer: impl Write) -> Result<(), GridError>

Serializes self into writer. Writing is buffered.

§Errors

If writing fails an error is returned.

Source

pub fn write_lz4(&self, writer: impl Write) -> Result<(), GridError>

Serializes self into writer, using LZ4 compression. Writing is buffered.

§Errors

If writing or compression fails an error is returned.

§Panics

TODO

Source

pub fn fill_all( &mut self, order: usize, observable: f64, ntuple: &Ntuple<()>, weights: &[f64], )

Fills the grid with events for the parton momentum fractions x1 and x2, the scale q2, and the order and observable. The events are stored in weights and their ordering corresponds to the ordering of Grid::channels.

Source

pub fn channels(&self) -> &[Channel]

Return the channels for this Grid.

Source

pub fn merge_bins(&mut self, bins: Range<usize>) -> Result<(), GridError>

Merges the bins for the corresponding range together in a single one.

§Errors

When the given bins are non-consecutive, an error is returned.

Source

pub fn merge(&mut self, other: Self) -> Result<(), GridError>

Merges the non-empty Subgrids contained in other into self.

§Errors

If the bin limits of self and other are different and if the bin limits of other can not be merged with self an error is returned.

§Panics

TODO

Source

pub fn convolutions(&self) -> Vec<Convolution>

Return a vector containing the type of convolutions performed with this grid.

§Panics

Panics if the metadata key–value pairs convolution_particle_1 and convolution_type_1, or convolution_particle_2 and convolution_type_2 are not correctly set.

Source

pub fn set_convolution(&mut self, index: usize, convolution: Convolution)

Set the convolution type for this grid for the corresponding index.

Source

pub fn scale(&mut self, factor: f64)

Scale all subgrids by factor.

Source

pub fn scale_by_order( &mut self, alphas: f64, alpha: f64, logxir: f64, logxif: f64, global: f64, )

Scales each subgrid by a factor which is the product of the given values alphas, alpha, logxir, and logxif, each raised to the corresponding powers for each subgrid. In addition, every subgrid is scaled by a factor global independently of its order.

§Panics

TODO

Source

pub fn scale_by_bin(&mut self, factors: &[f64])

Scales each subgrid by a bin-dependent factor given in factors. If a bin does not have a corresponding entry in factors it is not rescaled. If factors has more entries than there are bins the superfluous entries do not have an effect.

Source

pub fn orders(&self) -> &[Order]

Returns the subgrid parameters.

Source

pub fn orders_mut(&mut self) -> &mut [Order]

Return a mutable reference to the subgrid parameters.

Source

pub fn channels_mut(&mut self) -> &mut [Channel]

Return a mutable reference to the grid’s channels.

Source

pub fn subgrids(&self) -> ArrayView3<'_, SubgridEnum>

Return all subgrids as an ArrayView3.

Source

pub fn subgrids_mut(&mut self) -> ArrayViewMut3<'_, SubgridEnum>

Return all subgrids as an ArrayViewMut3.

Source

pub fn set_remapper(&mut self, remapper: BinRemapper) -> Result<(), GridError>

Sets a remapper. A remapper can change the dimensions and limits of each bin in this grid. This is useful because many Monte Carlo integrators and also PineAPPL do not support multi-dimensional bins. To work around the problem the multi-dimensional bins can be projected to one-dimensional bins, and the remapper can be used to restore the multi dimensionality. Furthermore, it allows to normalize each bin separately, and independently of the bin widths.

§Errors

Returns an error if the number of bins in the grid and in the remapper do not agree.

§Panics

TODO

Source

pub const fn remapper(&self) -> Option<&BinRemapper>

Return the currently set remapper, if there is any.

Source

pub const fn bin_info(&self) -> BinInfo<'_>

Returns all information about the bins in this grid.

Source

pub fn optimize(&mut self)

Calls Self::optimize_using with all possible optimization options (GridOptFlags::all).

Source

pub fn optimize_using(&mut self, flags: GridOptFlags)

Optimizes the internal datastructures for space efficiency. The parameter flags determines which optimizations are applied, see GridOptFlags.

Source

pub fn dedup_channels(&mut self, ulps: i64)

Try to deduplicate channels by detecting pairs of them that contain the same subgrids. The numerical equality is tested using a tolerance of ulps, given in units of least precision.

Source

pub fn upgrade(&mut self)

Upgrades the internal data structures to their latest versions.

Source

pub const fn key_values(&self) -> Option<&HashMap<String, String>>

Returns a map with key-value pairs, if there are any stored in this grid.

Source

pub fn key_values_mut(&mut self) -> &mut HashMap<String, String>

Returns a map with key-value pairs, if there are any stored in this grid.

§Panics

TODO

Source

pub fn set_key_value(&mut self, key: &str, value: &str)

Sets a specific key-value pair in this grid.

§Panics

TODO

Source

pub fn evolve_info(&self, order_mask: &[bool]) -> EvolveInfo

Returns information for the generation of evolution operators that are being used in Grid::evolve with the parameter order_mask.

Source

pub fn evolve( &self, operator: ArrayView5<'_, f64>, info: &OperatorInfo, order_mask: &[bool], ) -> Result<FkTable, GridError>

👎Deprecated since 0.7.4: use evolve_with_slice_iter instead

Converts this Grid into an FkTable using an evolution kernel operator (EKO) given as operator. The dimensions and properties of this operator must be described using info. The parameter order_mask can be used to include or exclude orders from this operation, and must correspond to the ordering given by Grid::orders. Orders that are not given are enabled, and in particular if order_mask is empty all orders are activated.

§Errors

Returns a GridError::EvolutionFailure if either the operator or its info is incompatible with this Grid.

Source

pub fn evolve_with_slice_iter<'a, E: Into<Error>>( &self, slices: impl IntoIterator<Item = Result<(OperatorSliceInfo, CowArray<'a, f64, Ix4>), E>>, order_mask: &[bool], xi: (f64, f64), alphas_table: &AlphasTable, ) -> Result<FkTable, GridError>

Converts this Grid into an FkTable using slices that must iterate over a Result of tuples of an OperatorSliceInfo and the corresponding sliced operator. The parameter order_mask can be used to include or exclude orders from this operation, and must correspond to the ordering given by Grid::orders. Orders that are not given are enabled, and in particular if order_mask is empty all orders are activated.

§Errors

Returns a GridError::EvolutionFailure if either the operator or its info is incompatible with this Grid. Returns a GridError::Other if the iterator from slices return an error.

Source

pub fn evolve_with_slice_iter2<'a, E: Into<Error>>( &self, slices_a: impl IntoIterator<Item = Result<(OperatorSliceInfo, CowArray<'a, f64, Ix4>), E>>, slices_b: impl IntoIterator<Item = Result<(OperatorSliceInfo, CowArray<'a, f64, Ix4>), E>>, order_mask: &[bool], xi: (f64, f64), alphas_table: &AlphasTable, ) -> Result<FkTable, GridError>

Converts this Grid into an FkTable using slices that must iterate over a Result of tuples of an OperatorSliceInfo and the corresponding sliced operator. The parameter order_mask can be used to include or exclude orders from this operation, and must correspond to the ordering given by Grid::orders. Orders that are not given are enabled, and in particular if order_mask is empty all orders are activated.

§Errors

Returns a GridError::EvolutionFailure if either the operator or its info is incompatible with this Grid. Returns a GridError::Other if the iterator from slices return an error.

Source

pub fn delete_bins(&mut self, bin_indices: &[usize])

Deletes bins with the corresponding bin_indices. Repeated indices and indices larger or equal the bin length are ignored.

Source

pub fn rotate_pid_basis(&mut self, pid_basis: PidBasis)

Change the particle ID convention.

Source

pub fn delete_channels(&mut self, channel_indices: &[usize])

Deletes channels with the corresponding channel_indices. Repeated indices and indices larger or equal than the number of channels are ignored.

Source

pub fn split_channels(&mut self)

Splits the grid such that each channel contains only a single tuple of PIDs.

Trait Implementations§

Source§

impl Clone for Grid

Source§

fn clone(&self) -> Grid

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<'de> Deserialize<'de> for Grid

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Grid

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TryFrom<Grid> for FkTable

Source§

type Error = TryFromGridError

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

fn try_from(grid: Grid) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl Freeze for Grid

§

impl RefUnwindSafe for Grid

§

impl Send for Grid

§

impl Sync for Grid

§

impl Unpin for Grid

§

impl UnwindSafe for Grid

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> 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> ToOwned for T
where T: Clone,

Source§

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>,

Source§

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>,

Source§

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,