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.
EvtVubBLNPHybrid.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/EvtGenKine.hh"
24 #include "EvtGenBase/EvtPDL.hh"
26 #include "EvtGenBase/EvtPatches.hh"
27 #include "EvtGenBase/EvtRandom.hh"
28 #include "EvtGenBase/EvtReport.hh"
30 
34 
35 #include <stdlib.h>
36 #include <string>
37 
38 // For incomplete gamma function
39 #include "math.h"
40 #include "signal.h"
41 #define ITMAX 100
42 #define EPS 3.0e-7
43 #define FPMIN 1.0e-30
44 
45 using std::cout;
46 using std::endl;
47 
49 {
50  return "VUB_BLNPHYBRID";
51 }
52 
54 {
55  return new EvtVubBLNPHybrid;
56 }
57 
59 {
60  // check that there are at least 3 arguments
62  EvtGenReport( EVTGEN_ERROR, "EvtVubBLNPHybrid" )
63  << "EvtVubBLNPHybrid generator expected "
64  << "at least " << EvtVubBLNPHybrid::nParameters
65  << " arguments but found: " << getNArg()
66  << "\nWill terminate execution!" << endl;
67  ::abort();
68  } else if ( getNArg() == EvtVubBLNPHybrid::nParameters ) {
69  EvtGenReport( EVTGEN_WARNING, "EvtVubBLNPHybrid" )
70  << "EvtVubBLNPHybrid: generate B -> Xu l nu events "
71  << "without using the hybrid reweighting." << endl;
72  _noHybrid = true;
73  } else if ( getNArg() <
75  EvtGenReport( EVTGEN_ERROR, "EvtVubBLNPHybrid" )
76  << "EvtVubBLNPHybrid could not read number of bins for "
77  << "all variables used in the reweighting\n"
78  << "Will terminate execution!" << endl;
79  ::abort();
80  }
81 
82  // get parameters (declared in the header file)
83 
84  // Input parameters
85  mBB = 5.2792;
86  lambda2 = 0.12;
87 
88  // Shape function parameters
89  b = getArg( 0 );
90  Lambda = getArg( 1 );
91  Ecut = 1.8;
92  wzero = mBB - 2 * Ecut;
93 
94  // SF and SSF modes
95  itype = (int)getArg( 5 );
96  dtype = getArg( 5 );
97  isubl = (int)getArg( 6 );
98 
99  // flags
100  flag1 = (int)getArg( 7 );
101  flag2 = (int)getArg( 8 );
102  flag3 = (int)getArg( 9 );
103 
104  // Quark mass
105  mb = 4.61;
106 
107  // hidden parameter what and SF stuff
108  const double xlow = 0;
109  const double xhigh = mBB;
110  const int aSize = 10000;
111  EvtPFermi pFermi( Lambda, b );
112  // pf is the cumulative distribution normalized to 1.
113  _pf.resize( aSize );
114  for ( int i = 0; i < aSize; i++ ) {
115  double what = xlow + (double)( i + 0.5 ) / ( (double)aSize ) *
116  ( xhigh - xlow );
117  if ( i == 0 )
118  _pf[i] = pFermi.getSFBLNP( what );
119  else
120  _pf[i] = _pf[i - 1] + pFermi.getSFBLNP( what );
121  }
122  for ( size_t i = 0; i < _pf.size(); i++ ) {
123  _pf[i] /= _pf[_pf.size() - 1];
124  }
125 
126  // Matching scales
127  muh = mBB * getArg( 2 ); // 0.5
128  mui = getArg( 3 ); // 1.5
129  mubar = getArg( 4 ); // 1.5
130 
131  // Perturbative quantities
132  CF = 4.0 / 3.0;
133  CA = 3.0;
134  double nf = 4.0;
135 
136  beta0 = 11.0 / 3.0 * CA - 2.0 / 3.0 * nf;
137  beta1 = 34.0 / 3.0 * CA * CA - 10.0 / 3.0 * CA * nf - 2.0 * CF * nf;
138  beta2 = 2857.0 / 54.0 * CA * CA * CA +
139  ( CF * CF - 205.0 / 18.0 * CF * CA - 1415.0 / 54.0 * CA * CA ) * nf +
140  ( 11.0 / 9.0 * CF + 79.0 / 54.0 * CA ) * nf * nf;
141 
142  zeta3 = 1.0 + 1 / 8.0 + 1 / 27.0 + 1 / 64.0;
143 
144  Gamma0 = 4 * CF;
145  Gamma1 = CF * ( ( 268.0 / 9.0 - 4.0 * M_PI * M_PI / 3.0 ) * CA -
146  40.0 / 9.0 * nf );
147  Gamma2 = 16 * CF *
148  ( ( 245.0 / 24.0 - 67.0 / 54.0 * M_PI * M_PI +
149  +11.0 / 180.0 * pow( M_PI, 4 ) + 11.0 / 6.0 * zeta3 ) *
150  CA * CA *
151  +( -209.0 / 108.0 + 5.0 / 27.0 * M_PI * M_PI -
152  7.0 / 3.0 * zeta3 ) *
153  CA * nf +
154  ( -55.0 / 24.0 + 2 * zeta3 ) * CF * nf - nf * nf / 27.0 );
155 
156  gp0 = -5.0 * CF;
157  gp1 = -8.0 * CF *
158  ( ( 3.0 / 16.0 - M_PI * M_PI / 4.0 + 3 * zeta3 ) * CF +
159  ( 1549.0 / 432.0 + 7.0 / 48.0 * M_PI * M_PI - 11.0 / 4.0 * zeta3 ) *
160  CA -
161  ( 125.0 / 216.0 + M_PI * M_PI / 24.0 ) * nf );
162 
163  // Lbar and mupisq
164 
165  Lbar = Lambda; // all models
166  mupisq = 3 * Lambda * Lambda / b;
167  if ( itype == 1 )
168  mupisq = 3 * Lambda * Lambda / b;
169  if ( itype == 2 )
170  mupisq = 3 * Lambda * Lambda *
171  ( Gamma( 1 + 0.5 * b ) * Gamma( 0.5 * b ) /
172  pow( Gamma( 0.5 + 0.5 * b ), 2 ) -
173  1 );
174 
175  // moment2 for SSFs
176  moment2 = pow( 0.3, 3 );
177 
178  // inputs for total rate (T for Total); use BLNP notebook defaults
179  flagpower = 1;
180  flag2loop = 1;
181 
182  // stuff for the integrator
183  maxLoop = 20;
184  //precision = 1.0e-3;
185  precision = 2.0e-2;
186 
187  // vector of global variables, to pass to static functions (which can't access globals);
188  gvars.push_back( 0.0 ); // 0
189  gvars.push_back( 0.0 ); // 1
190  gvars.push_back( mui ); // 2
191  gvars.push_back( b ); // 3
192  gvars.push_back( Lambda ); // 4
193  gvars.push_back( mBB ); // 5
194  gvars.push_back( mb ); // 6
195  gvars.push_back( wzero ); // 7
196  gvars.push_back( beta0 ); // 8
197  gvars.push_back( beta1 ); // 9
198  gvars.push_back( beta2 ); // 10
199  gvars.push_back( dtype ); // 11
200 
201  // check that there are 3 daughters and 10 arguments
202  checkNDaug( 3 );
203  // A. Volk: check for number of arguments is not necessary
204  //checkNArg(10);
205 
206  if ( _noHybrid )
207  return; // Without hybrid weighting, nothing else to do
208 
209  _bins_mX = std::vector<double>( abs( (int)getArg( 10 ) ) );
210  _bins_q2 = std::vector<double>( abs( (int)getArg( 11 ) ) );
211  _bins_El = std::vector<double>( abs( (int)getArg( 12 ) ) );
212 
214 
215  _nbins = _bins_mX.size() * _bins_q2.size() *
216  _bins_El.size(); // Binning of weight table
217 
218  int expectArgs = nextArg + _bins_mX.size() + _bins_q2.size() +
219  _bins_El.size() + _nbins;
220 
221  if ( getNArg() < expectArgs ) {
222  EvtGenReport( EVTGEN_ERROR, "EvtVubBLNPHybrid" )
223  << " finds " << getNArg() << " arguments, expected " << expectArgs
224  << ". Something is wrong with the tables of weights or thresholds."
225  << "\nWill terminate execution!" << endl;
226  ::abort();
227  }
228 
229  // read bin boundaries from decay.dec
230  for ( auto& b : _bins_mX )
231  b = getArg( nextArg++ );
232  _masscut = _bins_mX[0];
233  for ( auto& b : _bins_q2 )
234  b = getArg( nextArg++ );
235  for ( auto& b : _bins_El )
236  b = getArg( nextArg++ );
237 
238  // read in weights (and rescale to range 0..1)
239  readWeights( nextArg );
240 }
241 
243 {
244  noProbMax();
245 }
246 
248 {
249  int j;
250 
251  EvtParticle *xuhad( nullptr ), *lepton( nullptr ), *neutrino( nullptr );
252  EvtVector4R p4;
253  double EX( 0. ), sh( 0. ), El( 0. ), ml( 0. );
254  double Pp, Pm, Pl, pdf, qsq, mpi, ratemax;
255 
256  double xhigh, xlow, what;
257  double mX;
258 
259  bool rew( true );
260  while ( rew ) {
261  Bmeson->initializePhaseSpace( getNDaug(), getDaugs() );
262 
263  xuhad = Bmeson->getDaug( 0 );
264  lepton = Bmeson->getDaug( 1 );
265  neutrino = Bmeson->getDaug( 2 );
266 
267  mBB = Bmeson->mass();
268  ml = lepton->mass();
269 
270  // get SF value
271  xlow = 0;
272  xhigh = mBB;
273  // the case for alphas = 0 is not considered
274  what = 2 * xhigh;
275  while ( what > xhigh || what < xlow ) {
276  what = findBLNPWhat();
277  what = xlow + what * ( xhigh - xlow );
278  }
279 
280  bool tryit = true;
281 
282  while ( tryit ) {
283  // generate pp between 0 and
284  // Flat(min, max) gives R(max - min) + min, where R = random btwn 0 and 1
285 
286  Pp = EvtRandom::Flat( 0, mBB ); // P+ = EX - |PX|
287  Pl = EvtRandom::Flat( 0, mBB ); // mBB - 2El
288  Pm = EvtRandom::Flat( 0, mBB ); // P- = EX + |PX|
289 
290  sh = Pm * Pp;
291  EX = 0.5 * ( Pm + Pp );
292  qsq = ( mBB - Pp ) * ( mBB - Pm );
293  El = 0.5 * ( mBB - Pl );
294 
295  // Need maximum rate. Waiting for Mr. Paz to give it to me.
296  // Meanwhile, use this.
297  ratemax = 3.0; // From trial and error - most events below 3.0
298 
299  // kinematic bounds (Eq. 2)
300  mpi = 0.14;
301  if ( ( Pp > 0 ) && ( Pp <= Pl ) && ( Pl <= Pm ) && ( Pm < mBB ) &&
302  ( El > ml ) && ( sh > 4 * mpi * mpi ) ) {
303  // Probability of pass proportional to PDF
304  pdf = rate3( Pp, Pl, Pm );
305  double testRan = EvtRandom::Flat( 0., ratemax );
306  if ( pdf >= testRan )
307  tryit = false;
308  }
309  }
310 
311  // compute all kinematic variables needed for reweighting
312  mX = sqrt( sh );
313 
314  // Reweighting in bins of mX, q2, El
315  if ( _nbins > 0 ) {
316  double xran1 = EvtRandom::Flat();
317  double w = 1.0;
318  if ( !_noHybrid )
319  w = getWeight( mX, qsq, El );
320  if ( w >= xran1 )
321  rew = false;
322  } else {
323  rew = false;
324  }
325  }
326  // o.k. we have the three kineamtic variables
327  // now calculate a flat cos Theta_H [-1,1] distribution of the
328  // hadron flight direction w.r.t the B flight direction
329  // because the B is a scalar and should decay isotropic.
330  // Then chose a flat Phi_H [0,2Pi] w.r.t the B flight direction
331  // and and a flat Phi_L [0,2Pi] in the W restframe w.r.t the
332  // W flight direction.
333 
334  double ctH = EvtRandom::Flat( -1, 1 );
335  double phH = EvtRandom::Flat( 0, 2 * M_PI );
336  double phL = EvtRandom::Flat( 0, 2 * M_PI );
337 
338  // now compute the four vectors in the B Meson restframe
339 
340  double ptmp, sttmp;
341  // calculate the hadron 4 vector in the B Meson restframe
342 
343  sttmp = sqrt( 1 - ctH * ctH );
344  ptmp = sqrt( EX * EX - sh );
345  double pHB[4] = {EX, ptmp * sttmp * cos( phH ), ptmp * sttmp * sin( phH ),
346  ptmp * ctH};
347  p4.set( pHB[0], pHB[1], pHB[2], pHB[3] );
348  xuhad->init( getDaug( 0 ), p4 );
349 
350  if ( _storeWhat ) {
351  // cludge to store the hidden parameter what with the decay;
352  // the lifetime of the Xu is abused for this purpose.
353  // tau = 1 ps corresponds to ctau = 0.3 mm -> in order to
354  // stay well below BaBars sensitivity we take what/(10000 GeV).
355  // To extract what back from the StdHepTrk its necessary to get
356  // delta_ctau = Xu->decayVtx()->point().distanceTo(XuDaughter->decayVtx()->point());
357  //
358  // what = delta_ctau * 100000 * Mass_Xu/Momentum_Xu
359  //
360  xuhad->setLifetime( what / 10000. );
361  }
362 
363  // calculate the W 4 vector in the B Meson restrframe
364 
365  double apWB = ptmp;
366  double pWB[4] = {mBB - EX, -pHB[1], -pHB[2], -pHB[3]};
367 
368  // first go in the W restframe and calculate the lepton and
369  // the neutrino in the W frame
370 
371  double mW2 = mBB * mBB + sh - 2 * mBB * EX;
372  double beta = ptmp / pWB[0];
373  double gamma = pWB[0] / sqrt( mW2 );
374 
375  double pLW[4];
376 
377  ptmp = ( mW2 - ml * ml ) / 2 / sqrt( mW2 );
378  pLW[0] = sqrt( ml * ml + ptmp * ptmp );
379 
380  double ctL = ( El - gamma * pLW[0] ) / beta / gamma / ptmp;
381  if ( ctL < -1 )
382  ctL = -1;
383  if ( ctL > 1 )
384  ctL = 1;
385  sttmp = sqrt( 1 - ctL * ctL );
386 
387  // eX' = eZ x eW
388  double xW[3] = {-pWB[2], pWB[1], 0};
389  // eZ' = eW
390  double zW[3] = {pWB[1] / apWB, pWB[2] / apWB, pWB[3] / apWB};
391 
392  double lx = sqrt( xW[0] * xW[0] + xW[1] * xW[1] );
393  for ( j = 0; j < 2; j++ )
394  xW[j] /= lx;
395 
396  // eY' = eZ' x eX'
397  double yW[3] = {-pWB[1] * pWB[3], -pWB[2] * pWB[3],
398  pWB[1] * pWB[1] + pWB[2] * pWB[2]};
399  double ly = sqrt( yW[0] * yW[0] + yW[1] * yW[1] + yW[2] * yW[2] );
400  for ( j = 0; j < 3; j++ )
401  yW[j] /= ly;
402 
403  // p_lep = |p_lep| * ( sin(Theta) * cos(Phi) * eX'
404  // + sin(Theta) * sin(Phi) * eY'
405  // + cos(Theta) * eZ')
406  for ( j = 0; j < 3; j++ )
407  pLW[j + 1] = sttmp * cos( phL ) * ptmp * xW[j] +
408  sttmp * sin( phL ) * ptmp * yW[j] + ctL * ptmp * zW[j];
409 
410  double apLW = ptmp;
411 
412  // boost them back in the B Meson restframe
413 
414  double appLB = beta * gamma * pLW[0] + gamma * ctL * apLW;
415 
416  ptmp = sqrt( El * El - ml * ml );
417  double ctLL = appLB / ptmp;
418 
419  if ( ctLL > 1 )
420  ctLL = 1;
421  if ( ctLL < -1 )
422  ctLL = -1;
423 
424  double pLB[4] = {El, 0, 0, 0};
425  double pNB[4] = {pWB[0] - El, 0, 0, 0};
426 
427  for ( j = 1; j < 4; j++ ) {
428  pLB[j] = pLW[j] + ( ctLL * ptmp - ctL * apLW ) / apWB * pWB[j];
429  pNB[j] = pWB[j] - pLB[j];
430  }
431 
432  p4.set( pLB[0], pLB[1], pLB[2], pLB[3] );
433  lepton->init( getDaug( 1 ), p4 );
434 
435  p4.set( pNB[0], pNB[1], pNB[2], pNB[3] );
436  neutrino->init( getDaug( 2 ), p4 );
437 }
438 
439 double EvtVubBLNPHybrid::rate3( double Pp, double Pl, double Pm )
440 {
441  // rate3 in units of GF^2*Vub^2/pi^3
442 
443  double factor = 1.0 / 16 * ( mBB - Pp ) * U1lo( muh, mui ) *
444  pow( ( Pm - Pp ) / ( mBB - Pp ), alo( muh, mui ) );
445 
446  double doneJS = DoneJS( Pp, Pm, mui );
447  double done1 = Done1( Pp, Pm, mui );
448  double done2 = Done2( Pp, Pm, mui );
449  double done3 = Done3( Pp, Pm, mui );
450 
451  // The EvtSimpsonIntegrator returns zero for bad integrals.
452  // So if any of the integrals are zero (ie bad), return zero.
453  // This will cause pdf = 0, so the event will not pass.
454  // I hope this will not introduce a bias.
455  if ( doneJS * done1 * done2 * done3 == 0.0 ) {
456  //cout << "Integral failed: (Pp, Pm, Pl) = (" << Pp << ", " << Pm << ", " << Pl << ")" << endl;
457  return 0.0;
458  }
459  // if (doneJS*done1*done2*done3 != 0.0) {
460  // cout << "Integral OK: (Pp, Pm, Pl) = (" << Pp << ", " << Pm << ", " << Pl << ")" << endl;
461  //}
462 
463  double f1 = F1( Pp, Pm, muh, mui, mubar, doneJS, done1 );
464  double f2 = F2( Pp, Pm, muh, mui, mubar, done3 );
465  double f3 = F3( Pp, Pm, muh, mui, mubar, done2 );
466  double answer = factor * ( ( mBB + Pl - Pp - Pm ) * ( Pm - Pl ) * f1 +
467  2 * ( Pl - Pp ) * ( Pm - Pl ) * f2 +
468  ( mBB - Pm ) * ( Pm - Pp ) * f3 );
469  return answer;
470 }
471 
472 double EvtVubBLNPHybrid::F1( double Pp, double Pm, double muh, double mui,
473  double mubar, double doneJS, double done1 )
474 {
475  std::vector<double> vars( 12 );
476  vars[0] = Pp;
477  vars[1] = Pm;
478  for ( int j = 2; j < 12; j++ ) {
479  vars[j] = gvars[j];
480  }
481 
482  double y = ( Pm - Pp ) / ( mBB - Pp );
483  double ah = CF * alphas( muh, vars ) / 4 / M_PI;
484  double ai = CF * alphas( mui, vars ) / 4 / M_PI;
485  double abar = CF * alphas( mubar, vars ) / 4 / M_PI;
486  double lambda1 = -mupisq;
487 
488  double t1 = -4 * ai / ( Pp - Lbar ) * ( 2 * log( ( Pp - Lbar ) / mui ) + 1 );
489  double t2 = 1 + dU1nlo( muh, mui ) + anlo( muh, mui ) * log( y );
490  double t3 = -4.0 * pow( log( y * mb / muh ), 2 ) +
491  10.0 * log( y * mb / muh ) - 4.0 * log( y ) -
492  2.0 * log( y ) / ( 1 - y ) - 4.0 * PolyLog( 2, 1 - y ) -
493  M_PI * M_PI / 6.0 - 12.0;
494  double t4 = 2 * pow( log( y * mb * Pp / ( mui * mui ) ), 2 ) -
495  3 * log( y * mb * Pp / ( mui * mui ) ) + 7 - M_PI * M_PI;
496 
497  double t5 = -wS( Pp ) + 2 * t( Pp ) +
498  ( 1.0 / y - 1.0 ) * ( u( Pp ) - v( Pp ) );
499  double t6 = -( lambda1 + 3.0 * lambda2 ) / 3.0 +
500  1.0 / pow( y, 2 ) * ( 4.0 / 3.0 * lambda1 - 2.0 * lambda2 );
501 
502  double shapePp = Shat( Pp, vars );
503 
504  double answer = ( t2 + ah * t3 + ai * t4 ) * shapePp + ai * doneJS +
505  1 / ( mBB - Pp ) * ( flag2 * abar * done1 + flag1 * t5 ) +
506  1 / pow( mBB - Pp, 2 ) * flag3 * shapePp * t6;
507  if ( Pp > Lbar + mui / exp( 0.5 ) )
508  answer = answer + t1;
509  return answer;
510 }
511 
512 double EvtVubBLNPHybrid::F2( double Pp, double Pm, double muh, double /* mui */,
513  double mubar, double done3 )
514 {
515  std::vector<double> vars( 12 );
516  vars[0] = Pp;
517  vars[1] = Pm;
518  for ( int j = 2; j < 12; j++ ) {
519  vars[j] = gvars[j];
520  }
521 
522  double y = ( Pm - Pp ) / ( mBB - Pp );
523  double lambda1 = -mupisq;
524  double ah = CF * alphas( muh, vars ) / 4 / M_PI;
525  double abar = CF * alphas( mubar, vars ) / 4 / M_PI;
526 
527  double t6 = -wS( Pp ) - 2 * t( Pp ) + 1.0 / y * ( t( Pp ) + v( Pp ) );
528  double t7 = 1 / pow( y, 2 ) * ( 2.0 / 3.0 * lambda1 + 4.0 * lambda2 ) -
529  1 / y * ( 2.0 / 3.0 * lambda1 + 3.0 / 2.0 * lambda2 );
530 
531  double shapePp = Shat( Pp, vars );
532 
533  double answer = ah * log( y ) / ( 1 - y ) * shapePp +
534  1 / ( mBB - Pp ) *
535  ( flag2 * abar * 0.5 * done3 + flag1 / y * t6 ) +
536  1.0 / pow( mBB - Pp, 2 ) * flag3 * shapePp * t7;
537  return answer;
538 }
539 
540 double EvtVubBLNPHybrid::F3( double Pp, double Pm, double /*muh*/,
541  double /* mui */, double mubar, double done2 )
542 {
543  std::vector<double> vars( 12 );
544  vars[0] = Pp;
545  vars[1] = Pm;
546  for ( int j = 2; j < 12; j++ ) {
547  vars[j] = gvars[j];
548  }
549 
550  double y = ( Pm - Pp ) / ( mBB - Pp );
551  double lambda1 = -mupisq;
552  double abar = CF * alphas( mubar, vars ) / 4 / M_PI;
553 
554  double t7 = 1.0 / pow( y, 2 ) * ( -2.0 / 3.0 * lambda1 + lambda2 );
555 
556  double shapePp = Shat( Pp, vars );
557 
558  double answer = 1.0 / ( Pm - Pp ) * flag2 * 0.5 * y * abar * done2 +
559  1.0 / pow( mBB - Pp, 2 ) * flag3 * shapePp * t7;
560  return answer;
561 }
562 
563 double EvtVubBLNPHybrid::DoneJS( double Pp, double Pm, double /* mui */ )
564 {
565  std::vector<double> vars( 12 );
566  vars[0] = Pp;
567  vars[1] = Pm;
568  for ( int j = 2; j < 12; j++ ) {
569  vars[j] = gvars[j];
570  }
571 
572  double lowerlim = 0.001 * Pp;
573  double upperlim = ( 1.0 - 0.001 ) * Pp;
574 
575  auto func = EvtItgPtrFunction{&IntJS, lowerlim, upperlim, vars};
576  auto integ = EvtItgSimpsonIntegrator{func, precision, maxLoop};
577  return integ.evaluate( lowerlim, upperlim );
578 }
579 
580 double EvtVubBLNPHybrid::Done1( double Pp, double Pm, double /* mui */ )
581 {
582  std::vector<double> vars( 12 );
583  vars[0] = Pp;
584  vars[1] = Pm;
585  for ( int j = 2; j < 12; j++ ) {
586  vars[j] = gvars[j];
587  }
588 
589  double lowerlim = 0.001 * Pp;
590  double upperlim = ( 1.0 - 0.001 ) * Pp;
591 
592  auto func = EvtItgPtrFunction{&Int1, lowerlim, upperlim, vars};
593  auto integ = EvtItgSimpsonIntegrator{func, precision, maxLoop};
594  return integ.evaluate( lowerlim, upperlim );
595 }
596 
597 double EvtVubBLNPHybrid::Done2( double Pp, double Pm, double /* mui */ )
598 {
599  std::vector<double> vars( 12 );
600  vars[0] = Pp;
601  vars[1] = Pm;
602  for ( int j = 2; j < 12; j++ ) {
603  vars[j] = gvars[j];
604  }
605 
606  double lowerlim = 0.001 * Pp;
607  double upperlim = ( 1.0 - 0.001 ) * Pp;
608 
609  auto func = EvtItgPtrFunction{&Int2, lowerlim, upperlim, vars};
610  auto integ = EvtItgSimpsonIntegrator{func, precision, maxLoop};
611  return integ.evaluate( lowerlim, upperlim );
612 }
613 
614 double EvtVubBLNPHybrid::Done3( double Pp, double Pm, double /* mui */ )
615 {
616  std::vector<double> vars( 12 );
617  vars[0] = Pp;
618  vars[1] = Pm;
619  for ( int j = 2; j < 12; j++ ) {
620  vars[j] = gvars[j];
621  }
622 
623  double lowerlim = 0.001 * Pp;
624  double upperlim = ( 1.0 - 0.001 ) * Pp;
625 
626  auto func = EvtItgPtrFunction{&Int3, lowerlim, upperlim, vars};
627  auto integ = EvtItgSimpsonIntegrator{func, precision, maxLoop};
628  return integ.evaluate( lowerlim, upperlim );
629 }
630 
631 double EvtVubBLNPHybrid::Int1( double what, const std::vector<double>& vars )
632 {
633  return Shat( what, vars ) * g1( what, vars );
634 }
635 
636 double EvtVubBLNPHybrid::Int2( double what, const std::vector<double>& vars )
637 {
638  return Shat( what, vars ) * g2( what, vars );
639 }
640 
641 double EvtVubBLNPHybrid::Int3( double what, const std::vector<double>& vars )
642 {
643  return Shat( what, vars ) * g3( what, vars );
644 }
645 
646 double EvtVubBLNPHybrid::IntJS( double what, const std::vector<double>& vars )
647 {
648  double Pp = vars[0];
649  double Pm = vars[1];
650  double mui = vars[2];
651  double mBB = vars[5];
652  double mb = vars[6];
653  double y = ( Pm - Pp ) / ( mBB - Pp );
654 
655  return 1 / ( Pp - what ) * ( Shat( what, vars ) - Shat( Pp, vars ) ) *
656  ( 4 * log( y * mb * ( Pp - what ) / ( mui * mui ) ) - 3 );
657 }
658 
659 double EvtVubBLNPHybrid::g1( double w, const std::vector<double>& vars )
660 {
661  double Pp = vars[0];
662  double Pm = vars[1];
663  double mBB = vars[5];
664  double y = ( Pm - Pp ) / ( mBB - Pp );
665  double x = ( Pp - w ) / ( mBB - Pp );
666 
667  double q1 = ( 1 + x ) * ( 1 + x ) * y * ( x + y );
668  double q2 = y * ( -9 + 10 * y ) + x * x * ( -12.0 + 13.0 * y ) +
669  2 * x * ( -8.0 + 6 * y + 3 * y * y );
670  double q3 = 4 / x * log( y + y / x );
671  double q4 = 3.0 * pow( x, 4 ) * ( -2.0 + y ) - 2 * pow( y, 3 ) -
672  4 * pow( x, 3 ) * ( 2.0 + y ) - 2 * x * y * y * ( 4 + y ) -
673  x * x * y * ( 12 + 4 * y + y * y );
674  double q5 = log( 1 + y / x );
675 
676  double answer = q2 / q1 - q3 - 2 * q4 * q5 / ( q1 * y * x );
677  return answer;
678 }
679 
680 double EvtVubBLNPHybrid::g2( double w, const std::vector<double>& vars )
681 {
682  double Pp = vars[0];
683  double Pm = vars[1];
684  double mBB = vars[5];
685  double y = ( Pm - Pp ) / ( mBB - Pp );
686  double x = ( Pp - w ) / ( mBB - Pp );
687 
688  double q1 = ( 1 + x ) * ( 1 + x ) * pow( y, 3 ) * ( x + y );
689  double q2 = 10.0 * pow( x, 4 ) + y * y +
690  3.0 * pow( x, 2 ) * y * ( 10.0 + y ) +
691  pow( x, 3 ) * ( 12.0 + 19.0 * y ) +
692  x * y * ( 8.0 + 4.0 * y + y * y );
693  double q3 = 5 * pow( x, 4 ) + 2.0 * y * y +
694  6.0 * pow( x, 3 ) * ( 1.0 + 2.0 * y ) +
695  4.0 * x * y * ( 1 + 2.0 * y ) + x * x * y * ( 18.0 + 5.0 * y );
696  double q4 = log( 1 + y / x );
697 
698  double answer = 2.0 / q1 * ( y * q2 - 2 * x * q3 * q4 );
699  return answer;
700 }
701 
702 double EvtVubBLNPHybrid::g3( double w, const std::vector<double>& vars )
703 {
704  double Pp = vars[0];
705  double Pm = vars[1];
706  double mBB = vars[5];
707  double y = ( Pm - Pp ) / ( mBB - Pp );
708  double x = ( Pp - w ) / ( mBB - Pp );
709 
710  double q1 = ( 1 + x ) * ( 1 + x ) * pow( y, 3 ) * ( x + y );
711  double q2 = 2.0 * pow( y, 3 ) * ( -11.0 + 2.0 * y ) -
712  10.0 * pow( x, 4 ) * ( 6 - 6 * y + y * y ) +
713  x * y * y * ( -94.0 + 29.0 * y + 2.0 * y * y ) +
714  2.0 * x * x * y * ( -72.0 + 18.0 * y + 13.0 * y * y ) -
715  x * x * x * ( 72.0 + 42.0 * y - 70.0 * y * y + 3.0 * y * y * y );
716  double q3 = -6.0 * x * ( -5.0 + y ) * pow( y, 3 ) + 4 * pow( y, 4 ) +
717  5 * pow( x, 5 ) * ( 6 - 6 * y + y * y ) -
718  4 * x * x * y * y * ( -20.0 + 6 * y + y * y ) +
719  pow( x, 3 ) * y * ( 90.0 - 10.0 * y - 28.0 * y * y + y * y * y ) +
720  pow( x, 4 ) * ( 36.0 + 36.0 * y - 50.0 * y * y + 4 * y * y * y );
721  double q4 = log( 1 + y / x );
722 
723  double answer = q2 / q1 + 2 / q1 / y * q3 * q4;
724  return answer;
725 }
726 
727 double EvtVubBLNPHybrid::Shat( double w, const std::vector<double>& vars )
728 {
729  double mui = vars[2];
730  double b = vars[3];
731  double Lambda = vars[4];
732  double wzero = vars[7];
733  int itype = (int)vars[11];
734 
735  double norm = 0.0;
736  double shape = 0.0;
737 
738  if ( itype == 1 ) {
739  double Lambar = ( Lambda / b ) *
740  ( Gamma( 1 + b ) - Gamma( 1 + b, b * wzero / Lambda ) ) /
741  ( Gamma( b ) - Gamma( b, b * wzero / Lambda ) );
742  double muf = wzero - Lambar;
743  double mupisq = 3 * pow( Lambda, 2 ) / pow( b, 2 ) *
744  ( Gamma( 2 + b ) -
745  Gamma( 2 + b, b * wzero / Lambda ) ) /
746  ( Gamma( b ) - Gamma( b, b * wzero / Lambda ) ) -
747  3 * Lambar * Lambar;
748  norm = Mzero( muf, mui, mupisq, vars ) * Gamma( b ) /
749  ( Gamma( b ) - Gamma( b, b * wzero / Lambda ) );
750  shape = pow( b, b ) / Lambda / Gamma( b ) * pow( w / Lambda, b - 1 ) *
751  exp( -b * w / Lambda );
752  }
753 
754  if ( itype == 2 ) {
755  double dcoef = pow( Gamma( 0.5 * ( 1 + b ) ) / Gamma( 0.5 * b ), 2 );
756  double t1 = wzero * wzero * dcoef / ( Lambda * Lambda );
757  double Lambar =
758  Lambda * ( Gamma( 0.5 * ( 1 + b ) ) - Gamma( 0.5 * ( 1 + b ), t1 ) ) /
759  pow( dcoef, 0.5 ) / ( Gamma( 0.5 * b ) - Gamma( 0.5 * b, t1 ) );
760  double muf = wzero - Lambar;
761  double mupisq = 3 * Lambda * Lambda *
762  ( Gamma( 1 + 0.5 * b ) - Gamma( 1 + 0.5 * b, t1 ) ) /
763  dcoef / ( Gamma( 0.5 * b ) - Gamma( 0.5 * b, t1 ) ) -
764  3 * Lambar * Lambar;
765  norm = Mzero( muf, mui, mupisq, vars ) * Gamma( 0.5 * b ) /
766  ( Gamma( 0.5 * b ) -
767  Gamma( 0.5 * b, wzero * wzero * dcoef / ( Lambda * Lambda ) ) );
768  shape = 2 * pow( dcoef, 0.5 * b ) / Lambda / Gamma( 0.5 * b ) *
769  pow( w / Lambda, b - 1 ) *
770  exp( -dcoef * w * w / ( Lambda * Lambda ) );
771  }
772 
773  double answer = norm * shape;
774  return answer;
775 }
776 
777 double EvtVubBLNPHybrid::Mzero( double muf, double mu, double mupisq,
778  const std::vector<double>& vars )
779 {
780  double CF = 4.0 / 3.0;
781  double amu = CF * alphas( mu, vars ) / M_PI;
782  double answer = 1 -
783  amu * ( pow( log( muf / mu ), 2 ) + log( muf / mu ) +
784  M_PI * M_PI / 24.0 ) +
785  amu * ( log( muf / mu ) - 0.5 ) * mupisq / ( 3 * muf * muf );
786  return answer;
787 }
788 
789 double EvtVubBLNPHybrid::wS( double w )
790 {
791  double answer = ( Lbar - w ) * Shat( w, gvars );
792  return answer;
793 }
794 
795 double EvtVubBLNPHybrid::t( double w )
796 {
797  double t1 = -3 * lambda2 / mupisq * ( Lbar - w ) * Shat( w, gvars );
798  double myf = myfunction( w, Lbar, moment2 );
799  double myBIK = myfunctionBIK( w, Lbar, moment2 );
800  double answer = t1;
801 
802  if ( isubl == 1 )
803  answer = t1;
804  if ( isubl == 3 )
805  answer = t1 - myf;
806  if ( isubl == 4 )
807  answer = t1 + myf;
808  if ( isubl == 5 )
809  answer = t1 - myBIK;
810  if ( isubl == 6 )
811  answer = t1 + myBIK;
812 
813  return answer;
814 }
815 
816 double EvtVubBLNPHybrid::u( double w )
817 {
818  double u1 = -2 * ( Lbar - w ) * Shat( w, gvars );
819  double myf = myfunction( w, Lbar, moment2 );
820  double myBIK = myfunctionBIK( w, Lbar, moment2 );
821  double answer = u1;
822 
823  if ( isubl == 1 )
824  answer = u1;
825  if ( isubl == 3 )
826  answer = u1 + myf;
827  if ( isubl == 4 )
828  answer = u1 - myf;
829  if ( isubl == 5 )
830  answer = u1 + myBIK;
831  if ( isubl == 6 )
832  answer = u1 - myBIK;
833 
834  return answer;
835 }
836 
837 double EvtVubBLNPHybrid::v( double w )
838 {
839  double v1 = 3 * lambda2 / mupisq * ( Lbar - w ) * Shat( w, gvars );
840  double myf = myfunction( w, Lbar, moment2 );
841  double myBIK = myfunctionBIK( w, Lbar, moment2 );
842  double answer = v1;
843 
844  if ( isubl == 1 )
845  answer = v1;
846  if ( isubl == 3 )
847  answer = v1 - myf;
848  if ( isubl == 4 )
849  answer = v1 + myf;
850  if ( isubl == 5 )
851  answer = v1 - myBIK;
852  if ( isubl == 6 )
853  answer = v1 + myBIK;
854 
855  return answer;
856 }
857 
858 double EvtVubBLNPHybrid::myfunction( double w, double Lbar, double mom2 )
859 {
860  double bval = 5.0;
861  double x = w / Lbar;
862  double factor = 0.5 * mom2 * pow( bval / Lbar, 3 );
863  double answer = factor * exp( -bval * x ) *
864  ( 1 - 2 * bval * x + 0.5 * bval * bval * x * x );
865  return answer;
866 }
867 
868 double EvtVubBLNPHybrid::myfunctionBIK( double w, double Lbar, double /* mom2 */ )
869 {
870  double aval = 10.0;
871  double normBIK = ( 4 - M_PI ) * M_PI * M_PI / 8 / ( 2 - M_PI ) / aval + 1;
872  double z = 3 * M_PI * w / 8 / Lbar;
873  double q = M_PI * M_PI * 2 * pow( M_PI * aval, 0.5 ) * exp( -aval * z * z ) /
874  ( 4 * M_PI - 8 ) * ( 1 - 2 * pow( aval / M_PI, 0.5 ) * z ) +
875  8 / pow( 1 + z * z, 4 ) *
876  ( z * log( z ) + 0.5 * z * ( 1 + z * z ) -
877  M_PI / 4 * ( 1 - z * z ) );
878  double answer = q / normBIK;
879  return answer;
880 }
881 
882 double EvtVubBLNPHybrid::dU1nlo( double muh, double mui )
883 {
884  double ai = alphas( mui, gvars );
885  double ah = alphas( muh, gvars );
886 
887  double q1 = ( ah - ai ) / ( 4 * M_PI * beta0 );
888  double q2 = log( mb / muh ) * Gamma1 + gp1;
889  double q3 = 4 * beta1 * ( log( mb / muh ) * Gamma0 + gp0 ) +
890  Gamma2 * ( 1 - ai / ah );
891  double q4 = beta1 * beta1 * Gamma0 * ( -1.0 + ai / ah ) /
892  ( 4 * pow( beta0, 3 ) );
893  double q5 = -beta2 * Gamma0 * ( 1.0 + ai / ah ) +
894  beta1 * Gamma1 * ( 3 - ai / ah );
895  double q6 = beta1 * beta1 * Gamma0 * ( ah - ai ) / beta0 -
896  beta2 * Gamma0 * ah + beta1 * Gamma1 * ai;
897 
898  double answer =
899  q1 * ( q2 - q3 / 4 / beta0 + q4 + q5 / ( 4 * beta0 * beta0 ) ) +
900  1 / ( 8 * M_PI * beta0 * beta0 * beta0 ) * log( ai / ah ) * q6;
901  return answer;
902 }
903 
904 double EvtVubBLNPHybrid::U1lo( double muh, double mui )
905 {
906  double epsilon = 0.0;
907  double answer = pow( mb / muh, -2 * aGamma( muh, mui, epsilon ) ) *
908  exp( 2 * Sfun( muh, mui, epsilon ) -
909  2 * agp( muh, mui, epsilon ) );
910  return answer;
911 }
912 
913 double EvtVubBLNPHybrid::Sfun( double mu1, double mu2, double epsilon )
914 {
915  double a1 = alphas( mu1, gvars ) / 4 / M_PI;
916  double a2 = alphas( mu2, gvars ) / alphas( mu1, gvars );
917 
918  double answer = S0( a1, a2 ) + S1( a1, a2 ) + epsilon * S2( a1, a2 );
919  return answer;
920 }
921 
922 double EvtVubBLNPHybrid::S0( double a1, double r )
923 {
924  double answer = -Gamma0 / ( 4.0 * beta0 * beta0 * a1 ) *
925  ( -1.0 + 1.0 / r + log( r ) );
926  return answer;
927 }
928 
929 double EvtVubBLNPHybrid::S1( double /* a1 */, double r )
930 {
931  double answer = Gamma0 / ( 4 * beta0 * beta0 ) *
932  ( 0.5 * log( r ) * log( r ) * beta1 / beta0 +
933  ( Gamma1 / Gamma0 - beta1 / beta0 ) * ( 1 - r + log( r ) ) );
934  return answer;
935 }
936 
937 double EvtVubBLNPHybrid::S2( double a1, double r )
938 {
939  double w1 = pow( beta1, 2 ) / pow( beta0, 2 ) - beta2 / beta0 -
940  beta1 * Gamma1 / ( beta0 * Gamma0 ) + Gamma2 / Gamma0;
941  double w2 = pow( beta1, 2 ) / pow( beta0, 2 ) - beta2 / beta0;
942  double w3 = beta1 * Gamma1 / ( beta0 * Gamma0 ) - beta2 / beta0;
943  double w4 = a1 * Gamma0 / ( 4 * beta0 * beta0 );
944 
945  double answer = w4 *
946  ( -0.5 * pow( 1 - r, 2 ) * w1 + w2 * ( 1 - r ) * log( r ) +
947  w3 * ( 1 - r + r * log( r ) ) );
948  return answer;
949 }
950 
951 double EvtVubBLNPHybrid::aGamma( double mu1, double mu2, double epsilon )
952 {
953  double a1 = alphas( mu1, gvars );
954  double a2 = alphas( mu2, gvars );
955  double answer = Gamma0 / ( 2 * beta0 ) * log( a2 / a1 ) +
956  epsilon * ( a2 - a1 ) / ( 8.0 * M_PI ) *
957  ( Gamma1 / beta0 - beta1 * Gamma0 / ( beta0 * beta0 ) );
958  return answer;
959 }
960 
961 double EvtVubBLNPHybrid::agp( double mu1, double mu2, double epsilon )
962 {
963  double a1 = alphas( mu1, gvars );
964  double a2 = alphas( mu2, gvars );
965  double answer = gp0 / ( 2 * beta0 ) * log( a2 / a1 ) +
966  epsilon * ( a2 - a1 ) / ( 8.0 * M_PI ) *
967  ( gp1 / beta0 - beta1 * gp0 / ( beta0 * beta0 ) );
968  return answer;
969 }
970 
971 double EvtVubBLNPHybrid::alo( double muh, double mui )
972 {
973  return -2.0 * aGamma( muh, mui, 0 );
974 }
975 
976 double EvtVubBLNPHybrid::anlo( double muh, double mui )
977 { // d/depsilon of aGamma
978 
979  double ah = alphas( muh, gvars );
980  double ai = alphas( mui, gvars );
981  double answer = ( ah - ai ) / ( 8.0 * M_PI ) *
982  ( Gamma1 / beta0 - beta1 * Gamma0 / ( beta0 * beta0 ) );
983  return answer;
984 }
985 
986 double EvtVubBLNPHybrid::alphas( double mu, const std::vector<double>& vars )
987 {
988  // Note: Lambda4 and Lambda5 depend on mbMS = 4.25
989  // So if you change mbMS, then you will have to recalculate them.
990 
991  double beta0 = vars[8];
992  double beta1 = vars[9];
993  double beta2 = vars[10];
994 
995  double Lambda4 = 0.298791;
996  double lg = 2 * log( mu / Lambda4 );
997  double answer = 4 * M_PI / ( beta0 * lg ) *
998  ( 1 - beta1 * log( lg ) / ( beta0 * beta0 * lg ) +
999  beta1 * beta1 / ( beta0 * beta0 * beta0 * beta0 * lg * lg ) *
1000  ( ( log( lg ) - 0.5 ) * ( log( lg ) - 0.5 ) -
1001  5.0 / 4.0 + beta2 * beta0 / ( beta1 * beta1 ) ) );
1002  return answer;
1003 }
1004 
1005 double EvtVubBLNPHybrid::PolyLog( double v, double z )
1006 {
1007  if ( z >= 1 )
1008  cout << "Error in EvtVubBLNPHybrid: 2nd argument to PolyLog is >= 1."
1009  << endl;
1010 
1011  double sum = 0.0;
1012  for ( int k = 1; k < 101; k++ ) {
1013  sum = sum + pow( z, k ) / pow( k, v );
1014  }
1015  return sum;
1016 }
1017 
1018 double EvtVubBLNPHybrid::Gamma( double z )
1019 {
1020  if ( z <= 0 )
1021  return 0;
1022 
1023  double v = lgamma( z );
1024  return exp( v );
1025 }
1026 
1027 double EvtVubBLNPHybrid::Gamma( double a, double x )
1028 {
1029  double LogGamma;
1030  /* if (x<0.0 || a<= 0.0) raise(SIGFPE);*/
1031  if ( x < 0.0 )
1032  x = 0.0;
1033  if ( a <= 0.0 )
1034  a = 1.e-50;
1035  LogGamma = lgamma( a );
1036  if ( x < ( a + 1.0 ) )
1037  return gamser( a, x, LogGamma );
1038  else
1039  return 1.0 - gammcf( a, x, LogGamma );
1040 }
1041 
1042 /* ------------------Incomplete gamma function-----------------*/
1043 /* ------------------via its series representation-------------*/
1044 
1045 double EvtVubBLNPHybrid::gamser( double a, double x, double LogGamma )
1046 {
1047  double n;
1048  double ap, del, sum;
1049 
1050  ap = a;
1051  del = sum = 1.0 / a;
1052  for ( n = 1; n < ITMAX; n++ ) {
1053  ++ap;
1054  del *= x / ap;
1055  sum += del;
1056  if ( fabs( del ) < fabs( sum ) * EPS )
1057  return sum * exp( -x + a * log( x ) - LogGamma );
1058  }
1059  raise( SIGFPE );
1060 
1061  return 0.0;
1062 }
1063 
1064 /* ------------------Incomplete gamma function complement------*/
1065 /* ------------------via its continued fraction representation-*/
1066 
1067 double EvtVubBLNPHybrid::gammcf( double a, double x, double LogGamma )
1068 {
1069  double an, b, c, d, del, h;
1070  int i;
1071 
1072  b = x + 1.0 - a;
1073  c = 1.0 / FPMIN;
1074  d = 1.0 / b;
1075  h = d;
1076  for ( i = 1; i < ITMAX; i++ ) {
1077  an = -i * ( i - a );
1078  b += 2.0;
1079  d = an * d + b;
1080  if ( fabs( d ) < FPMIN )
1081  d = FPMIN;
1082  c = b + an / c;
1083  if ( fabs( c ) < FPMIN )
1084  c = FPMIN;
1085  d = 1.0 / d;
1086  del = d * c;
1087  h *= del;
1088  if ( fabs( del - 1.0 ) < EPS )
1089  return exp( -x + a * log( x ) - LogGamma ) * h;
1090  }
1091  raise( SIGFPE );
1092 
1093  return 0.0;
1094 }
1095 
1097 {
1098  double ranNum = EvtRandom::Flat();
1099  double oOverBins = 1.0 / ( float( _pf.size() ) );
1100  int nBinsBelow = 0; // largest k such that I[k] is known to be <= rand
1101  int nBinsAbove = _pf.size(); // largest k such that I[k] is known to be > rand
1102  int middle;
1103 
1104  while ( nBinsAbove > nBinsBelow + 1 ) {
1105  middle = ( nBinsAbove + nBinsBelow + 1 ) >> 1;
1106  if ( ranNum >= _pf[middle] ) {
1107  nBinsBelow = middle;
1108  } else {
1109  nBinsAbove = middle;
1110  }
1111  }
1112 
1113  double bSize = _pf[nBinsAbove] - _pf[nBinsBelow];
1114  // binMeasure is always aProbFunc[nBinsBelow],
1115 
1116  if ( bSize == 0 ) {
1117  // rand lies right in a bin of measure 0. Simply return the center
1118  // of the range of that bin. (Any value between k/N and (k+1)/N is
1119  // equally good, in this rare case.)
1120  return ( nBinsBelow + .5 ) * oOverBins;
1121  }
1122 
1123  double bFract = ( ranNum - _pf[nBinsBelow] ) / bSize;
1124 
1125  return ( nBinsBelow + bFract ) * oOverBins;
1126 }
1127 
1128 double EvtVubBLNPHybrid::getWeight( double mX, double q2, double El )
1129 {
1130  int ibin_mX = -1;
1131  int ibin_q2 = -1;
1132  int ibin_El = -1;
1133 
1134  for ( unsigned i = 0; i < _bins_mX.size(); i++ ) {
1135  if ( mX >= _bins_mX[i] )
1136  ibin_mX = i;
1137  }
1138  for ( unsigned i = 0; i < _bins_q2.size(); i++ ) {
1139  if ( q2 >= _bins_q2[i] )
1140  ibin_q2 = i;
1141  }
1142  for ( unsigned i = 0; i < _bins_El.size(); i++ ) {
1143  if ( El >= _bins_El[i] )
1144  ibin_El = i;
1145  }
1146  int ibin = ibin_mX + ibin_q2 * _bins_mX.size() +
1147  ibin_El * _bins_mX.size() * _bins_q2.size();
1148 
1149  if ( ( ibin_mX < 0 ) || ( ibin_q2 < 0 ) || ( ibin_El < 0 ) ) {
1150  EvtGenReport( EVTGEN_ERROR, "EvtVubHybrid" )
1151  << "Cannot determine hybrid weight "
1152  << "for this event "
1153  << "-> assign weight = 0" << endl;
1154  return 0.0;
1155  }
1156 
1157  return _weights[ibin];
1158 }
1159 
1160 void EvtVubBLNPHybrid::readWeights( int startArg )
1161 {
1162  _weights.resize( _nbins );
1163 
1164  double maxw = 0.0;
1165  for ( auto& w : _weights ) {
1166  w = getArg( startArg++ );
1167  if ( w > maxw )
1168  maxw = w;
1169  }
1170 
1171  if ( maxw == 0 ) {
1172  EvtGenReport( EVTGEN_ERROR, "EvtVubBLNPHybrid" )
1173  << "EvtVub generator expected at least one "
1174  << " weight > 0, but found none! "
1175  << "Will terminate execution!" << endl;
1176  ::abort();
1177  }
1178 
1179  // rescale weights (to be in range 0..1)
1180  for ( auto& w : _weights )
1181  w /= maxw;
1182 }
std::vector< double > _bins_mX
double aGamma(double mu1, double mu2, double epsilon)
double myfunction(double w, double Lbar, double mom2)
std::vector< double > _bins_El
EvtDecayBase * clone() override
double F2(double Pp, double Pm, double muh, double mui, double mubar, double done3)
double Done3(double Pp, double Pm, double mui)
double dU1nlo(double muh, double mui)
double DoneJS(double Pp, double Pm, double mui)
double getSFBLNP(const double &what)
Definition: EvtPFermi.cpp:68
double getArg(unsigned int j)
double Done1(double Pp, double Pm, double mui)
std::vector< double > _weights
double Sfun(double mu1, double mu2, double epsilon)
static double g3(double w, const std::vector< double > &vars)
static double IntJS(double what, const std::vector< double > &vars)
std::ostream & EvtGenReport(EvtGenSeverity severity, const char *facility=0)
Definition: EvtReport.cpp:33
virtual void init(EvtId part_n, const EvtVector4R &p4)=0
double S1(double a1, double r)
void decay(EvtParticle *Bmeson) override
static double Int1(double what, const std::vector< double > &vars)
std::vector< double > _pf
const double a2
std::vector< double > gvars
void readWeights(int startArg=0)
static double Int3(double what, const std::vector< double > &vars)
const double a1
void set(int i, double d)
Definition: EvtVector4R.hh:167
static double Mzero(double muf, double mu, double mupisq, const std::vector< double > &vars)
static double alphas(double mu, const std::vector< double > &vars)
static double Gamma(double z)
double F1(double Pp, double Pm, double muh, double mui, double mubar, double doneJS, double done1)
EvtId * getDaugs()
Definition: EvtDecayBase.hh:66
#define FPMIN
double S0(double a1, double r)
double initializePhaseSpace(unsigned int numdaughter, EvtId *daughters, bool forceResetMasses=false, double poleSize=-1., int whichTwo1=0, int whichTwo2=1)
double getWeight(double mX, double q2, double El)
double PolyLog(double v, double z)
#define EPS
void checkNDaug(int d1, int d2=-1)
double rate3(double Pp, double Pl, double Pm)
static double Flat()
Definition: EvtRandom.cpp:72
#define ITMAX
double abs(const EvtComplex &c)
Definition: EvtComplex.hh:201
double wS(double w)
double mass() const
std::vector< double > _bins_q2
static double gammcf(double a, double x, double LogGamma)
int getNDaug() const
Definition: EvtDecayBase.hh:65
EvtComplex exp(const EvtComplex &c)
Definition: EvtComplex.hh:240
void initProbMax() override
double alo(double muh, double mui)
double v(double w)
void init() override
static double Shat(double w, const std::vector< double > &vars)
double Done2(double Pp, double Pm, double mui)
EvtParticle * getDaug(int i)
Definition: EvtParticle.cpp:91
static double g1(double w, const std::vector< double > &vars)
double F3(double Pp, double Pm, double muh, double mui, double mubar, double done2)
static double Int2(double what, const std::vector< double > &vars)
double agp(double mu1, double mu2, double epsilon)
double myfunctionBIK(double w, double Lbar, double mom2)
static double gamser(double a, double x, double LogGamma)
double u(double w)
static double g2(double w, const std::vector< double > &vars)
double t(double w)
int getNArg() const
Definition: EvtDecayBase.hh:68
double S2(double a1, double r)
std::string getName() override
double anlo(double muh, double mui)
double U1lo(double muh, double mui)
EvtId getDaug(int i) const
Definition: EvtDecayBase.hh:67