yoda is hosted by Hepforge, IPPP Durham
YODA - Yet more Objects for Data Analysis 2.0.2
DbnUtils.h
Go to the documentation of this file.
1// -*- C++ -*-
2//
3// This file is part of YODA -- Yet more Objects for Data Analysis
4// Copyright (C) 2008-2024 The YODA collaboration (see AUTHORS for details)
5//
6#ifndef YODA_DbnUtils_h
7#define YODA_DbnUtils_h
8
9#include "YODA/Exceptions.h"
12#include <cmath>
13#include <string>
14#include <array>
15
16namespace YODA {
17
20
22 template <class Derived>
23 struct XDbnMixin {
24
27
28 void scaleX(double factor) { static_cast<Derived*>(this)->scale(1,factor); }
29
31
34
35 double xMean() const { return static_cast<const Derived*>(this)->mean(1); }
36 double xVariance() const { return static_cast<const Derived*>(this)->variance(1); }
37 double xStdDev() const { return static_cast<const Derived*>(this)->stdDev(1); }
38 double xStdErr() const { return static_cast<const Derived*>(this)->stdErr(1); }
39 double xRMS() const { return static_cast<const Derived*>(this)->RMS(1); }
40 double sumWX() const { return static_cast<const Derived*>(this)->sumW(1); }
41 double sumWX2() const { return static_cast<const Derived*>(this)->sumW2(1); }
42
44
45 };
46
48 template <class Derived>
49 struct YDbnMixin {
50
53
54 void scaleY(double factor) { static_cast<Derived*>(this)->scale(2,factor); }
55
56 void scaleXY(double fx, double fy) {
57 static_cast<Derived*>(this)->scale(1,fx);
58 static_cast<Derived*>(this)->scale(2,fy);
59 }
60
62
65
66 double yMean() const { return static_cast<const Derived*>(this)->mean(2); }
67 double yVariance() const { return static_cast<const Derived*>(this)->variance(2); }
68 double yStdDev() const { return static_cast<const Derived*>(this)->stdDev(2); }
69 double yStdErr() const { return static_cast<const Derived*>(this)->stdErr(2); }
70 double yRMS() const { return static_cast<const Derived*>(this)->RMS(2); }
71 double sumWY() const { return static_cast<const Derived*>(this)->sumW(2); }
72 double sumWY2() const { return static_cast<const Derived*>(this)->sumW2(2); }
73 double sumWXY() const { return static_cast<const Derived*>(this)->crossTerm(0,1); }
74
76
77 };
78
80 template <class Derived>
81 struct ZDbnMixin {
82
85
86 void scaleZ(double factor) {
87 static_cast<Derived*>(this)->scale(3,factor);
88 }
89
90 void scaleXZ(double fx, double fz) {
91 static_cast<Derived*>(this)->scale(1,fx);
92 static_cast<Derived*>(this)->scale(3,fz);
93 }
94
95 void scaleYZ(double fy, double fz) {
96 static_cast<Derived*>(this)->scale(2,fy);
97 static_cast<Derived*>(this)->scale(3,fz);
98 }
99
100 void scaleXYZ(double fx, double fy, double fz) {
101 static_cast<Derived*>(this)->scale(1,fx);
102 static_cast<Derived*>(this)->scale(2,fy);
103 static_cast<Derived*>(this)->scale(3,fz);
104 }
105
107
110
111 double zMean() const { return static_cast<const Derived*>(this)->mean(3); }
112 double zVariance() const { return static_cast<const Derived*>(this)->variance(3); }
113 double zStdDev() const { return static_cast<const Derived*>(this)->stdDev(3); }
114 double zStdErr() const { return static_cast<const Derived*>(this)->stdErr(3); }
115 double zRMS() const { return static_cast<const Derived*>(this)->RMS(3); }
116 double sumWZ() const { return static_cast<const Derived*>(this)->sumW(3); }
117 double sumWZ2() const { return static_cast<const Derived*>(this)->sumW2(3); }
118 double sumWXZ() const { return static_cast<const Derived*>(this)->crossTerm(0,2); }
119 double sumWYZ() const { return static_cast<const Derived*>(this)->crossTerm(1,2); }
120
122
123 };
124
126
127}
128
129#endif
Anonymous namespace to limit visibility.
double stdErr(const double sumWX, const double sumW, const double sumWX2, const double sumW2)
Calculate the weighted standard error of a sample.
Definition MathUtils.h:470
double RMS(const double sumWX2, const double sumW, const double sumW2)
Calculate the weighted RMS of a sample.
Definition MathUtils.h:489
double stdDev(const double sumWX, const double sumW, const double sumWX2, const double sumW2)
Calculate the weighted standard deviation of a sample.
Definition MathUtils.h:458
double variance(const double sumWX, const double sumW, const double sumWX2, const double sumW2)
Calculate the weighted variance of a sample.
Definition MathUtils.h:421
double mean(const std::vector< int > &sample)
Calculate the mean of a sample.
Definition MathUtils.h:391
CRTP mixin introducing convenience aliases along X axis.
Definition DbnUtils.h:23
double sumWX() const
Definition DbnUtils.h:40
double xRMS() const
Definition DbnUtils.h:39
double sumWX2() const
Definition DbnUtils.h:41
double xVariance() const
Definition DbnUtils.h:36
double xMean() const
Definition DbnUtils.h:35
double xStdDev() const
Definition DbnUtils.h:37
void scaleX(double factor)
Definition DbnUtils.h:28
double xStdErr() const
Definition DbnUtils.h:38
CRTP mixin introducing convenience aliases along Y axis.
Definition DbnUtils.h:49
void scaleY(double factor)
Definition DbnUtils.h:54
double yVariance() const
Definition DbnUtils.h:67
void scaleXY(double fx, double fy)
Definition DbnUtils.h:56
double yStdErr() const
Definition DbnUtils.h:69
double yRMS() const
Definition DbnUtils.h:70
double sumWY() const
Definition DbnUtils.h:71
double sumWXY() const
Definition DbnUtils.h:73
double yMean() const
Definition DbnUtils.h:66
double yStdDev() const
Definition DbnUtils.h:68
double sumWY2() const
Definition DbnUtils.h:72
CRTP mixin introducing convenience aliases along Z axis.
Definition DbnUtils.h:81
void scaleZ(double factor)
Definition DbnUtils.h:86
void scaleYZ(double fy, double fz)
Definition DbnUtils.h:95
double zRMS() const
Definition DbnUtils.h:115
double sumWYZ() const
Definition DbnUtils.h:119
void scaleXZ(double fx, double fz)
Definition DbnUtils.h:90
void scaleXYZ(double fx, double fy, double fz)
Definition DbnUtils.h:100
double sumWZ() const
Definition DbnUtils.h:116
double zMean() const
Definition DbnUtils.h:111
double zVariance() const
Definition DbnUtils.h:112
double sumWXZ() const
Definition DbnUtils.h:118
double sumWZ2() const
Definition DbnUtils.h:117
double zStdErr() const
Definition DbnUtils.h:114
double zStdDev() const
Definition DbnUtils.h:113