Logo ROOT   master
Reference Guide
ROOT::Experimental::RAxisBase Class Referenceabstract


Histogram axis base class.

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

Bin indices are starting from 0 for the underflow bin (representing values that are lower than the axis range). Starting at index 1 are the actual bins of the axis, up to N + 1 for an axis with N bins. Index N + 2 is the overflow bin for values larger than the axis range.

Definition at line 43 of file RAxis.hxx.

Classes

class  const_iterator
 
Random const_iterator through bins. More...
 

Public Types

enum  EFindStatus { EFindStatus::kCanGrow, EFindStatus::kValid }
 Status of FindBin(x) More...
 

Public Member Functions

virtual bool CanGrow () const noexcept=0
 Whether this axis can grow (and thus has no overflow bins). More...
 
virtual int FindBin (double x) const noexcept=0
 Find the bin index for the given coordinate. More...
 
virtual double GetBinCenter (int bin) const =0
 Get the bin center for the given bin index. More...
 
virtual double GetBinFrom (int bin) const =0
 Get the low bin border ("left edge") for the given bin index. More...
 
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. More...
 
double GetBinTo (int bin) const
 Get the high bin border ("right edge") for the given bin index. More...
 
double GetMaximum () const
 Get the high end of the axis range. More...
 
double GetMinimum () const
 Get the low end of the axis range. More...
 
int GetNBins () const noexcept
 Get the number of bins, including under- and overflow. More...
 
virtual int GetNBinsNoOver () const noexcept=0
 Get the number of bins, excluding under- and overflow. More...
 
int GetNOverflowBins () const noexcept
 Get the number of over- and underflow bins: 0 for growable axes, 2 otherwise. More...
 
int GetOverflowBin () const noexcept
 Get the bin index for the underflow bin (or the next bin outside range if CanGrow()). More...
 
const std::string & GetTitle () const
 Get the axis's title. More...
 
int GetUnderflowBin () const noexcept
 Get the bin index for the underflow bin (or the last bin outside range if CanGrow()). More...
 
bool HasSameBinningAs (const RAxisBase &other) const
 Check if two axes use the same binning convention, i.e. More...
 
bool IsOverflowBin (int bin) const noexcept
 Whether the bin index is referencing a bin higher than the axis range. More...
 
bool IsUnderflowBin (int bin) const noexcept
 Whether the bin index is referencing a bin lower than the axis range. More...
 
Iterator interfaces
const_iterator begin () const noexcept
 Get a const_iterator pointing to the first non-underflow bin. More...
 
const_iterator begin_with_underflow () const noexcept
 Get a const_iterator pointing the first bin, whether underflow or not. More...
 
const_iterator end () const noexcept
 Get a const_iterator pointing right beyond the last non-overflow bin (i.e. More...
 
const_iterator end_with_overflow () const noexcept
 Get a const_iterator pointing right beyond the last bin, whether overflow or not. More...
 

Static Public Attributes

static constexpr const int kIgnoreBin = -1
 FindBin() returns this bin to signal that the bin number is invalid. More...
 
static constexpr const int kNOverflowBins [4] = {0, 1, 1, 2}
 Extra bins for each EAxisOverflow value. More...
 

Protected Member Functions

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

#include <ROOT/RAxis.hxx>

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

Member Enumeration Documentation

◆ EFindStatus

Status of FindBin(x)

Enumerator
kCanGrow 

Coordinate could fit after growing the axis.

kValid 

The returned bin index is valid.

Definition at line 46 of file RAxis.hxx.

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 23 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 71 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 actual bin number taking into account how over/underflow should be handled.

Parameters
[out]statusresult status of the bin determination.
Returns
Returns the bin number adjusted for potential over- and underflow bins. Returns kIgnoreBin if the axis cannot handle the over- / underflow, in which case status will tell how to deal with this overflow.

Definition at line 82 of file RAxis.hxx.

◆ begin()

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

Get a const_iterator pointing to the first non-underflow bin.

Definition at line 289 of file RAxis.hxx.

◆ begin_with_underflow()

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

Get a const_iterator pointing the first bin, whether underflow or not.

Definition at line 292 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::RAxisIrregular, ROOT::Experimental::RAxisGrow, and ROOT::Experimental::RAxisEquidistant.

◆ end()

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

Get a const_iterator pointing right beyond the last non-overflow bin (i.e.

pointing to the overflow bin, if any).

Definition at line 296 of file RAxis.hxx.

◆ end_with_overflow()

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

Get a const_iterator pointing right beyond the last bin, whether overflow or not.

Definition at line 299 of file RAxis.hxx.

◆ FindBin()

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

Find the bin index 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::RAxisIrregular, and ROOT::Experimental::RAxisEquidistant.

◆ 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::RAxisIrregular, and ROOT::Experimental::RAxisEquidistant.

◆ 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::RAxisIrregular, and ROOT::Experimental::RAxisEquidistant.

◆ 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 -1.

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

◆ 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 317 of file RAxis.hxx.

◆ GetMaximum()

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

Get the high end of the axis range.

Definition at line 323 of file RAxis.hxx.

◆ GetMinimum()

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

Get the low end of the axis range.

Definition at line 320 of file RAxis.hxx.

◆ GetNBins()

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

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

Definition at line 250 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::RAxisIrregular, and ROOT::Experimental::RAxisEquidistant.

◆ 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 253 of file RAxis.hxx.

◆ GetOverflowBin()

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

Get the bin index for the underflow bin (or the next bin outside range if CanGrow()).

Definition at line 272 of file RAxis.hxx.

◆ GetTitle()

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

Get the axis's title.

Definition at line 241 of file RAxis.hxx.

◆ GetUnderflowBin()

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

Get the bin index for the underflow bin (or the last bin outside range if CanGrow()).

Definition at line 263 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::RAxisIrregular, and ROOT::Experimental::RAxisEquidistant.

Definition at line 106 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 25 of file RAxis.cxx.

◆ IsOverflowBin()

bool ROOT::Experimental::RAxisBase::IsOverflowBin ( int  bin) const
inlinenoexcept

Whether the bin index is referencing a bin higher than the axis range.

Definition at line 283 of file RAxis.hxx.

◆ IsUnderflowBin()

bool ROOT::Experimental::RAxisBase::IsUnderflowBin ( int  bin) const
inlinenoexcept

Whether the bin index is referencing a bin lower than the axis range.

Definition at line 280 of file RAxis.hxx.

◆ 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 338 of file RAxis.hxx.

◆ kIgnoreBin

constexpr const int ROOT::Experimental::RAxisBase::kIgnoreBin = -1
static

FindBin() returns this bin to signal that the bin number is invalid.

Definition at line 234 of file RAxis.hxx.

◆ kNOverflowBins

constexpr const int ROOT::Experimental::RAxisBase::kNOverflowBins = {0, 1, 1, 2}
static

Extra bins for each EAxisOverflow value.

Definition at line 238 of file RAxis.hxx.


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