5#ifndef ROOT_RVariableBinAxis
6#define ROOT_RVariableBinAxis
22namespace Experimental {
58 throw std::invalid_argument(
"must have >= 2 bin edges");
60 for (std::size_t i = 1; i <
fBinEdges.size(); i++) {
62 std::string
msg =
"binEdges must be sorted, but for bin " + std::to_string(i - 1) +
": ";
64 throw std::invalid_argument(
msg);
76 return lhs.fBinEdges ==
rhs.fBinEdges &&
lhs.fEnableFlowBins ==
rhs.fEnableFlowBins;
94 }
else if (overflow) {
99 for (std::size_t bin = 0; bin <
fBinEdges.size() - 2; bin++) {
117 if (
index.IsUnderflow()) {
119 }
else if (
index.IsOverflow()) {
121 }
else if (
index.IsInvalid()) {
125 std::size_t bin =
index.GetIndex();
126 return {bin, bin <
fBinEdges.size() - 1};
145 throw std::invalid_argument(
"begin must be a normal bin");
148 throw std::invalid_argument(
"begin must be inside the axis");
150 if (!end.IsNormal()) {
151 throw std::invalid_argument(
"end must be a normal bin");
153 if (end.GetIndex() >
fBinEdges.size() - 1) {
154 throw std::invalid_argument(
"end must be inside or past the axis");
156 if (!(end >= begin)) {
157 throw std::invalid_argument(
"end must be >= begin");
174 void Streamer(
TBuffer &) {
throw std::runtime_error(
"unable to store RVariableBinAxis"); }
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
A bin index with special values for underflow and overflow bins.
std::size_t GetIndex() const
Return the index for a normal bin.
bool IsNormal() const
A bin index is normal iff it is not one of the special values.
static RBinIndex Underflow()
An axis with variable bins defined by their edges.
RLinearizedIndex GetLinearizedIndex(RBinIndex index) const
Get the linearized index for an RBinIndex.
RBinIndexRange GetNormalRange(RBinIndex begin, RBinIndex end) const
Get a range of normal bins.
RLinearizedIndex ComputeLinearizedIndex(double x) const
Compute the linarized index for a single argument.
RBinIndexRange GetFullRange() const
Get the full range of all bins.
bool fEnableFlowBins
Whether underflow and overflow bins are enabled.
void Streamer(TBuffer &)
ROOT Streamer function to throw when trying to store an object of this class.
std::vector< double > fBinEdges
The (ordered) edges of the normal bins.
RVariableBinAxis(std::vector< double > binEdges, bool enableFlowBins=true)
Construct an axis object with variable bins.
friend bool operator==(const RVariableBinAxis &lhs, const RVariableBinAxis &rhs)
std::size_t GetTotalNBins() const
std::size_t GetNNormalBins() const
const std::vector< double > & GetBinEdges() const
RBinIndexRange GetNormalRange() const
Get the range of all normal bins.
Buffer base class used for serializing objects.
RBinIndexRange CreateBinIndexRange(RBinIndex begin, RBinIndex end, std::size_t nNormalBins)
Internal function to create RBinIndexRange.
A linearized index that can be invalid.