evtgen is hosted by Hepforge, IPPP Durham
EvtGen  2.0.0
Monte Carlo generator of particle decays, in particular the weak decays of heavy flavour particles such as B mesons.
EvtBtoXsgammaFermiUtil.cpp
Go to the documentation of this file.
1 
2 /***********************************************************************
3 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors *
4 * *
5 * This file is part of EvtGen. *
6 * *
7 * EvtGen is free software: you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation, either version 3 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * EvtGen is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with EvtGen. If not, see <https://www.gnu.org/licenses/>. *
19 ***********************************************************************/
20 
22 
23 #include "EvtGenBase/EvtConst.hh"
24 #include "EvtGenBase/EvtPatches.hh"
25 #include "EvtGenBase/EvtReport.hh"
26 
30 
31 #include <iostream>
32 #include <math.h>
33 using std::endl;
34 
36  const std::vector<double>& coeffs )
37 {
38  //coeffs: 1 = lambdabar, 2 = a, 3 = lam1, 4 = norm
39  // EvtGenReport(EVTGEN_INFO,"EvtGen")<<coeffs[4]<<endl;
40  return ( pow( 1. - ( y / coeffs[1] ), coeffs[2] ) *
41  exp( ( -3. * pow( coeffs[1], 2. ) / coeffs[3] ) * y / coeffs[1] ) ) /
42  coeffs[4];
43 }
44 
46  const std::vector<double>& coeffs )
47 {
48  //coeffs: 1 = lambdabar, 2 = a, 3 = c, 4 = norm
49  return ( pow( 1. - ( y / coeffs[1] ), coeffs[2] ) *
50  exp( -pow( coeffs[3], 2. ) * pow( 1. - ( y / coeffs[1] ), 2. ) ) ) /
51  coeffs[4];
52 }
53 
55  double lambdabar, double lam1, double mb, std::vector<double>& gammaCoeffs )
56 {
57  std::vector<double> coeffs1 = {0.2, lambdabar, 0.0};
58  std::vector<double> coeffs2 = {0.2, lambdabar, -lam1 / 3.};
59 
60  auto lhFunc = EvtItgTwoCoeffFcn{&FermiGaussRootFcnA, -mb, lambdabar,
61  coeffs1, gammaCoeffs};
62  auto rhFunc = EvtItgTwoCoeffFcn{&FermiGaussRootFcnB, -mb, lambdabar,
63  coeffs2, gammaCoeffs};
64  auto rootFinder = EvtBtoXsgammaRootFinder{};
65 
66  return rootFinder.GetGaussIntegFcnRoot( &lhFunc, &rhFunc, 1.0e-4, 1.0e-4,
67  40, 40, -mb, lambdabar, 0.2, 0.4,
68  1.0e-6 );
69 }
70 
72  double y, const std::vector<double>& coeffs1,
73  const std::vector<double>& coeffs2 )
74 {
75  //coeffs1: 0=ap, 1=lambdabar, coeffs2=gamma function coeffs
76  double cp = Gamma( ( 2.0 + coeffs1[0] ) / 2., coeffs2 ) /
77  Gamma( ( 1.0 + coeffs1[0] ) / 2., coeffs2 );
78 
79  return ( y * y ) * pow( ( 1. - ( y / coeffs1[1] ) ), coeffs1[0] ) *
80  exp( -pow( cp, 2 ) * pow( ( 1. - ( y / coeffs1[1] ) ), 2. ) );
81 }
82 
84  double y, const std::vector<double>& coeffs1,
85  const std::vector<double>& coeffs2 )
86 {
87  //coeffs1: 0=ap, 1=lambdabar, coeffs2=gamma function coeffs
88  double cp = Gamma( ( 2.0 + coeffs1[0] ) / 2., coeffs2 ) /
89  Gamma( ( 1.0 + coeffs1[0] ) / 2., coeffs2 );
90  return pow( ( 1. - ( y / coeffs1[1] ) ), coeffs1[0] ) *
91  exp( -pow( cp, 2 ) * pow( ( 1. - ( y / coeffs1[1] ) ), 2. ) );
92 }
93 
94 double EvtBtoXsgammaFermiUtil::Gamma( double z, const std::vector<double>& coeffs )
95 {
96  //Lifted from Numerical Recipies in C
97  double x, y, tmp, ser;
98 
99  int j;
100  y = z;
101  x = z;
102 
103  tmp = x + 5.5;
104  tmp = tmp - ( x + 0.5 ) * log( tmp );
105  ser = 1.000000000190015;
106 
107  for ( j = 0; j < 6; j++ ) {
108  y = y + 1.0;
109  ser = ser + coeffs[j] / y;
110  }
111 
112  return exp( -tmp + log( 2.5066282746310005 * ser / x ) );
113 }
114 
116 {
117  //Lifted from Numerical Recipies in C : Returns the modified Bessel
118  //function K_1(x) for positive real x
119  if ( x < 0.0 )
120  EvtGenReport( EVTGEN_INFO, "EvtGen" ) << "x is negative !" << endl;
121 
122  double y, ans;
123 
124  if ( x <= 2.0 ) {
125  y = x * x / 4.0;
126  ans = ( log( x / 2.0 ) * BesselI1( x ) ) +
127  ( 1.0 / x ) *
128  ( 1.0 +
129  y * ( 0.15443144 +
130  y * ( -0.67278579 +
131  y * ( -0.18156897 +
132  y * ( -0.1919402e-1 +
133  y * ( -0.110404e-2 +
134  y * ( -0.4686e-4 ) ) ) ) ) ) );
135  } else {
136  y = 2.0 / x;
137  ans = ( exp( -x ) / sqrt( x ) ) *
138  ( 1.25331414 +
139  y * ( 0.23498619 +
140  y * ( -0.3655620e-1 +
141  y * ( 0.1504268e-1 +
142  y * ( -0.780353e-2 +
143  y * ( 0.325614e-2 +
144  y * ( -0.68245e-3 ) ) ) ) ) ) );
145  }
146  return ans;
147 }
148 
150 {
151  //Lifted from Numerical Recipies in C : Returns the modified Bessel
152  //function I_1(x) for any real x
153 
154  double ax, ans;
155  double y;
156 
157  ax = fabs( x );
158  if ( ax < 3.75 ) {
159  y = x / 3.75;
160  y *= y;
161  ans = ax *
162  ( 0.5 + y * ( 0.87890594 +
163  y * ( 0.51498869 +
164  y * ( 0.15084934 +
165  y * ( 0.2658733e-1 +
166  y * ( 0.301532e-2 +
167  y * 0.32411e-3 ) ) ) ) ) );
168  } else {
169  y = 3.75 / ax;
170  ans = 0.2282967e-1 +
171  y * ( -0.2895312e-1 + y * ( 0.1787654e-1 - y * 0.420059e-2 ) );
172  ans = 0.398914228 +
173  y * ( -0.3988024e-1 +
174  y * ( -0.362018e-2 +
175  y * ( 0.163801e-2 + y * ( -0.1031555e-1 + y * ans ) ) ) );
176  ans *= ( exp( ax ) / sqrt( ax ) );
177  }
178  return x < 0.0 ? -ans : ans;
179 }
180 
181 double EvtBtoXsgammaFermiUtil::FermiRomanFuncRoot( double lambdabar, double lam1 )
182 {
183  auto lhFunc = EvtItgFunction{&FermiRomanRootFcnA, -1.e-6, 1.e6};
184 
185  auto rootFinder = EvtBtoXsgammaRootFinder{};
186  double rhSide = 1.0 - ( lam1 / ( 3.0 * lambdabar * lambdabar ) );
187 
188  double rho = rootFinder.GetRootSingleFunc( &lhFunc, rhSide, 0.1, 0.4, 1.0e-6 );
189  //rho=0.250353;
190  EvtGenReport( EVTGEN_INFO, "EvtGen" )
191  << "rho/2 " << rho / 2. << " bessel " << BesselK1( rho / 2. ) << endl;
192  double pF = lambdabar * sqrt( EvtConst::pi ) /
193  ( rho * exp( rho / 2. ) * BesselK1( rho / 2. ) );
194  EvtGenReport( EVTGEN_INFO, "EvtGen" )
195  << "rho " << rho << " pf " << pF << endl;
196 
197  return rho;
198 }
199 
201 {
202  return EvtConst::pi * ( 2. + y ) * pow( y, -2. ) * exp( -y ) *
203  pow( BesselK1( y / 2. ), -2. );
204 }
206  const std::vector<double>& coeffs )
207 {
208  if ( y == ( coeffs[1] - coeffs[2] ) )
209  y = 0.99999999 * ( coeffs[1] - coeffs[2] );
210 
211  //coeffs: 1 = mB, 2=mb, 3=rho, 4=lambdabar, 5=norm
212  double pF = coeffs[4] * sqrt( EvtConst::pi ) /
213  ( coeffs[3] * exp( coeffs[3] / 2. ) * BesselK1( coeffs[3] / 2. ) );
214  // EvtGenReport(EVTGEN_INFO,"EvtGen")<<" pf "<<y<<" "<<pF<<" "<<coeffs[1]<<" "<<coeffs[2]<<" "<<coeffs[3]<<" "<<coeffs[4]<<" "<<coeffs[5]<<endl;
215  //double pF=0.382533;
216 
217  //EvtGenReport(EVTGEN_INFO,"EvtGen")<<(coeffs[1]-coeffs[2])*(1./(sqrt(EvtConst::pi)*pF))<<endl;
218  //EvtGenReport(EVTGEN_INFO,"EvtGen")<<(1.-y/(coeffs[1]-coeffs[2]))<<endl;
219  //EvtGenReport(EVTGEN_INFO,"EvtGen")<<(coeffs[1]-coeffs[2])<<endl;
220  //EvtGenReport(EVTGEN_INFO,"EvtGen")<<(coeffs[1]-coeffs[2])*(1.-y/(coeffs[1]-coeffs[2]))<<endl;
221 
222  //EvtGenReport(EVTGEN_INFO,"EvtGen")<<" "<<pF*coeffs[3]/((coeffs[1]-coeffs[2])*(1.-y/(coeffs[1]-coeffs[2])))<<endl;
223  // EvtGenReport(EVTGEN_INFO,"EvtGen")<<" "<<((coeffs[1]-coeffs[2])/pF)*(1. -y/(coeffs[1]-coeffs[2]))<<endl;
224 
225  //EvtGenReport(EVTGEN_INFO,"EvtGen")<<"result "<<(coeffs[1]-coeffs[2])*(1./(sqrt(EvtConst::pi)*pF))*exp(-(1./4.)*pow(pF*(coeffs[3]/((coeffs[1]-coeffs[2])*(1.-y/(coeffs[1]-coeffs[2])))) - ((coeffs[1]-coeffs[2])/pF)*(1. -y/(coeffs[1]-coeffs[2])),2.))/coeffs[5];
226 
227  //EvtGenReport(EVTGEN_INFO,"EvtGen")<<"leaving"<<endl;
228  return ( coeffs[1] - coeffs[2] ) * ( 1. / ( sqrt( EvtConst::pi ) * pF ) ) *
229  exp( -( 1. / 4. ) *
230  pow( pF * ( coeffs[3] /
231  ( ( coeffs[1] - coeffs[2] ) *
232  ( 1. - y / ( coeffs[1] - coeffs[2] ) ) ) ) -
233  ( ( coeffs[1] - coeffs[2] ) / pF ) *
234  ( 1. - y / ( coeffs[1] - coeffs[2] ) ),
235  2. ) ) /
236  coeffs[5];
237 }
static double FermiRomanRootFcnA(double)
static double FermiRomanFunc(double, std::vector< double > const &coeffs)
static double FermiGaussRootFcnA(double, const std::vector< double > &coeffs1, const std::vector< double > &coeffs2)
static double Gamma(double, const std::vector< double > &coeffs)
std::ostream & EvtGenReport(EvtGenSeverity severity, const char *facility=0)
Definition: EvtReport.cpp:33
static double FermiRomanFuncRoot(double, double)
static double FermiGaussFunc(double, std::vector< double > const &coeffs)
static double FermiGaussFuncRoot(double, double, double, std::vector< double > &coeffs)
static const double pi
Definition: EvtConst.hh:26
static double FermiExpFunc(double var, const std::vector< double > &coeffs)
double GetGaussIntegFcnRoot(EvtItgAbsFunction *theFunc1, EvtItgAbsFunction *theFunc2, double integ1Precision, double integ2Precision, int maxLoop1, int maxLoop2, double integLower, double integUpper, double lowerValue, double upperValue, double precision)
double GetRootSingleFunc(const EvtItgAbsFunction *theFunc, double functionValue, double lowerValue, double upperValue, double precision)
EvtComplex exp(const EvtComplex &c)
Definition: EvtComplex.hh:240
static double BesselI1(double)
static double BesselK1(double)
static double FermiGaussRootFcnB(double, const std::vector< double > &coeffs1, const std::vector< double > &coeffs2)