Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4UniversalFluctuation Class Reference

#include <G4UniversalFluctuation.hh>

+ Inheritance diagram for G4UniversalFluctuation:

Public Member Functions

 G4UniversalFluctuation (const G4String &nam="UniFluc")
 
virtual ~G4UniversalFluctuation ()
 
virtual G4double SampleFluctuations (const G4Material *, const G4DynamicParticle *, G4double &, G4double &, G4double &)
 
virtual G4double Dispersion (const G4Material *, const G4DynamicParticle *, G4double &, G4double &)
 
virtual void InitialiseMe (const G4ParticleDefinition *)
 
virtual void SetParticleAndCharge (const G4ParticleDefinition *, G4double q2)
 
- Public Member Functions inherited from G4VEmFluctuationModel
 G4VEmFluctuationModel (const G4String &nam)
 
virtual ~G4VEmFluctuationModel ()
 
virtual G4double SampleFluctuations (const G4Material *, const G4DynamicParticle *, G4double &tmax, G4double &length, G4double &meanLoss)=0
 
virtual G4double Dispersion (const G4Material *, const G4DynamicParticle *, G4double &tmax, G4double &length)=0
 
virtual void InitialiseMe (const G4ParticleDefinition *)
 
virtual void SetParticleAndCharge (const G4ParticleDefinition *, G4double q2)
 
G4String GetName () const
 

Detailed Description

Definition at line 62 of file G4UniversalFluctuation.hh.

Constructor & Destructor Documentation

◆ G4UniversalFluctuation()

G4UniversalFluctuation::G4UniversalFluctuation ( const G4String nam = "UniFluc")

Definition at line 83 of file G4UniversalFluctuation.cc.

85 particle(0),
86 minNumberInteractionsBohr(10.0),
87 theBohrBeta2(50.0*keV/proton_mass_c2),
88 minLoss(10.*eV),
89 nmaxCont(16.),
90 rate(0.55),
91 fw(4.)
92{
93 lastMaterial = 0;
94
95 particleMass = chargeSquare = ipotFluct = electronDensity = f1Fluct = f2Fluct
96 = e1Fluct = e2Fluct = e1LogFluct = e2LogFluct = ipotLogFluct = e0 = esmall
97 = e1 = e2 = 0;
98
99}

◆ ~G4UniversalFluctuation()

G4UniversalFluctuation::~G4UniversalFluctuation ( )
virtual

Definition at line 103 of file G4UniversalFluctuation.cc.

104{}

Member Function Documentation

◆ Dispersion()

G4double G4UniversalFluctuation::Dispersion ( const G4Material material,
const G4DynamicParticle dp,
G4double tmax,
G4double length 
)
virtual

Implements G4VEmFluctuationModel.

Definition at line 348 of file G4UniversalFluctuation.cc.

353{
354 if(!particle) { InitialiseMe(dp->GetDefinition()); }
355
356 electronDensity = material->GetElectronDensity();
357
358 G4double gam = (dp->GetKineticEnergy())/particleMass + 1.0;
359 G4double beta2 = 1.0 - 1.0/(gam*gam);
360
361 G4double siga = (1.0/beta2 - 0.5) * twopi_mc2_rcl2 * tmax * length
362 * electronDensity * chargeSquare;
363
364 return siga;
365}
double G4double
Definition: G4Types.hh:64
G4ParticleDefinition * GetDefinition() const
G4double GetKineticEnergy() const
G4double GetElectronDensity() const
Definition: G4Material.hh:216
virtual void InitialiseMe(const G4ParticleDefinition *)

◆ InitialiseMe()

void G4UniversalFluctuation::InitialiseMe ( const G4ParticleDefinition part)
virtual

Reimplemented from G4VEmFluctuationModel.

Definition at line 108 of file G4UniversalFluctuation.cc.

109{
110 particle = part;
111 particleMass = part->GetPDGMass();
112 G4double q = part->GetPDGCharge()/eplus;
113 chargeSquare = q*q;
114}
G4double GetPDGCharge() const

Referenced by Dispersion(), G4IonFluctuations::InitialiseMe(), and SampleFluctuations().

◆ SampleFluctuations()

G4double G4UniversalFluctuation::SampleFluctuations ( const G4Material material,
const G4DynamicParticle dp,
G4double tmax,
G4double length,
G4double averageLoss 
)
virtual

Implements G4VEmFluctuationModel.

Definition at line 118 of file G4UniversalFluctuation.cc.

123{
124 // Calculate actual loss from the mean loss.
125 // The model used to get the fluctuations is essentially the same
126 // as in Glandz in Geant3 (Cern program library W5013, phys332).
127 // L. Urban et al. NIM A362, p.416 (1995) and Geant4 Physics Reference Manual
128
129 // shortcut for very small loss or from a step nearly equal to the range
130 // (out of validity of the model)
131 //
132 G4double meanLoss = averageLoss;
133 G4double tkin = dp->GetKineticEnergy();
134 //G4cout<< "Emean= "<< meanLoss<< " tmax= "<< tmax<< " L= "<<length<<G4endl;
135 if (meanLoss < minLoss) { return meanLoss; }
136
137 if(!particle) { InitialiseMe(dp->GetDefinition()); }
138
139 G4double tau = tkin/particleMass;
140 G4double gam = tau + 1.0;
141 G4double gam2 = gam*gam;
142 G4double beta2 = tau*(tau + 2.0)/gam2;
143
144 G4double loss(0.), siga(0.);
145
146 // Gaussian regime
147 // for heavy particles only and conditions
148 // for Gauusian fluct. has been changed
149 //
150 if ((particleMass > electron_mass_c2) &&
151 (meanLoss >= minNumberInteractionsBohr*tmax))
152 {
153 G4double massrate = electron_mass_c2/particleMass ;
154 G4double tmaxkine = 2.*electron_mass_c2*beta2*gam2/
155 (1.+massrate*(2.*gam+massrate)) ;
156 if (tmaxkine <= 2.*tmax)
157 {
158 electronDensity = material->GetElectronDensity();
159 siga = sqrt((1.0/beta2 - 0.5) * twopi_mc2_rcl2 * tmax * length
160 * electronDensity * chargeSquare);
161
162
163 G4double sn = meanLoss/siga;
164
165 // thick target case
166 if (sn >= 2.0) {
167
168 G4double twomeanLoss = meanLoss + meanLoss;
169 do {
170 loss = G4RandGauss::shoot(meanLoss,siga);
171 } while (0.0 > loss || twomeanLoss < loss);
172
173 // Gamma distribution
174 } else {
175
176 G4double neff = sn*sn;
177 loss = meanLoss*CLHEP::RandGamma::shoot(neff,1.0)/neff;
178 }
179 //G4cout << "Gauss: " << loss << G4endl;
180 return loss;
181 }
182 }
183
184 // Glandz regime : initialisation
185 //
186 if (material != lastMaterial) {
187 f1Fluct = material->GetIonisation()->GetF1fluct();
188 f2Fluct = material->GetIonisation()->GetF2fluct();
189 e1Fluct = material->GetIonisation()->GetEnergy1fluct();
190 e2Fluct = material->GetIonisation()->GetEnergy2fluct();
191 e1LogFluct = material->GetIonisation()->GetLogEnergy1fluct();
192 e2LogFluct = material->GetIonisation()->GetLogEnergy2fluct();
193 ipotFluct = material->GetIonisation()->GetMeanExcitationEnergy();
194 ipotLogFluct = material->GetIonisation()->GetLogMeanExcEnergy();
195 e0 = material->GetIonisation()->GetEnergy0fluct();
196 esmall = 0.5*sqrt(e0*ipotFluct);
197 lastMaterial = material;
198 }
199
200 // very small step or low-density material
201 if(tmax <= e0) { return meanLoss; }
202
203 G4double losstot = 0.;
204 G4int nstep = 1;
205 if(meanLoss < 25.*ipotFluct)
206 {
207 if(G4UniformRand() < 0.04*meanLoss/ipotFluct)
208 { nstep = 1; }
209 else
210 {
211 nstep = 2;
212 meanLoss *= 0.5;
213 }
214 }
215
216 for (G4int istep=0; istep < nstep; ++istep) {
217
218 loss = 0.;
219
220 G4double a1 = 0. , a2 = 0., a3 = 0. ;
221
222 if(tmax > ipotFluct) {
223 G4double w2 = log(2.*electron_mass_c2*beta2*gam2)-beta2;
224
225 if(w2 > ipotLogFluct) {
226 G4double C = meanLoss*(1.-rate)/(w2-ipotLogFluct);
227 a1 = C*f1Fluct*(w2-e1LogFluct)/e1Fluct;
228 if(w2 > e2LogFluct) {
229 a2 = C*f2Fluct*(w2-e2LogFluct)/e2Fluct;
230 }
231 if(a1 < nmaxCont) {
232 //small energy loss
233 G4double sa1 = sqrt(a1);
234 if(G4UniformRand() < exp(-sa1))
235 {
236 e1 = esmall;
237 a1 = meanLoss*(1.-rate)/e1;
238 a2 = 0.;
239 e2 = e2Fluct;
240 }
241 else
242 {
243 a1 = sa1 ;
244 e1 = sa1*e1Fluct;
245 e2 = e2Fluct;
246 }
247
248 } else {
249 //not small energy loss
250 //correction to get better fwhm value
251 a1 /= fw;
252 e1 = fw*e1Fluct;
253 e2 = e2Fluct;
254 }
255 }
256 }
257
258 G4double w1 = tmax/e0;
259 if(tmax > e0) {
260 a3 = rate*meanLoss*(tmax-e0)/(e0*tmax*log(w1));
261 }
262 //'nearly' Gaussian fluctuation if a1>nmaxCont&&a2>nmaxCont&&a3>nmaxCont
263 G4double emean = 0.;
264 G4double sig2e = 0., sige = 0.;
265 G4double p1 = 0., p2 = 0., p3 = 0.;
266
267 // excitation of type 1
268 if(a1 > nmaxCont)
269 {
270 emean += a1*e1;
271 sig2e += a1*e1*e1;
272 }
273 else if(a1 > 0.)
274 {
275 p1 = G4double(G4Poisson(a1));
276 loss += p1*e1;
277 if(p1 > 0.) {
278 loss += (1.-2.*G4UniformRand())*e1;
279 }
280 }
281
282
283 // excitation of type 2
284 if(a2 > nmaxCont)
285 {
286 emean += a2*e2;
287 sig2e += a2*e2*e2;
288 }
289 else if(a2 > 0.)
290 {
291 p2 = G4double(G4Poisson(a2));
292 loss += p2*e2;
293 if(p2 > 0.)
294 loss += (1.-2.*G4UniformRand())*e2;
295 }
296
297 if(emean > 0.)
298 {
299 sige = sqrt(sig2e);
300 loss += max(0.,G4RandGauss::shoot(emean,sige));
301 }
302
303 // ionisation
304 G4double lossc = 0.;
305 if(a3 > 0.) {
306 emean = 0.;
307 sig2e = 0.;
308 sige = 0.;
309 p3 = a3;
310 G4double alfa = 1.;
311 if(a3 > nmaxCont)
312 {
313 alfa = w1*(nmaxCont+a3)/(w1*nmaxCont+a3);
314 G4double alfa1 = alfa*log(alfa)/(alfa-1.);
315 G4double namean = a3*w1*(alfa-1.)/((w1-1.)*alfa);
316 emean += namean*e0*alfa1;
317 sig2e += e0*e0*namean*(alfa-alfa1*alfa1);
318 p3 = a3-namean;
319 }
320
321 G4double w2 = alfa*e0;
322 G4double w = (tmax-w2)/tmax;
323 G4int nb = G4Poisson(p3);
324 if(nb > 0) {
325 for (G4int k=0; k<nb; k++) lossc += w2/(1.-w*G4UniformRand());
326 }
327 }
328
329 if(emean > 0.)
330 {
331 sige = sqrt(sig2e);
332 lossc += max(0.,G4RandGauss::shoot(emean,sige));
333 }
334
335 loss += lossc;
336
337 losstot += loss;
338 }
339 //G4cout << "Vavilov: " << losstot << " Nstep= " << nstep << G4endl;
340
341 return losstot;
342
343}
G4long G4Poisson(G4double mean)
Definition: G4Poisson.hh:50
int G4int
Definition: G4Types.hh:66
#define G4UniformRand()
Definition: Randomize.hh:53
static double shoot()
G4double GetF2fluct() const
G4double GetLogEnergy1fluct() const
G4double GetLogEnergy2fluct() const
G4double GetMeanExcitationEnergy() const
G4double GetF1fluct() const
G4double GetEnergy2fluct() const
G4double GetEnergy1fluct() const
G4double GetEnergy0fluct() const
G4double GetLogMeanExcEnergy() const
G4IonisParamMat * GetIonisation() const
Definition: G4Material.hh:225

Referenced by G4IonFluctuations::SampleFluctuations().

◆ SetParticleAndCharge()

void G4UniversalFluctuation::SetParticleAndCharge ( const G4ParticleDefinition part,
G4double  q2 
)
virtual

Reimplemented from G4VEmFluctuationModel.

Definition at line 370 of file G4UniversalFluctuation.cc.

372{
373 if(part != particle) {
374 particle = part;
375 particleMass = part->GetPDGMass();
376 }
377 chargeSquare = q2;
378}

Referenced by G4IonFluctuations::SetParticleAndCharge().


The documentation for this class was generated from the following files: