43 #include "CLHEP/Random/RandFlat.h"
44 #include "CLHEP/Random/RandGaussQ.h"
45 #include "CLHEP/Random/RandPoisson.h"
46 #include "CLHEP/Units/GlobalPhysicalConstants.h"
47 #include "CLHEP/Units/GlobalSystemOfUnits.h"
52 #include <gsl/gsl_fit.h>
67 : minNumberInteractionsBohr(10.0),
68 theBohrBeta2(50.0 * keV / proton_mass_c2),
69 minLoss(0.000001 * eV),
97 const double momentum,
const double mass,
double &
tmax,
const double length,
const double meanLoss) {
115 double beta2 = 1.0 - 1.0 / gam2;
125 loss = CLHEP::RandGaussQ::shoot(meanLoss, siga);
126 }
while (loss < 0. || loss > 2. * meanLoss);
132 double suma, w1,
w2,
C, lossc,
w;
136 double corrfac, na, alfa, rfac, namean, sa, alfa1, ea, sea;
140 w2 =
log(2. * electron_mass_c2 * (gam2 - 1.0));
167 p3 =
std::max(0,
int(CLHEP::RandGaussQ::shoot(a3, siga) + 0.5));
169 p3 = CLHEP::RandPoisson::shoot(a3);
176 loss += (1. - 2. * CLHEP::RandFlat::shoot()) *
e0;
185 p3 =
std::max(0,
int(CLHEP::RandGaussQ::shoot(a3, siga) + 0.5));
187 p3 = CLHEP::RandPoisson::shoot(a3);
200 for (
int i = 0;
i <
p3;
i++)
201 loss += 1. / (1. -
w * CLHEP::RandFlat::shoot());
202 loss *=
e0 * corrfac;
213 p1 =
std::max(0,
int(CLHEP::RandGaussQ::shoot(a1, siga) + 0.5));
215 p1 = CLHEP::RandPoisson::shoot(a1);
222 p2 =
std::max(0,
int(CLHEP::RandGaussQ::shoot(
a2, siga) + 0.5));
224 p2 = CLHEP::RandPoisson::shoot(
a2);
232 loss += (1. - 2. * CLHEP::RandFlat::shoot()) *
e2Fluct;
234 loss += (1. - 2. * CLHEP::RandFlat::shoot()) *
e1Fluct;
240 p3 =
std::max(0,
int(CLHEP::RandGaussQ::shoot(a3, siga) + 0.5));
242 p3 = CLHEP::RandPoisson::shoot(a3);
253 na = CLHEP::RandGaussQ::shoot(namean, sa);
256 alfa1 = alfa *
log(alfa) / (alfa - 1.);
259 lossc += CLHEP::RandGaussQ::shoot(ea, sea);
263 nb =
int(
float(
p3) - na);
267 for (
int k = 0;
k < nb;
k++)
268 lossc +=
w2 / (1. -
w * CLHEP::RandFlat::shoot());