|
ROOT
Reference Guide |
|
Go to the documentation of this file.
23 #include <unordered_map>
31 namespace Experimental {
57 RAxisBase() noexcept(noexcept(std::
string())) = default;
126 class const_iterator:
public std::iterator<std::random_access_iterator_tag, int , int ,
127 const int * , const int & > {
344 return lhs.fCursor < rhs.fCursor;
350 return lhs.fCursor > rhs.fCursor;
356 return lhs.fCursor <= rhs.fCursor;
362 return lhs.fCursor >= rhs.fCursor;
368 return lhs.fCursor == rhs.fCursor;
374 return lhs.fCursor != rhs.fCursor;
394 static double GetInvBinWidth(
int nbinsNoOver,
double lowOrHigh,
double highOrLow)
396 return nbinsNoOver /
std::fabs(highOrLow - lowOrHigh);
450 int FindBin(
double x)
const noexcept
final override
457 bool CanGrow() const noexcept
override {
return false; }
494 return RAxisEquidistant(cfg.GetTitle(), cfg.GetNBinsNoOver(), cfg.GetBinBorders()[0], cfg.GetBinBorders()[1]);
561 bool CanGrow() const noexcept final
override {
return true; }
572 return RAxisGrow(cfg.GetTitle(), cfg.GetNBinsNoOver(), cfg.GetBinBorders()[0], cfg.GetBinBorders()[1]);
608 auto iNotLess = std::lower_bound(bBegin, bEnd,
x);
609 return iNotLess - bBegin;
620 #ifdef R__DO_RANGE_CHECKS
633 #ifdef R__DO_RANGE_CHECKS
644 #ifdef R__DO_RANGE_CHECKS
657 #ifdef R__DO_RANGE_CHECKS
672 int FindBin(
double x)
const noexcept
final override
703 bool CanGrow() const noexcept final
override {
return false; }
745 :
RAxisGrow(title, labels.size(), 0., static_cast<
double>(labels.size()))
747 for (
size_t i = 0,
n = labels.size(); i <
n; ++i)
753 :
RAxisGrow(title, labels.size(), 0., static_cast<
double>(labels.size()))
755 for (
size_t i = 0,
n = labels.size(); i <
n; ++i)
772 if (insertResult.second) {
775 insertResult.first->second = idx;
778 return insertResult.first->second;
792 vec.at(kv.second) = kv.first;
815 size_t missing_in_other = 0;
819 auto iter = other.fLabelsIndex.find(kv.first);
820 if (iter == other.fLabelsIndex.cend()) {
822 }
else if (iter->second != kv.second) {
826 if (missing_in_other > 0)
830 if (
fLabelsIndex.size() == other.fLabelsIndex.size() + missing_in_other)
834 for (
const auto &kv: other.fLabelsIndex)
int GetNOverflowBins() const noexcept
Get the number of over- and underflow bins: 0 for growable axes, 2 otherwise.
constexpr static const Grow_t Grow
Tag signalling that an axis should be able to grow; used for calling the appropriate constructor like...
@ kLabelsCmpSuperset
The other axis has some labels which this axis doesn't have.
virtual double GetBinFrom(int bin) const =0
Get the low bin border ("left edge") for the given bin index.
friend bool operator==(const_iterator lhs, const_iterator rhs) noexcept
i == j
RAxisIrregular(std::string_view title, std::vector< double > &&binborders) noexcept
Construct a RAxisIrregular from a vector of bin borders.
int GetOverflowBin() const noexcept
Get the bin index for the overflow bin (or kInvalidBin if CanGrow()).
double GetBinFrom(int bin) const final override
Get the lower bin border for a given bin index.
virtual bool HasSameBinBordersAs(const RAxisBase &other) const
Check if two axis have the same bin borders.
virtual int FindBin(double x) const noexcept=0
Find the adjusted bin index (returning kUnderflowBin for underflow and kOverflowBin for overflow) for...
bool operator!=(RAxisBase::const_iterator lhs, RAxisBase::const_iterator rhs) noexcept
i != j
friend bool operator!=(const_iterator lhs, const_iterator rhs) noexcept
i != j
const std::string & GetTitle() const
Get the axis's title.
bool operator>=(RAxisBase::const_iterator lhs, RAxisBase::const_iterator rhs) noexcept
i >= j
std::unordered_map< std::string, int > fLabelsIndex
Map of label (view on fLabels's elements) to bin index.
const std::vector< std::string > & GetBinLabels() const noexcept
Get the bin labels; non-empty if the GetKind() == kLabels.
Objects used to configure the different axis types.
#define R__LOG_ERROR(...)
ELogLevel operator+(ELogLevel severity, int offset)
const_iterator operator-(int d) noexcept
EAxisCompatibility CanMap(const RAxisEquidistant &target, const RAxisEquidistant &source) noexcept
Whether (and how) the source axis can be merged into the target axis.
std::vector< double > fBinBorders
Bin borders, one more than the number of regular bins.
const_iterator end() const noexcept
Get a const_iterator pointing beyond the last regular bin.
const std::vector< double > & GetBinBorders() const noexcept
Get the bin borders; non-empty if the GetKind() == kIrregular.
double GetBinCenter(int bin) const final override
Get the bin center of the bin with the given index.
double FindBinRaw(double x) const noexcept
Find the raw bin index (not adjusted) for the given coordinate x.
const std::vector< double > & GetBinBorders() const noexcept
Access to the bin borders used by this axis.
std::string fTitle
Title of this axis, used for graphics / text.
RAxisLabels(std::string_view title, const std::vector< std::string > &labels)
Construct a RAxisLables from a vector of strings, with title.
@ kIncompatible
The source axis and target axis have different binning.
An axis with non-equidistant bins (also known as "variable binning").
basic_string_view< char > string_view
int FindBin(double x) const noexcept final override
Find the adjusted bin index (returning kUnderflowBin for underflow and kOverflowBin for overflow) for...
int operator[](int d) noexcept
RAxisLabels(const std::vector< std::string_view > &labels)
Construct a RAxisLables from a vector of string_views.
RAxisBase(const RAxisBase &)=default
int fCursor
Current iteration position.
An axis that can extend its range, keeping the number of its bins unchanged.
friend bool operator>=(const_iterator lhs, const_iterator rhs) noexcept
i >= j
int GetFirstBin() const noexcept
Get the bin index for the first bin of the axis.
int operator*() const noexcept
int FindBinByName(const std::string &label)
Get the bin index with label.
std::vector< std::string_view > GetBinLabels() const
Build a vector of labels. The position in the vector defines the label's bin.
bool operator<=(RAxisBase::const_iterator lhs, RAxisBase::const_iterator rhs) noexcept
i <= j
const_iterator & operator++() noexcept
++i
const std::string & GetTitle() const
Get the axis's title.
RAxisEquidistant(std::string_view title, int nbinsNoOver, double low, double high) noexcept
Initialize a RAxisEquidistant.
constexpr static const int kOverflowBin
Index of the overflow bin, if any.
@ kLabelsCmpDisordered
The labels shared by both axes do not map into the same bins.
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 ...
double GetBinCenter(int bin) const final override
Get the bin center for the given bin index.
double GetMinimum() const
Get the low end of the axis range.
LabelsCmpFlags
Result of an RAxisLabels label set comparison.
int operator-(const const_iterator &j) noexcept
double GetBinTo(int bin) const
Get the high bin border ("right edge") for the given bin index.
double fLow
The lower limit of the axis.
const_iterator operator+(int d) noexcept
@ kSampling
The bins of the source axis have finer granularity, but the bin borders are compatible.
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 ...
const_iterator(int cursor) noexcept
Initialize a const_iterator with its position.
RAxisIrregular(std::string_view title, const std::vector< double > &binborders)
Construct a RAxisIrregular from a vector of bin borders.
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 ...
double FindBinRaw(double x) const noexcept
Find the raw bin index (not adjusted) for the given coordinate.
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
@ kLabelsCmpSame
Both axes have the same labels, mapping to the same bins.
const_iterator & operator--() noexcept
–i
RAxisBase & operator=(RAxisBase &&)=default
RAxisLabels(std::string_view title, const std::vector< std::string_view > &labels)
Construct a RAxisLables from a vector of string_views, with title.
Axis with equidistant bin borders.
bool operator<(RAxisBase::const_iterator lhs, RAxisBase::const_iterator rhs) noexcept
i < j
Random const_iterator through bins.
constexpr static const int kInvalidBin
Special bin index returned to signify that no bin matches a request.
A RAxisGrow that has a label assigned to each bin and a bin width of 1.
RAxisGrow(int nbins, double low, double high) noexcept
Initialize a RAxisGrow.
@ kIdentical
Source and target axes are identical.
RAxisGrow(std::string_view title, int nbins, double low, double high) noexcept
Initialize a RAxisGrow.
int GetLastBin() const noexcept
Get the bin index for the last bin of the axis.
Axis_t operator()(const RAxisConfig &cfg) noexcept
RAxisIrregular(const std::vector< double > &binborders)
Construct a RAxisIrregular from a vector of bin borders.
Axis_t operator()(const RAxisConfig &cfg)
constexpr static const int kUnderflowBin
Index of the underflow bin, if any.
RAxisBase() noexcept(noexcept(std::string()))=default
Default construct a RAxisBase (for use by derived classes for I/O)
double GetBinWidth() const noexcept
Get the width of the bins.
bool HasSameBinBordersAs(const RAxisBase &other) const override
See RAxisBase::HasSameBinBordersAs.
const_iterator & operator+=(int d) noexcept
bool HasSameBinBordersAs(const RAxisBase &other) const override
See RAxisBase::HasSameBinBordersAs.
bool CanGrow() const noexcept final override
This axis cannot be extended.
double GetInverseBinWidth() const noexcept
Get the inverse of the width of the bins.
int AdjustOverflowBinNumber(double rawbin) const
Given rawbin (<0 for underflow, >=GetNBinsNoOver() for overflow), determine the bin number taking int...
virtual bool CanGrow() const noexcept=0
Whether this axis can grow (and thus has no overflow bins).
bool CanGrow() const noexcept override
This axis cannot grow.
static double GetInvBinWidth(int nbinsNoOver, double lowOrHigh, double highOrLow)
Determine the inverse bin width.
Histogram axis base class.
friend bool operator<(const_iterator lhs, const_iterator rhs) noexcept
i < j
int GetNBins() const noexcept
Get the number of bins, including under- and overflow.
const_iterator begin() const noexcept
Get a const_iterator pointing to the first regular bin.
@ kLabelsCmpSubset
The other axis doesn't have some labels from this axis.
bool HasSameBinningAs(const RAxisBase &other) const
Check if two axes use the same binning convention, i.e.
int GetNBinsNoOver() const noexcept final override
Get the number of bins, excluding under- and overflow.
LabelsCmpFlags CompareBinLabels(const RAxisLabels &other) const noexcept
Compare the labels of this axis with those of another axis.
int GetNBinsNoOver() const noexcept final override
Get the number of bins, excluding under- and overflow.
const_iterator & operator-=(int d) noexcept
virtual int GetNBinsNoOver() const noexcept=0
Get the number of bins, excluding under- and overflow.
Axis_t operator()(const RAxisConfig &cfg)
friend bool operator<=(const_iterator lhs, const_iterator rhs) noexcept
i <= j
RAxisLabels(const std::vector< std::string > &labels)
Construct a RAxisLables from a vector of strings.
unsigned int fNBinsNoOver
Number of bins excluding under- and overflow.
double fInvBinWidth
The inverse of the bin width.
const int * operator->() const noexcept
RAxisBase & operator=(const RAxisBase &)=default
Converts a RAxisConfig of whatever kind to the corresponding RAxisBase-derived object.
friend bool operator>(const_iterator lhs, const_iterator rhs) noexcept
i > j
@ kContains
The source is a subset of bins of the target axis.
bool operator==(const TString &t, const std::string &s)
RAxisBase(RAxisBase &&)=default
int GetUnderflowBin() const noexcept
Get the bin index for the underflow bin (or kInvalidBin if CanGrow()).
RAxisEquidistant(int nbinsNoOver, double low, double high) noexcept
Initialize a RAxisEquidistant.
RAxisIrregular(std::vector< double > &&binborders) noexcept
Construct a RAxisIrregular from a vector of bin borders.
double GetMaximum() const
Get the high end of the axis range.
int FindBin(double x) const noexcept final override
Find the bin index (adjusted with under- and overflow) for the given coordinate x.
virtual double GetBinCenter(int bin) const =0
Get the bin center for the given bin index.
int Grow(int toBin)
Grow this axis to make the "virtual bin" toBin in-range.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
RAxisEquidistant()=default
const_iterator operator++(int) noexcept
i++
double GetBinCenterByName(const std::string &label)
Get the center of the bin with label.
Axis_t operator()(const RAxisConfig &cfg) noexcept
const_iterator operator--(int) noexcept
bool operator>(RAxisBase::const_iterator lhs, RAxisBase::const_iterator rhs) noexcept
i > j
bool CanGrow() const noexcept final override
This axis kind can increase its range.
double GetBinFrom(int bin) const final override
Get the low bin border for the given bin index.