Logo ROOT   6.10/09
Reference Guide
List of all members | Public Member Functions | Private Attributes | List of all members
ROOT::Experimental::TAxisLabels Class Reference

A TAxisGrow 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), TAxisLabels 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 TAxisGrow might differ: the TAxisGrow will only grow when seeing a Fill(), while the TAxisLabels 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 761 of file TAxis.hxx.

Public Member Functions

 TAxisLabels (std::string_view title, const std::vector< std::string_view > &labels)
 Construct a TAxisLables from a vector of string_views, with title. More...
 
 TAxisLabels (std::string_view title, const std::vector< std::string > &labels)
 Construct a TAxisLables from a vector of strings, with title. More...
 
 TAxisLabels (const std::vector< std::string_view > &labels)
 Construct a TAxisLables from a vector of string_views. More...
 
 TAxisLabels (const std::vector< std::string > &labels)
 Construct a TAxisLables from a vector of strings. More...
 
double GetBinCenter (const std::string &label)
 Get the center of the bin with label. More...
 
int GetBinIndex (const std::string &label)
 Get the bin index with label. More...
 
std::vector< std::string_view > GetBinLabels () const
 Build a vector of labels. The position in the vector defines the label's bin. More...
 
- Public Member Functions inherited from ROOT::Experimental::TAxisGrow
 TAxisGrow (std::string_view title, int nbins, double low, double high) noexcept
 Initialize a TAxisGrow. More...
 
 TAxisGrow (int nbins, double low, double high) noexcept
 Initialize a TAxisGrow. More...
 
bool CanGrow () const
 This axis kind can increase its range. More...
 
int Grow (int toBin)
 Grow this axis to make the "virtual bin" toBin in-range. More...
 
 operator TAxisConfig () const
 Convert to TAxisConfig. More...
 
- Public Member Functions inherited from ROOT::Experimental::TAxisEquidistant
 TAxisEquidistant ()=default
 
 TAxisEquidistant (int nbinsNoOver, double low, double high) noexcept
 Initialize a TAxisEquidistant. More...
 
 TAxisEquidistant (std::string_view title, int nbinsNoOver, double low, double high) noexcept
 Initialize a TAxisEquidistant. More...
 
int FindBin (double x) const noexcept
 Find the bin index for the given coordinate. More...
 
double GetBinCenter (int bin) const noexcept
 Get the bin center for the given bin index. More...
 
double GetBinFrom (int bin) const noexcept
 Get the low bin border for the given bin index. More...
 
int GetBinIndexForLowEdge (double x) const noexcept
 If the coordinate x is a bin low edge (within 1E-6 of the coordinate), return the bin for which this is a low edge. More...
 
double GetBinTo (int bin) const noexcept
 Get the high bin border for the given bin index. More...
 
double GetBinWidth () const noexcept
 Get the width of the bins. More...
 
double GetInverseBinWidth () const noexcept
 Get the inverse of the width of the bins. More...
 
double GetMaximum () const noexcept
 Get the high end of the axis range. More...
 
double GetMinimum () const noexcept
 Get the low end of the axis range. More...
 
 operator TAxisConfig () const
 Convert to TAxisConfig. More...
 
- Public Member Functions inherited from ROOT::Experimental::TAxisBase
 TAxisBase (std::string_view title, int nbinsNoOver, bool canGrow) noexcept
 Construct a TAxisBase. More...
 
 TAxisBase (int nbinsNoOver, bool canGrow) noexcept
 Construct a TAxisBase. More...
 
int GetNBins () const noexcept
 Get the number of bins, including under- and overflow. More...
 
int GetNBinsNoOver () const noexcept
 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
 
int GetUnderflowBin () const noexcept
 Get the bin index for the underflow bin. 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...
 
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 underflow bin. 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 overflow bin. More...
 

Private Attributes

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

Additional Inherited Members

- Public Types inherited from ROOT::Experimental::TAxisBase
enum  EFindStatus { EFindStatus::kCanGrow, EFindStatus::kValid }
 Status of FindBin(x) More...
 
- Static Public Member Functions inherited from ROOT::Experimental::TAxisEquidistant
static bool CanGrow () noexcept
 This axis cannot grow. More...
 
- Static Public Attributes inherited from ROOT::Experimental::TAxisBase
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 inherited from ROOT::Experimental::TAxisEquidistant
 TAxisEquidistant (std::string_view title, int nbinsNoOver, double low, double high, bool canGrow) noexcept
 Initialize a TAxisEquidistant. More...
 
 TAxisEquidistant (int nbinsNoOver, double low, double high, bool canGrow) noexcept
 Initialize a TAxisEquidistant. More...
 
- Protected Member Functions inherited from ROOT::Experimental::TAxisBase
 TAxisBase ()
 Default construct a TAxisBase (for use by derived classes for I/O) More...
 
int AdjustOverflowBinNumber (int 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...
 
 TAxisBase (const TAxisBase &)=default
 
 TAxisBase (TAxisBase &&)=default
 
TAxisBaseoperator= (const TAxisBase &)=default
 
TAxisBaseoperator= (TAxisBase &&)=default
 
- Static Protected Member Functions inherited from ROOT::Experimental::TAxisEquidistant
static double GetInvBinWidth (int nbinsNoOver, double lowOrHigh, double highOrLow)
 Determine the inverse bin width. More...
 
- Protected Attributes inherited from ROOT::Experimental::TAxisEquidistant
double fInvBinWidth = 0.
 The inverse of the bin width. More...
 
double fLow = 0.
 The lower limit of the axis. More...
 

#include <ROOT/TAxis.hxx>

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

Constructor & Destructor Documentation

◆ TAxisLabels() [1/4]

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

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

Definition at line 768 of file TAxis.hxx.

◆ TAxisLabels() [2/4]

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

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

Definition at line 775 of file TAxis.hxx.

◆ TAxisLabels() [3/4]

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

Construct a TAxisLables from a vector of string_views.

Definition at line 782 of file TAxis.hxx.

◆ TAxisLabels() [4/4]

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

Construct a TAxisLables from a vector of strings.

Definition at line 786 of file TAxis.hxx.

Member Function Documentation

◆ GetBinCenter()

double ROOT::Experimental::TAxisLabels::GetBinCenter ( const std::string &  label)
inline

Get the center of the bin with label.

Definition at line 802 of file TAxis.hxx.

◆ GetBinIndex()

int ROOT::Experimental::TAxisLabels::GetBinIndex ( const std::string &  label)
inline

Get the bin index with label.

Definition at line 790 of file TAxis.hxx.

◆ GetBinLabels()

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

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

Definition at line 807 of file TAxis.hxx.

Member Data Documentation

◆ fLabelsIndex

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

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

Definition at line 764 of file TAxis.hxx.


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