CLHEP 2.4.6.4
C++ Class Library for High Energy Physics
Loading...
Searching...
No Matches
BivariateGaussian.cc
Go to the documentation of this file.
1// -*- C++ -*-
2// $Id: BivariateGaussian.cc,v 1.8 2010/06/16 18:22:01 garren Exp $
3#include "CLHEP/GenericFunctions/defs.h"
4#include "CLHEP/GenericFunctions/BivariateGaussian.hh"
5#include <assert.h>
6#include <cmath> // for exp()
7#include <iostream>
8
9#if (defined __STRICT_ANSI__) || (defined _WIN32)
10#ifndef M_PI
11#define M_PI 3.14159265358979323846
12#endif // M_PI
13#endif // __STRICT_ANSI__
14
15namespace Genfun {
16FUNCTION_OBJECT_IMP(BivariateGaussian)
17
19 _mean0("Mean0", 0.0,-10,10),
20 _mean1("Mean1", 0.0,-10,10),
21 _sigma0("Sigma0",1.0,0, 10),
22 _sigma1("Sigma1",1.0,0, 10),
23 _corr01("Corr01", 0.0, -1.0, 1.0)
24{}
25
27}
28
30 AbsFunction(right),
31 _mean0(right._mean0),
32 _mean1(right._mean1),
33 _sigma0(right._sigma0),
34 _sigma1(right._sigma1),
35 _corr01(right._corr01)
36{
37}
38
40 assert (a.dimension()==2);
41 double x = a[0];
42 double y = a[1];
43
44 double x0 = _mean0.getValue();
45 double y0 = _mean1.getValue();
46 double dx = x-x0;
47 double dy = y-y0;
48
49 double sx = _sigma0.getValue();
50 double sy = _sigma1.getValue();
51
52 double sxs = sx*sx;
53 double sys = sy*sy;
54 double rho = _corr01.getValue();
55 double dt = (1.0+rho)*(1.0-rho);
56
57 return (1.0/(2*M_PI*sx*sy*sqrt(dt))) *
58 exp(-1.0/(2.0*dt)*(dx*dx/sxs+dy*dy/sys-2.0*rho*dx*dy/sx/sy));
59}
60
62 return _mean0;
63}
64
66 return _sigma0;
67}
68
70 return _mean0;
71}
72
74 return _sigma0;
75}
76
78 return _mean1;
79}
80
82 return _sigma1;
83}
84
86 return _mean1;
87}
88
90 return _sigma1;
91}
92
93
94
96 return _corr01;
97}
98
100 return _corr01;
101}
102
103
105 return 2;
106}
107
109{
110 std::cerr
111 << "Warning. bivariate Gaussian called with scalar argument"
112 << std::endl;
113 assert(0);
114 return 0;
115}
116
117} // namespace Genfun
#define FUNCTION_OBJECT_IMP(classname)
Definition: AbsFunction.hh:149
unsigned int dimension() const
Definition: Argument.hh:61
virtual double operator()(double argument) const override
virtual unsigned int dimensionality() const override
virtual double getValue() const
Definition: Parameter.cc:29
Definition: Abs.hh:14