CLHEP 2.4.6.4
C++ Class Library for High Energy Physics
Loading...
Searching...
No Matches
TrivariateGaussian.cc
Go to the documentation of this file.
1// -*- C++ -*-
2// $Id: TrivariateGaussian.cc,v 1.8 2010/06/16 18:22:01 garren Exp $
3// ---------------------------------------------------------------------------
4
5#include "CLHEP/GenericFunctions/defs.h"
6#include "CLHEP/GenericFunctions/TrivariateGaussian.hh"
7#include <assert.h>
8#include <cmath> // for exp()
9#include <iostream>
10
11#if (defined __STRICT_ANSI__) || (defined _WIN32)
12#ifndef M_PI
13#define M_PI 3.14159265358979323846
14#endif // M_PI
15#endif // __STRICT_ANSI__
16
17namespace Genfun {
18FUNCTION_OBJECT_IMP(TrivariateGaussian)
19
21 _mean0("Mean0", 0.0,-10,10),
22 _mean1("Mean1", 0.0,-10,10),
23 _mean2("Mean2", 0.0,-10,10),
24 _sigma0("Sigma0",1.0,0, 10),
25 _sigma1("Sigma1",1.0,0, 10),
26 _sigma2("Sigma2",1.0,0, 10),
27 _corr01("Corr01", 0.0, -1.0, 1.0),
28 _corr02("Corr02", 0.0, -1.0, 1.0),
29 _corr12("Corr12", 0.0, -1.0, 1.0)
30{}
31
33}
34
36 AbsFunction(right),
37 _mean0(right._mean0),
38 _mean1(right._mean1),
39 _mean2(right._mean2),
40 _sigma0(right._sigma0),
41 _sigma1(right._sigma1),
42 _sigma2(right._sigma2),
43 _corr01(right._corr01),
44 _corr02(right._corr02),
45 _corr12(right._corr12)
46{
47}
48
49
51 assert (a.dimension()==3);
52 double x = a[0];
53 double y = a[1];
54 double z = a[2];
55
56
57 double x0 = _mean0.getValue();
58 double y0 = _mean1.getValue();
59 double z0 = _mean2.getValue();
60
61 double dx = x-x0;
62 double dy = y-y0;
63 double dz = z-z0;
64
65 double sx = _sigma0.getValue();
66 double sy = _sigma1.getValue();
67 double sz = _sigma2.getValue();
68
69
70 double sxs = sx*sx;
71 double sys = sy*sy;
72 double szs = sz*sz;
73
74
75 double rho1 = _corr01.getValue();
76 double rho2 = _corr12.getValue();
77 double rho3 = _corr02.getValue();
78
79 double dt = (1.0+rho1*rho2*rho3-rho1*rho1-rho2*rho2-rho3*rho3);
80 double tmp1 ,tmp2;
81
82 tmp1= 1.0/((2*M_PI)*sqrt(2*M_PI)*sx*sy*sz*sqrt(dt));
83 tmp2= exp(-0.5/dt*(dx*dx*(1.0-rho2*rho2)/sxs+dy*dy*(1.0-rho3*rho3)/sys+dz*dz*(1.0-rho1*rho1)/szs+2.0*dx*dy*(rho2*rho3-rho1)/sx/sy+2.0*dy*dz*(rho1*rho3-rho2)/sy/sz+2.0*dx*dz*(rho1*rho2-rho3)/sx/sz));
84
85
86 return tmp1*tmp2;
87
88
89}
90
92 return _mean0;
93}
94
96 return _sigma0;
97}
98
100 return _mean0;
101}
102
104 return _sigma0;
105}
106
108 return _mean1;
109}
110
112 return _sigma1;
113}
114
116 return _mean1;
117}
118
120 return _sigma1;
121}
122
124 return _mean2;
125}
126
127
129 return _sigma2;
130}
131
133 return _mean2;
134}
135
137 return _sigma2;
138}
139
140
141
143 return _corr01;
144}
145
147 return _corr01;
148}
149
151 return _corr02;
152}
153
155 return _corr02;
156}
157
159 return _corr12;
160}
161
163 return _corr12;
164}
165
166
168 return 3;
169}
170
172{
173 std::cerr
174 << "Warning. trivariate Gaussian called with scalar argument"
175 << std::endl;
176 assert(0);
177 return 0;
178}
179
180} // namespace Genfun
#define FUNCTION_OBJECT_IMP(classname)
Definition: AbsFunction.hh:149
unsigned int dimension() const
Definition: Argument.hh:61
virtual double getValue() const
Definition: Parameter.cc:29
virtual double operator()(double argument) const override
virtual unsigned int dimensionality() const override
Definition: Abs.hh:14