File indexing completed on 2026-06-05 08:44:20
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
0018 template <class Derived, typename EdgeT = double>
0019 struct XAxisMixin {
0020
0021
0022
0023
0024
0025 size_t numBinsX(const bool includeOverflows=false) const {
0026 return static_cast<const Derived*>(this)->numBinsAt(0, includeOverflows);
0027 }
0028
0029
0030 template <class T = EdgeT>
0031 enable_if_CAxisT<T> xMin() const { return static_cast<const Derived*>(this)->template min<0>(); }
0032
0033
0034 template <class T = EdgeT>
0035 enable_if_CAxisT<T> xMax() const { return static_cast<const Derived*>(this)->template max<0>(); }
0036
0037
0038 std::vector<EdgeT> xEdges(const bool includeOverflows = false) const {
0039 return static_cast<const Derived*>(this)->template edges<0>(includeOverflows);
0040 }
0041
0042
0043
0044
0045 template <class T = EdgeT>
0046 std::enable_if_t<std::is_floating_point<T>::value, std::vector<T>>
0047 xWidths(const bool includeOverflows = false) const {
0048 return static_cast<const Derived*>(this)->template widths<0>(includeOverflows);
0049 }
0050
0051
0052
0053
0054 template <class T = EdgeT>
0055 std::enable_if_t<std::is_floating_point<T>::value, std::vector<T>>
0056 xMins(const bool includeOverflows = false) const {
0057 return static_cast<const Derived*>(this)->template mins<0>(includeOverflows);
0058 }
0059
0060
0061
0062
0063 template <class T = EdgeT>
0064 std::enable_if_t<std::is_floating_point<T>::value, std::vector<T>>
0065 xMaxs(const bool includeOverflows = false) const {
0066 return static_cast<const Derived*>(this)->template maxs<0>(includeOverflows);
0067 }
0068
0069
0070
0071
0072 template <class T = EdgeT>
0073 std::enable_if_t<std::is_floating_point<T>::value, std::vector<T>>
0074 xMids(const bool includeOverflows = false) const {
0075 return static_cast<const Derived*>(this)->template mids<0>(includeOverflows);
0076 }
0077
0078
0079
0080
0081 template <class T = EdgeT, typename = std::enable_if_t<std::is_floating_point<T>::value>>
0082 void rebinXBy(unsigned int n, size_t begin=1, size_t end=UINT_MAX) {
0083 static_cast<Derived*>(this)->template rebinBy<0>(n, begin, end);
0084 }
0085
0086
0087
0088
0089 template <class T = EdgeT, typename = std::enable_if_t<std::is_floating_point<T>::value>>
0090 void rebinXTo(const std::vector<double>& newedges) {
0091 static_cast<Derived*>(this)->template rebinTo<0>(newedges);
0092 }
0093
0094
0095
0096
0097 template <class T = EdgeT, typename = std::enable_if_t<std::is_floating_point<T>::value>>
0098 void rebinX(unsigned int n, size_t begin=1, size_t end=UINT_MAX) {
0099 static_cast<Derived*>(this)->template rebinBy<0>(n, begin, end);
0100 }
0101
0102
0103
0104
0105 template <class T = EdgeT, typename = std::enable_if_t<std::is_floating_point<T>::value>>
0106 void rebinX(const std::vector<double>& newedges) {
0107 static_cast<Derived*>(this)->template rebinTo<0>(newedges);
0108 }
0109
0110
0111
0112 };
0113
0114
0115
0116 template <class Derived>
0117 struct XStatsMixin {
0118
0119
0120
0121
0122
0123 std::vector<double> xMeans(const bool includeOverflows=true) const noexcept {
0124 return static_cast<const Derived*>(this)->means(0, includeOverflows);
0125 }
0126
0127
0128 double xMean(const bool includeOverflows=true) const noexcept {
0129 return static_cast<const Derived*>(this)->mean(0, includeOverflows);
0130 }
0131
0132
0133 double xVariance(const bool includeOverflows=true) const noexcept {
0134 return static_cast<const Derived*>(this)->variance(0, includeOverflows);
0135 }
0136
0137
0138 double xStdDev(const bool includeOverflows=true) const noexcept {
0139 return static_cast<const Derived*>(this)->stdDev(0, includeOverflows);
0140 }
0141
0142
0143 double xStdErr(const bool includeOverflows=true) const noexcept {
0144 return static_cast<const Derived*>(this)->stdErr(0, includeOverflows);
0145 }
0146
0147
0148 double xRMS(const bool includeOverflows=true) const noexcept {
0149 return static_cast<const Derived*>(this)->rms(0, includeOverflows);
0150 }
0151
0152
0153 };
0154
0155
0156
0157 template <class Derived, typename EdgeT = double>
0158 struct YAxisMixin {
0159
0160
0161
0162
0163
0164 size_t numBinsY(const bool includeOverflows=false) const {
0165 return static_cast<const Derived*>(this)->numBinsAt(1, includeOverflows);
0166 }
0167
0168
0169 template <class T = EdgeT>
0170 enable_if_CAxisT<T> yMin() const { return static_cast<const Derived*>(this)->template min<1>(); }
0171
0172
0173 template <class T = EdgeT>
0174 enable_if_CAxisT<T> yMax() const { return static_cast<const Derived*>(this)->template max<1>(); }
0175
0176
0177 std::vector<EdgeT> yEdges(const bool includeOverflows = false) const {
0178 return static_cast<const Derived*>(this)->template edges<1>(includeOverflows);
0179 }
0180
0181
0182
0183
0184 template <class T = EdgeT>
0185 std::enable_if_t<std::is_floating_point<T>::value, std::vector<T>>
0186 yWidths(const bool includeOverflows = false) const {
0187 return static_cast<const Derived*>(this)->template widths<1>(includeOverflows);
0188 }
0189
0190
0191
0192
0193 template <class T = EdgeT>
0194 std::enable_if_t<std::is_floating_point<T>::value, std::vector<T>>
0195 yMins(const bool includeOverflows = false) const {
0196 return static_cast<const Derived*>(this)->template mins<1>(includeOverflows);
0197 }
0198
0199
0200
0201
0202 template <class T = EdgeT>
0203 std::enable_if_t<std::is_floating_point<T>::value, std::vector<T>>
0204 yMaxs(const bool includeOverflows = false) const {
0205 return static_cast<const Derived*>(this)->template maxs<1>(includeOverflows);
0206 }
0207
0208
0209
0210
0211 template <class T = EdgeT>
0212 std::enable_if_t<std::is_floating_point<T>::value, std::vector<T>>
0213 yMids(const bool includeOverflows = false) const {
0214 return static_cast<const Derived*>(this)->template mids<1>(includeOverflows);
0215 }
0216
0217
0218
0219
0220 template <class T = EdgeT, typename = std::enable_if_t<std::is_floating_point<T>::value>>
0221 void rebinYBy(unsigned int n, size_t begin=1, size_t end=UINT_MAX) {
0222 static_cast<Derived*>(this)->template rebinBy<1>(n, begin, end);
0223 }
0224
0225
0226
0227
0228 template <class T = EdgeT, typename = std::enable_if_t<std::is_floating_point<T>::value>>
0229 void rebinYTo(const std::vector<double>& newedges) {
0230 static_cast<Derived*>(this)->template rebinTo<1>(newedges);
0231 }
0232
0233
0234
0235
0236 template <class T = EdgeT, typename = std::enable_if_t<std::is_floating_point<T>::value>>
0237 void rebinY(unsigned int n, size_t begin=1, size_t end=UINT_MAX) {
0238 static_cast<Derived*>(this)->template rebinBy<1>(n, begin, end);
0239 }
0240
0241
0242
0243
0244 template <class T = EdgeT, typename = std::enable_if_t<std::is_floating_point<T>::value>>
0245 void rebinY(const std::vector<double>& newedges) {
0246 static_cast<Derived*>(this)->template rebinTo<1>(newedges);
0247 }
0248
0249
0250
0251 };
0252
0253
0254 template <class Derived>
0255 struct YStatsMixin {
0256
0257
0258
0259
0260
0261 std::vector<double> yMeans(const bool includeOverflows=true) const noexcept {
0262 return static_cast<const Derived*>(this)->means(1, includeOverflows);
0263 }
0264
0265
0266 double yMean(const bool includeOverflows=true) const noexcept {
0267 return static_cast<const Derived*>(this)->mean(1, includeOverflows);
0268 }
0269
0270
0271 double yVariance(const bool includeOverflows=true) const noexcept {
0272 return static_cast<const Derived*>(this)->variance(1, includeOverflows);
0273 }
0274
0275
0276 double yStdDev(const bool includeOverflows=true) const noexcept {
0277 return static_cast<const Derived*>(this)->stdDev(1, includeOverflows);
0278 }
0279
0280
0281 double yStdErr(const bool includeOverflows=true) const noexcept {
0282 return static_cast<const Derived*>(this)->stdErr(1, includeOverflows);
0283 }
0284
0285
0286 double yRMS(const bool includeOverflows=true) const noexcept {
0287 return static_cast<const Derived*>(this)->rms(1, includeOverflows);
0288 }
0289
0290
0291
0292 };
0293
0294
0295
0296 template <class Derived, typename EdgeT = double>
0297 struct ZAxisMixin {
0298
0299
0300
0301
0302
0303 size_t numBinsZ(const bool includeOverflows=false) const {
0304 return static_cast<const Derived*>(this)->numBinsAt(2, includeOverflows);
0305 }
0306
0307
0308 template <class T = EdgeT>
0309 enable_if_CAxisT<T> zMin() const { return static_cast<const Derived*>(this)->template min<2>(); }
0310
0311
0312 template <class T = EdgeT>
0313 enable_if_CAxisT<T> zMax() const { return static_cast<const Derived*>(this)->template max<2>(); }
0314
0315
0316 std::vector<EdgeT> zEdges(const bool includeOverflows = false) const {
0317 return static_cast<const Derived*>(this)->template edges<2>(includeOverflows);
0318 }
0319
0320
0321
0322
0323 template <class T = EdgeT>
0324 std::enable_if_t<std::is_floating_point<T>::value, std::vector<T>>
0325 zWidths(const bool includeOverflows = false) const {
0326 return static_cast<const Derived*>(this)->template widths<2>(includeOverflows);
0327 }
0328
0329
0330
0331
0332 template <class T = EdgeT>
0333 std::enable_if_t<std::is_floating_point<T>::value, std::vector<T>>
0334 zMins(const bool includeOverflows = false) const {
0335 return static_cast<const Derived*>(this)->template mins<2>(includeOverflows);
0336 }
0337
0338
0339
0340
0341 template <class T = EdgeT>
0342 std::enable_if_t<std::is_floating_point<T>::value, std::vector<T>>
0343 zMaxs(const bool includeOverflows = false) const {
0344 return static_cast<const Derived*>(this)->template maxs<2>(includeOverflows);
0345 }
0346
0347
0348
0349
0350 template <class T = EdgeT>
0351 std::enable_if_t<std::is_floating_point<T>::value, std::vector<T>>
0352 zMids(const bool includeOverflows = false) const {
0353 return static_cast<const Derived*>(this)->template mids<2>(includeOverflows);
0354 }
0355
0356
0357
0358
0359 template <class T = EdgeT, typename = std::enable_if_t<std::is_floating_point<T>::value>>
0360 void rebinZBy(unsigned int n, size_t begin=1, size_t end=UINT_MAX) {
0361 static_cast<Derived*>(this)->template rebinBy<2>(n, begin, end);
0362 }
0363
0364
0365
0366
0367 template <class T = EdgeT, typename = std::enable_if_t<std::is_floating_point<T>::value>>
0368 void rebinZTo(const std::vector<double>& newedges) {
0369 static_cast<Derived*>(this)->template rebinTo<2>(newedges);
0370 }
0371
0372
0373
0374
0375 template <class T = EdgeT, typename = std::enable_if_t<std::is_floating_point<T>::value>>
0376 void rebinZ(unsigned int n, size_t begin=1, size_t end=UINT_MAX) {
0377 static_cast<Derived*>(this)->template rebinBy<2>(n, begin, end);
0378 }
0379
0380
0381
0382
0383 template <class T = EdgeT, typename = std::enable_if_t<std::is_floating_point<T>::value>>
0384 void rebinZ(const std::vector<double>& newedges) {
0385 static_cast<Derived*>(this)->template rebinTo<2>(newedges);
0386 }
0387
0388
0389
0390 };
0391
0392
0393 template <class Derived>
0394 struct ZStatsMixin {
0395
0396
0397
0398
0399
0400 std::vector<double> zMeans(const bool includeOverflows=true) const noexcept {
0401 return static_cast<const Derived*>(this)->means(2, includeOverflows);
0402 }
0403
0404
0405 double zMean(const bool includeOverflows=true) const noexcept {
0406 return static_cast<const Derived*>(this)->mean(2, includeOverflows);
0407 }
0408
0409
0410 double zVariance(const bool includeOverflows=true) const noexcept {
0411 return static_cast<const Derived*>(this)->variance(2, includeOverflows);
0412 }
0413
0414
0415 double zStdDev(const bool includeOverflows=true) const noexcept {
0416 return static_cast<const Derived*>(this)->stdDev(2, includeOverflows);
0417 }
0418
0419
0420 double zStdErr(const bool includeOverflows=true) const noexcept {
0421 return static_cast<const Derived*>(this)->stdErr(2, includeOverflows);
0422 }
0423
0424
0425 double zRMS(const bool includeOverflows=true) const noexcept {
0426 return static_cast<const Derived*>(this)->rms(2, includeOverflows);
0427 }
0428
0429 };
0430
0431
0432
0433 }
0434
0435 #endif