23#include <unordered_map>
31namespace Experimental {
57 RAxisBase() noexcept(noexcept(std::
string())) = default;
349 return lhs.fCursor < rhs.fCursor;
355 return lhs.fCursor > rhs.fCursor;
361 return lhs.fCursor <= rhs.fCursor;
367 return lhs.fCursor >= rhs.fCursor;
373 return lhs.fCursor == rhs.fCursor;
379 return lhs.fCursor != rhs.fCursor;
399 static double GetInvBinWidth(
int nbinsNoOver,
double lowOrHigh,
double highOrLow)
401 return nbinsNoOver / std::fabs(highOrLow - lowOrHigh);
427 explicit RAxisEquidistant(std::string_view title,
int nbinsNoOver,
double low,
double high) noexcept
462 bool CanGrow() const noexcept
override {
return false; }
499 return RAxisEquidistant(cfg.GetTitle(), cfg.GetNBinsNoOver(), cfg.GetBinBorders()[0], cfg.GetBinBorders()[1]);
521 explicit RAxisGrow(std::string_view title,
int nbins,
double low,
double high) noexcept
566 bool CanGrow() const noexcept final {
return true; }
577 return RAxisGrow(cfg.GetTitle(), cfg.GetNBinsNoOver(), cfg.GetBinBorders()[0], cfg.GetBinBorders()[1]);
613 auto iNotLess = std::lower_bound(bBegin, bEnd,
x);
614 return iNotLess - bBegin;
625#ifdef R__DO_RANGE_CHECKS
638#ifdef R__DO_RANGE_CHECKS
646 explicit RAxisIrregular(std::string_view title,
const std::vector<double> &binborders)
649#ifdef R__DO_RANGE_CHECKS
659 explicit RAxisIrregular(std::string_view title, std::vector<double> &&binborders) noexcept
662#ifdef R__DO_RANGE_CHECKS
708 bool CanGrow() const noexcept final {
return false; }
749 explicit RAxisLabels(std::string_view title,
const std::vector<std::string_view> &labels)
752 for (
size_t i = 0,
n = labels.size(); i <
n; ++i)
757 explicit RAxisLabels(std::string_view title,
const std::vector<std::string> &labels)
760 for (
size_t i = 0,
n = labels.size(); i <
n; ++i)
777 if (insertResult.second) {
780 insertResult.first->second = idx;
783 return insertResult.first->second;
797 vec.at(kv.second) = kv.first;
820 size_t missing_in_other = 0;
824 auto iter = other.fLabelsIndex.find(kv.first);
825 if (iter == other.fLabelsIndex.cend()) {
827 }
else if (iter->second != kv.second) {
831 if (missing_in_other > 0)
835 if (
fLabelsIndex.size() == other.fLabelsIndex.size() + missing_in_other)
839 for (
const auto &kv: other.fLabelsIndex)
#define R__LOG_ERROR(...)
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t cursor
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t target
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Random const_iterator through bins.
int operator[](int d) noexcept
std::random_access_iterator_tag iterator_category
const_iterator & operator-=(int d) noexcept
const_iterator operator-(int d) noexcept
int operator-(const const_iterator &j) noexcept
const_iterator operator++(int) noexcept
i++
friend bool operator>(const_iterator lhs, const_iterator rhs) noexcept
i > j
const_iterator operator+(int d) noexcept
int fCursor
Current iteration position.
friend const_iterator operator+(int d, const_iterator rhs) noexcept
2 + i
const int * operator->() const noexcept
const_iterator & operator+=(int d) noexcept
const_iterator & operator--() noexcept
–i
const_iterator & operator++() noexcept
++i
const_iterator operator--(int) noexcept
const_iterator(int cursor) noexcept
Initialize a const_iterator with its position.
friend bool operator<=(const_iterator lhs, const_iterator rhs) noexcept
i <= j
int operator*() const noexcept
friend bool operator<(const_iterator lhs, const_iterator rhs) noexcept
i < j
friend bool operator>=(const_iterator lhs, const_iterator rhs) noexcept
i >= j
friend bool operator==(const_iterator lhs, const_iterator rhs) noexcept
i == j
friend bool operator!=(const_iterator lhs, const_iterator rhs) noexcept
i != j
Histogram axis base class.
int GetFirstBin() const noexcept
Get the bin index for the first bin of the axis.
const_iterator end() const noexcept
Get a const_iterator pointing beyond the last regular bin.
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 ...
int GetNOverflowBins() const noexcept
Get the number of over- and underflow bins: 0 for growable axes, 2 otherwise.
RAxisBase(const RAxisBase &)=default
double GetMinimum() const
Get the low end of the axis range.
virtual int GetNBinsNoOver() const noexcept=0
Get the number of bins, excluding under- and overflow.
static constexpr const int kUnderflowBin
Index of the underflow bin, if any.
double GetMaximum() const
Get the high end of the axis range.
std::string fTitle
Title of this axis, used for graphics / text.
virtual int FindBin(double x) const noexcept=0
Find the adjusted bin index (returning kUnderflowBin for underflow and kOverflowBin for overflow) for...
int GetUnderflowBin() const noexcept
Get the bin index for the underflow bin (or kInvalidBin if CanGrow()).
virtual double GetBinFrom(int bin) const =0
Get the low bin border ("left edge") for the given bin index.
const std::string & GetTitle() const
Get the axis's title.
RAxisBase & operator=(RAxisBase &&)=default
const_iterator begin() const noexcept
Get a const_iterator pointing to the first regular bin.
int GetOverflowBin() const noexcept
Get the bin index for the overflow bin (or kInvalidBin if CanGrow()).
virtual double GetBinCenter(int bin) const =0
Get the bin center for the given bin index.
static constexpr const int kOverflowBin
Index of the overflow bin, if any.
RAxisBase() noexcept(noexcept(std::string()))=default
Default construct a RAxisBase (for use by derived classes for I/O)
virtual bool CanGrow() const noexcept=0
Whether this axis can grow (and thus has no overflow bins).
int AdjustOverflowBinNumber(double rawbin) const
Given rawbin (<0 for underflow, >=GetNBinsNoOver() for overflow), determine the bin number taking int...
int GetLastBin() const noexcept
Get the bin index for the last bin of the axis.
double GetBinTo(int bin) const
Get the high bin border ("right edge") for the given bin index.
virtual bool HasSameBinBordersAs(const RAxisBase &other) const
Check if two axis have the same bin borders.
RAxisBase(RAxisBase &&)=default
static constexpr const int kInvalidBin
Special bin index returned to signify that no bin matches a request.
bool HasSameBinningAs(const RAxisBase &other) const
Check if two axes use the same binning convention, i.e.
int GetNBins() const noexcept
Get the number of bins, including under- and overflow.
RAxisBase & operator=(const RAxisBase &)=default
Objects used to configure the different axis types.
const std::vector< std::string > & GetBinLabels() const noexcept
Get the bin labels; non-empty if the GetKind() == kLabels.
const std::vector< double > & GetBinBorders() const noexcept
Get the bin borders; non-empty if the GetKind() == kIrregular.
static constexpr const Grow_t Grow
Tag signalling that an axis should be able to grow; used for calling the appropriate constructor like...
const std::string & GetTitle() const
Get the axis's title.
Axis with equidistant bin borders.
RAxisEquidistant(std::string_view title, int nbinsNoOver, double low, double high) noexcept
Initialize a RAxisEquidistant.
RAxisEquidistant(int nbinsNoOver, double low, double high) noexcept
Initialize a RAxisEquidistant.
double GetBinWidth() const noexcept
Get the width of the bins.
double FindBinRaw(double x) const noexcept
Find the raw bin index (not adjusted) for the given coordinate.
double GetInverseBinWidth() const noexcept
Get the inverse of the width of the bins.
RAxisEquidistant()=default
int GetBinIndexForLowEdge(double x) const noexcept final
If the coordinate x is within 10 ULPs of a bin low edge coordinate, return the bin for which this is ...
bool HasSameBinBordersAs(const RAxisBase &other) const override
See RAxisBase::HasSameBinBordersAs.
double fInvBinWidth
The inverse of the bin width.
int GetNBinsNoOver() const noexcept final
Get the number of bins, excluding under- and overflow.
double GetBinCenter(int bin) const final
Get the bin center for the given bin index.
double GetBinFrom(int bin) const final
Get the low bin border for the given bin index.
static double GetInvBinWidth(int nbinsNoOver, double lowOrHigh, double highOrLow)
Determine the inverse bin width.
bool CanGrow() const noexcept override
This axis cannot grow.
unsigned int fNBinsNoOver
Number of bins excluding under- and overflow.
int FindBin(double x) const noexcept final
Find the adjusted bin index (returning kUnderflowBin for underflow and kOverflowBin for overflow) for...
double fLow
The lower limit of the axis.
An axis that can extend its range, keeping the number of its bins unchanged.
RAxisGrow(std::string_view title, int nbins, double low, double high) noexcept
Initialize a RAxisGrow.
int Grow(int toBin)
Grow this axis to make the "virtual bin" toBin in-range.
RAxisGrow(int nbins, double low, double high) noexcept
Initialize a RAxisGrow.
bool CanGrow() const noexcept final
This axis kind can increase its range.
An axis with non-equidistant bins (also known as "variable binning").
bool CanGrow() const noexcept final
This axis cannot be extended.
int FindBin(double x) const noexcept final
Find the bin index (adjusted with under- and overflow) for the given coordinate x.
const std::vector< double > & GetBinBorders() const noexcept
Access to the bin borders used by this axis.
bool HasSameBinBordersAs(const RAxisBase &other) const override
See RAxisBase::HasSameBinBordersAs.
RAxisIrregular(std::vector< double > &&binborders) noexcept
Construct a RAxisIrregular from a vector of bin borders.
RAxisIrregular(const std::vector< double > &binborders)
Construct a RAxisIrregular from a vector of bin borders.
double GetBinCenter(int bin) const final
Get the bin center of the bin with the given index.
std::vector< double > fBinBorders
Bin borders, one more than the number of regular bins.
int GetBinIndexForLowEdge(double x) const noexcept final
If the coordinate x is within 10 ULPs of a bin low edge coordinate, return the bin for which this is ...
RAxisIrregular(std::string_view title, std::vector< double > &&binborders) noexcept
Construct a RAxisIrregular from a vector of bin borders.
double GetBinFrom(int bin) const final
Get the lower bin border for a given bin index.
RAxisIrregular(std::string_view title, const std::vector< double > &binborders)
Construct a RAxisIrregular from a vector of bin borders.
double FindBinRaw(double x) const noexcept
Find the raw bin index (not adjusted) for the given coordinate x.
int GetNBinsNoOver() const noexcept final
Get the number of bins, excluding under- and overflow.
A RAxisGrow that has a label assigned to each bin and a bin width of 1.
LabelsCmpFlags
Result of an RAxisLabels label set comparison.
@ kLabelsCmpDisordered
The labels shared by both axes do not map into the same bins.
@ kLabelsCmpSubset
The other axis doesn't have some labels from this axis.
@ kLabelsCmpSame
Both axes have the same labels, mapping to the same bins.
@ kLabelsCmpSuperset
The other axis has some labels which this axis doesn't have.
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.
std::unordered_map< std::string, int > fLabelsIndex
Map of label (view on fLabels's elements) to bin index.
std::vector< std::string_view > GetBinLabels() const
Build a vector of labels. The position in the vector defines the label's bin.
double GetBinCenterByName(const std::string &label)
Get the center of the bin with label.
int FindBinByName(const std::string &label)
Get the bin index with label.
RAxisLabels(std::string_view title, const std::vector< std::string_view > &labels)
Construct a RAxisLables from a vector of string_views, with title.
RAxisLabels(std::string_view title, const std::vector< std::string > &labels)
Construct a RAxisLables from a vector of strings, with title.
LabelsCmpFlags CompareBinLabels(const RAxisLabels &other) const noexcept
Compare the labels of this axis with those of another axis.
EAxisCompatibility CanMap(const RAxisEquidistant &target, const RAxisEquidistant &source) noexcept
Whether (and how) the source axis can be merged into the target axis.
bool operator>=(RAxisBase::const_iterator lhs, RAxisBase::const_iterator rhs) noexcept
i >= j
ELogLevel operator+(ELogLevel severity, int offset)
bool operator>(RAxisBase::const_iterator lhs, RAxisBase::const_iterator rhs) noexcept
i > j
@ kContains
The source is a subset of bins of the target axis.
@ kIdentical
Source and target axes are identical.
@ kIncompatible
The source axis and target axis have different binning.
@ kSampling
The bins of the source axis have finer granularity, but the bin borders are compatible.
bool operator<(RAxisBase::const_iterator lhs, RAxisBase::const_iterator rhs) noexcept
i < j
bool operator<=(RAxisBase::const_iterator lhs, RAxisBase::const_iterator rhs) noexcept
i <= j
bool operator!=(RAxisBase::const_iterator lhs, RAxisBase::const_iterator rhs) noexcept
i != j
bool operator==(const RConcurrentHashColl::HashValue &lhs, const RConcurrentHashColl::HashValue &rhs)
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Axis_t operator()(const RAxisConfig &cfg) noexcept
Axis_t operator()(const RAxisConfig &cfg) noexcept
Axis_t operator()(const RAxisConfig &cfg)
Axis_t operator()(const RAxisConfig &cfg)
Converts a RAxisConfig of whatever kind to the corresponding RAxisBase-derived object.