7 #ifndef LHAPDF_KnotArray_H
8 #define LHAPDF_KnotArray_H
10 #include "LHAPDF/Exceptions.h"
11 #include "LHAPDF/Utils.h"
27 KnotArray1F(
const std::vector<double>& xknots,
const std::vector<double>& q2knots,
const std::vector<double>&
xfs)
36 KnotArray1F(
const std::vector<double>& xknots,
const std::vector<double>& q2knots)
52 void setxs(
const std::vector<double>&
xs) {
55 _xfs = std::vector<double>(
size(), 0.0);
62 const std::vector<double>&
xs()
const {
return _xs; }
76 if (x <
xs().front())
throw GridError(
"x value " +
to_str(x) +
" is lower than lowest-x grid point at " +
to_str(
xs().front()));
77 if (x >
xs().back())
throw GridError(
"x value " +
to_str(x) +
" is higher than highest-x grid point at " +
to_str(
xs().back()));
79 size_t i = upper_bound(
xs().begin(),
xs().end(), x) -
xs().begin();
80 if (i ==
xs().
size()) i -= 1;
97 _xfs = std::vector<double>(
size(), 0.0);
104 const std::vector<double>&
q2s()
const {
return _q2s; }
118 if (q2 <
q2s().front())
throw GridError(
"Q2 value " +
to_str(q2) +
" is lower than lowest-Q2 grid point at " +
to_str(
q2s().front()));
119 if (q2 >
q2s().back())
throw GridError(
"Q2 value " +
to_str(q2) +
" is higher than highest-Q2 grid point at " +
to_str(
q2s().back()));
121 size_t i = upper_bound(
q2s().begin(),
q2s().end(), q2) -
q2s().begin();
137 const std::vector<double>&
xfs()
const {
return _xfs; }
144 const double&
xf(
size_t ix,
size_t iq2)
const {
return _xfs[ix*
q2size() + iq2]; }
154 for (
size_t i = 0; i <
_xs.size(); ++i)
_logxs[i] = log(
_xs[i]);
168 size_t _mkhash(
const std::vector<double>& xx)
const;
211 return _map.find(
id)->second;
216 if (
empty())
throw GridError(
"Tried to access grid indices when no flavour grids were loaded");
217 return _map.begin()->second;
245 std::map<int, KnotArray1F>
_map;
262 AlphaSArray(
const std::vector<double>& q2knots,
const std::vector<double>& as)
275 const std::vector<double>&
q2s()
const {
return _q2s; }
288 size_t i = upper_bound(
q2s().begin(),
q2s().end(), q2) -
q2s().begin();
289 if (i ==
q2s().size()) i -= 1;
303 if (i ==
logq2s().size()) i -= 1;
315 const std::vector<double>&
alphas()
const {
return _as; }
Internal storage class for alpha_s interpolation grids.
Definition: KnotArray.h:252
size_t iq2below(double q2) const
Definition: KnotArray.h:283
const std::vector< double > & alphas() const
alpha_s value accessor (const)
Definition: KnotArray.h:315
std::vector< double > _as
List of alpha_s values across the knot array.
Definition: KnotArray.h:358
AlphaSArray(const std::vector< double > &q2knots, const std::vector< double > &as)
Constructor from Q2 knot values and alpha_s values.
Definition: KnotArray.h:262
std::vector< double > _logq2s
List of log(Q2) knots.
Definition: KnotArray.h:356
AlphaSArray()
Default constructor just for std::map insertability.
Definition: KnotArray.h:259
double ddlogq_forward(size_t i) const
Forward derivative w.r.t. logQ2.
Definition: KnotArray.h:328
std::vector< double > _q2s
List of Q2 knots.
Definition: KnotArray.h:354
const std::vector< double > & logq2s() const
log(Q2) knot vector accessor
Definition: KnotArray.h:278
void _syncq2s()
Synchronise the log(Q2) array from the Q2 one.
Definition: KnotArray.h:348
double ddlogq_backward(size_t i) const
Backward derivative w.r.t. logQ2.
Definition: KnotArray.h:333
const std::vector< double > & q2s() const
Q2 knot vector accessor.
Definition: KnotArray.h:275
size_t ilogq2below(double logq2) const
Definition: KnotArray.h:297
double ddlogq_central(size_t i) const
Central (avg of forward and backward) derivative w.r.t. logQ2.
Definition: KnotArray.h:338
Error for general AlphaS computation problems.
Definition: Exceptions.h:94
Error for requests for unsupported/invalid flavour PIDs.
Definition: Exceptions.h:70
Error for general PDF grid problems.
Definition: Exceptions.h:30
Internal storage class for PDF data point grids.
Definition: KnotArray.h:20
size_t _q2gridhash
Hash for this set of Q2 knots.
Definition: KnotArray.h:182
size_t size() const
Number of x knots.
Definition: KnotArray.h:134
std::vector< double > _q2s
List of Q2 knots.
Definition: KnotArray.h:178
void _syncq2()
Synchronise log(x) and log(Q2) arrays from the x and Q2 ones.
Definition: KnotArray.h:160
size_t q2size() const
Number of Q2 knots.
Definition: KnotArray.h:101
std::vector< double > _logq2s
List of log(Q2) knots, precomputed for efficiency.
Definition: KnotArray.h:180
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:36
KnotArray1F()
Default constructor just for std::map insertability.
Definition: KnotArray.h:24
std::vector< double > _xfs
List of xf values across the 2D knot array, stored as a strided [ix][iQ2] 1D array.
Definition: KnotArray.h:185
void setq2s(const std::vector< double > &q2s)
Definition: KnotArray.h:94
size_t iq2below(double q2) const
Definition: KnotArray.h:116
const std::vector< double > & xs() const
x knot accessor
Definition: KnotArray.h:62
std::vector< double > _xs
List of x knots.
Definition: KnotArray.h:171
size_t _xgridhash
Hash for this set of x knots.
Definition: KnotArray.h:175
const std::vector< double > & xfs() const
xf value accessor (const)
Definition: KnotArray.h:137
std::vector< double > & xfs()
xf value accessor (non-const)
Definition: KnotArray.h:139
size_t ixbelow(double x) const
Get the index of the closest x knot row <= x.
Definition: KnotArray.h:74
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:27
const std::vector< double > & logxs() const
log(x) knot accessor
Definition: KnotArray.h:65
size_t _mkhash(const std::vector< double > &xx) const
Utility function for making a hash code from a vector<double>
const double & xf(size_t ix, size_t iq2) const
Get the xf value at a particular indexed x,Q2 knot.
Definition: KnotArray.h:144
void setxfs(const std::vector< double > &xfs)
xf value setter
Definition: KnotArray.h:141
const std::vector< double > & q2s() const
Q2 knot accessor.
Definition: KnotArray.h:104
bool samexs(const KnotArray1F &other) const
Hash comparator.
Definition: KnotArray.h:68
bool sameq2s(const KnotArray1F &other) const
Hash comparator for Q2 knots.
Definition: KnotArray.h:110
void _syncx()
Synchronise log(x) array and hash from the x array.
Definition: KnotArray.h:152
std::vector< double > _logxs
List of log(x) knots, precomputed for efficiency.
Definition: KnotArray.h:173
void setxs(const std::vector< double > &xs)
Definition: KnotArray.h:52
const std::vector< double > & logq2s() const
log(Q2) knot accessor
Definition: KnotArray.h:107
size_t xsize() const
Number of x knots.
Definition: KnotArray.h:59
A collection of {KnotArray1F}s accessed by PID code.
Definition: KnotArray.h:194
std::map< int, KnotArray1F > _map
Storage.
Definition: KnotArray.h:245
bool empty() const
Is this container empty?
Definition: KnotArray.h:201
const std::vector< double > & logxs() const
Access the log(x)s array.
Definition: KnotArray.h:231
size_t size() const
How many {KnotArray1F}s are stored in this container?
Definition: KnotArray.h:198
void set_pid(int id, const KnotArray1F &ka)
Get the KnotArray1F for PID code id.
Definition: KnotArray.h:221
KnotArray1F & operator[](int id)
Indexing operator (non-const)
Definition: KnotArray.h:226
size_t ixbelow(double x) const
Get the index of the closest x knot column <= x (see KnotArray1F)
Definition: KnotArray.h:233
const std::vector< double > & q2s() const
Access the Q2s array.
Definition: KnotArray.h:236
const std::vector< double > & xs() const
Access the xs array.
Definition: KnotArray.h:229
const KnotArray1F & get_first() const
Convenience accessor for any valid subgrid, to get access to the x/Q2/etc. arrays.
Definition: KnotArray.h:215
const std::vector< double > & logq2s() const
Access the log(Q2)s array.
Definition: KnotArray.h:238
const KnotArray1F & get_pid(int id) const
Get the KnotArray1F for PID code id.
Definition: KnotArray.h:209
bool has_pid(int id) const
Does this contain a KnotArray1F for PID code id?
Definition: KnotArray.h:204
size_t iq2below(double q2) const
Get the index of the closest Q2 knot row <= q2 (see KnotArray1F)
Definition: KnotArray.h:240
std::string to_str(const T &val)
Make a string representation of val.
Definition: Utils.h:61
Namespace for all LHAPDF functions and classes.
Definition: AlphaS.h:14