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"
69 :minNumberInteractionsBohr(10.0),
70 theBohrBeta2(50.0*keV/proton_mass_c2),
112 const double meanLoss,
113 CLHEP::HepRandomEngine* engine)
122 if (meanLoss <
minLoss)
return meanLoss;
126 double beta2 = 1.0 - 1.0/gam2;
127 double gam =
sqrt(gam2);
129 double loss(0.), siga(0.);
135 if ((particleMass > electron_mass_c2) &&
139 double tmaxkine = 2.*electron_mass_c2*beta2*gam2/
140 (1.+massrate*(2.*gam+massrate)) ;
141 if (tmaxkine <= 2.*tmax)
144 siga = (1.0/beta2 - 0.5) * twopi_mc2_rcl2 * tmax * length
147 double twomeanLoss = meanLoss + meanLoss;
148 if (twomeanLoss < siga) {
151 loss = twomeanLoss*CLHEP::RandFlat::shoot(engine);
152 x = (loss - meanLoss)/siga;
153 }
while (1.0 - 0.5*x*x < CLHEP::RandFlat::shoot(engine));
156 loss = CLHEP::RandGaussQ::shoot(engine, meanLoss, siga);
157 }
while (loss < 0. || loss > twomeanLoss);
163 double a1 = 0., a2 = 0., a3 = 0.;
168 double w2 = vdt::fast_log(2.*electron_mass_c2*beta2*gam2)-beta2;
191 double suma = a1+a2+a3;
203 p1 =
max(0., CLHEP::RandGaussQ::shoot(engine, a1, siga) + 0.5);
205 p1 = double(CLHEP::RandPoissonQ::shoot(engine,a1));
211 p2 =
max(0., CLHEP::RandGaussQ::shoot(engine, a2, siga) + 0.5);
213 p2 = double(CLHEP::RandPoissonQ::shoot(engine,a2));
220 loss += (1.-2.*CLHEP::RandFlat::shoot(engine))*e2Fluct;
222 loss += (1.-2.*CLHEP::RandFlat::shoot(engine))*
e1Fluct;
223 if (loss < 0.) loss = 0.0;
230 p3 =
max(0., CLHEP::RandGaussQ::shoot(engine, a3, siga) + 0.5);
232 p3 = double(CLHEP::RandPoissonQ::shoot(engine,a3));
240 double namean = p3*rfac;
242 na = CLHEP::RandGaussQ::shoot(engine, namean, sa);
245 double alfa1 = alfa*vdt::fast_log(alfa)/(alfa-1.);
248 lossc += CLHEP::RandGaussQ::shoot(engine, ea, sea);
254 double w = (tmax-
w2)/tmax;
256 for (
int k=0;
k<nb;
k++) lossc += w2/(1.-w*CLHEP::RandFlat::shoot(engine));
265 a3 = meanLoss*(tmax-
e0)/(tmax*
e0*vdt::fast_log(tmax/
e0));
269 p3 =
max(0., CLHEP::RandGaussQ::shoot(engine, a3, siga) + 0.5);
271 p3 = double(CLHEP::RandPoissonQ::shoot(engine,a3));
274 double w = (tmax-
e0)/tmax;
281 for (
int i=0;
i<ip3;
i++) loss += 1./(1.-w*CLHEP::RandFlat::shoot(engine));
285 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