Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-19 09:13:36

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