5#ifndef ROOT_RSliceBinIndexMapper
6#define ROOT_RSliceBinIndexMapper
33 std::size_t dimensionality = 0;
34 for (
auto &&spec : sliceSpecs) {
36 if (spec.GetOperationSum() ==
nullptr) {
40 return dimensionality;
49 throw std::invalid_argument(
"must have at least 1 slice specification");
61 bool Map(
const std::vector<RBinIndex> &original, std::vector<RBinIndex> &mapped)
const
64 throw std::invalid_argument(
"invalid number of original indices passed to RSliceBinIndexMapper::Map");
67 throw std::invalid_argument(
"invalid size of mapped indices passed to RSliceBinIndexMapper::Map");
70 std::size_t mappedPos = 0;
71 for (std::size_t i = 0; i < original.size(); i++) {
73 if (
index.IsInvalid()) {
74 throw std::invalid_argument(
"invalid bin index passed to RSliceBinIndexMapper::Map");
78 const auto &range = sliceSpec.
GetRange();
79 bool contained =
true;
80 if (!range.IsInvalid()) {
83 if (
index.IsUnderflow()) {
84 contained = range.GetBegin().IsUnderflow();
85 }
else if (
index.IsOverflow()) {
86 contained = range.GetEnd().IsInvalid();
87 }
else if (
index.IsNormal()) {
88 const auto &begin = range.GetBegin();
89 const auto &end = range.GetEnd();
90 if (begin.IsNormal() &&
index < begin) {
93 }
else if (end.IsNormal() &&
index >= end) {
96 }
else if (begin.IsNormal()) {
99 index -= begin.GetIndex();
100 assert(!
index.IsInvalid());
106 if (
index.IsNormal()) {
118 mapped[mappedPos] =
index;
123 assert(mappedPos == mapped.size());
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
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.
static RBinIndex Overflow()
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.