17 static const Double_t rootpi(sqrt(TMath::Pi())) ;
18 std::complex<double> evalApprox(Double_t x,
const std::complex<double>& z) {
23 static const std::complex<double> mi(0,-1);
24 std::complex<double> zp = mi*(z-x);
25 std::complex<double> zsq = zp*zp;
26 std::complex<double> v = -zsq - x*x;
27 std::complex<double> iz(z.imag()+x,z.real()-x);
28 return exp(v)*(exp(zsq)/(iz*rootpi) + 1.)*2. ;
32 std::complex<double> eval(Double_t x,
const std::complex<double>& z) {
33 Double_t re = z.real()-x;
34 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,34,8) 35 return (re>-5.0) ? RooMath::faddeeva_fast(std::complex<double>(-z.imag(),re))*exp(-x*x)
39 RooComplex erfc = RooMath::FastComplexErrFunc(RooComplex(-z.imag(),re));
40 return std::complex<double>(erfc.re(), erfc.im())*exp(-x*x);
42 return evalApprox(x,z) ;
49 N(
double x,
const std::complex<double>& z) ;
50 std::complex<double> operator()(
unsigned i)
const {
return _N[i]; }
52 std::complex<double> _N[3];
58 L(
double x) : _x(x) { }
59 double operator()(
unsigned j,
unsigned k)
const ;
64 N::N(
double x,
const std::complex<double>& z)
66 _N[0] = TMath::Erf(x);
72 L::operator()(
unsigned j,
unsigned k)
const 79 static const double factor = 2. / rootpi;
82 default:
return factor*(*this)(j-1,2);
97 case 1:
return -2.*_x;
98 case 2:
return 2.* ( 1.-x2*2.);
99 case 3:
return 4.*_x*( 3.-x2*2.);
100 case 4:
return -4.* ( 3.-x2*( 12.-x2*4.));
101 case 5:
return -8.*_x*( 15.-x2*( 20.-x2*4.));
102 case 6:
return 8.* ( 15.-x2*( 90.-x2*( 60.-x2*8.)));
103 case 7:
return 16.*_x*( 105.-x2*( 210.-x2*( 84.-x2*8.)));
104 case 8:
return -16.* ( 105.-x2*( 840.-x2*( 840.-x2*( 224.-x2*16.))));
105 case 9:
return -32.*_x*( 945.-x2*( 2520.-x2*( 1512.-x2*( 288.-x2*16.))));
106 case 10:
return 32.* ( 945.-x2*( 9450.-x2*( 12600.-x2*( 5040.-x2*( 720.-x2*32.)))));
107 case 11:
return 64.*_x*( 10395.-x2*( 34650.-x2*( 27720.-x2*( 7920.-x2*( 880.-x2*32.)))));
108 case 12:
return -64.* ( 10395.-x2*( 124740.-x2*( 207900.-x2*( 110880.-x2*( 23760.-x2*( 2112.-x2*64.))))));
109 case 13:
return -128.*_x*( 135135.-x2*( 540540.-x2*( 540540.-x2*( 205920.-x2*( 34320.-x2*( 2496.-x2*64.))))));
110 case 14:
return 128.* ( 135135.-x2*( 1891890.-x2*( 3783780.-x2*( 2522520.-x2*( 720720.-x2*( 96096.-x2*( 5824.-x2*128.)))))));
111 case 15:
return 256.*_x*( 2027025.-x2*( 9459450.-x2*( 11351340.-x2*( 5405400.-x2*( 1201200.-x2*( 131040.-x2*( 6720.-x2*128.)))))));
112 case 16:
return -256.* ( 2027025.-x2*( 32432400.-x2*( 75675600.-x2*( 60540480.-x2*(21621600.-x2*(3843840.-x2*(349440.-x2*(15360.-x2*256.))))))));
113 case 17:
return -512.*_x*(34459425.-x2*(183783600.-x2*(257297040.-x2*(147026880.-x2*(40840800.-x2*(5940480.-x2*(456960.-x2*(17408.-x2*256.))))))));
124 template <
unsigned MaxOrder>
128 for (
unsigned i=0;i<MaxOrder;++i) _m[i] = n(0)*l(i,0) + n(1)*l(i,1) + n(2)*l(i,2);
137 const std::complex<double> zi2 =
_zi*
_zi ;
138 std::complex<double> f(1,0);
144 case 13: f *= 13.*
_zi;
145 case 12:
return f* 332640.*
_zi*(1.+6.*zi2*(1.+5.*zi2*(1.+4.*zi2*(1.+3.*zi2*(1.+2.*zi2*(1.+zi2))))));
146 case 11: f *= 11.*
_zi;
147 case 10:
return f* 15120.*
_zi*(1.+5.*zi2*(1.+4.*zi2*(1.+3.*zi2*(1.+2.*zi2*(1.+zi2)))));
149 case 8:
return f* 840.*
_zi*(1.+4.*zi2*(1.+3.*zi2*(1.+2.*zi2*(1.+zi2))));
151 case 6:
return f* 60.*
_zi*(1.+3.*zi2*(1.+2.*zi2*(1.+zi2)));
153 case 4:
return f* 6.*
_zi*(1.+2.*zi2*(1.+zi2));
155 case 2:
return f*
_zi*(1.+zi2);
157 case 0:
return f* 0.5*
_zi;
161 std::cerr <<
"K_n only implemented upto (and including) 13th order" << std::endl;
std::complex< double > _zi
std::complex< double > operator()(unsigned i) const
M_n(double x, const std::complex< double > &z)
~RooAbsGaussModelEfficiency()