7 #ifndef LHAPDF_KnotArray_H
8 #define LHAPDF_KnotArray_H
10 #include "LHAPDF/Exceptions.h"
29 KnotArray1F(
const std::vector<double>& xknots,
const std::vector<double>& q2knots,
const std::vector<double>&
xfs)
37 KnotArray1F(
const std::vector<double>& xknots,
const std::vector<double>& q2knots)
53 void setxs(
const std::vector<double>&
xs) {
56 _xfs = std::vector<double>(
size(), 0.0);
60 const size_t xsize()
const {
return _xs.size(); }
63 const std::vector<double>&
xs()
const {
return _xs; }
73 if (x <
xs().front())
throw GridError(
"x value " +
to_str(x) +
" is lower than lowest-x grid point at " +
to_str(
xs().front()));
74 if (x >
xs().back())
throw GridError(
"x value " +
to_str(x) +
" is higher than highest-x grid point at " +
to_str(
xs().back()));
76 size_t i = upper_bound(
xs().begin(),
xs().end(), x) -
xs().begin();
77 if (i ==
xs().
size()) i -= 1;
93 _xfs = std::vector<double>(
size(), 0.0);
100 const std::vector<double>&
q2s()
const {
return _q2s; }
110 if (q2 <
q2s().front())
throw GridError(
"Q2 value " +
to_str(q2) +
" is lower than lowest-Q2 grid point at " +
to_str(
q2s().front()));
111 if (q2 >
q2s().back())
throw GridError(
"Q2 value " +
to_str(q2) +
" is higher than highest-Q2 grid point at " +
to_str(
q2s().back()));
113 size_t i = upper_bound(
q2s().begin(),
q2s().end(), q2) -
q2s().begin();
129 const std::vector<double>&
xfs()
const {
return _xfs; }
136 const double&
xf(
size_t ix,
size_t iq2)
const {
return _xfs[ix*
q2size() + iq2]; }
147 for (
size_t i = 0; i <
_xs.size(); ++i)
_logxs[i] = log(
_xs[i]);
185 return _map.find(
id)->second;
190 if (
empty())
throw GridError(
"Tried to access grid indices when no flavour grids were loaded");
191 return _map.begin()->second;
219 std::map<int, KnotArray1F>
_map;
236 AlphaSArray(
const std::vector<double>& q2knots,
const std::vector<double>& as)
249 const std::vector<double>&
q2s()
const {
return _q2s; }
262 size_t i = upper_bound(
q2s().begin(),
q2s().end(), q2) -
q2s().begin();
263 if (i ==
q2s().size()) i -= 1;
277 if (i ==
logq2s().size()) i -= 1;
289 const std::vector<double>&
alphas()
const {
return _as; }
const std::vector< double > & q2s() const
Q2 knot vector accessor.
Definition: KnotArray.h:249
KnotArray1F & operator[](int id)
Indexing operator (non-const)
Definition: KnotArray.h:200
std::vector< double > & xfs()
xf value accessor (non-const)
Definition: KnotArray.h:131
const std::vector< double > & logxs() const
Access the log(x)s array.
Definition: KnotArray.h:205
size_t iq2below(double q2) const
Definition: KnotArray.h:108
std::vector< double > _logq2s
List of log(Q2) knots.
Definition: KnotArray.h:158
size_t iq2below(double q2) const
Get the index of the closest Q2 knot row <= q2 (see KnotArray1F)
Definition: KnotArray.h:214
Error for general PDF grid problems.
Definition: Exceptions.h:30
const std::vector< double > & q2s() const
Q2 knot accessor.
Definition: KnotArray.h:100
const std::vector< double > & q2s() const
Access the Q2s array.
Definition: KnotArray.h:210
const KnotArray1F & get_first() const
Convenience accessor for any valid subgrid, to get access to the x/Q2/etc. arrays.
Definition: KnotArray.h:189
const size_t size() const
Number of x knots.
Definition: KnotArray.h:126
Internal storage class for PDF data point grids.
Definition: KnotArray.h:19
void setxfs(const std::vector< double > &xfs)
xf value setter
Definition: KnotArray.h:133
void setq2s(const std::vector< double > &q2s)
Definition: KnotArray.h:90
const std::vector< double > & xfs() const
xf value accessor (const)
Definition: KnotArray.h:129
const std::vector< double > & logq2s() const
Access the log(Q2)s array.
Definition: KnotArray.h:212
AlphaSArray()
Default constructor just for std::map insertability.
Definition: KnotArray.h:233
std::vector< double > _as
List of alpha_s values across the knot array.
Definition: KnotArray.h:332
size_t ilogq2below(double logq2) const
Definition: KnotArray.h:271
std::string to_str(const T &val)
Make a string representation of val.
Definition: Utils.h:60
const std::vector< double > & logxs() const
log(x) knot accessor
Definition: KnotArray.h:66
size_t ixbelow(double x) const
Get the index of the closest x knot row <= x.
Definition: KnotArray.h:71
size_t ixbelow(double x) const
Get the index of the closest x knot column <= x (see KnotArray1F)
Definition: KnotArray.h:207
Internal storage class for alpha_s interpolation grids.
Definition: KnotArray.h:226
Error for requests for unsupported/invalid flavour PIDs.
Definition: Exceptions.h:70
std::vector< double > _logq2s
List of log(Q2) knots.
Definition: KnotArray.h:330
const std::vector< double > & logq2s() const
log(Q2) knot accessor
Definition: KnotArray.h:103
void _synclogs()
Synchronise log(x) and log(Q2) arrays from the x and Q2 ones.
Definition: KnotArray.h:144
const std::vector< double > & logq2s() const
log(Q2) knot vector accessor
Definition: KnotArray.h:252
bool has_pid(int id) const
Does this contain a KnotArray1F for PID code id?
Definition: KnotArray.h:178
double ddlogq_forward(size_t i) const
Forward derivative w.r.t. logQ2.
Definition: KnotArray.h:302
AlphaSArray(const std::vector< double > &q2knots, const std::vector< double > &as)
Constructor from Q2 knot values and alpha_s values.
Definition: KnotArray.h:236
void set_pid(int id, const KnotArray1F &ka)
Get the KnotArray1F for PID code id.
Definition: KnotArray.h:195
KnotArray1F()
Default constructor just for std::map insertability.
Definition: KnotArray.h:26
const size_t xsize() const
Number of x knots.
Definition: KnotArray.h:60
void _synclogs()
Synchronise the log(Q2) array from the Q2 one.
Definition: KnotArray.h:322
double ddlogq_backward(size_t i) const
Backward derivative w.r.t. logQ2.
Definition: KnotArray.h:307
double ddlogq_central(size_t i) const
Central (avg of forward and backward) derivative w.r.t. logQ2.
Definition: KnotArray.h:312
const std::vector< double > & xs() const
Access the xs array.
Definition: KnotArray.h:203
std::vector< double > _q2s
List of Q2 knots.
Definition: KnotArray.h:154
Error for general AlphaS computation problems.
Definition: Exceptions.h:94
std::vector< double > _logxs
List of log(x) knots.
Definition: KnotArray.h:156
std::vector< double > _xs
List of x knots.
Definition: KnotArray.h:152
A collection of {KnotArray1F}s accessed by PID code.
Definition: KnotArray.h:168
std::vector< double > _xfs
List of xf values across the 2D knot array, stored as a strided [ix][iQ2] 1D array.
Definition: KnotArray.h:160
KnotArray1F(const std::vector< double > &xknots, const std::vector< double > &q2knots)
Constructor of a zero-valued array from x and Q2 knot values.
Definition: KnotArray.h:37
const size_t q2size() const
Number of Q2 knots.
Definition: KnotArray.h:97
bool empty() const
Is this container empty?
Definition: KnotArray.h:175
const double & xf(size_t ix, size_t iq2) const
Get the xf value at a particular indexed x,Q2 knot.
Definition: KnotArray.h:136
size_t size() const
How many {KnotArray1F}s are stored in this container?
Definition: KnotArray.h:172
const std::vector< double > & alphas() const
alpha_s value accessor (const)
Definition: KnotArray.h:289
const KnotArray1F & get_pid(int id) const
Get the KnotArray1F for PID code id.
Definition: KnotArray.h:183
size_t iq2below(double q2) const
Definition: KnotArray.h:257
KnotArray1F(const std::vector< double > &xknots, const std::vector< double > &q2knots, const std::vector< double > &xfs)
Constructor from x and Q2 knot values, and an xf value grid as strided list.
Definition: KnotArray.h:29
Namespace for all LHAPDF functions and classes.
Definition: AlphaS.h:14
std::vector< double > _q2s
List of Q2 knots.
Definition: KnotArray.h:328
std::map< int, KnotArray1F > _map
Storage.
Definition: KnotArray.h:219
const std::vector< double > & xs() const
x knot accessor
Definition: KnotArray.h:63
void setxs(const std::vector< double > &xs)
Definition: KnotArray.h:53