00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "RooFit.h"
00031
00032 #include "Riostream.h"
00033 #include "Riostream.h"
00034 #include <math.h>
00035
00036 #include "RooVoigtian.h"
00037 #include "RooAbsReal.h"
00038 #include "RooRealVar.h"
00039 #include "RooComplex.h"
00040 #include "RooMath.h"
00041
00042 ClassImp(RooVoigtian)
00043
00044
00045
00046 RooVoigtian::RooVoigtian(const char *name, const char *title,
00047 RooAbsReal& _x, RooAbsReal& _mean,
00048 RooAbsReal& _width, RooAbsReal& _sigma,
00049 Bool_t doFast) :
00050 RooAbsPdf(name,title),
00051 x("x","Dependent",this,_x),
00052 mean("mean","Mean",this,_mean),
00053 width("width","Breit-Wigner Width",this,_width),
00054 sigma("sigma","Gauss Width",this,_sigma),
00055 _doFast(doFast)
00056 {
00057 _invRootPi= 1./sqrt(atan2(0.,-1.));
00058 }
00059
00060
00061
00062
00063 RooVoigtian::RooVoigtian(const RooVoigtian& other, const char* name) :
00064 RooAbsPdf(other,name), x("x",this,other.x), mean("mean",this,other.mean),
00065 width("width",this,other.width),sigma("sigma",this,other.sigma),
00066 _doFast(other._doFast)
00067 {
00068 _invRootPi= 1./sqrt(atan2(0.,-1.));
00069 }
00070
00071
00072
00073
00074 Double_t RooVoigtian::evaluate() const
00075 {
00076 Double_t s = (sigma>0) ? sigma : -sigma ;
00077 Double_t w = (width>0) ? width : -width ;
00078
00079 Double_t coef= -0.5/(s*s);
00080 Double_t arg = x - mean;
00081
00082
00083 if (s==0. && w==0.) return 1.;
00084
00085
00086 if (s==0.) return (1./(arg*arg+0.25*w*w));
00087
00088
00089 if (w==0.) return exp(coef*arg*arg);
00090
00091
00092 Double_t c = 1./(sqrt(2.)*s);
00093 Double_t a = 0.5*c*w;
00094 Double_t u = c*arg;
00095 RooComplex z(u,a) ;
00096 RooComplex v(0.) ;
00097
00098 if (_doFast) {
00099 v = RooMath::FastComplexErrFunc(z);
00100 } else {
00101 v = RooMath::ComplexErrFunc(z);
00102 }
00103 return c*_invRootPi*v.re();
00104
00105 }