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
sourceimpl Grid
impl Grid
sourcepub fn new(
lumi: Vec<LumiEntry>,
orders: Vec<Order>,
bin_limits: Vec<f64>,
subgrid_params: SubgridParams
) -> Self
pub fn new(
lumi: Vec<LumiEntry>,
orders: Vec<Order>,
bin_limits: Vec<f64>,
subgrid_params: SubgridParams
) -> Self
Constructor.
sourcepub 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>
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.
sourcepub fn convolute(
&self,
lumi_cache: &mut LumiCache<'_>,
order_mask: &[bool],
bin_indices: &[usize],
lumi_mask: &[bool],
xi: &[(f64, f64)]
) -> Vec<f64>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
pub fn convolute(
&self,
lumi_cache: &mut LumiCache<'_>,
order_mask: &[bool],
bin_indices: &[usize],
lumi_mask: &[bool],
xi: &[(f64, f64)]
) -> Vec<f64>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
A: Allocator,
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
sourcepub fn convolute_subgrid(
&self,
lumi_cache: &mut LumiCache<'_>,
ord: usize,
bin: usize,
lumi: usize,
xir: f64,
xif: f64
) -> Array3<f64>
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
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 must be ordered as
the corresponding luminosity function was created.
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 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 subgrid(&self, order: usize, bin: usize, lumi: usize) -> &SubgridEnum
pub fn subgrid(&self, order: usize, bin: usize, lumi: usize) -> &SubgridEnum
Returns the subgrid with the specified indices order
, bin
, and lumi
.
sourcepub const fn subgrids(&self) -> &Array3<SubgridEnum>
pub const fn subgrids(&self) -> &Array3<SubgridEnum>
Returns all subgrids as an Array3
.
sourcepub fn set_subgrid(
&mut self,
order: usize,
bin: usize,
lumi: usize,
subgrid: SubgridEnum
)
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
.
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)
Optimize the internal datastructures for space efficiency. This changes all subgrids of
type LagrangeSubgrid
to LagrangeSparseSubgrid
.
Panics
TODO
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 axes(&self) -> Option<GridAxes>
pub fn axes(&self) -> Option<GridAxes>
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
sourcepub fn convolute_eko(
&self,
operator: Array5<f64>,
eko_info: EkoInfo,
order_mask: &[bool]
) -> Option<FkTable>
pub fn convolute_eko(
&self,
operator: Array5<f64>,
eko_info: EkoInfo,
order_mask: &[bool]
) -> Option<FkTable>
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.
sourcepub fn evolve(
&self,
operator: &Array5<f64>,
info: &OperatorInfo,
order_mask: &[bool]
) -> Result<FkTable, GridError>
pub fn evolve(
&self,
operator: &Array5<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 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 has_pdf1(&self) -> bool
pub fn has_pdf1(&self) -> bool
Returns true
if the first initial state needs a convolution, false
otherwise.
sourcepub fn has_pdf2(&self) -> bool
pub fn has_pdf2(&self) -> bool
Returns true
if the second initial state needs a convolution, false
otherwise.
sourcepub fn initial_state_1(&self) -> i32
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
.
sourcepub fn initial_state_2(&self) -> i32
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
.