CLHEP
2.4.6.4
C++ Class Library for High Energy Physics
Loading...
Searching...
No Matches
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
#include <iostream>
9
10
#if (defined __STRICT_ANSI__) || (defined _WIN32)
11
#ifndef M_PI
12
#define M_PI 3.14159265358979323846
13
#endif
// M_PI
14
#endif
// __STRICT_ANSI__
15
16
namespace
Genfun
{
17
FUNCTION_OBJECT_IMP
(Gaussian)
18
19
Gaussian
::
Gaussian
():
20
_mean("Mean", 0.0,-10,10),
21
_sigma("
Sigma
",1.0,0, 10)
22
{}
23
24
Gaussian::~Gaussian
() {
25
}
26
27
Gaussian::Gaussian
(
const
Gaussian
& right):
28
AbsFunction
(right),
29
_mean(right._mean),
30
_sigma(right._sigma)
31
{
32
}
33
34
double
Gaussian::operator()
(
double
x)
const
{
35
double
s = _sigma.
getValue
();
36
double
x0 = _mean.
getValue
();
37
return
(1.0/(sqrt(2*M_PI)*s))*
38
exp(-(x-x0)*(x-x0)/(2.0*s*s));
39
}
40
41
Parameter
&
Gaussian::mean
() {
42
return
_mean;
43
}
44
45
Parameter
&
Gaussian::sigma
() {
46
return
_sigma;
47
}
48
49
const
Parameter
&
Gaussian::mean
()
const
{
50
return
_mean;
51
}
52
53
const
Parameter
&
Gaussian::sigma
()
const
{
54
return
_sigma;
55
}
56
57
// don't generate warnings about unused parameter inside assert
58
#if defined __GNUC__
59
#if __GNUC__ > 3 && __GNUC_MINOR__ > 6
60
#pragma GCC diagnostic push
61
#pragma GCC diagnostic ignored "-Wunused-parameter"
62
#endif
63
#endif
64
#ifdef __clang__
65
#pragma clang diagnostic push
66
#pragma clang diagnostic ignored "-Wunused-parameter"
67
#endif
68
Derivative
Gaussian::partial
(
unsigned
int
index)
const
{
69
assert(index==0);
70
Variable
x;
71
const
AbsFunction
& fPrime = (*this)*(_mean-x)/_sigma/_sigma;
72
return
Derivative
(&fPrime);
73
}
74
#if defined __GNUC__
75
#if __GNUC__ > 3 && __GNUC_MINOR__ > 6
76
#pragma GCC diagnostic pop
77
#endif
78
#endif
79
#ifdef __clang__
80
#pragma clang diagnostic pop
81
#endif
82
83
}
// namespace Genfun
FUNCTION_OBJECT_IMP
#define FUNCTION_OBJECT_IMP(classname)
Definition:
AbsFunction.hh:149
Genfun::AbsFunction
Definition:
AbsFunction.hh:48
Genfun::FunctionNoop
Definition:
FunctionNoop.hh:19
Genfun::Gaussian
Definition:
Gaussian.hh:20
Genfun::Gaussian::Gaussian
Gaussian()
Definition:
Gaussian.cc:19
Genfun::Gaussian::mean
Parameter & mean()
Definition:
Gaussian.cc:41
Genfun::Gaussian::operator()
virtual double operator()(double argument) const override
Definition:
Gaussian.cc:34
Genfun::Gaussian::~Gaussian
virtual ~Gaussian()
Definition:
Gaussian.cc:24
Genfun::Gaussian::partial
Derivative partial(unsigned int) const override
Definition:
Gaussian.cc:68
Genfun::Gaussian::sigma
Parameter & sigma()
Definition:
Gaussian.cc:45
Genfun::Parameter
Definition:
Parameter.hh:35
Genfun::Parameter::getValue
virtual double getValue() const
Definition:
Parameter.cc:29
Genfun::Sigma
Definition:
Sigma.hh:19
Genfun::Variable
Definition:
Variable.hh:19
Genfun
Definition:
Abs.hh:14
Genfun::Derivative
FunctionNoop Derivative
Definition:
AbsFunction.hh:42
CLHEP-CLHEP_2_4_6_4
GenericFunctions
src
Gaussian.cc
Generated by
1.9.6