CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/PhysicsTools/Utilities/interface/Gaussian.h

Go to the documentation of this file.
00001 #ifndef PhysicsTools_Utilities_Gaussian_h
00002 #define PhysicsTools_Utilities_Gaussian_h
00003 #include "PhysicsTools/Utilities/interface/Parameter.h"
00004 #include <boost/shared_ptr.hpp>
00005 #include <cmath>
00006 
00007 namespace funct {
00008 
00009   const double oneOverSqrtTwoPi = 1/sqrt(2*M_PI);
00010   
00011   struct Gaussian {
00012     Gaussian(const Parameter & m, const Parameter & s) : 
00013       mean(m.ptr()), sigma(s.ptr()) { }
00014     Gaussian(boost::shared_ptr<double> m, boost::shared_ptr<double> s): 
00015       mean(m), sigma(s) { }
00016     Gaussian(double m, double s): 
00017       mean(new double(m)), sigma(new double(s)){}
00018     double operator()(double x) const {
00019       double z = (x - *mean)/ *sigma;
00020       if(fabs(z)>8) return 0;
00021       return oneOverSqrtTwoPi/ *sigma * exp(-z*z/2);
00022     }
00023     boost::shared_ptr<double> mean, sigma;
00024   };
00025 
00026 }
00027 
00028 #endif