28 throw std::runtime_error(
"CustomBinAxis::CustomBinAxis() -> Error."
29 " start >= end is not allowed.");
31 double start_sin = std::sin(start);
32 double end_sin = std::sin(end);
33 double step = (end_sin - start_sin) / (
m_nbins - 1);
39 std::vector<double> bin_boundaries;
40 bin_boundaries.resize(
m_nbins + 1, 0.0);
41 for (
size_t i = 0; i < bin_boundaries.size(); ++i)
42 bin_boundaries[i] = std::asin(start_sin - step / 2. + step * i);
54 throw std::runtime_error(
"CustomBinAxis::bin() -> Error. Wrong index.");
67 throw std::runtime_error(
"CustomBinAxis::clip() -> Error."
73 ostr <<
"CustomBinAxis(\"" <<
axisName() <<
"\", " <<
size() <<
", "
74 << std::setprecision(std::numeric_limits<double>::digits10 + 2) <<
m_start <<
", " <<
m_end
82 if (
const auto* otherAxis =
dynamic_cast<const CustomBinAxis*
>(&other)) {
83 if (
size() != otherAxis->size())
Defines and implements namespace BaseUtils::algo with some algorithms.
Defines structs Bin1D, Bin1DCVector.
Defines class CustomBinAxis.
Axis with fixed bin size in sin(angle) space used for numerical comparison with IsGisaxs....
void clip(double lower, double upper) override
Clips this axis to the given values.
std::vector< double > binCenters() const override
void print(std::ostream &ostr) const override
CustomBinAxis * clone() const override
CustomBinAxis(const std::string &name, size_t nbins, double start, double end)
CustomBinAxis constructor.
std::vector< double > m_bin_centers
bool equals(const IAxis &other) const override
Bin1D bin(size_t index) const override
retrieve a 1d bin for the given index
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.
void setBinBoundaries(const std::vector< double > &bin_boundaries)
size_t size() const override
Returns the number of bins.
bool almostEqual(double a, double b)
Returns true if two doubles agree within machine epsilon.