PDFxTMDLib  1.0.0
InterpolateQCDCoupling.h
Go to the documentation of this file.
1 // taken from lhapdf
2 #pragma once
5 #include <array>
6 #include <map>
7 #include <memory>
8 #include <string>
9 #include <vector>
10 
11 namespace PDFxTMD
12 {
14 {
15  public:
16  void initialize(const YamlCouplingInfo &couplingInfo);
17  double AlphaQCDMu2(double mu2);
18 
19  private:
20  void setup_grids();
21  double interpolateCubic(double T, double VL, double VDL, double VH, double VDH) const;
22  class AlphaSArray
23  {
24  public:
25  AlphaSArray() = default;
26  AlphaSArray(const std::vector<double> &q2knots, const std::vector<double> &as)
27  : _q2s(q2knots), _as(as)
28  {
29  _syncq2s();
30  }
31  const std::vector<double> &q2s() const
32  {
33  return _q2s;
34  }
35 
36  const std::vector<double> &logq2s() const
37  {
38  return _logq2s;
39  }
40 
44  size_t iq2below(double q2) const
45  {
46  // Test that Q2 is in the grid range
47  if (q2 < q2s().front())
48  throw AlphaQCDError("Q2 value " + std::to_string(q2) +
49  " is lower than lowest-Q2 grid point at " +
50  std::to_string(q2s().front()));
51  if (q2 > q2s().back())
52  throw AlphaQCDError("Q2 value " + std::to_string(q2) +
53  " is higher than highest-Q2 grid point at " +
54  std::to_string(q2s().back()));
56  size_t i = upper_bound(q2s().begin(), q2s().end(), q2) - q2s().begin();
57  if (i == q2s().size())
58  i -= 1; // can't return the last knot index
59  i -= 1; // have to step back to get the knot <= q2 behaviour
60  return i;
61  }
62 
66  size_t ilogq2below(double logq2) const
67  {
68  // Test that log(Q2) is in the grid range
69  if (logq2 < logq2s().front())
70  throw AlphaQCDError("logQ2 value " + std::to_string(logq2) +
71  " is lower than lowest-logQ2 grid point at " +
72  std::to_string(logq2s().front()));
73  if (logq2 > logq2s().back())
74  throw AlphaQCDError("logQ2 value " + std::to_string(logq2) +
75  " is higher than highest-logQ2 grid point at " +
76  std::to_string(logq2s().back()));
78  size_t i = upper_bound(logq2s().begin(), logq2s().end(), logq2) - logq2s().begin();
79  if (i == logq2s().size())
80  i -= 1; // can't return the last knot index
81  i -= 1; // have to step back to get the knot <= q2 behaviour
82  return i;
83  }
84  const std::vector<double> &alphas() const
85  {
86  return _as;
87  }
88 
90  double ddlogq_forward(size_t i) const
91  {
92  return (alphas()[i + 1] - alphas()[i]) / (logq2s()[i + 1] - logq2s()[i]);
93  }
94 
96  double ddlogq_backward(size_t i) const
97  {
98  return (alphas()[i] - alphas()[i - 1]) / (logq2s()[i] - logq2s()[i - 1]);
99  }
100 
102  double ddlogq_central(size_t i) const
103  {
104  return 0.5 * (ddlogq_forward(i) + ddlogq_backward(i));
105  }
106 
107  private:
109  void _syncq2s()
110  {
111  _logq2s.resize(_q2s.size());
112  for (size_t i = 0; i < _q2s.size(); ++i)
113  _logq2s[i] = log(_q2s[i]);
114  }
115 
117  std::vector<double> _q2s;
119  std::vector<double> _logq2s;
121  std::vector<double> _as;
122  };
123 
124  private:
125  double m_mu2Min = 0;
126  double m_mu2Max = 0;
127  std::vector<double> m_mu2_vec;
128  std::vector<double> m_alsphasVec_vec;
129  std::vector<double> m_logMu2_vec;
130  std::array<int, 1> m_dimensions;
131  YamlCouplingInfo m_couplingInfo;
132  std::map<double, AlphaSArray> _knotarrays;
133 };
134 } // namespace PDFxTMD
Definition: InterpolateQCDCoupling.h:14
double AlphaQCDMu2(double mu2)
void initialize(const YamlCouplingInfo &couplingInfo)
Definition: AllFlavorsShape.h:14
int mu2
Definition: pdfset_tutorial.py:14
Definition: YamlCouplingInfo.h:25