5#ifndef ROOT_RRegularAxis
6#define ROOT_RRegularAxis
23namespace Experimental {
65 throw std::invalid_argument(
"nNormalBins must be > 0");
67 if (!std::isfinite(
fLow)) {
68 throw std::invalid_argument(
"low must be a finite value, but is " + std::to_string(
fLow));
70 if (!std::isfinite(
fHigh)) {
71 throw std::invalid_argument(
"high must be a finite value, but is " + std::to_string(
fHigh));
74 std::string
msg =
"high must be > low, but " + std::to_string(
fLow) +
" >= " + std::to_string(
fHigh);
75 throw std::invalid_argument(
msg);
93 throw std::invalid_argument(
"bin must be inside the axis");
104 throw std::invalid_argument(
"bin must be inside the axis");
111 return lhs.fNNormalBins ==
rhs.fNNormalBins &&
lhs.fLow ==
rhs.fLow &&
lhs.fHigh ==
rhs.fHigh &&
112 lhs.fEnableFlowBins ==
rhs.fEnableFlowBins;
128 bool overflow = !(
x <
fHigh);
131 }
else if (overflow) {
156 if (
index.IsUnderflow()) {
158 }
else if (
index.IsOverflow()) {
160 }
else if (
index.IsInvalid()) {
164 std::uint64_t bin =
index.GetIndex();
192 throw std::invalid_argument(
"begin must be a normal bin");
195 throw std::invalid_argument(
"begin must be inside the axis");
198 throw std::invalid_argument(
"end must be a normal bin");
201 throw std::invalid_argument(
"end must be inside or past the axis");
203 if (!(end >= begin)) {
204 throw std::invalid_argument(
"end must be >= begin");
230 if (
sliceSpec.GetOperationSum() !=
nullptr) {
231 throw std::runtime_error(
"sum operation makes dimension disappear");
240 if (!
range.IsInvalid()) {
241 std::uint64_t begin = 0;
243 if (
range.GetBegin().IsNormal()) {
244 begin =
range.GetBegin().GetIndex();
250 if (
range.GetEnd().IsNormal()) {
251 end =
range.GetEnd().GetIndex();
262 throw std::runtime_error(
"rebin operation does not divide number of normal bins");
274 void Streamer(
TBuffer &) {
throw std::runtime_error(
"unable to store RRegularAxis"); }
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.
bool IsNormal() const
A bin index is normal iff it is not one of the special values.
std::uint64_t GetIndex() const
Return the index for a normal bin.
static RBinIndex Underflow()
A regular axis with equidistant bins in the interval .
std::uint64_t GetTotalNBins() const
RBinIndexRange GetNormalRange(RBinIndex begin, RBinIndex end) const
Get a range of normal bins.
RRegularAxis Slice(const RSliceSpec &sliceSpec) const
Slice this axis according to the specification.
bool fEnableFlowBins
Whether underflow and overflow bins are enabled.
friend bool operator==(const RRegularAxis &lhs, const RRegularAxis &rhs)
RBinIndexRange GetFullRange() const
Get the full range of all bins.
double ComputeHighEdge(std::uint64_t bin) const
Compute the high edge of a bin.
double fInvBinWidth
The cached inverse of the bin width to speed up ComputeLinearizedIndex.
RRegularAxis(std::uint64_t nNormalBins, std::pair< double, double > interval, bool enableFlowBins=true)
Construct a regular axis object.
double ComputeLowEdge(std::uint64_t bin) const
Compute the low edge of a bin.
std::uint64_t fNNormalBins
The number of normal bins.
double fLow
The lower end of the axis interval.
RBinIndexRange GetNormalRange() const
Get the range of all normal bins.
void Streamer(TBuffer &)
ROOT Streamer function to throw when trying to store an object of this class.
double fHigh
The upper end of the axis interval.
RLinearizedIndex GetLinearizedIndex(RBinIndex index) const
Compute the linarized index for a single argument.
std::uint64_t GetNNormalBins() const
Specification of a slice operation along one dimension.
Buffer base class used for serializing objects.
static RBinIndexRange CreateBinIndexRange(RBinIndex begin, RBinIndex end, std::uint64_t nNormalBins)
Internal function to create RBinIndexRange.
A linearized index that can be invalid.