CLHEP VERSION Reference Documentation
CLHEP Home Page
CLHEP Documentation
CLHEP Bug Reports
Main Page
Namespaces
Classes
Files
File List
File Members
GenericFunctions
src
Gaussian.cc
Go to the documentation of this file.
1
// -*- C++ -*-
2
// $Id: Gaussian.cc,v 1.8 2010/06/16 18:22:01 garren Exp $
3
#include "
CLHEP/GenericFunctions/defs.h
"
4
#include "
CLHEP/GenericFunctions/Gaussian.hh
"
5
#include "
CLHEP/GenericFunctions/Variable.hh
"
6
#include <assert.h>
7
#include <cmath>
// for exp()
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
15
namespace
Genfun {
16
FUNCTION_OBJECT_IMP
(Gaussian)
17
18
Gaussian
::
Gaussian
():
19
_mean("Mean", 0.0,-10,10),
20
_sigma("
Sigma
",1.0,0, 10)
21
{}
22
23
Gaussian::~Gaussian
() {
24
}
25
26
Gaussian::Gaussian
(
const
Gaussian
& right):
27
AbsFunction
(right),
28
_mean(right._mean),
29
_sigma(right._sigma)
30
{
31
}
32
33
double
Gaussian::operator()
(
double
x)
const
{
34
double
s = _sigma.
getValue
();
35
double
x0 = _mean.
getValue
();
36
return
(1.0/(sqrt(2*M_PI)*s))*
37
exp(-(x-x0)*(x-x0)/(2.0*s*s));
38
}
39
40
Parameter
&
Gaussian::mean
() {
41
return
_mean;
42
}
43
44
Parameter
&
Gaussian::sigma
() {
45
return
_sigma;
46
}
47
48
const
Parameter
&
Gaussian::mean
()
const
{
49
return
_mean;
50
}
51
52
const
Parameter
&
Gaussian::sigma
()
const
{
53
return
_sigma;
54
}
55
56
57
58
Derivative
Gaussian::partial
(
unsigned
int
index)
const
{
59
assert(index==0);
60
Variable
x;
61
const
AbsFunction
& fPrime = (*this)*(_mean-x)/_sigma/_sigma;
62
return
Derivative
(&fPrime);
63
}
64
65
}
// namespace Genfun
Generated on Mon May 6 2013 04:04:10 for CLHEP by
1.8.1.2