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(
bwfl: BinsWithFillLimits,
orders: Vec<Order>,
channels: Vec<Channel>,
pid_basis: PidBasis,
convolutions: Vec<Conv>,
interps: Vec<Interp>,
kinematics: Vec<Kinematics>,
scales: Scales,
) -> Self
pub fn new( bwfl: BinsWithFillLimits, orders: Vec<Order>, channels: Vec<Channel>, pid_basis: PidBasis, convolutions: Vec<Conv>, interps: Vec<Interp>, kinematics: Vec<Kinematics>, scales: Scales, ) -> Self
Constructor.
§Panics
Panics when the number of PIDs in channels is not equal to convolutions.len(), or
interps and kinematics have different lengths or if kinematics are not compatible
with scales.
Sourcepub fn set_reference(&mut self, reference: Reference)
pub fn set_reference(&mut self, reference: Reference)
TODO
Sourcepub const fn pid_basis(&self) -> &PidBasis
pub const fn pid_basis(&self) -> &PidBasis
Return the convention by which the channels’ PIDs are encoded.
Sourcepub fn interpolations(&self) -> &[Interp]
pub fn interpolations(&self) -> &[Interp]
Return a vector containing the interpolation specifications for this grid.
Sourcepub fn kinematics(&self) -> &[Kinematics]
pub fn kinematics(&self) -> &[Kinematics]
Return a vector containing the kinematic specifications for this grid.
Sourcepub const fn scales(&self) -> &Scales
pub const fn scales(&self) -> &Scales
Return a vector containg the scale specifications for this grid.
Sourcepub fn convolve(
&self,
cache: &mut ConvolutionCache<'_>,
order_mask: &[bool],
bin_indices: &[usize],
channel_mask: &[bool],
xi: &[(f64, f64, f64)],
) -> Vec<f64>
pub fn convolve( &self, cache: &mut ConvolutionCache<'_>, order_mask: &[bool], bin_indices: &[usize], channel_mask: &[bool], xi: &[(f64, f64, f64)], ) -> Vec<f64>
Perform a convolution using the PDFs and strong coupling in lumi_cache, and
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 fill(
&mut self,
order: usize,
observable: f64,
channel: usize,
ntuple: &[f64],
weight: f64,
)
pub fn fill( &mut self, order: usize, observable: f64, channel: usize, ntuple: &[f64], weight: f64, )
Sourcepub fn read(reader: impl Read) -> Result<Self>
pub fn read(reader: impl Read) -> Result<Self>
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 write_lz4(&self, writer: impl Write) -> Result<()>
pub fn write_lz4(&self, writer: impl Write) -> Result<()>
Serializes self into writer, using LZ4 compression. Writing is buffered.
§Errors
If writing or compression fails an error is returned.
Sourcepub fn merge_bins(&mut self, range: impl RangeBounds<usize>) -> Result<()>
pub fn merge_bins(&mut self, range: impl RangeBounds<usize>) -> Result<()>
Merge the bins in indices in range together in a single one.
§Errors
When the given bins are non-consecutive, an error is returned.
Sourcepub fn merge(&mut self, other: Self) -> Result<()>
pub fn merge(&mut self, other: Self) -> Result<()>
Merge non-empty Subgrids contained in other into self. Subgrids with the same bin
limits are summed and subgrids with non-overlapping bin limits create new bins in self.
§Errors
If self and other in have different convolutions, PID bases, kinematics,
interpolations, or scales an error is returned. If the bin limits of self and other
are different and if the bin limits of other cannot be merged with self an error is
returned.
Sourcepub fn convolutions(&self) -> &[Conv]
pub fn convolutions(&self) -> &[Conv]
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 convolutions_mut(&mut self) -> &mut [Conv]
pub fn convolutions_mut(&mut self) -> &mut [Conv]
Return the convolution types.
Sourcepub fn charge_conjugate(&mut self, convolution: usize)
pub fn charge_conjugate(&mut self, convolution: usize)
Charge conjugate both the convolution function with index convolution and the PIDs in the
channel definition corresponding to it. This leaves the the results returned by
Grid::convolve invariant.
Sourcepub fn repair(&mut self) -> bool
pub fn repair(&mut self) -> bool
Repair the grid if it was written by bugged versions to disk.
Returns true if this operations did anything. Currently, this scans for these problems:
Sourcepub fn scale_by_order(
&mut self,
alphas: f64,
alpha: f64,
logxir: f64,
logxif: f64,
logxia: f64,
global: f64,
)
pub fn scale_by_order( &mut self, alphas: f64, alpha: f64, logxir: f64, logxif: f64, logxia: 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 const fn bwfl(&self) -> &BinsWithFillLimits
pub const fn bwfl(&self) -> &BinsWithFillLimits
TODO
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 fn metadata_mut(&mut self) -> &mut BTreeMap<String, String>
pub fn metadata_mut(&mut self) -> &mut BTreeMap<String, String>
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::convolve with the parameter order_mask.
Sourcepub fn evolve<'a, E: Into<Error>, S: IntoIterator<Item = Result<(OperatorSliceInfo, CowArray<'a, f64, Ix4>), E>>>(
&self,
slices: Vec<S>,
order_mask: &[bool],
xi: (f64, f64, f64),
alphas_table: &AlphasTable,
) -> Result<FkTable>
pub fn evolve<'a, E: Into<Error>, S: IntoIterator<Item = Result<(OperatorSliceInfo, CowArray<'a, f64, Ix4>), E>>>( &self, slices: Vec<S>, order_mask: &[bool], xi: (f64, f64, f64), alphas_table: &AlphasTable, ) -> Result<FkTable>
Convert this Grid into an FkTable using slices.len() evolution operators, which for
each entry 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 an error if either the operator or its info is incompatible with this Grid,
or 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 delete_orders(&mut self, order_indices: &[usize])
pub fn delete_orders(&mut self, order_indices: &[usize])
Delete orders with the corresponding order_indices. Repeated indices and indices larger
or equal than the number of orders 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.
Sourcepub fn merge_channel_factors(&mut self)
pub fn merge_channel_factors(&mut self)
Merges the factors of the channels into the subgrids to normalize channel coefficients.
This method factors out the smallest absolute coefficient from each channel using
[boc::Channel::factor] and then scales the corresponding subgrids by these factors.
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