6 #include "CLHEP/Units/GlobalSystemOfUnits.h"
7 #include "CLHEP/Units/GlobalPhysicalConstants.h"
8 #include "CLHEP/Random/RandGaussQ.h"
9 #include "CLHEP/Random/RandPoissonQ.h"
10 #include "CLHEP/Random/RandFlat.h"
19 :minNumberInteractionsBohr(10.0),
20 theBohrBeta2(50.0*keV/proton_mass_c2),
60 const double meanLoss,
61 CLHEP::HepRandomEngine* engine)
70 if (meanLoss <
minLoss)
return meanLoss;
74 double beta2 = 1.0 - 1.0/gam2;
75 double gam =
sqrt(gam2);
77 double loss(0.), siga(0.);
83 if ((particleMass > electron_mass_c2) &&
87 double tmaxkine = 2.*electron_mass_c2*beta2*gam2/
88 (1.+massrate*(2.*gam+massrate)) ;
89 if (tmaxkine <= 2.*tmax)
91 siga = (1.0/beta2 - 0.5) * twopi_mc2_rcl2 * tmax * length
94 double twomeanLoss = meanLoss + meanLoss;
95 if (twomeanLoss < siga) {
98 loss = twomeanLoss*CLHEP::RandFlat::shoot(engine);
99 x = (loss - meanLoss)/siga;
100 }
while (1.0 - 0.5*x*x < CLHEP::RandFlat::shoot(engine));
103 loss = CLHEP::RandGaussQ::shoot(engine, meanLoss, siga);
104 }
while (loss < 0. || loss > twomeanLoss);
110 double a1 = 0., a2 = 0., a3 = 0.;
115 double w2 = vdt::fast_log(2.*electron_mass_c2*beta2*gam2)-beta2;
138 double suma = a1+a2+a3;
150 p1 =
max(0., CLHEP::RandGaussQ::shoot(engine, a1, siga) + 0.5);
152 p1 = double(CLHEP::RandPoissonQ::shoot(engine,a1));
158 p2 =
max(0., CLHEP::RandGaussQ::shoot(engine, a2, siga) + 0.5);
160 p2 = double(CLHEP::RandPoissonQ::shoot(engine,a2));
167 loss += (1.-2.*CLHEP::RandFlat::shoot(engine))*e2Fluct;
169 loss += (1.-2.*CLHEP::RandFlat::shoot(engine))*
e1Fluct;
170 if (loss < 0.) loss = 0.0;
177 p3 =
max(0., CLHEP::RandGaussQ::shoot(engine, a3, siga) + 0.5);
179 p3 = double(CLHEP::RandPoissonQ::shoot(engine,a3));
187 double namean = p3*rfac;
189 na = CLHEP::RandGaussQ::shoot(engine, namean, sa);
192 double alfa1 = alfa*vdt::fast_log(alfa)/(alfa-1.);
195 lossc += CLHEP::RandGaussQ::shoot(engine, ea, sea);
201 double w = (tmax-
w2)/tmax;
203 for (
int k=0;
k<nb;
k++) lossc += w2/(1.-w*CLHEP::RandFlat::shoot(engine));
212 a3 = meanLoss*(tmax-
e0)/(tmax*
e0*vdt::fast_log(tmax/
e0));
216 p3 =
max(0., CLHEP::RandGaussQ::shoot(engine, a3, siga) + 0.5);
218 p3 = double(CLHEP::RandPoissonQ::shoot(engine,a3));
221 double w = (tmax-
e0)/tmax;
228 for (
int i=0;
i<ip3;
i++) loss += 1./(1.-w*CLHEP::RandFlat::shoot(engine));
232 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