38 throw std::runtime_error(
"FixedBinAxis::operator[] -> Error. Wrong index.");
41 return m_start + (index + 0.5) * step;
47 throw std::runtime_error(
"FixedBinAxis::bin() -> Error. Wrong index.");
62 return int((value -
m_start) / step);
67 std::vector<double> result;
68 result.resize(
size(), 0.0);
69 for (
size_t i = 0; i <
size(); ++i)
76 std::vector<double> result;
77 result.resize(
size() + 1, 0.0);
78 for (
size_t i = 0; i <
size(); ++i)
87 throw std::runtime_error(
88 "FixedBinAxis::clip() -> Error. 'lower' should be smaller than 'upper'");
110 ostr <<
"FixedBinAxis(\"" <<
axisName() <<
"\", " <<
size() <<
", "
111 << std::setprecision(std::numeric_limits<double>::digits10 + 2) <<
min() <<
", " <<
max()
119 if (
const auto* otherAxis =
dynamic_cast<const FixedBinAxis*
>(&other)) {
120 if (
size() != otherAxis->size())
Defines and implements namespace BaseUtils::algo with some algorithms.
Defines structs Bin1D, Bin1DCVector.
Defines class FixedBinAxis.
double m_upper
upper bound of the bin
double m_lower
lower bound of the bin
Axis with fixed bin size.
bool equals(const IAxis &other) const override
void clip(double lower, double upper) override
Clips this axis to the given values.
std::vector< double > binCenters() const override
FixedBinAxis * clone() const override
size_t findClosestIndex(double value) const override
find bin index which is best match for given value
void print(std::ostream &ostr) const override
double operator[](size_t index) const override
indexed accessor retrieves a sample
size_t size() const override
Returns the number of bins.
double max() const override
Returns value of last point of axis.
Bin1D bin(size_t index) const override
retrieve a 1d bin for the given index
double min() const override
Returns value of first point of axis.
std::vector< double > binBoundaries() const override
FixedBinAxis(const std::string &name, size_t nbins, double start, double end)
FixedBinAxis constructor.
Abstract base class for one-dimensional axes.
virtual bool equals(const IAxis &other) const
std::string axisName() const
Returns the label of the axis.
bool almostEqual(double a, double b)
Returns true if two doubles agree within machine epsilon.