10 #ifndef ICARUSALG_UTILITIES_BINNINGSPECS_H
11 #define ICARUSALG_UTILITIES_BINNINGSPECS_H
15 #include <initializer_list>
20 namespace icarus::ns::util {
43 { 1.0, 0.8, 2.0, 0.5, 4.0, 5.0, 10.0, 20.0 };
72 double lower,
double upper,
double width,
100 double lower,
double upper,
unsigned long nBins,
122 (BinningSpecs
const& binning,
double boundary,
bool extendCoverage =
true);
147 double lower,
double upper,
double width,
unsigned long nBins,
216 std::pair<double, double>
binBorders(
int iBin)
const;
230 #endif // ICARUSALG_UTILITIES_BINNINGSPECS_H
double range() const
Returns the full range covered by the binning.
unsigned long fNBins
Number of bins.
constexpr double DefaultAllowedBinningStretch
Stretch factor on the requested binning range an algorithm is allowed.
int binWith(double value) const
BinningSpecs(double lower, double upper, double width)
Constructor: all fields specified, no adjustment performed.
double lower() const
Returns the value of the lower end of the first bin.
double chooseBinningWidth(double lower, double upper, double width, unsigned long nBins, std::initializer_list< double > hints=DefaultBinningHints, double allowedStretch=DefaultAllowedBinningStretch)
Returns the "optimal" bin width for the requested parameters.
BinningSpecs alignBinningTo(BinningSpecs const &binning, double boundary, bool extendCoverage=true)
Returns a binning shifted to align with the specified boundary.
double fUpper
Upper range limit.
Data structure holding binning information.
double binWidth() const
Returns the width of the bins (all bins have the same width).
std::pair< double, double > binBorders(int iBin) const
Returns the lower and upper borders of the bin with the specified index.
constexpr std::initializer_list< double > DefaultBinningHints
Set of bin sizes to be considered by the binning algorithms.
double fLower
Lower range limit.
double fWidth
Width of all bins.
double upper() const
Returns the value of the upper end of the last bin.
static unsigned long NBinsFor(double lower, double upper, double width)
Returns a number of bins large enough to cover the specified range.
BinningSpecs makeBinningFromNBins(double lower, double upper, unsigned long nBins, std::initializer_list< double > hints=DefaultBinningHints, double allowedStretch=DefaultAllowedBinningStretch)
Returns the "optimal" binning for the requested parameters.
unsigned long nBins() const
Returns the number of bins.
BinningSpecs makeBinningFromBinWidth(double lower, double upper, double width, std::initializer_list< double > hints=DefaultBinningHints, double allowedStretch=DefaultAllowedBinningStretch)
Returns the "optimal" binning for the requested parameters.