5#ifndef ROOT_RVariableBinAxis
6#define ROOT_RVariableBinAxis
61 throw std::invalid_argument(
"must have >= 2 bin edges");
64 throw std::invalid_argument(
"bin egde 0 is NaN");
66 for (std::size_t i = 1; i <
fBinEdges.size(); i++) {
68 throw std::invalid_argument(
"bin egde " + std::to_string(i) +
" is NaN");
71 std::string msg =
"binEdges must be sorted, but for bin " + std::to_string(i - 1) +
": ";
73 throw std::invalid_argument(msg);
104 }
else if (overflow) {
109 for (std::size_t bin = 0; bin <
fBinEdges.size() - 2; bin++) {
144 std::uint64_t bin = index.
GetIndex();
172 throw std::invalid_argument(
"begin must be a normal bin");
175 throw std::invalid_argument(
"begin must be inside the axis");
178 throw std::invalid_argument(
"end must be a normal bin");
181 throw std::invalid_argument(
"end must be inside or past the axis");
183 if (!(end >= begin)) {
184 throw std::invalid_argument(
"end must be >= begin");
211 throw std::runtime_error(
"sum operation makes dimension disappear");
215 std::size_t nNormalBins =
fBinEdges.size() - 1;
216 std::size_t begin = 0;
217 std::size_t end = nNormalBins;
219 const auto &range = sliceSpec.
GetRange();
220 if (!range.IsInvalid()) {
221 if (range.GetBegin().IsNormal()) {
222 begin = range.GetBegin().GetIndex();
224 if (range.GetEnd().IsNormal()) {
225 end = range.GetEnd().GetIndex();
227 nNormalBins = end - begin;
230 std::uint64_t nGroup = 1;
232 nGroup = opRebin->GetNGroup();
233 if (nNormalBins % nGroup != 0) {
234 throw std::runtime_error(
"rebin operation does not divide number of normal bins");
239 std::vector<double> binEdges;
240 for (std::size_t bin = begin; bin < end; bin += nGroup) {
247 bool enableFlowBins =
true;
252 void Streamer(
TBuffer &) {
throw std::runtime_error(
"unable to store RVariableBinAxis"); }
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()
Specification of a slice operation along one dimension.
const ROperationSum * GetOperationSum() const
const ROperationRebin * GetOperationRebin() const
const RBinIndexRange & GetRange() const
RLinearizedIndex GetLinearizedIndex(RBinIndex index) const
Compute the linarized index for a single argument.
RBinIndexRange GetNormalRange(RBinIndex begin, RBinIndex end) const
Get a range of normal bins.
RVariableBinAxis Slice(const RSliceSpec &sliceSpec) const
Slice this axis according to the specification.
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)
const std::vector< double > & GetBinEdges() const
std::uint64_t GetNNormalBins() const
RBinIndexRange GetNormalRange() const
Get the range of all normal bins.
std::uint64_t GetTotalNBins() const
Buffer base class used for serializing objects.
static RBinIndexRange CreateBinIndexRange(RBinIndex begin, RBinIndex end, std::uint64_t nNormalBins)
Internal function to create RBinIndexRange.
Namespace for ROOT features in testing.
if(pos!=-1) leafTypeName.Remove(pos)
A linearized index that can be invalid.