Logo ROOT  
Reference Guide
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). More...
 
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. 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...
 
int GetFirstBin () const noexcept
 Get the bin index for the first bin of the axis. More...
 
int GetLastBin () const noexcept
 Get the bin index for the last bin of the axis. 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 overflow bin (or kInvalidBin 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 kInvalidBin if CanGrow()). More...
 
bool HasSameBinningAs (const RAxisBase &other) const
 Check if two axes use the same binning convention, i.e. More...
 
Iterator interfaces
const_iterator begin () const noexcept
 Get a const_iterator pointing to the first regular bin. More...
 
const_iterator end () const noexcept
 Get a const_iterator pointing beyond the last regular bin. More...
 

Static Public Attributes

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

Protected Member Functions

 RAxisBase () noexcept(noexcept(std::string()))=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 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]

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 21 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
[out]resultstatus of the bin determination.
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 283 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 286 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 305 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 274 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 277 of file RAxis.hxx.

◆ GetMaximum()

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

Get the high end of the axis range.

Definition at line 314 of file RAxis.hxx.

◆ GetMinimum()

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

Get the low end of the axis range.

Definition at line 311 of file RAxis.hxx.

◆ GetNBins()

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

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

Definition at line 244 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 247 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 266 of file RAxis.hxx.

◆ GetTitle()

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

Get the axis's title.

Definition at line 235 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 257 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 23 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 329 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 226 of file RAxis.hxx.

◆ kOverflowBin

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

Index of the overflow bin, if any.

Definition at line 232 of file RAxis.hxx.

◆ kUnderflowBin

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

Index of the underflow bin, if any.

Definition at line 229 of file RAxis.hxx.

Libraries for ROOT::Experimental::RAxisBase:
[legend]

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