Grid

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

Source

pub const fn reference(&self) -> &Reference

TODO

Source

pub fn set_reference(&mut self, reference: Reference)

TODO

Source

pub const fn pid_basis(&self) -> &PidBasis

Return the convention by which the channels’ PIDs are encoded.

Source

pub fn interpolations(&self) -> &[Interp]

Return a vector containing the interpolation specifications for this grid.

Source

pub fn kinematics(&self) -> &[Kinematics]

Return a vector containing the kinematic specifications for this grid.

Source

pub const fn scales(&self) -> &Scales

Return a vector containg the scale specifications for this grid.

Source

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

Source

pub fn fill( &mut self, order: usize, observable: f64, channel: usize, ntuple: &[f64], weight: f64, )

Fills the grid with an ntuple for the given order, observable, and channel. The parameter ntuple must contain the variables specified by the kinematics parameter in the constructor Grid::new in the same order.

§Panics

TODO

Source

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.

Source

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

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<()>

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

§Errors

If writing or compression fails an error is returned.

Source

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

Return the channels for this Grid.

Source

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.

Source

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.

Source

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.

Source

pub fn convolutions_mut(&mut self) -> &mut [Conv]

Return the convolution types.

Source

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.

Source

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

Scale all subgrids by factor.

Source

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:

Source

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

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_bwfl(&mut self, bwfl: BinsWithFillLimits) -> Result<()>

TODO

§Errors

TODO

Source

pub const fn bwfl(&self) -> &BinsWithFillLimits

TODO

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 metadata(&self) -> &BTreeMap<String, String>

Return the metadata of this grid.

Source

pub fn metadata_mut(&mut self) -> &mut BTreeMap<String, String>

Return the metadata of 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::convolve with the parameter order_mask.

Source

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.

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

Source

pub fn split_channels(&mut self)

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

Source

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 Clone for Grid

Source§

fn clone(&self) -> Grid

Returns a duplicate 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 = Error

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

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

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

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