CLHEP VERSION Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

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 $
5 #include <assert.h>
6 #include <cmath> // for exp()
7 
8 #if (defined __STRICT_ANSI__) || (defined _WIN32)
9 #ifndef M_PI
10 #define M_PI 3.14159265358979323846
11 #endif // M_PI
12 #endif // __STRICT_ANSI__
13 
14 namespace Genfun {
15 FUNCTION_OBJECT_IMP(BivariateGaussian)
16 
18  _mean0("Mean0", 0.0,-10,10),
19  _mean1("Mean1", 0.0,-10,10),
20  _sigma0("Sigma0",1.0,0, 10),
21  _sigma1("Sigma1",1.0,0, 10),
22  _corr01("Corr01", 0.0, -1.0, 1.0)
23 {}
24 
26 }
27 
29  AbsFunction(right),
30  _mean0(right._mean0),
31  _mean1(right._mean1),
32  _sigma0(right._sigma0),
33  _sigma1(right._sigma1),
34  _corr01(right._corr01)
35 {
36 }
37 
38 double BivariateGaussian::operator() (const Argument & a) const {
39  assert (a.dimension()==2);
40  double x = a[0];
41  double y = a[1];
42 
43  double x0 = _mean0.getValue();
44  double y0 = _mean1.getValue();
45  double dx = x-x0;
46  double dy = y-y0;
47 
48  double sx = _sigma0.getValue();
49  double sy = _sigma1.getValue();
50 
51  double sxs = sx*sx;
52  double sys = sy*sy;
53  double rho = _corr01.getValue();
54  double dt = (1.0+rho)*(1.0-rho);
55 
56  return (1.0/(2*M_PI*sx*sy*sqrt(dt))) *
57  exp(-1.0/(2.0*dt)*(dx*dx/sxs+dy*dy/sys-2.0*rho*dx*dy/sx/sy));
58 }
59 
61  return _mean0;
62 }
63 
65  return _sigma0;
66 }
67 
69  return _mean0;
70 }
71 
73  return _sigma0;
74 }
75 
77  return _mean1;
78 }
79 
81  return _sigma1;
82 }
83 
85  return _mean1;
86 }
87 
89  return _sigma1;
90 }
91 
92 
93 
95  return _corr01;
96 }
97 
99  return _corr01;
100 }
101 
102 
103 unsigned int BivariateGaussian::dimensionality() const {
104  return 2;
105 }
106 
107 double BivariateGaussian::operator ()(double) const
108 {
109  std::cerr
110  << "Warning. bivariate Gaussian called with scalar argument"
111  << std::endl;
112  assert(0);
113  return 0;
114 }
115 
116 } // namespace Genfun
virtual double operator()(double argument) const
unsigned int dimension() const
#define FUNCTION_OBJECT_IMP(classname)
virtual unsigned int dimensionality() const
virtual double getValue() const
Definition: Parameter.cc:27