23 :
IAxis(name), m_nbins(nbins), m_start(start), m_end(end)
39 return m_start + (index + 0.5) * step;
56 }
else if (value >=
getMax()) {
61 return int((value -
m_start) / step);
66 std::vector<double> result;
67 result.resize(
size(), 0.0);
68 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) {
89 "'left' should be smaller than 'right'");
105 ostr <<
"FixedBinAxis(\"" <<
getName() <<
"\", " <<
size() <<
", "
106 << std::setprecision(std::numeric_limits<double>::digits10 + 2) <<
getMin() <<
", "
115 if (
size() != otherAxis->size())
128 std::ostringstream result;
Defines and implements namespace algo with some algorithms.
Defines many exception classes in namespace Exceptionss.
Defines class FixedBinAxis.
Defines functions in namespace pyfmt.
Axis with fixed bin size.
FixedBinAxis * createClippedAxis(double left, double right) const
Creates a new clipped axis.
virtual bool equals(const IAxis &other) const
double operator[](size_t index) const
indexed accessor retrieves a sample
size_t findClosestIndex(double value) const
find bin index which is best match for given value
double getMax() const
Returns value of last point of axis.
void print(std::ostream &ostr) const
FixedBinAxis * clone() const
clone function
std::vector< double > getBinBoundaries() const
double getMin() const
Returns value of first point of axis.
std::vector< double > getBinCenters() const
std::string pyString(const std::string &units, size_t) const final
FixedBinAxis(const std::string &name, size_t nbins, double start, double end)
FixedBinAxis constructor.
size_t size() const
retrieve the number of bins
Bin1D getBin(size_t index) const
retrieve a 1d bin for the given index
Interface for one-dimensional axes.
virtual bool equals(const IAxis &other) const
std::string getName() const
retrieve the label of the axis
bool almostEqual(double a, double b)
Returns true if two doubles agree within machine epsilon.
std::string printString(const std::string &value)
std::string printValue(double value, const std::string &units)
double m_upper
upper bound of the bin
double m_lower
lower bound of the bin
double getMidPoint() const