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 p1 = double(CLHEP::RandPoissonQ::shoot(engine,a1));
239 p2 =
max(0., CLHEP::RandGaussQ::shoot(engine, a2, siga) + 0.5);
241 p2 = double(CLHEP::RandPoissonQ::shoot(engine,a2));
248 loss += (1.-2.*CLHEP::RandFlat::shoot(engine))*e2Fluct;
250 loss += (1.-2.*CLHEP::RandFlat::shoot(engine))*
e1Fluct;
251 if (loss < 0.) loss = 0.0;
258 p3 =
max(0., CLHEP::RandGaussQ::shoot(engine, a3, siga) + 0.5);
260 p3 = double(CLHEP::RandPoissonQ::shoot(engine,a3));
268 double namean = p3*rfac;
270 na = CLHEP::RandGaussQ::shoot(engine, namean, sa);
273 double alfa1 = alfa*vdt::fast_log(alfa)/(alfa-1.);
276 lossc += CLHEP::RandGaussQ::shoot(engine, ea, sea);
282 double w = (tmax-
w2)/tmax;
284 for (
int k=0;
k<nb;
k++) lossc += w2/(1.-w*CLHEP::RandFlat::shoot(engine));
296 a3 = meanLoss*(tmax-
e0)/(tmax*
e0*vdt::fast_log(tmax/
e0));
300 p3 =
max(0., CLHEP::RandGaussQ::shoot(engine, a3, siga) + 0.5);
302 p3 = double(CLHEP::RandPoissonQ::shoot(engine,a3));
305 double w = (tmax-
e0)/tmax;
312 for (
int i=0;
i<ip3;
i++) loss += 1./(1.-w*CLHEP::RandFlat::shoot(engine));
316 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