File indexing completed on 2025-04-19 09:13:36
0001
0002
0003
0004
0005
0006 #ifndef YODA_BinnedUtils_h
0007 #define YODA_BinnedUtils_h
0008
0009 #include "YODA/Utils/BinningUtils.h"
0010
0011 namespace YODA {
0012
0013
0014
0015
0016
0017 template <class Derived, typename EdgeT = double>
0018 struct XAxisMixin {
0019
0020
0021
0022
0023
0024 size_t numBinsX(const bool includeOverflows=false) const {
0025 return static_cast<const Derived*>(this)->numBinsAt(0, includeOverflows);
0026 }
0027
0028
0029 template <class T = EdgeT>
0030 enable_if_CAxisT<T> xMin() const { return static_cast<const Derived*>(this)->template min<0>(); }
0031
0032
0033 template <class T = EdgeT>
0034 enable_if_CAxisT<T> xMax() const { return static_cast<const Derived*>(this)->template max<0>(); }
0035
0036
0037 std::vector<EdgeT> xEdges(const bool includeOverflows = false) const {
0038 return static_cast<const Derived*>(this)->template edges<0>(includeOverflows);
0039 }
0040
0041
0042
0043
0044 template <class T = EdgeT>
0045 std::enable_if_t<std::is_floating_point<T>::value, std::vector<T>>
0046 xWidths(const bool includeOverflows = false) const {
0047 return static_cast<const Derived*>(this)->template widths<0>(includeOverflows);
0048 }
0049
0050 void rebinXBy(unsigned int n, size_t begin=1, size_t end=UINT_MAX) {
0051 static_cast<Derived*>(this)->template rebinBy<0>(n, begin, end);
0052 }
0053
0054 void rebinXTo(const std::vector<double>& newedges) {
0055 static_cast<Derived*>(this)->template rebinTo<0>(newedges);
0056 }
0057
0058 void rebinX(unsigned int n, size_t begin=1, size_t end=UINT_MAX) {
0059 static_cast<Derived*>(this)->template rebinBy<0>(n, begin, end);
0060 }
0061
0062 void rebinX(const std::vector<double>& newedges) {
0063 static_cast<Derived*>(this)->template rebinTo<0>(newedges);
0064 }
0065
0066
0067
0068 };
0069
0070
0071
0072 template <class Derived>
0073 struct XStatsMixin {
0074
0075
0076
0077
0078
0079 double xMean(const bool includeOverflows=true) const noexcept {
0080 return static_cast<const Derived*>(this)->mean(0, includeOverflows);
0081 }
0082
0083
0084 double xVariance(const bool includeOverflows=true) const noexcept {
0085 return static_cast<const Derived*>(this)->variance(0, includeOverflows);
0086 }
0087
0088
0089 double xStdDev(const bool includeOverflows=true) const noexcept {
0090 return static_cast<const Derived*>(this)->stdDev(0, includeOverflows);
0091 }
0092
0093
0094 double xStdErr(const bool includeOverflows=true) const noexcept {
0095 return static_cast<const Derived*>(this)->stdErr(0, includeOverflows);
0096 }
0097
0098
0099 double xRMS(const bool includeOverflows=true) const noexcept {
0100 return static_cast<const Derived*>(this)->rms(0, includeOverflows);
0101 }
0102
0103
0104 };
0105
0106
0107
0108 template <class Derived, typename EdgeT = double>
0109 struct YAxisMixin {
0110
0111
0112
0113
0114
0115 size_t numBinsY(const bool includeOverflows=false) const {
0116 return static_cast<const Derived*>(this)->numBinsAt(1, includeOverflows);
0117 }
0118
0119
0120 template <class T = EdgeT>
0121 enable_if_CAxisT<T> yMin() const { return static_cast<const Derived*>(this)->template min<1>(); }
0122
0123
0124 template <class T = EdgeT>
0125 enable_if_CAxisT<T> yMax() const { return static_cast<const Derived*>(this)->template max<1>(); }
0126
0127
0128 std::vector<EdgeT> yEdges(const bool includeOverflows = false) const {
0129 return static_cast<const Derived*>(this)->template edges<1>(includeOverflows);
0130 }
0131
0132
0133
0134
0135 template <class T = EdgeT>
0136 std::enable_if_t<std::is_floating_point<T>::value, std::vector<T>>
0137 yWidths(const bool includeOverflows = false) const {
0138 return static_cast<const Derived*>(this)->template widths<1>(includeOverflows);
0139 }
0140
0141 void rebinYBy(unsigned int n, size_t begin=1, size_t end=UINT_MAX) {
0142 static_cast<Derived*>(this)->template rebinBy<1>(n, begin, end);
0143 }
0144
0145 void rebinYTo(const std::vector<double>& newedges) {
0146 static_cast<Derived*>(this)->template rebinTo<1>(newedges);
0147 }
0148
0149 void rebinY(unsigned int n, size_t begin=1, size_t end=UINT_MAX) {
0150 static_cast<Derived*>(this)->template rebinBy<1>(n, begin, end);
0151 }
0152
0153 void rebinY(const std::vector<double>& newedges) {
0154 static_cast<Derived*>(this)->template rebinTo<1>(newedges);
0155 }
0156
0157
0158
0159 };
0160
0161
0162 template <class Derived>
0163 struct YStatsMixin {
0164
0165
0166
0167
0168
0169 double yMean(const bool includeOverflows=true) const noexcept {
0170 return static_cast<const Derived*>(this)->mean(1, includeOverflows);
0171 }
0172
0173
0174 double yVariance(const bool includeOverflows=true) const noexcept {
0175 return static_cast<const Derived*>(this)->variance(1, includeOverflows);
0176 }
0177
0178
0179 double yStdDev(const bool includeOverflows=true) const noexcept {
0180 return static_cast<const Derived*>(this)->stdDev(1, includeOverflows);
0181 }
0182
0183
0184 double yStdErr(const bool includeOverflows=true) const noexcept {
0185 return static_cast<const Derived*>(this)->stdErr(1, includeOverflows);
0186 }
0187
0188
0189 double yRMS(const bool includeOverflows=true) const noexcept {
0190 return static_cast<const Derived*>(this)->rms(1, includeOverflows);
0191 }
0192
0193 };
0194
0195
0196
0197 template <class Derived, typename EdgeT = double>
0198 struct ZAxisMixin {
0199
0200
0201
0202
0203
0204 size_t numBinsZ(const bool includeOverflows=false) const {
0205 return static_cast<const Derived*>(this)->numBinsAt(2, includeOverflows);
0206 }
0207
0208
0209 template <class T = EdgeT>
0210 enable_if_CAxisT<T> zMin() const { return static_cast<const Derived*>(this)->template min<2>(); }
0211
0212
0213 template <class T = EdgeT>
0214 enable_if_CAxisT<T> zMax() const { return static_cast<const Derived*>(this)->template max<2>(); }
0215
0216
0217 std::vector<EdgeT> zEdges(const bool includeOverflows = false) const {
0218 return static_cast<const Derived*>(this)->template edges<2>(includeOverflows);
0219 }
0220
0221
0222
0223
0224 template <class T = EdgeT>
0225 std::enable_if_t<std::is_floating_point<T>::value, std::vector<T>>
0226 zWidths(const bool includeOverflows = false) const {
0227 return static_cast<const Derived*>(this)->template widths<2>(includeOverflows);
0228 }
0229
0230 void rebinZBy(unsigned int n, size_t begin=1, size_t end=UINT_MAX) {
0231 static_cast<Derived*>(this)->template rebinBy<2>(n, begin, end);
0232 }
0233
0234 void rebinZTo(const std::vector<double>& newedges) {
0235 static_cast<Derived*>(this)->template rebinTo<2>(newedges);
0236 }
0237
0238 void rebinZ(unsigned int n, size_t begin=1, size_t end=UINT_MAX) {
0239 static_cast<Derived*>(this)->template rebinBy<2>(n, begin, end);
0240 }
0241
0242 void rebinZ(const std::vector<double>& newedges) {
0243 static_cast<Derived*>(this)->template rebinTo<2>(newedges);
0244 }
0245
0246
0247
0248 };
0249
0250
0251 template <class Derived>
0252 struct ZStatsMixin {
0253
0254
0255
0256
0257
0258 double zMean(const bool includeOverflows=true) const noexcept {
0259 return static_cast<const Derived*>(this)->mean(2, includeOverflows);
0260 }
0261
0262
0263 double zVariance(const bool includeOverflows=true) const noexcept {
0264 return static_cast<const Derived*>(this)->variance(2, includeOverflows);
0265 }
0266
0267
0268 double zStdDev(const bool includeOverflows=true) const noexcept {
0269 return static_cast<const Derived*>(this)->stdDev(2, includeOverflows);
0270 }
0271
0272
0273 double zStdErr(const bool includeOverflows=true) const noexcept {
0274 return static_cast<const Derived*>(this)->stdErr(2, includeOverflows);
0275 }
0276
0277
0278 double zRMS(const bool includeOverflows=true) const noexcept {
0279 return static_cast<const Derived*>(this)->rms(2, includeOverflows);
0280 }
0281
0282 };
0283
0284
0285
0286 }
0287
0288 #endif