Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ROOT::Experimental::RAxisBase Class Referenceabstract

Histogram axis base class.

Keeps track of the number of bins and overflow handling. Offers bin iteration.

Regular bin indices are starting from 1, up to N + 1 for an axis with N bins. Index -1 is for the underflow bin, representing values that are lower than the axis range. Index -2 is the overflow bin for values larger than the axis range. Growable axes do not have underflow or overflow bins, as they don't need them.

Definition at line 44 of file RAxis.hxx.

Classes

class  const_iterator
 Random const_iterator through bins. More...
 

Public Member Functions

virtual bool CanGrow () const noexcept=0
 Whether this axis can grow (and thus has no overflow bins).
 
virtual int FindBin (double x) const noexcept=0
 Find the adjusted bin index (returning kUnderflowBin for underflow and kOverflowBin for overflow) for the given coordinate.
 
virtual double GetBinCenter (int bin) const =0
 Get the bin center for the given bin index.
 
virtual double GetBinFrom (int bin) const =0
 Get the low bin border ("left edge") for the given bin index.
 
virtual int GetBinIndexForLowEdge (double x) const noexcept=0
 If the coordinate x is within 10 ULPs of a bin low edge coordinate, return the bin for which this is a low edge.
 
double GetBinTo (int bin) const
 Get the high bin border ("right edge") for the given bin index.
 
int GetFirstBin () const noexcept
 Get the bin index for the first bin of the axis.
 
int GetLastBin () const noexcept
 Get the bin index for the last bin of the axis.
 
double GetMaximum () const
 Get the high end of the axis range.
 
double GetMinimum () const
 Get the low end of the axis range.
 
int GetNBins () const noexcept
 Get the number of bins, including under- and overflow.
 
virtual int GetNBinsNoOver () const noexcept=0
 Get the number of bins, excluding under- and overflow.
 
int GetNOverflowBins () const noexcept
 Get the number of over- and underflow bins: 0 for growable axes, 2 otherwise.
 
int GetOverflowBin () const noexcept
 Get the bin index for the overflow bin (or kInvalidBin if CanGrow()).
 
const std::string & GetTitle () const
 Get the axis's title.
 
int GetUnderflowBin () const noexcept
 Get the bin index for the underflow bin (or kInvalidBin if CanGrow()).
 
bool HasSameBinningAs (const RAxisBase &other) const
 Check if two axes use the same binning convention, i.e.
 
Iterator interfaces
const_iterator begin () const noexcept
 Get a const_iterator pointing to the first regular bin.
 
const_iterator end () const noexcept
 Get a const_iterator pointing beyond the last regular bin.
 

Static Public Attributes

static constexpr const int kInvalidBin = 0
 Special bin index returned to signify that no bin matches a request.
 
static constexpr const int kOverflowBin = -2
 Index of the overflow bin, if any.
 
static constexpr const int kUnderflowBin = -1
 Index of the underflow bin, if any.
 

Protected Member Functions

 RAxisBase () noexcept(noexcept(std::string()))=default
 Default construct a RAxisBase (for use by derived classes for I/O)
 
 RAxisBase (std::string_view title) noexcept
 Construct a RAxisBase.
 
virtual ~RAxisBase ()
 Virtual destructor needed in this inheritance-based design.
 
int AdjustOverflowBinNumber (double rawbin) const
 Given rawbin (<0 for underflow, >=GetNBinsNoOver() for overflow), determine the bin number taking into account how over/underflow should be handled.
 
virtual bool HasSameBinBordersAs (const RAxisBase &other) const
 Check if two axis have the same bin borders.
 
Inaccessible copy, assignment

The copy and move constructors and assignment operators are protected to prevent slicing.

 RAxisBase (const RAxisBase &)=default
 
 RAxisBase (RAxisBase &&)=default
 
RAxisBaseoperator= (const RAxisBase &)=default
 
RAxisBaseoperator= (RAxisBase &&)=default
 

Private Attributes

std::string fTitle
 Title of this axis, used for graphics / text.
 

#include <ROOT/RAxis.hxx>

Inheritance diagram for ROOT::Experimental::RAxisBase:
[legend]

Constructor & Destructor Documentation

◆ RAxisBase() [1/4]

ROOT::Experimental::RAxisBase::RAxisBase ( const RAxisBase )
protecteddefault

◆ RAxisBase() [2/4]

ROOT::Experimental::RAxisBase::RAxisBase ( RAxisBase &&  )
protecteddefault

◆ RAxisBase() [3/4]

ROOT::Experimental::RAxisBase::RAxisBase ( )
protecteddefaultnoexcept

Default construct a RAxisBase (for use by derived classes for I/O)

◆ ~RAxisBase()

ROOT::Experimental::RAxisBase::~RAxisBase ( )
protectedvirtual

Virtual destructor needed in this inheritance-based design.

Definition at line 31 of file RAxis.cxx.

◆ RAxisBase() [4/4]

ROOT::Experimental::RAxisBase::RAxisBase ( std::string_view  title)
inlineprotectednoexcept

Construct a RAxisBase.

Parameters
[in]title- axis title used for graphics and text representation.

Definition at line 65 of file RAxis.hxx.

Member Function Documentation

◆ AdjustOverflowBinNumber()

int ROOT::Experimental::RAxisBase::AdjustOverflowBinNumber ( double  rawbin) const
inlineprotected

Given rawbin (<0 for underflow, >=GetNBinsNoOver() for overflow), determine the bin number taking into account how over/underflow should be handled.

Parameters
[in]rawbinfor which to determine the bin number.
Returns
Returns the bin number adjusted for potential over- and underflow bins. Returns kInvalidBin if the axis cannot handle the over- / underflow.

Definition at line 75 of file RAxis.hxx.

◆ begin()

const_iterator ROOT::Experimental::RAxisBase::begin ( ) const
inlinenoexcept

Get a const_iterator pointing to the first regular bin.

Definition at line 288 of file RAxis.hxx.

◆ CanGrow()

virtual bool ROOT::Experimental::RAxisBase::CanGrow ( ) const
pure virtualnoexcept

Whether this axis can grow (and thus has no overflow bins).

Implemented in ROOT::Experimental::RAxisGrow, ROOT::Experimental::RAxisIrregular, and ROOT::Experimental::RAxisEquidistant.

◆ end()

const_iterator ROOT::Experimental::RAxisBase::end ( ) const
inlinenoexcept

Get a const_iterator pointing beyond the last regular bin.

Definition at line 291 of file RAxis.hxx.

◆ FindBin()

virtual int ROOT::Experimental::RAxisBase::FindBin ( double  x) const
pure virtualnoexcept

Find the adjusted bin index (returning kUnderflowBin for underflow and kOverflowBin for overflow) for the given coordinate.

Note
Passing a bin border coordinate can either return the bin above or below the bin border. I.e. don't do that for reliable results!

Implemented in ROOT::Experimental::RAxisEquidistant, and ROOT::Experimental::RAxisIrregular.

◆ GetBinCenter()

virtual double ROOT::Experimental::RAxisBase::GetBinCenter ( int  bin) const
pure virtual

Get the bin center for the given bin index.

The result of this method on an overflow or underflow bin is unspecified.

Implemented in ROOT::Experimental::RAxisEquidistant, and ROOT::Experimental::RAxisIrregular.

◆ GetBinFrom()

virtual double ROOT::Experimental::RAxisBase::GetBinFrom ( int  bin) const
pure virtual

Get the low bin border ("left edge") for the given bin index.

The result of this method on an underflow bin is unspecified.

Implemented in ROOT::Experimental::RAxisEquidistant, and ROOT::Experimental::RAxisIrregular.

◆ GetBinIndexForLowEdge()

virtual int ROOT::Experimental::RAxisBase::GetBinIndexForLowEdge ( double  x) const
pure virtualnoexcept

If the coordinate x is within 10 ULPs of a bin low edge coordinate, return the bin for which this is a low edge.

If it's not a bin edge, return kInvalidBin.

Implemented in ROOT::Experimental::RAxisEquidistant, and ROOT::Experimental::RAxisIrregular.

◆ GetBinTo()

double ROOT::Experimental::RAxisBase::GetBinTo ( int  bin) const
inline

Get the high bin border ("right edge") for the given bin index.

The result of this method on an overflow bin is unspecified.

Definition at line 310 of file RAxis.hxx.

◆ GetFirstBin()

int ROOT::Experimental::RAxisBase::GetFirstBin ( ) const
inlinenoexcept

Get the bin index for the first bin of the axis.

Definition at line 279 of file RAxis.hxx.

◆ GetLastBin()

int ROOT::Experimental::RAxisBase::GetLastBin ( ) const
inlinenoexcept

Get the bin index for the last bin of the axis.

Definition at line 282 of file RAxis.hxx.

◆ GetMaximum()

double ROOT::Experimental::RAxisBase::GetMaximum ( ) const
inline

Get the high end of the axis range.

Definition at line 319 of file RAxis.hxx.

◆ GetMinimum()

double ROOT::Experimental::RAxisBase::GetMinimum ( ) const
inline

Get the low end of the axis range.

Definition at line 316 of file RAxis.hxx.

◆ GetNBins()

int ROOT::Experimental::RAxisBase::GetNBins ( ) const
inlinenoexcept

Get the number of bins, including under- and overflow.

Definition at line 249 of file RAxis.hxx.

◆ GetNBinsNoOver()

virtual int ROOT::Experimental::RAxisBase::GetNBinsNoOver ( ) const
pure virtualnoexcept

Get the number of bins, excluding under- and overflow.

Implemented in ROOT::Experimental::RAxisEquidistant, and ROOT::Experimental::RAxisIrregular.

◆ GetNOverflowBins()

int ROOT::Experimental::RAxisBase::GetNOverflowBins ( ) const
inlinenoexcept

Get the number of over- and underflow bins: 0 for growable axes, 2 otherwise.

Definition at line 252 of file RAxis.hxx.

◆ GetOverflowBin()

int ROOT::Experimental::RAxisBase::GetOverflowBin ( ) const
inlinenoexcept

Get the bin index for the overflow bin (or kInvalidBin if CanGrow()).

Definition at line 271 of file RAxis.hxx.

◆ GetTitle()

const std::string & ROOT::Experimental::RAxisBase::GetTitle ( ) const
inline

Get the axis's title.

Definition at line 240 of file RAxis.hxx.

◆ GetUnderflowBin()

int ROOT::Experimental::RAxisBase::GetUnderflowBin ( ) const
inlinenoexcept

Get the bin index for the underflow bin (or kInvalidBin if CanGrow()).

Definition at line 262 of file RAxis.hxx.

◆ HasSameBinBordersAs()

virtual bool ROOT::Experimental::RAxisBase::HasSameBinBordersAs ( const RAxisBase other) const
inlineprotectedvirtual

Check if two axis have the same bin borders.

Default implementation should work for any RAxis type, but is quite inefficient as it does virtual GetBinFrom calls in a loop. RAxis implementations are encouraged to provide optimized overrides for common axis binning comparison scenarios.

Reimplemented in ROOT::Experimental::RAxisEquidistant, and ROOT::Experimental::RAxisIrregular.

Definition at line 98 of file RAxis.hxx.

◆ HasSameBinningAs()

bool ROOT::Experimental::RAxisBase::HasSameBinningAs ( const RAxisBase other) const

Check if two axes use the same binning convention, i.e.

  • Either they are both growable or neither of them is growable.
  • Minimum, maximum, and all bin borders in the middle are the same.
  • Bin labels must match (exactly including order, for now).

Definition at line 33 of file RAxis.cxx.

◆ operator=() [1/2]

RAxisBase & ROOT::Experimental::RAxisBase::operator= ( const RAxisBase )
protecteddefault

◆ operator=() [2/2]

RAxisBase & ROOT::Experimental::RAxisBase::operator= ( RAxisBase &&  )
protecteddefault

Member Data Documentation

◆ fTitle

std::string ROOT::Experimental::RAxisBase::fTitle
private

Title of this axis, used for graphics / text.

Definition at line 334 of file RAxis.hxx.

◆ kInvalidBin

constexpr const int ROOT::Experimental::RAxisBase::kInvalidBin = 0
staticconstexpr

Special bin index returned to signify that no bin matches a request.

Definition at line 231 of file RAxis.hxx.

◆ kOverflowBin

constexpr const int ROOT::Experimental::RAxisBase::kOverflowBin = -2
staticconstexpr

Index of the overflow bin, if any.

Definition at line 237 of file RAxis.hxx.

◆ kUnderflowBin

constexpr const int ROOT::Experimental::RAxisBase::kUnderflowBin = -1
staticconstexpr

Index of the underflow bin, if any.

Definition at line 234 of file RAxis.hxx.

Libraries for ROOT::Experimental::RAxisBase:

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