5 #include "CLHEP/Random/RandFlat.h"
6 #include "CLHEP/Random/RandGaussQ.h"
7 #include "CLHEP/Random/RandPoissonQ.h"
8 #include "CLHEP/Units/GlobalPhysicalConstants.h"
9 #include "CLHEP/Units/GlobalSystemOfUnits.h"
19 : minNumberInteractionsBohr(10.0),
20 theBohrBeta2(50.0 * keV / proton_mass_c2),
57 const double meanLoss,
58 CLHEP::HepRandomEngine *engine) {
71 double beta2 = 1.0 - 1.0 / gam2;
72 double gam =
sqrt(gam2);
74 double loss(0.), siga(0.);
82 double tmaxkine = 2. * electron_mass_c2 * beta2 * gam2 / (1. + massrate * (2. * gam + massrate));
83 if (tmaxkine <= 2. *
tmax) {
86 double twomeanLoss = meanLoss + meanLoss;
87 if (twomeanLoss < siga) {
90 loss = twomeanLoss * CLHEP::RandFlat::shoot(engine);
91 x = (loss - meanLoss) / siga;
92 }
while (1.0 - 0.5 *
x *
x < CLHEP::RandFlat::shoot(engine));
95 loss = CLHEP::RandGaussQ::shoot(engine, meanLoss, siga);
96 }
while (loss < 0. || loss > twomeanLoss);
102 double a1 = 0.,
a2 = 0., a3 = 0.;
107 double w2 = vdt::fast_log(2. * electron_mass_c2 * beta2 * gam2) - beta2;
126 double suma = a1 +
a2 + a3;
131 if ((a1 +
a2) > 0.) {
136 p1 =
max(0., CLHEP::RandGaussQ::shoot(engine, a1, siga) + 0.5);
138 p1 = double(CLHEP::RandPoissonQ::shoot(engine, a1));
144 p2 =
max(0., CLHEP::RandGaussQ::shoot(engine,
a2, siga) + 0.5);
146 p2 = double(CLHEP::RandPoissonQ::shoot(engine,
a2));
153 loss += (1. - 2. * CLHEP::RandFlat::shoot(engine)) *
e2Fluct;
155 loss += (1. - 2. * CLHEP::RandFlat::shoot(engine)) *
e1Fluct;
164 p3 =
max(0., CLHEP::RandGaussQ::shoot(engine, a3, siga) + 0.5);
166 p3 = double(CLHEP::RandPoissonQ::shoot(engine, a3));
174 double namean =
p3 * rfac;
176 na = CLHEP::RandGaussQ::shoot(engine, namean, sa);
179 double alfa1 = alfa * vdt::fast_log(alfa) / (alfa - 1.);
182 lossc += CLHEP::RandGaussQ::shoot(engine, ea, sea);
189 int nb =
int(
p3 - na);
190 for (
int k = 0;
k < nb;
k++)
191 lossc +=
w2 / (1. -
w * CLHEP::RandFlat::shoot(engine));
203 p3 =
max(0., CLHEP::RandGaussQ::shoot(engine, a3, siga) + 0.5);
205 p3 = double(CLHEP::RandPoissonQ::shoot(engine, a3));
215 for (
int i = 0;
i < ip3;
i++)
216 loss += 1. / (1. -
w * CLHEP::RandFlat::shoot(engine));
217 loss *=
e0 * corrfac;
220 loss +=
e0 * (1. - 2. * CLHEP::RandFlat::shoot(engine));