Logo ROOT  
Reference Guide
ROOT::Experimental::RAxisIrregular Class Reference

An axis with non-equidistant bins (also known as "variable binning").

It is defined by an array of bin borders - one more than the number of (non-overflow-) bins it has! As an example, an axis with two bin needs three bin borders:

  • lower edge of the first bin;
  • higher edge of the first bin, identical to the lower edge of the second bin;
  • higher edge of the second bin

This axis cannot grow; the size of new bins would not be well defined.

Definition at line 591 of file RAxis.hxx.

Public Member Functions

 RAxisIrregular ()=default
 
 RAxisIrregular (const std::vector< double > &binborders)
 Construct a RAxisIrregular from a vector of bin borders. More...
 
 RAxisIrregular (std::string_view title, const std::vector< double > &binborders)
 Construct a RAxisIrregular from a vector of bin borders. More...
 
 RAxisIrregular (std::string_view title, std::vector< double > &&binborders) noexcept
 Construct a RAxisIrregular from a vector of bin borders. More...
 
 RAxisIrregular (std::vector< double > &&binborders) noexcept
 Construct a RAxisIrregular from a vector of bin borders. More...
 
bool CanGrow () const noexcept final override
 This axis cannot be extended. More...
 
int FindBin (double x) const noexcept final override
 Find the bin index (adjusted with under- and overflow) for the given coordinate x. More...
 
const std::vector< double > & GetBinBorders () const noexcept
 Access to the bin borders used by this axis. More...
 
double GetBinCenter (int bin) const final override
 Get the bin center of the bin with the given index. More...
 
double GetBinFrom (int bin) const final override
 Get the lower bin border for a given bin index. More...
 
int GetBinIndexForLowEdge (double x) const noexcept final override
 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...
 
int GetNBinsNoOver () const noexcept final override
 Get the number of bins, excluding under- and overflow. More...
 
 operator RAxisConfig () const
 Convert to RAxisConfig. More...
 
- Public Member Functions inherited from ROOT::Experimental::RAxisBase
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...
 
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...
 

Protected Member Functions

double FindBinRaw (double x) const noexcept
 Find the raw bin index (not adjusted) for the given coordinate x. More...
 
bool HasSameBinBordersAs (const RAxisBase &other) const override
 See RAxisBase::HasSameBinBordersAs. More...
 
- Protected Member Functions inherited from ROOT::Experimental::RAxisBase
 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...
 
 RAxisBase (const RAxisBase &)=default
 
 RAxisBase (RAxisBase &&)=default
 
RAxisBaseoperator= (const RAxisBase &)=default
 
RAxisBaseoperator= (RAxisBase &&)=default
 

Private Attributes

std::vector< doublefBinBorders
 Bin borders, one more than the number of regular bins. More...
 

Additional Inherited Members

- Static Public Attributes inherited from ROOT::Experimental::RAxisBase
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...
 

#include <ROOT/RAxis.hxx>

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

Constructor & Destructor Documentation

◆ RAxisIrregular() [1/5]

ROOT::Experimental::RAxisIrregular::RAxisIrregular ( )
default

◆ RAxisIrregular() [2/5]

ROOT::Experimental::RAxisIrregular::RAxisIrregular ( const std::vector< double > &  binborders)
inlineexplicit

Construct a RAxisIrregular from a vector of bin borders.

Note
The bin borders must be sorted in increasing order!

Definition at line 618 of file RAxis.hxx.

◆ RAxisIrregular() [3/5]

ROOT::Experimental::RAxisIrregular::RAxisIrregular ( std::vector< double > &&  binborders)
inlineexplicitnoexcept

Construct a RAxisIrregular from a vector of bin borders.

Note
The bin borders must be sorted in increasing order! Faster, noexcept version taking an rvalue of binborders. The compiler will know when it can take this one.

Definition at line 631 of file RAxis.hxx.

◆ RAxisIrregular() [4/5]

ROOT::Experimental::RAxisIrregular::RAxisIrregular ( std::string_view  title,
const std::vector< double > &  binborders 
)
inlineexplicit

Construct a RAxisIrregular from a vector of bin borders.

Note
The bin borders must be sorted in increasing order!

Definition at line 642 of file RAxis.hxx.

◆ RAxisIrregular() [5/5]

ROOT::Experimental::RAxisIrregular::RAxisIrregular ( std::string_view  title,
std::vector< double > &&  binborders 
)
inlineexplicitnoexcept

Construct a RAxisIrregular from a vector of bin borders.

Note
The bin borders must be sorted in increasing order! Faster, noexcept version taking an rvalue of binborders. The compiler will know when it can take this one.

Definition at line 655 of file RAxis.hxx.

Member Function Documentation

◆ CanGrow()

bool ROOT::Experimental::RAxisIrregular::CanGrow ( ) const
inlinefinaloverridevirtualnoexcept

This axis cannot be extended.

Implements ROOT::Experimental::RAxisBase.

Definition at line 704 of file RAxis.hxx.

◆ FindBin()

int ROOT::Experimental::RAxisIrregular::FindBin ( double  x) const
inlinefinaloverridevirtualnoexcept

Find the bin index (adjusted with under- and overflow) for the given coordinate x.

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!

Implements ROOT::Experimental::RAxisBase.

Definition at line 673 of file RAxis.hxx.

◆ FindBinRaw()

double ROOT::Experimental::RAxisIrregular::FindBinRaw ( double  x) const
inlineprotectednoexcept

Find the raw bin index (not adjusted) for the given coordinate x.

The resulting raw bin is 1-based.

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!

Definition at line 604 of file RAxis.hxx.

◆ GetBinBorders()

const std::vector< double > & ROOT::Experimental::RAxisIrregular::GetBinBorders ( ) const
inlinenoexcept

Access to the bin borders used by this axis.

Definition at line 707 of file RAxis.hxx.

◆ GetBinCenter()

double ROOT::Experimental::RAxisIrregular::GetBinCenter ( int  bin) const
inlinefinaloverridevirtual

Get the bin center of the bin with the given index.

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

Implements ROOT::Experimental::RAxisBase.

Definition at line 687 of file RAxis.hxx.

◆ GetBinFrom()

double ROOT::Experimental::RAxisIrregular::GetBinFrom ( int  bin) const
inlinefinaloverridevirtual

Get the lower bin border for a given bin index.

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

Implements ROOT::Experimental::RAxisBase.

Definition at line 691 of file RAxis.hxx.

◆ GetBinIndexForLowEdge()

int ROOT::Experimental::RAxisIrregular::GetBinIndexForLowEdge ( double  x) const
finaloverridevirtualnoexcept

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.

Implements ROOT::Experimental::RAxisBase.

Definition at line 81 of file RAxis.cxx.

◆ GetNBinsNoOver()

int ROOT::Experimental::RAxisIrregular::GetNBinsNoOver ( ) const
inlinefinaloverridevirtualnoexcept

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

Implements ROOT::Experimental::RAxisBase.

Definition at line 668 of file RAxis.hxx.

◆ HasSameBinBordersAs()

bool ROOT::Experimental::RAxisIrregular::HasSameBinBordersAs ( const RAxisBase other) const
overrideprotectedvirtual

See RAxisBase::HasSameBinBordersAs.

Reimplemented from ROOT::Experimental::RAxisBase.

Definition at line 104 of file RAxis.cxx.

◆ operator RAxisConfig()

ROOT::Experimental::RAxisIrregular::operator RAxisConfig ( ) const
inline

Convert to RAxisConfig.

Definition at line 665 of file RAxis.hxx.

Member Data Documentation

◆ fBinBorders

std::vector<double> ROOT::Experimental::RAxisIrregular::fBinBorders
private

Bin borders, one more than the number of regular bins.

Definition at line 594 of file RAxis.hxx.

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

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