27namespace Experimental {
30using RAxisVariant = std::variant<RRegularAxis, RVariableBinAxis, RCategoricalAxis>;
43 friend class ::ROOT::Experimental::RHistEngine;
45 std::vector<RAxisVariant>
fAxes;
52 throw std::invalid_argument(
"must have at least 1 axis object");
57 const std::vector<RAxisVariant> &
Get()
const {
return fAxes; }
70 for (
auto &&axis :
fAxes) {
71 if (
auto *
regular = std::get_if<RRegularAxis>(&axis)) {
73 }
else if (
auto *variable = std::get_if<RVariableBinAxis>(&axis)) {
75 }
else if (
auto *
categorical = std::get_if<RCategoricalAxis>(&axis)) {
78 throw std::logic_error(
"unimplemented axis type");
85 template <std::size_t
I, std::size_t
N,
typename... A>
88 using ArgumentType = std::tuple_element_t<
I, std::tuple<A...>>;
89 const auto &axis =
fAxes[
I];
91 if (
auto *
regular = std::get_if<RRegularAxis>(&axis)) {
92 if constexpr (std::is_convertible_v<ArgumentType, RRegularAxis::ArgumentType>) {
96 throw std::invalid_argument(
"invalid type of argument");
98 }
else if (
auto *variable = std::get_if<RVariableBinAxis>(&axis)) {
99 if constexpr (std::is_convertible_v<ArgumentType, RVariableBinAxis::ArgumentType>) {
100 index *= variable->GetTotalNBins();
101 linIndex = variable->ComputeLinearizedIndex(std::get<I>(args));
103 throw std::invalid_argument(
"invalid type of argument");
105 }
else if (
auto *
categorical = std::get_if<RCategoricalAxis>(&axis)) {
106 if constexpr (std::is_convertible_v<ArgumentType, RCategoricalAxis::ArgumentType>) {
110 throw std::invalid_argument(
"invalid type of argument");
113 throw std::logic_error(
"unimplemented axis type");
119 if constexpr (
I + 1 <
N) {
122 return {
index,
true};
125 template <std::size_t
N,
typename... A>
139 template <
typename... A>
142 if (
sizeof...(A) !=
fAxes.size()) {
143 throw std::invalid_argument(
"invalid number of arguments to ComputeGlobalIndex");
152 template <std::
size_t N>
156 throw std::invalid_argument(
"invalid number of indices passed to ComputeGlobalIndex");
159 for (std::size_t i = 0; i <
N; i++) {
161 const auto &axis =
fAxes[i];
163 if (
auto *
regular = std::get_if<RRegularAxis>(&axis)) {
166 }
else if (
auto *variable = std::get_if<RVariableBinAxis>(&axis)) {
169 }
else if (
auto *
categorical = std::get_if<RCategoricalAxis>(&axis)) {
173 throw std::logic_error(
"unimplemented axis type");
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
Bin configurations for all dimensions of a histogram.
friend bool operator==(const RAxes &lhs, const RAxes &rhs)
std::size_t GetNDimensions() const
friend bool operator!=(const RAxes &lhs, const RAxes &rhs)
RLinearizedIndex ComputeGlobalIndexImpl(std::size_t index, const std::tuple< A... > &args) const
RLinearizedIndex ComputeGlobalIndex(const std::tuple< A... > &args) const
Compute the global index for all axes.
std::size_t ComputeTotalNBins() const
Compute the total number of bins for all axes.
RLinearizedIndex ComputeGlobalIndexImpl(const std::tuple< A... > &args) const
RAxes(std::vector< RAxisVariant > axes)
void Streamer(TBuffer &)
ROOT Streamer function to throw when trying to store an object of this class.
RLinearizedIndex ComputeGlobalIndex(const std::array< RBinIndex, N > &indices) const
Compute the global index for all axes.
std::vector< RAxisVariant > fAxes
const std::vector< RAxisVariant > & Get() const
A histogram data structure to bin data along multiple dimensions.
Buffer base class used for serializing objects.
std::variant< RRegularAxis, RVariableBinAxis, RCategoricalAxis > RAxisVariant
Variant of all supported axis types.
A linearized index that can be invalid.