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

An axis with variable bins defined by their edges.

For example, the following creates an axis with 3 log-spaced bins:

std::vector<double> binEdges = {1, 10, 100, 1000};
An axis with variable bins defined by their edges.

It is possible to disable underflow and overflow bins by passing enableFlowBins = 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 RVariableBinAxis.hxx.

Public Types

using ArgumentType = double
 

Public Member Functions

 RVariableBinAxis (std::vector< double > binEdges, bool enableFlowBins=true)
 Construct an axis object with variable bins.
 
const std::vector< double > & GetBinEdges () const
 
RBinIndexRange GetFullRange () const
 Get the full range of all bins.
 
RLinearizedIndex GetLinearizedIndex (RBinIndex index) const
 Compute the linarized index for a single argument.
 
std::uint64_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::uint64_t GetTotalNBins () const
 
bool HasFlowBins () const
 
void Streamer (TBuffer &)
 ROOT Streamer function to throw when trying to store an object of this class.
 

Private Attributes

std::vector< doublefBinEdges
 The (ordered) edges of the normal bins.
 
bool fEnableFlowBins
 Whether underflow and overflow bins are enabled.
 

Friends

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

#include <ROOT/RVariableBinAxis.hxx>

Member Typedef Documentation

◆ ArgumentType

Constructor & Destructor Documentation

◆ RVariableBinAxis()

ROOT::Experimental::RVariableBinAxis::RVariableBinAxis ( std::vector< double > binEdges,
bool enableFlowBins = true )
inlineexplicit

Construct an axis object with variable bins.

Parameters
[in]binEdgesthe (ordered) edges of the normal bins, must define at least one bin (i.e. size >= 2)
[in]enableFlowBinswhether to enable underflow and overflow bins

Definition at line 56 of file RVariableBinAxis.hxx.

Member Function Documentation

◆ GetBinEdges()

const std::vector< double > & ROOT::Experimental::RVariableBinAxis::GetBinEdges ( ) const
inline

Definition at line 79 of file RVariableBinAxis.hxx.

◆ GetFullRange()

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

Get the full range of all bins.

This includes underflow and overflow bins, if enabled.

Returns
the bin index range of all bins

Definition at line 193 of file RVariableBinAxis.hxx.

◆ GetLinearizedIndex()

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

Compute the linarized index for a single argument.

If flow bins are disabled, the normal bins have indices \(0\) to \(fBinEdges.size() - 2\). Otherwise the underflow bin has index \(0\$, the indices of all normal bins shift by one, and the overflow bin has index \)@_fakenlfBinEdges.size() \(. If the argument is outside all bin edges and the flow bins are disabled, the return value is invalid. \param[in] x the argument \return the linearized index that may be invalid RLinearizedIndex ComputeLinearizedIndex(double x) const { bool underflow = x < fBinEdges.front(); // Put NaNs into overflow bin. bool overflow = !(x < fBinEdges.back()); if (underflow) { return {0, fEnableFlowBins}; } else if (overflow) { return {fBinEdges.size(), fEnableFlowBins}; } // TODO (for later): The following can be optimized with binary search... for (std::size_t bin = 0; bin < fBinEdges.size() - 2; bin++) { if (x < fBinEdges[bin + 1]) { // If the underflow bin is enabled, shift the normal bins by one. if (fEnableFlowBins) { bin += 1; } return {bin, true}; } } std::size_t bin = fBinEdges.size() - 2; // If the underflow bin is enabled, shift the normal bins by one. if (fEnableFlowBins) { bin += 1; } return {bin, true}; } Get the linearized index for an RBinIndex. If flow bins are disabled, the normal bins have indices \)@_fakenl0 \( to \)fBinEdges.size() - 2 \(. Otherwise the underflow bin has index \)@_fakenl0$, the indices of all normal bins shift by one, and the overflow bin has index \(fBinEdges.size()\).

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

Definition at line 133 of file RVariableBinAxis.hxx.

◆ GetNNormalBins()

std::uint64_t ROOT::Experimental::RVariableBinAxis::GetNNormalBins ( ) const
inline

Definition at line 77 of file RVariableBinAxis.hxx.

◆ GetNormalRange() [1/2]

RBinIndexRange ROOT::Experimental::RVariableBinAxis::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 158 of file RVariableBinAxis.hxx.

◆ GetNormalRange() [2/2]

RBinIndexRange ROOT::Experimental::RVariableBinAxis::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 168 of file RVariableBinAxis.hxx.

◆ GetTotalNBins()

std::uint64_t ROOT::Experimental::RVariableBinAxis::GetTotalNBins ( ) const
inline

Definition at line 78 of file RVariableBinAxis.hxx.

◆ HasFlowBins()

bool ROOT::Experimental::RVariableBinAxis::HasFlowBins ( ) const
inline

Definition at line 80 of file RVariableBinAxis.hxx.

◆ Streamer()

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

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

Definition at line 200 of file RVariableBinAxis.hxx.

Friends And Related Symbol Documentation

◆ operator==

Definition at line 82 of file RVariableBinAxis.hxx.

Member Data Documentation

◆ fBinEdges

std::vector<double> ROOT::Experimental::RVariableBinAxis::fBinEdges
private

The (ordered) edges of the normal bins.

Definition at line 47 of file RVariableBinAxis.hxx.

◆ fEnableFlowBins

bool ROOT::Experimental::RVariableBinAxis::fEnableFlowBins
private

Whether underflow and overflow bins are enabled.

Definition at line 49 of file RVariableBinAxis.hxx.

Libraries for ROOT::Experimental::RVariableBinAxis:

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