25 template <
typename TX=
double>
40 return edges.size() - 1;
52 if (x <
edges.front())
throw std::out_of_range(
"Bin position underflow");
53 if (x >
edges.back())
throw std::out_of_range(
"Bin position overflow");
57 const size_t iguess = floor(
num_bins() * xfrac );
58 if (
edges[iguess] <= x &&
edges[iguess+1] > x)
return iguess;
60 if (
edges.size() > 64) {
61 const TX lnxlow = log(
edges.front());
62 const TX lnxtot = log(
edges.back()) - lnxlow;
63 const TX dlnx = log(x) - lnxlow;
64 const TX xfrac2 = dlnx / lnxtot;
65 const size_t iguess2 = floor(
num_bins() * xfrac2 );
66 if (
edges[iguess2] <= x &&
edges[iguess2+1] > x)
return iguess2;
71 if (i ==
edges.size()) i -= 1;
79 assert(
edges.size() > 1);
85 if (
edges.size() <= 1)
throw std::length_error(
"There must be 2 or more bin edges");
97 template <
typename TX=
double,
typename TY=
double>
102 Binning2D(
const std::vector<TX>& xbinedges,
const std::vector<TY>& ybinedges)
103 :
binningX(xbinedges), binningY(ybinedges)
110 :
binningX(xbinning), binningY(ybinning)
123 return binningY.num_bins();
143 return binningY.get_index(y);
175 template <
typename T,
typename TX=
double>
187 BinnedFn1D(
const std::vector<TX>& binedges,
const std::vector<T>& binvalues)
238 if (
values.size() < 1)
throw std::length_error(
"There must be 1 or more bin values");
239 if (
binning.size() !=
values.size())
throw std::length_error(
"There must be one more bin edge than there are bin values");
255 template <
typename T,
typename TX=
double,
typename TY=
double>
260 BinnedFn2D(
const std::vector<TX>& xbinedges,
const std::vector<TY>& ybinedges)
261 :
binning(xbinedges, ybinedges)
267 BinnedFn2D(
const std::vector<TX>& xbinedges,
const std::vector<TY>& ybinedges,
const std::vector<T>& binvalues)
300 return binning.get_index_pair(x, y);
332 const T&
get_at(
const TX& x,
const TY& y)
const {
349 void set_at(
const TX& x,
const TY& y,
const T& val) {
365 if (
values.size() < 1)
throw std::length_error(
"There must be 1 or more bin values");
366 if (
binning.size() !=
values.size())
throw std::length_error(
"There must be one more bin edge than there are bin values");
Definition: BinnedFn.h:176
std::vector< T > values
The list of values.
Definition: BinnedFn.h:247
BinnedFn1D(const std::vector< TX > &binedges, const std::vector< T > &binvalues)
Constructor taking lists of bin edges and values.
Definition: BinnedFn.h:187
size_t get_index(const TX &x) const
Get the bin index enclosing position x.
Definition: BinnedFn.h:200
const T & get_at_index(size_t ix) const
Get the value in bin number ix.
Definition: BinnedFn.h:205
void set_at(const TX &x, const T &val)
Set the value in the bin at position x.
Definition: BinnedFn.h:222
void reset()
Clear the bin contents (but leave the binning intact)
Definition: BinnedFn.h:228
void check() const
Check consistency of the edges and values vectors.
Definition: BinnedFn.h:236
void set_at_index(size_t ix, const T &val)
Set the value in bin number ix.
Definition: BinnedFn.h:216
size_t num_bins() const
Get the number of bins.
Definition: BinnedFn.h:195
BinnedFn1D(const std::vector< TX > &binedges)
Constructor taking a list of bin edges.
Definition: BinnedFn.h:180
const T & get_at(const TX &x) const
Get the value in the bin at position x.
Definition: BinnedFn.h:211
Binning1D< TX > binning
The list of bin edges.
Definition: BinnedFn.h:244
Definition: BinnedFn.h:256
void set_at(const TX &x, const TY &y, const T &val)
Set the value in the bin at position (x,y)
Definition: BinnedFn.h:349
Binning2D< TX, TY > binning
The list of bin edges.
Definition: BinnedFn.h:371
size_t get_index(const TX &x, const TY &y) const
Get the global bin index enclosing position (x,y)
Definition: BinnedFn.h:304
BinnedFn2D(const std::vector< TX > &xbinedges, const std::vector< TY > &ybinedges)
Constructor taking a list of bin edges.
Definition: BinnedFn.h:260
size_t num_bins_x() const
Get the number of bins in x.
Definition: BinnedFn.h:279
const T & get_at_index(size_t i) const
Get the value in global bin number i.
Definition: BinnedFn.h:321
void check() const
Check consistency of the edges and values vectors.
Definition: BinnedFn.h:363
size_t num_bins_y() const
Get the number of bins in y.
Definition: BinnedFn.h:283
size_t global_index(size_t ix, size_t iy) const
Get the global bin index from individual indices ix and iy.
Definition: BinnedFn.h:310
size_t get_index_x(const TX &x) const
Get the x bin index enclosing position x.
Definition: BinnedFn.h:289
void set_at_index(size_t i, const T &val)
Set the value in global bin number ix.
Definition: BinnedFn.h:338
BinnedFn2D(const std::vector< TX > &xbinedges, const std::vector< TY > &ybinedges, const std::vector< T > &binvalues)
Constructor taking lists of bin edges and values.
Definition: BinnedFn.h:267
size_t num_bins() const
Get the number of bins.
Definition: BinnedFn.h:275
const T & get_at_index(size_t ix, size_t iy) const
Get the value in bin number pair (ix, iy)
Definition: BinnedFn.h:327
size_t global_index(const std::pair< size_t, size_t > &ixiy) const
Get the global bin index from individual indices ix and iy.
Definition: BinnedFn.h:314
size_t get_index_y(const TY &y) const
Get the y bin index enclosing position y.
Definition: BinnedFn.h:294
std::vector< T > values
The list of values.
Definition: BinnedFn.h:374
const T & get_at(const TX &x, const TY &y) const
Get the value in the bin at position (x,y)
Definition: BinnedFn.h:332
void set_at_index(size_t ix, size_t iy, const T &val)
Set the value in bin number pair (ix, iy)
Definition: BinnedFn.h:344
std::pair< size_t, size_t > get_index_pair(const TX &x, const TY &y) const
Get the x,y bin index pair enclosing position (x,y)
Definition: BinnedFn.h:299
void reset()
Clear the bin contents (but leave the binning intact)
Definition: BinnedFn.h:355
Definition: BinnedFn.h:26
void check() const
Check consistency.
Definition: BinnedFn.h:84
size_t num_bins() const
Get the number of bins.
Definition: BinnedFn.h:38
Binning1D(const std::vector< TX > &binedges)
Constructor taking a list of bin edges.
Definition: BinnedFn.h:30
size_t get_index(const TX &x) const
Definition: BinnedFn.h:50
std::vector< TX > edges
The list of bin edges.
Definition: BinnedFn.h:89
size_t size() const
Get the number of bins.
Definition: BinnedFn.h:43
void reset()
Clear the bin contents (but leave the binning intact)
Definition: BinnedFn.h:78
Definition: BinnedFn.h:98
Binning1D< TX > binningX
The lists of bin edges.
Definition: BinnedFn.h:166
size_t get_index_x(const TX &x) const
Get the x bin index enclosing position x.
Definition: BinnedFn.h:137
Binning2D(const Binning1D< TX > &xbinning, const Binning1D< TY > &ybinning)
Constructor taking 1D binnings.
Definition: BinnedFn.h:109
size_t get_index_y(const TY &y) const
Get the y bin index enclosing position y.
Definition: BinnedFn.h:142
size_t size() const
Get the total number of bins.
Definition: BinnedFn.h:131
void check() const
Check consistency.
Definition: BinnedFn.h:160
void reset()
Clear the bin contents (but leave the binning intact)
Definition: BinnedFn.h:153
Binning2D(const std::vector< TX > &xbinedges, const std::vector< TY > &ybinedges)
Constructor taking lists of bin edges.
Definition: BinnedFn.h:102
size_t num_bins() const
Get the total number of bins.
Definition: BinnedFn.h:127
std::pair< size_t, size_t > get_index_pair(const TX &x, const TY &y) const
Get the (x,y) bin index pair enclosing position (x,y)
Definition: BinnedFn.h:147
size_t num_bins_y() const
Get the number of bins in y.
Definition: BinnedFn.h:122
size_t num_bins_x() const
Get the number of bins in x.
Definition: BinnedFn.h:117
Modified by Mark Goodsell goodsell@lpthe.jussieu.fr
Definition: ATLAS_SUSY_2018_16.cc:27