30 "ConstKBinAxis::ConstKBinAxis() -> Error. start >= end is not allowed.");
32 double start_sin = std::sin(
m_start);
33 double end_sin = std::sin(
m_end);
34 double step = (end_sin - start_sin) / (
m_nbins);
36 std::vector<double> bin_boundaries;
37 bin_boundaries.resize(
m_nbins + 1, 0.0);
38 for (
size_t i = 0; i < bin_boundaries.size(); ++i) {
39 bin_boundaries[i] = std::asin(start_sin + step * i);
53 "ConstKBinAxis::createClippedAxis() -> Error. 'left'' should be smaller than 'right'");
63 size_t new_nbins = nbin2 - nbin1 + 1;
64 std::vector<double> new_boundaries;
66 for (
size_t i = 0; i < new_nbins + 1; ++i) {
67 new_boundaries.push_back(old_boundaries[nbin1 + i]);
71 result->
m_start = new_boundaries.front();
72 result->
m_end = new_boundaries.back();
82 if (
size() != otherAxis->size())
95 ostr <<
"ConstKBinAxis(\"" <<
getName() <<
"\", " <<
size() <<
", "
96 << std::setprecision(std::numeric_limits<double>::digits10 + 2) <<
m_start <<
", " <<
m_end
Defines and implements namespace algo with some algorithms.
Defines class ConstKBinAxis.
Defines many exception classes in namespace Exceptionss.
Axis with fixed bin size in sin(angle) space.
ConstKBinAxis * createClippedAxis(double left, double right) const final
Creates a new clipped axis.
void print(std::ostream &ostr) const final
ConstKBinAxis(const std::string &name, size_t nbins, double start, double end)
ConstKBinAxis constructor.
bool equals(const IAxis &other) const final
ConstKBinAxis * clone() const final
clone function
Interface for one-dimensional axes.
virtual bool equals(const IAxis &other) const
std::string getName() const
retrieve the label of the axis
Axis with variable bin size.
double getMax() const
Returns value of last point of axis.
size_t size() const
retrieve the number of bins
void setBinBoundaries(const std::vector< double > &bin_boundaries)
Bin1D getBin(size_t index) const
retrieve a 1d bin for the given index
double getMin() const
Returns value of first point of axis.
std::vector< double > getBinBoundaries() const
size_t findClosestIndex(double value) const
find bin index which is best match for given value
bool almostEqual(double a, double b)
Returns true if two doubles agree within machine epsilon.
double getMidPoint() const