File indexing completed on 2025-01-18 10:10:36
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef ROOT7_RAxisConfig
0017 #define ROOT7_RAxisConfig
0018
0019 #include <string>
0020 #include <utility>
0021 #include <vector>
0022
0023 #include <string_view>
0024
0025 namespace ROOT {
0026 namespace Experimental {
0027
0028
0029
0030
0031
0032
0033
0034
0035 class RAxisConfig {
0036 public:
0037 enum EKind {
0038 kEquidistant,
0039 kGrow,
0040 kIrregular,
0041 kLabels,
0042 kNumKinds
0043 };
0044
0045 private:
0046 std::string fTitle;
0047 int fNBinsNoOver;
0048 EKind fKind;
0049 std::vector<double> fBinBorders;
0050 std::vector<std::string> fLabels;
0051
0052
0053
0054 explicit RAxisConfig(std::string_view title, int nbins, double from, double to, EKind kind)
0055 : fTitle(title), fNBinsNoOver(nbins), fKind(kind), fBinBorders(2)
0056 {
0057 if (from > to)
0058 std::swap(to, from);
0059
0060 fBinBorders[0] = from;
0061 fBinBorders[1] = to;
0062 }
0063
0064 public:
0065
0066
0067 struct Grow_t {
0068 };
0069
0070
0071
0072 constexpr static const Grow_t Grow{};
0073
0074
0075
0076 RAxisConfig(std::string_view title, int nbins, double from, double to)
0077 : RAxisConfig(title, nbins, from, to, kEquidistant)
0078 {}
0079
0080
0081 RAxisConfig(int nbins, double from, double to): RAxisConfig("", nbins, from, to, kEquidistant) {}
0082
0083
0084 RAxisConfig(std::string_view title, Grow_t, int nbins, double from, double to)
0085 : RAxisConfig(title, nbins, from, to, kGrow)
0086 {}
0087
0088
0089 RAxisConfig(Grow_t, int nbins, double from, double to): RAxisConfig("", nbins, from, to, kGrow) {}
0090
0091
0092 RAxisConfig(std::string_view title, const std::vector<double> &binborders)
0093 : fTitle(title), fNBinsNoOver(binborders.size() - 1), fKind(kIrregular), fBinBorders(binborders)
0094 {}
0095
0096
0097 RAxisConfig(const std::vector<double> &binborders): RAxisConfig("", binborders) {}
0098
0099
0100 RAxisConfig(std::string_view title, std::vector<double> &&binborders) noexcept
0101 : fTitle(title), fNBinsNoOver(binborders.size() - 1), fKind(kIrregular),
0102 fBinBorders(std::move(binborders))
0103 {}
0104
0105
0106 RAxisConfig(std::vector<double> &&binborders) noexcept: RAxisConfig("", std::move(binborders)) {}
0107
0108
0109 RAxisConfig(std::string_view title, const std::vector<std::string_view> &labels)
0110 : fTitle(title), fNBinsNoOver(labels.size()), fKind(kLabels), fLabels(labels.begin(), labels.end())
0111 {}
0112
0113
0114 RAxisConfig(const std::vector<std::string_view> &labels): RAxisConfig("", labels) {}
0115
0116
0117 RAxisConfig(std::string_view title, std::vector<std::string> &&labels)
0118 : fTitle(title), fNBinsNoOver(labels.size()), fKind(kLabels), fLabels(std::move(labels))
0119 {}
0120
0121
0122 RAxisConfig(std::vector<std::string> &&labels): RAxisConfig("", std::move(labels)) {}
0123
0124
0125 const std::string &GetTitle() const { return fTitle; }
0126
0127
0128 EKind GetKind() const noexcept { return fKind; }
0129
0130
0131 int GetNBinsNoOver() const noexcept { return fNBinsNoOver; }
0132
0133
0134 const std::vector<double> &GetBinBorders() const noexcept { return fBinBorders; }
0135
0136
0137 const std::vector<std::string> &GetBinLabels() const noexcept { return fLabels; }
0138 };
0139
0140 namespace Internal {
0141
0142
0143
0144 template <RAxisConfig::EKind>
0145 struct AxisConfigToType;
0146
0147 }
0148 }
0149 }
0150
0151 #endif