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

A RAxisGrow that has a label assigned to each bin and a bin width of 1.

While filling still works through coordinates (i.e. arrays of doubles), RAxisLabels allows to convert a string to a bin number or the bin's coordinate center. The number of labels and the number of bins reported by RAxisGrow might differ: the RAxisGrow will only grow when seeing a Fill(), while the RAxisLabels will add a new label whenever GetBinCenter() is called.

Implementation details: Filling happens often; GetBinCenter() needs to be fast. Thus the unordered_map. The painter needs the reverse: it wants the label for bin 0, bin 1 etc. The axis should only store the bin labels once; referencing them is (due to re-allocation, hashing etc) non-trivial. So instead, build a vector<string_view> for the few times the axis needs to be painted.

Definition at line 742 of file RAxis.hxx.

Public Types

enum  LabelsCmpFlags { kLabelsCmpSame = 0 , kLabelsCmpSubset = 0b1 , kLabelsCmpSuperset = 0b10 , kLabelsCmpDisordered = 0b100 }
 Result of an RAxisLabels label set comparison. More...
 

Public Member Functions

 RAxisLabels (const std::vector< std::string > &labels)
 Construct a RAxisLables from a vector of strings.
 
 RAxisLabels (const std::vector< std::string_view > &labels)
 Construct a RAxisLables from a vector of string_views.
 
 RAxisLabels (std::string_view title, const std::vector< std::string > &labels)
 Construct a RAxisLables from a vector of strings, with title.
 
 RAxisLabels (std::string_view title, const std::vector< std::string_view > &labels)
 Construct a RAxisLables from a vector of string_views, with title.
 
LabelsCmpFlags CompareBinLabels (const RAxisLabels &other) const noexcept
 Compare the labels of this axis with those of another axis.
 
int FindBinByName (const std::string &label)
 Get the bin index with label.
 
double GetBinCenterByName (const std::string &label)
 Get the center of the bin with label.
 
std::vector< std::string_view > GetBinLabels () const
 Build a vector of labels. The position in the vector defines the label's bin.
 
 operator RAxisConfig () const
 Convert to RAxisConfig.
 
- Public Member Functions inherited from ROOT::Experimental::RAxisGrow
 RAxisGrow (int nbins, double low, double high) noexcept
 Initialize a RAxisGrow.
 
 RAxisGrow (std::string_view title, int nbins, double low, double high) noexcept
 Initialize a RAxisGrow.
 
bool CanGrow () const noexcept final override
 This axis kind can increase its range.
 
int Grow (int toBin)
 Grow this axis to make the "virtual bin" toBin in-range.
 
 operator RAxisConfig () const
 Convert to RAxisConfig.
 
- Public Member Functions inherited from ROOT::Experimental::RAxisEquidistant
 RAxisEquidistant ()=default
 
 RAxisEquidistant (int nbinsNoOver, double low, double high) noexcept
 Initialize a RAxisEquidistant.
 
 RAxisEquidistant (std::string_view title, int nbinsNoOver, double low, double high) noexcept
 Initialize a RAxisEquidistant.
 
int FindBin (double x) const noexcept final override
 Find the adjusted bin index (returning kUnderflowBin for underflow and kOverflowBin for overflow) for the given coordinate.
 
double GetBinCenter (int bin) const final override
 Get the bin center for the given bin index.
 
double GetBinFrom (int bin) const final override
 Get the low bin border for the given bin index.
 
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.
 
double GetBinWidth () const noexcept
 Get the width of the bins.
 
double GetInverseBinWidth () const noexcept
 Get the inverse of the width of the bins.
 
int GetNBinsNoOver () const noexcept final override
 Get the number of bins, excluding under- and overflow.
 
 operator RAxisConfig () const
 Convert to RAxisConfig.
 
- Public Member Functions inherited from ROOT::Experimental::RAxisBase
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.
 
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.
 
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.
 

Private Attributes

std::unordered_map< std::string, intfLabelsIndex
 Map of label (view on fLabels's elements) to bin index.
 

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.
 
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 inherited from ROOT::Experimental::RAxisEquidistant
double FindBinRaw (double x) const noexcept
 Find the raw bin index (not adjusted) for the given coordinate.
 
bool HasSameBinBordersAs (const RAxisBase &other) const override
 See RAxisBase::HasSameBinBordersAs.
 
- 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)
 
 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.
 
 RAxisBase (const RAxisBase &)=default
 
 RAxisBase (RAxisBase &&)=default
 
RAxisBaseoperator= (const RAxisBase &)=default
 
RAxisBaseoperator= (RAxisBase &&)=default
 
- Static Protected Member Functions inherited from ROOT::Experimental::RAxisEquidistant
static double GetInvBinWidth (int nbinsNoOver, double lowOrHigh, double highOrLow)
 Determine the inverse bin width.
 
- Protected Attributes inherited from ROOT::Experimental::RAxisEquidistant
double fInvBinWidth = 0.
 The inverse of the bin width.
 
double fLow = 0.
 The lower limit of the axis.
 
unsigned int fNBinsNoOver
 Number of bins excluding under- and overflow.
 

#include <ROOT/RAxis.hxx>

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

Member Enumeration Documentation

◆ LabelsCmpFlags

Result of an RAxisLabels label set comparison.

Enumerator
kLabelsCmpSame 

Both axes have the same labels, mapping to the same bins.

kLabelsCmpSubset 

The other axis doesn't have some labels from this axis.

kLabelsCmpSuperset 

The other axis has some labels which this axis doesn't have.

kLabelsCmpDisordered 

The labels shared by both axes do not map into the same bins.

Definition at line 802 of file RAxis.hxx.

Constructor & Destructor Documentation

◆ RAxisLabels() [1/4]

ROOT::Experimental::RAxisLabels::RAxisLabels ( std::string_view  title,
const std::vector< std::string_view > &  labels 
)
inlineexplicit

Construct a RAxisLables from a vector of string_views, with title.

Definition at line 749 of file RAxis.hxx.

◆ RAxisLabels() [2/4]

ROOT::Experimental::RAxisLabels::RAxisLabels ( std::string_view  title,
const std::vector< std::string > &  labels 
)
inlineexplicit

Construct a RAxisLables from a vector of strings, with title.

Definition at line 757 of file RAxis.hxx.

◆ RAxisLabels() [3/4]

ROOT::Experimental::RAxisLabels::RAxisLabels ( const std::vector< std::string_view > &  labels)
inlineexplicit

Construct a RAxisLables from a vector of string_views.

Definition at line 765 of file RAxis.hxx.

◆ RAxisLabels() [4/4]

ROOT::Experimental::RAxisLabels::RAxisLabels ( const std::vector< std::string > &  labels)
inlineexplicit

Construct a RAxisLables from a vector of strings.

Definition at line 768 of file RAxis.hxx.

Member Function Documentation

◆ CompareBinLabels()

LabelsCmpFlags ROOT::Experimental::RAxisLabels::CompareBinLabels ( const RAxisLabels other) const
inlinenoexcept

Compare the labels of this axis with those of another axis.

Definition at line 817 of file RAxis.hxx.

◆ FindBinByName()

int ROOT::Experimental::RAxisLabels::FindBinByName ( const std::string &  label)
inline

Get the bin index with label.

Definition at line 774 of file RAxis.hxx.

◆ GetBinCenterByName()

double ROOT::Experimental::RAxisLabels::GetBinCenterByName ( const std::string &  label)
inline

Get the center of the bin with label.

Definition at line 787 of file RAxis.hxx.

◆ GetBinLabels()

std::vector< std::string_view > ROOT::Experimental::RAxisLabels::GetBinLabels ( ) const
inline

Build a vector of labels. The position in the vector defines the label's bin.

Definition at line 793 of file RAxis.hxx.

◆ operator RAxisConfig()

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

Convert to RAxisConfig.

Definition at line 771 of file RAxis.hxx.

Member Data Documentation

◆ fLabelsIndex

std::unordered_map<std::string, int > ROOT::Experimental::RAxisLabels::fLabelsIndex
private

Map of label (view on fLabels's elements) to bin index.

Definition at line 745 of file RAxis.hxx.

Libraries for ROOT::Experimental::RAxisLabels:

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