Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ROOT::Experimental::RCategoricalAxis Class Referencefinal

An axis with categorical bins.

For example, the following creates an axis with 3 categories:

std::vector<std::string> categories = {"a", "b", "c"};
An axis with categorical bins.

It is possible to disable the overflow bin by passing enableOverflowBin = false. In that case, arguments outside the axis will be silently discarded.

Warning
This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!

Definition at line 41 of file RCategoricalAxis.hxx.

Public Types

using ArgumentType = std::string_view
 

Public Member Functions

 RCategoricalAxis (std::vector< std::string > categories, bool enableOverflowBin=true)
 Construct an axis object with categories.
 
RLinearizedIndex ComputeLinearizedIndex (std::string_view x) const
 Compute the linarized index for a single argument.
 
const std::vector< std::string > & GetCategories () const
 
RBinIndexRange GetFullRange () const
 Get the full range of all bins.
 
RLinearizedIndex GetLinearizedIndex (RBinIndex index) const
 Get the linearized index for an RBinIndex.
 
std::size_t GetNNormalBins () const
 
RBinIndexRange GetNormalRange () const
 Get the range of all normal bins.
 
RBinIndexRange GetNormalRange (RBinIndex begin, RBinIndex end) const
 Get a range of normal bins.
 
std::size_t GetTotalNBins () const
 
bool HasOverflowBin () const
 
void Streamer (TBuffer &)
 ROOT Streamer function to throw when trying to store an object of this class.
 

Private Attributes

std::vector< std::string > fCategories
 The categories as defined by the user.
 
bool fEnableOverflowBin
 Whether the overflow bin is enabled.
 

Friends

bool operator== (const RCategoricalAxis &lhs, const RCategoricalAxis &rhs)
 

#include <ROOT/RCategoricalAxis.hxx>

Member Typedef Documentation

◆ ArgumentType

Definition at line 43 of file RCategoricalAxis.hxx.

Constructor & Destructor Documentation

◆ RCategoricalAxis()

ROOT::Experimental::RCategoricalAxis::RCategoricalAxis ( std::vector< std::string > categories,
bool enableOverflowBin = true )
inlineexplicit

Construct an axis object with categories.

Parameters
[in]categoriesthe categories without duplicates, must define at least one bin (i.e. size >= 1)
[in]enableOverflowBinwhether to enable the overflow bin

Definition at line 56 of file RCategoricalAxis.hxx.

Member Function Documentation

◆ ComputeLinearizedIndex()

RLinearizedIndex ROOT::Experimental::RCategoricalAxis::ComputeLinearizedIndex ( std::string_view x) const
inline

Compute the linarized index for a single argument.

The normal bins have indices \(0\) to \(fCategories.size() - 1\) and the overflow bin has index \(fCategories.size()\). If the argument is not a recognized category and the overflow bin is disabled, the return value is invalid.

Parameters
[in]xthe argument
Returns
the linearized index that may be invalid

Definition at line 90 of file RCategoricalAxis.hxx.

◆ GetCategories()

const std::vector< std::string > & ROOT::Experimental::RCategoricalAxis::GetCategories ( ) const
inline

Definition at line 74 of file RCategoricalAxis.hxx.

◆ GetFullRange()

RBinIndexRange ROOT::Experimental::RCategoricalAxis::GetFullRange ( ) const
inline

Get the full range of all bins.

This includes the overflow bin, if enabled.

Returns
the bin index range of all bins

Definition at line 163 of file RCategoricalAxis.hxx.

◆ GetLinearizedIndex()

RLinearizedIndex ROOT::Experimental::RCategoricalAxis::GetLinearizedIndex ( RBinIndex index) const
inline

Get the linearized index for an RBinIndex.

The normal bins have indices \(0\) to \(fCategories.size() - 1\) and the overflow bin has index \(fCategories.size()\).

Parameters
[in]indexthe RBinIndex
Returns
the linearized index that may be invalid

Definition at line 110 of file RCategoricalAxis.hxx.

◆ GetNNormalBins()

std::size_t ROOT::Experimental::RCategoricalAxis::GetNNormalBins ( ) const
inline

Definition at line 72 of file RCategoricalAxis.hxx.

◆ GetNormalRange() [1/2]

RBinIndexRange ROOT::Experimental::RCategoricalAxis::GetNormalRange ( ) const
inline

Get the range of all normal bins.

Returns
the bin index range from the first to the last normal bin, inclusive

Definition at line 128 of file RCategoricalAxis.hxx.

◆ GetNormalRange() [2/2]

RBinIndexRange ROOT::Experimental::RCategoricalAxis::GetNormalRange ( RBinIndex begin,
RBinIndex end ) const
inline

Get a range of normal bins.

Parameters
[in]beginthe begin of the bin index range (inclusive), must be normal
[in]endthe end of the bin index range (exclusive), must be normal and >= begin
Returns
a bin index range \([begin, end)\)

Definition at line 138 of file RCategoricalAxis.hxx.

◆ GetTotalNBins()

std::size_t ROOT::Experimental::RCategoricalAxis::GetTotalNBins ( ) const
inline

Definition at line 73 of file RCategoricalAxis.hxx.

◆ HasOverflowBin()

bool ROOT::Experimental::RCategoricalAxis::HasOverflowBin ( ) const
inline

Definition at line 75 of file RCategoricalAxis.hxx.

◆ Streamer()

void ROOT::Experimental::RCategoricalAxis::Streamer ( TBuffer & )
inline

ROOT Streamer function to throw when trying to store an object of this class.

Definition at line 170 of file RCategoricalAxis.hxx.

Friends And Related Symbol Documentation

◆ operator==

Definition at line 77 of file RCategoricalAxis.hxx.

Member Data Documentation

◆ fCategories

std::vector<std::string> ROOT::Experimental::RCategoricalAxis::fCategories
private

The categories as defined by the user.

Definition at line 47 of file RCategoricalAxis.hxx.

◆ fEnableOverflowBin

bool ROOT::Experimental::RCategoricalAxis::fEnableOverflowBin
private

Whether the overflow bin is enabled.

Definition at line 49 of file RCategoricalAxis.hxx.

Libraries for ROOT::Experimental::RCategoricalAxis:

The documentation for this class was generated from the following file: