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 
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) : mean(m.ptr()), sigma(s.ptr()) {}
13  Gaussian(std::shared_ptr<double> m, std::shared_ptr<double> s) : mean(m), sigma(s) {}
14  Gaussian(double m, double s) : mean(new double(m)), sigma(new double(s)) {}
15  double operator()(double x) const {
16  double z = (x - *mean) / *sigma;
17  if (fabs(z) > 8)
18  return 0;
19  return oneOverSqrtTwoPi / *sigma * exp(-z * z / 2);
20  }
21  std::shared_ptr<double> mean, sigma;
22  };
23 
24 } // namespace funct
25 
26 #endif
funct::Gaussian::Gaussian
Gaussian(const Parameter &m, const Parameter &s)
Definition: Gaussian.h:12
funct::Parameter
Definition: Parameter.h:8
funct::Gaussian::operator()
double operator()(double x) const
Definition: Gaussian.h:15
Parameter.h
alignCSCRings.s
s
Definition: alignCSCRings.py:92
funct::sqrt
Sqrt< T >::type sqrt(const T &t)
Definition: Sqrt.h:22
funct::Gaussian
Definition: Gaussian.h:11
funct::Gaussian::Gaussian
Gaussian(double m, double s)
Definition: Gaussian.h:14
funct::m
m
Definition: Factorize.h:45
funct::Gaussian::mean
std::shared_ptr< double > mean
Definition: Gaussian.h:21
funct::Gaussian::sigma
std::shared_ptr< double > sigma
Definition: Gaussian.h:21
funct::oneOverSqrtTwoPi
const double oneOverSqrtTwoPi
Definition: Gaussian.h:9
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
funct::exp
Exp< T >::type exp(const T &t)
Definition: Exp.h:22
funct::Gaussian::Gaussian
Gaussian(std::shared_ptr< double > m, std::shared_ptr< double > s)
Definition: Gaussian.h:13
funct
Definition: Abs.h:5