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++) {
72 if (
index.IsInvalid()) {
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()) {
82 if (
index.IsUnderflow()) {
83 contained = range.GetBegin().IsUnderflow();
84 }
else if (
index.IsOverflow()) {
85 contained = range.GetEnd().IsInvalid();
86 }
else if (
index.IsNormal()) {
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()) {
98 index -= begin.GetIndex();
99 assert(!
index.IsInvalid());
105 if (
index.IsNormal()) {
117 mapped[mappedPos] =
index;
122 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.