CMS 3D CMS Logo

Gaussian.h
Go to the documentation of this file.
1 #ifndef PhysicsTools_Utilities_Gaussian_h
2 #define PhysicsTools_Utilities_Gaussian_h
4 #include <boost/shared_ptr.hpp>
5 #include <cmath>
6 
7 namespace funct {
8 
9  const double oneOverSqrtTwoPi = 1/sqrt(2*M_PI);
10 
11  struct Gaussian {
12  Gaussian(const Parameter & m, const Parameter & s) :
13  mean(m.ptr()), sigma(s.ptr()) { }
14  Gaussian(boost::shared_ptr<double> m, boost::shared_ptr<double> s):
15  mean(m), sigma(s) { }
16  Gaussian(double m, double s):
17  mean(new double(m)), sigma(new double(s)){}
18  double operator()(double x) const {
19  double z = (x - *mean)/ *sigma;
20  if(fabs(z)>8) return 0;
21  return oneOverSqrtTwoPi/ *sigma * exp(-z*z/2);
22  }
23  boost::shared_ptr<double> mean, sigma;
24  };
25 
26 }
27 
28 #endif
Definition: Abs.h:5
Gaussian(boost::shared_ptr< double > m, boost::shared_ptr< double > s)
Definition: Gaussian.h:14
const double oneOverSqrtTwoPi
Definition: Gaussian.h:9
Exp< T >::type exp(const T &t)
Definition: Exp.h:22
Sqrt< T >::type sqrt(const T &t)
Definition: Sqrt.h:22
Gaussian(const Parameter &m, const Parameter &s)
Definition: Gaussian.h:12
Gaussian(double m, double s)
Definition: Gaussian.h:16
#define M_PI
boost::shared_ptr< double > mean
Definition: Gaussian.h:23
double operator()(double x) const
Definition: Gaussian.h:18
boost::shared_ptr< double > sigma
Definition: Gaussian.h:23