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
impl Grid
Sourcepub fn new(
channels: Vec<Channel>,
orders: Vec<Order>,
bin_limits: Vec<f64>,
subgrid_params: SubgridParams,
) -> Self
pub fn new( channels: Vec<Channel>, orders: Vec<Order>, bin_limits: Vec<f64>, subgrid_params: SubgridParams, ) -> Self
Constructor.
Sourcepub 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>
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:
LagrangeSubgridLagrangeSparseSubgridNtupleSubgrid
§Errors
If subgrid_type is none of the values listed above, an error is returned.
Sourcepub fn set_pid_basis(&mut self, pid_basis: PidBasis)
pub fn set_pid_basis(&mut self, pid_basis: PidBasis)
Set the convention by which PIDs of channels are interpreted.
Sourcepub fn convolve(
&self,
lumi_cache: &mut LumiCache<'_>,
order_mask: &[bool],
bin_indices: &[usize],
channel_mask: &[bool],
xi: &[(f64, f64)],
) -> Vec<f64>
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
Sourcepub fn convolve_subgrid(
&self,
lumi_cache: &mut LumiCache<'_>,
ord: usize,
bin: usize,
channel: usize,
xir: f64,
xif: f64,
) -> Array3<f64>
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
Sourcepub fn fill(
&mut self,
order: usize,
observable: f64,
channel: usize,
ntuple: &Ntuple<f64>,
)
pub fn fill( &mut self, order: usize, observable: f64, channel: usize, ntuple: &Ntuple<f64>, )
Sourcepub fn read(reader: impl Read) -> Result<Self, GridError>
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.
Sourcepub fn fill_all(
&mut self,
order: usize,
observable: f64,
ntuple: &Ntuple<()>,
weights: &[f64],
)
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.
Sourcepub fn merge_bins(&mut self, bins: Range<usize>) -> Result<(), GridError>
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.
Sourcepub fn convolutions(&self) -> Vec<Convolution>
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.
Sourcepub fn set_convolution(&mut self, index: usize, convolution: Convolution)
pub fn set_convolution(&mut self, index: usize, convolution: Convolution)
Set the convolution type for this grid for the corresponding index.
Sourcepub fn scale_by_order(
&mut self,
alphas: f64,
alpha: f64,
logxir: f64,
logxif: f64,
global: f64,
)
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
Sourcepub fn scale_by_bin(&mut self, factors: &[f64])
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.
Sourcepub fn orders_mut(&mut self) -> &mut [Order]
pub fn orders_mut(&mut self) -> &mut [Order]
Return a mutable reference to the subgrid parameters.
Sourcepub fn channels_mut(&mut self) -> &mut [Channel]
pub fn channels_mut(&mut self) -> &mut [Channel]
Return a mutable reference to the grid’s channels.
Sourcepub fn subgrids(&self) -> ArrayView3<'_, SubgridEnum>
pub fn subgrids(&self) -> ArrayView3<'_, SubgridEnum>
Return all subgrids as an ArrayView3.
Sourcepub fn subgrids_mut(&mut self) -> ArrayViewMut3<'_, SubgridEnum>
pub fn subgrids_mut(&mut self) -> ArrayViewMut3<'_, SubgridEnum>
Return all subgrids as an ArrayViewMut3.
Sourcepub fn set_remapper(&mut self, remapper: BinRemapper) -> Result<(), GridError>
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
Sourcepub const fn remapper(&self) -> Option<&BinRemapper>
pub const fn remapper(&self) -> Option<&BinRemapper>
Return the currently set remapper, if there is any.
Sourcepub const fn bin_info(&self) -> BinInfo<'_>
pub const fn bin_info(&self) -> BinInfo<'_>
Returns all information about the bins in this grid.
Sourcepub fn optimize(&mut self)
pub fn optimize(&mut self)
Calls Self::optimize_using with all possible optimization options
(GridOptFlags::all).
Sourcepub fn optimize_using(&mut self, flags: GridOptFlags)
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.
Sourcepub fn dedup_channels(&mut self, ulps: i64)
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.
Sourcepub const fn key_values(&self) -> Option<&HashMap<String, String>>
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.
Sourcepub fn key_values_mut(&mut self) -> &mut HashMap<String, String>
pub fn key_values_mut(&mut self) -> &mut HashMap<String, String>
Sourcepub fn set_key_value(&mut self, key: &str, value: &str)
pub fn set_key_value(&mut self, key: &str, value: &str)
Sourcepub fn evolve_info(&self, order_mask: &[bool]) -> EvolveInfo
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.
Sourcepub 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
pub fn evolve( &self, operator: ArrayView5<'_, f64>, info: &OperatorInfo, order_mask: &[bool], ) -> Result<FkTable, GridError>
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.
Sourcepub 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>
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.
Sourcepub 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>
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.
Sourcepub fn delete_bins(&mut self, bin_indices: &[usize])
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.
Sourcepub fn rotate_pid_basis(&mut self, pid_basis: PidBasis)
pub fn rotate_pid_basis(&mut self, pid_basis: PidBasis)
Change the particle ID convention.
Sourcepub fn delete_channels(&mut self, channel_indices: &[usize])
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.
Sourcepub fn split_channels(&mut self)
pub fn split_channels(&mut self)
Splits the grid such that each channel contains only a single tuple of PIDs.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Grid
impl<'de> Deserialize<'de> for Grid
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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> 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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 more