62 ApplyFineBinning(
const std::vector<std::pair<double, double>>& input,
unsigned nbins) {
63 std::vector<std::pair<double, double>> ret;
66 std::map<double, double> buffer;
68 for (
auto entry : input)
69 buffer[entry.first] = entry.second;
72 if (buffer.size() < 2 || nbins < 2)
75 double from = (*buffer.begin()).first;
76 double to = (*buffer.rbegin()).first;
78 double step = (to - from) / nbins;
80 for (
auto entry : buffer) {
81 double e1 = entry.first;
82 double qe1 = entry.second;
85 ret.push_back(std::make_pair(e1, qe1));
87 const auto& prev = ret[ret.size() - 1];
89 double e0 = prev.first;
90 double qe0 = prev.second;
91 double a = (qe1 - qe0) / (e1 - e0);
92 double b = qe0 - a * e0;
95 for (
double e = e0 + step; e < e1; e += step)
96 ret.push_back(std::make_pair(e, a * e + b));
106 double argument,
double* entry) {
109 unsigned dim = table.size();
114 auto const& from = table[0];
115 auto const& to = table[dim - 1];
116 double emin = from.first;
117 double emax = to.first;
118 double step = (emax - emin) / (dim - 1);
119 int ibin = (int)floor((argument - emin) / step);
124 if (ibin < 0 || ibin >=
int(dim))
127 *entry = table[ibin].second;