56 #include "CLHEP/Units/GlobalSystemOfUnits.h"
57 #include "CLHEP/Units/GlobalPhysicalConstants.h"
58 #include "CLHEP/Random/RandGaussQ.h"
59 #include "CLHEP/Random/RandPoissonQ.h"
60 #include "CLHEP/Random/RandFlat.h"
76 :minNumberInteractionsBohr(10.0),
77 theBohrBeta2(50.0*keV/proton_mass_c2),
119 const double meanLoss,
120 CLHEP::HepRandomEngine* engine)
129 if (meanLoss <
minLoss)
return meanLoss;
139 double beta2 = 1.0 - 1.0/gam2;
140 double gam =
sqrt(gam2);
142 double loss(0.), siga(0.);
148 if ((particleMass > electron_mass_c2) &&
152 double tmaxkine = 2.*electron_mass_c2*beta2*gam2/
153 (1.+massrate*(2.*gam+massrate)) ;
154 if (tmaxkine <= 2.*tmax)
157 siga = (1.0/beta2 - 0.5) * twopi_mc2_rcl2 * tmax * length
160 double twomeanLoss = meanLoss + meanLoss;
161 if (twomeanLoss < siga) {
164 loss = twomeanLoss*CLHEP::RandFlat::shoot(engine);
165 x = (loss - meanLoss)/siga;
166 }
while (1.0 - 0.5*x*x < CLHEP::RandFlat::shoot(engine));
169 loss = CLHEP::RandGaussQ::shoot(engine, meanLoss, siga);
170 }
while (loss < 0. || loss > twomeanLoss);
191 double a1 = 0. , a2 = 0., a3 = 0. ;
196 double w2 = vdt::fast_log(2.*electron_mass_c2*beta2*gam2)-beta2;
219 double suma = a1+a2+a3;
231 p1 =
max(0., CLHEP::RandGaussQ::shoot(engine, a1, siga) + 0.5);
233 CLHEP::RandPoissonQ randPoissonQ(*engine, a1);
234 p1 = double(randPoissonQ.fire());
240 p2 =
max(0., CLHEP::RandGaussQ::shoot(engine, a2, siga) + 0.5);
242 CLHEP::RandPoissonQ randPoissonQ(*engine, a2);
243 p2 = double(randPoissonQ.fire());
250 loss += (1.-2.*CLHEP::RandFlat::shoot(engine))*e2Fluct;
252 loss += (1.-2.*CLHEP::RandFlat::shoot(engine))*
e1Fluct;
253 if (loss < 0.) loss = 0.0;
260 p3 =
max(0., CLHEP::RandGaussQ::shoot(engine, a3, siga) + 0.5);
262 CLHEP::RandPoissonQ randPoissonQ(*engine, a3);
263 p3 = double(randPoissonQ.fire());
271 double namean = p3*rfac;
273 na = CLHEP::RandGaussQ::shoot(engine, namean, sa);
276 double alfa1 = alfa*vdt::fast_log(alfa)/(alfa-1.);
279 lossc += CLHEP::RandGaussQ::shoot(engine, ea, sea);
285 double w = (tmax-
w2)/tmax;
287 for (
int k=0;
k<nb;
k++) lossc += w2/(1.-w*CLHEP::RandFlat::shoot(engine));
299 a3 = meanLoss*(tmax-
e0)/(tmax*
e0*vdt::fast_log(tmax/
e0));
303 p3 =
max(0., CLHEP::RandGaussQ::shoot(engine, a3, siga) + 0.5);
305 CLHEP::RandPoissonQ randPoissonQ(*engine, a3);
306 p3 = double(randPoissonQ.fire());
309 double w = (tmax-
e0)/tmax;
316 for (
int i=0;
i<ip3;
i++) loss += 1./(1.-w*CLHEP::RandFlat::shoot(engine));
320 loss +=
e0*(1.-2.*CLHEP::RandFlat::shoot(engine)) ;
common ppss p3p6s2 common epss epspn46 common const1 w2
~SiG4UniversalFluctuation()
SiG4UniversalFluctuation()
static const double tmax[3]
double SampleFluctuations(const double momentum, const double mass, double &tmax, const double length, const double meanLoss, CLHEP::HepRandomEngine *)
double minNumberInteractionsBohr