5#ifndef ROOT_RSliceBinIndexMapper
6#define ROOT_RSliceBinIndexMapper
32 std::size_t dimensionality = 0;
33 for (
auto &&spec : sliceSpecs) {
35 if (spec.GetOperationSum() ==
nullptr) {
39 return dimensionality;
48 throw std::invalid_argument(
"must have at least 1 slice specification");
60 bool Map(
const std::vector<RBinIndex> &original, std::vector<RBinIndex> &mapped)
const
63 throw std::invalid_argument(
"invalid number of original indices passed to RSliceBinIndexMapper::Map");
66 throw std::invalid_argument(
"invalid size of mapped indices passed to RSliceBinIndexMapper::Map");
69 std::size_t mappedPos = 0;
70 for (std::size_t i = 0; i < original.size(); i++) {
73 throw std::invalid_argument(
"invalid bin index passed to RSliceBinIndexMapper::Map");
77 const auto &range = sliceSpec.
GetRange();
78 bool contained =
true;
79 if (!range.IsInvalid()) {
83 contained = range.GetBegin().IsUnderflow();
85 contained = range.GetEnd().IsInvalid();
87 const auto &begin = range.GetBegin();
88 const auto &end = range.GetEnd();
89 if (begin.IsNormal() && index < begin) {
92 }
else if (end.IsNormal() && index >= end) {
95 }
else if (begin.IsNormal()) {
117 mapped[mappedPos] = index;
122 assert(mappedPos == mapped.size());
bool Map(const std::vector< RBinIndex > &original, std::vector< RBinIndex > &mapped) const
Map a vector of RBinIndex according to the slice specifications.
RSliceBinIndexMapper(std::vector< RSliceSpec > sliceSpecs)
const std::vector< RSliceSpec > & GetSliceSpecs() const
std::size_t GetMappedDimensionality() const
std::size_t fMappedDimensionality
The expected dimensionality of the mapped indices.
std::vector< RSliceSpec > fSliceSpecs
The requested slice specifications.
static std::size_t ComputeMappedDimensionality(const std::vector< RSliceSpec > &sliceSpecs)
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.
static RBinIndex Overflow()
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
Namespace for ROOT features in testing.