Struct pineappl::grid::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( lumi: Vec<LumiEntry>, orders: Vec<Order>, bin_limits: Vec<f64>, subgrid_params: SubgridParams ) -> Self

Constructor.

source

pub fn with_subgrid_type( lumi: Vec<LumiEntry>, 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 convolute( &self, lumi_cache: &mut LumiCache<'_>, order_mask: &[bool], bin_indices: &[usize], lumi_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 luminosities corresponding to order_mask, bin_indices and lumi_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 convolute_subgrid( &self, lumi_cache: &mut LumiCache<'_>, ord: usize, bin: usize, lumi: usize, xir: f64, xif: f64 ) -> Array3<f64>

Convolutes a single subgrid (order, bin, lumi) 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, lumi: usize, ntuple: &Ntuple<f64> )

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

§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 must be ordered as the corresponding luminosity function was created.

source

pub fn lumi(&self) -> &[LumiEntry]

Returns the luminosity function.

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 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 set_lumis(&mut self, lumis: Vec<LumiEntry>)

Set the luminosity function for this grid.

source

pub fn subgrid(&self, order: usize, bin: usize, lumi: usize) -> &SubgridEnum

Returns the subgrid with the specified indices order, bin, and lumi.

source

pub const fn subgrids(&self) -> &Array3<SubgridEnum>

Returns all subgrids as an Array3.

source

pub fn set_subgrid( &mut self, order: usize, bin: usize, lumi: usize, subgrid: SubgridEnum )

Replaces the subgrid for the specified indices order, bin, and lumi with subgrid.

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 axes(&self) -> Option<GridAxes>

👎Deprecated since 0.6.0: use evolve_info instead

Provide information used to compute a suitable EKO for the current grid. More specific, the x_grid and muf2_grid are extracted and checked.

§Panics

TODO

source

pub fn convolute_eko( &self, operator: Array5<f64>, eko_info: EkoInfo, order_mask: &[bool] ) -> Option<FkTable>

👎Deprecated since 0.6.0: use evolve instead

Applies an evolution kernel operator (EKO) to the grids to evolve them from different values of the factorization scale to a single one given by the parameter q2. Using xir and xif you can trigger renormalization and factorization scale variations respectively in the grid.

§Panics

Panics if the parameters do not match with the given grid.

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>

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 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 split_lumi(&mut self)

Splits the grid such that the luminosity function contains only a single combination per channel.

source

pub fn has_pdf1(&self) -> bool

Returns true if the first initial state needs a convolution, false otherwise.

source

pub fn has_pdf2(&self) -> bool

Returns true if the second initial state needs a convolution, false otherwise.

source

pub fn initial_state_1(&self) -> i32

Returns the particle identifier of the first initial state. This is usually but not always a proton, which is represented by the PDG ID 2212.

§Panics

TODO

source

pub fn initial_state_2(&self) -> i32

Returns the particle identifier of the second initial state. This is usually but not always a proton, which is represented by the PDG ID 2212.

§Panics

TODO

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

§

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