Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-04 09:29:56

0001 // -*- C++ -*-
0002 //
0003 // This file is part of YODA -- Yet more Objects for Data Analysis
0004 // Copyright (C) 2008-2025 The YODA collaboration (see AUTHORS for details)
0005 //
0006 #ifndef YODA_DbnUtils_h
0007 #define YODA_DbnUtils_h
0008 
0009 #include "YODA/Exceptions.h"
0010 #include "YODA/Utils/MathUtils.h"
0011 #include "YODA/Utils/MetaUtils.h"
0012 #include <cmath>
0013 #include <string>
0014 #include <array>
0015 
0016 namespace YODA {
0017 
0018 
0019   /// @name Mixin of convenience methods using CRTP
0020   /// @{
0021 
0022   /// @brief CRTP mixin introducing convenience aliases along X axis.
0023   template <class Derived>
0024   struct XDbnMixin {
0025 
0026     /// @name Dbn axis scalings
0027     /// @{
0028 
0029     void scaleX(double factor) { static_cast<Derived*>(this)->scale(1,factor); }
0030 
0031     /// @}
0032 
0033     /// @name Dbn statistics
0034     /// @{
0035 
0036     double xMean() const { return static_cast<const Derived*>(this)->mean(1); }
0037     double xVariance() const { return static_cast<const Derived*>(this)->variance(1); }
0038     double xStdDev() const { return static_cast<const Derived*>(this)->stdDev(1); }
0039     double xStdErr() const { return static_cast<const Derived*>(this)->stdErr(1); }
0040     double xRMS() const { return static_cast<const Derived*>(this)->RMS(1); }
0041     double sumWX() const { return static_cast<const Derived*>(this)->sumW(1); }
0042     double sumWX2() const { return static_cast<const Derived*>(this)->sumW2(1); }
0043 
0044     /// @}
0045 
0046   };
0047 
0048   /// @brief CRTP mixin introducing convenience aliases along Y axis.
0049   template <class Derived>
0050   struct YDbnMixin {
0051 
0052     /// @name Dbn axis scalings
0053     /// @{
0054 
0055     void scaleY(double factor) { static_cast<Derived*>(this)->scale(2,factor); }
0056 
0057     void scaleXY(double fx, double fy) {
0058       static_cast<Derived*>(this)->scale(1,fx);
0059       static_cast<Derived*>(this)->scale(2,fy);
0060     }
0061 
0062     /// @}
0063 
0064     /// @name Dbn statistics
0065     /// @{
0066 
0067     double yMean() const { return static_cast<const Derived*>(this)->mean(2); }
0068     double yVariance() const { return static_cast<const Derived*>(this)->variance(2); }
0069     double yStdDev() const { return static_cast<const Derived*>(this)->stdDev(2); }
0070     double yStdErr() const { return static_cast<const Derived*>(this)->stdErr(2); }
0071     double yRMS() const { return static_cast<const Derived*>(this)->RMS(2); }
0072     double sumWY() const { return static_cast<const Derived*>(this)->sumW(2); }
0073     double sumWY2() const { return static_cast<const Derived*>(this)->sumW2(2); }
0074     double sumWXY() const { return static_cast<const Derived*>(this)->crossTerm(0,1); }
0075 
0076     /// @}
0077 
0078   };
0079 
0080   /// @brief CRTP mixin introducing convenience aliases along Z axis.
0081   template <class Derived>
0082   struct ZDbnMixin {
0083 
0084     /// @name Dbn axis scalings
0085     /// @{
0086 
0087     void scaleZ(double factor) {
0088       static_cast<Derived*>(this)->scale(3,factor);
0089     }
0090 
0091     void scaleXZ(double fx, double fz) {
0092       static_cast<Derived*>(this)->scale(1,fx);
0093       static_cast<Derived*>(this)->scale(3,fz);
0094     }
0095 
0096     void scaleYZ(double fy, double fz) {
0097       static_cast<Derived*>(this)->scale(2,fy);
0098       static_cast<Derived*>(this)->scale(3,fz);
0099     }
0100 
0101     void scaleXYZ(double fx, double fy, double fz) {
0102       static_cast<Derived*>(this)->scale(1,fx);
0103       static_cast<Derived*>(this)->scale(2,fy);
0104       static_cast<Derived*>(this)->scale(3,fz);
0105     }
0106 
0107     /// @}
0108 
0109     /// @name Dbn statistics
0110     /// @{
0111 
0112     double zMean() const { return static_cast<const Derived*>(this)->mean(3); }
0113     double zVariance() const { return static_cast<const Derived*>(this)->variance(3); }
0114     double zStdDev() const { return static_cast<const Derived*>(this)->stdDev(3); }
0115     double zStdErr() const { return static_cast<const Derived*>(this)->stdErr(3); }
0116     double zRMS() const { return static_cast<const Derived*>(this)->RMS(3); }
0117     double sumWZ() const { return static_cast<const Derived*>(this)->sumW(3); }
0118     double sumWZ2() const { return static_cast<const Derived*>(this)->sumW2(3); }
0119     double sumWXZ() const { return static_cast<const Derived*>(this)->crossTerm(0,2); }
0120     double sumWYZ() const { return static_cast<const Derived*>(this)->crossTerm(1,2); }
0121 
0122     /// @}
0123 
0124   };
0125 
0126   /// @}
0127 
0128 }
0129 
0130 #endif