34 throw std::runtime_error(
35 "ConstKBinAxis::ConstKBinAxis() -> Error. start >= end is not allowed.");
37 double start_sin = std::sin(
m_start);
38 double end_sin = std::sin(
m_end);
39 double step = (end_sin - start_sin) / (
m_nbins);
41 std::vector<double> bin_boundaries;
42 bin_boundaries.resize(
m_nbins + 1, 0.0);
43 for (
size_t i = 0; i < bin_boundaries.size(); ++i)
44 bin_boundaries[i] = std::asin(start_sin + step * i);
56 throw std::runtime_error(
57 "ConstKBinAxis::clip() -> Error. 'lower' should be smaller than 'upper'");
67 size_t new_nbins = nbin2 - nbin1 + 1;
68 std::vector<double> new_boundaries;
70 for (
size_t i = 0; i < new_nbins + 1; ++i)
71 new_boundaries.push_back(old_boundaries[nbin1 + i]);
74 m_start = new_boundaries.front();
75 m_end = new_boundaries.back();
83 if (
const auto* otherAxis =
dynamic_cast<const ConstKBinAxis*
>(&other)) {
84 if (
size() != otherAxis->size())
97 ostr <<
"ConstKBinAxis(\"" <<
axisName() <<
"\", " <<
size() <<
", "
98 << std::setprecision(std::numeric_limits<double>::digits10 + 2) <<
m_start <<
", " <<
m_end
Defines and implements namespace BaseUtils::algo with some algorithms.
Defines structs Bin1D, Bin1DCVector.
Defines class ConstKBinAxis.
Axis with fixed bin size in sin(angle) space.
void print(std::ostream &ostr) const override
bool equals(const IAxis &other) const override
ConstKBinAxis(const std::string &name, size_t nbins, double start, double end)
ConstKBinAxis constructor.
void clip(double lower, double upper) override
Clips this axis to the given values.
ConstKBinAxis * clone() const override
Abstract base class for one-dimensional axes.
virtual bool equals(const IAxis &other) const
std::string axisName() const
Returns the label of the axis.
Axis with variable bin size.
double max() const override
Returns value of last point of axis.
void setBinBoundaries(const std::vector< double > &bin_boundaries)
Bin1D bin(size_t index) const override
retrieve a 1d bin for the given index
size_t size() const override
Returns the number of bins.
std::vector< double > binBoundaries() const override
size_t findClosestIndex(double value) const override
find bin index which is best match for given value
double min() const override
Returns value of first point of axis.
bool almostEqual(double a, double b)
Returns true if two doubles agree within machine epsilon.