Geant4 11.1.1
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")
 
 ~G4UniversalFluctuation () override
 
G4double SampleFluctuations (const G4MaterialCutsCouple *, const G4DynamicParticle *, const G4double, const G4double, const G4double, const G4double) override
 
G4double Dispersion (const G4Material *, const G4DynamicParticle *, const G4double, const G4double, const G4double) override
 
void InitialiseMe (const G4ParticleDefinition *) override
 
void SetParticleAndCharge (const G4ParticleDefinition *, G4double q2) override
 
G4UniversalFluctuationoperator= (const G4UniversalFluctuation &right)=delete
 
 G4UniversalFluctuation (const G4UniversalFluctuation &)=delete
 
- Public Member Functions inherited from G4VEmFluctuationModel
 G4VEmFluctuationModel (const G4String &nam)
 
virtual ~G4VEmFluctuationModel ()
 
virtual G4double SampleFluctuations (const G4MaterialCutsCouple *, const G4DynamicParticle *, const G4double tcut, const G4double tmax, const G4double length, const G4double meanLoss)=0
 
virtual G4double Dispersion (const G4Material *, const G4DynamicParticle *, const G4double tcut, const G4double tmax, const G4double length)=0
 
virtual void InitialiseMe (const G4ParticleDefinition *)
 
virtual void SetParticleAndCharge (const G4ParticleDefinition *, G4double q2)
 
const G4StringGetName () const
 
G4VEmFluctuationModeloperator= (const G4VEmFluctuationModel &right)=delete
 
 G4VEmFluctuationModel (const G4VEmFluctuationModel &)=delete
 

Protected Member Functions

virtual G4double SampleGlandz (CLHEP::HepRandomEngine *rndm, const G4Material *, const G4double tcut)
 
void AddExcitation (CLHEP::HepRandomEngine *rndm, const G4double ax, const G4double ex, G4double &eav, G4double &eloss, G4double &esig2)
 
void SampleGauss (CLHEP::HepRandomEngine *rndm, const G4double eav, const G4double esig2, G4double &eloss)
 

Protected Attributes

G4double particleMass = 0.0
 
G4double m_Inv_particleMass = DBL_MAX
 
G4double m_massrate = DBL_MAX
 
G4double chargeSquare = 1.0
 
G4double ipotFluct = 0.0
 
G4double ipotLogFluct = 0.0
 
G4double e0 = 0.0
 
G4double minNumberInteractionsBohr = 10.0
 
G4double minLoss
 
G4double nmaxCont = 8.0
 
G4double rate = 0.56
 
G4double fw = 4.0
 
G4double a0 = 42.0
 
G4double w2 = 0.0
 
G4double meanLoss = 0.0
 
const G4ParticleDefinitionparticle = nullptr
 
G4doublerndmarray = nullptr
 
G4int sizearray = 30
 

Detailed Description

Definition at line 55 of file G4UniversalFluctuation.hh.

Constructor & Destructor Documentation

◆ G4UniversalFluctuation() [1/2]

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

◆ ~G4UniversalFluctuation()

G4UniversalFluctuation::~G4UniversalFluctuation ( )
override

Definition at line 67 of file G4UniversalFluctuation.cc.

68{
69 delete [] rndmarray;
70}

◆ G4UniversalFluctuation() [2/2]

G4UniversalFluctuation::G4UniversalFluctuation ( const G4UniversalFluctuation )
delete

Member Function Documentation

◆ AddExcitation()

void G4UniversalFluctuation::AddExcitation ( CLHEP::HepRandomEngine rndm,
const G4double  ax,
const G4double  ex,
G4double eav,
G4double eloss,
G4double esig2 
)
inlineprotected

Definition at line 129 of file G4UniversalFluctuation.hh.

133{
134 if(ax > nmaxCont) {
135 eav += ax*ex;
136 esig2 += ax*ex*ex;
137 } else {
138 const G4int p = (G4int)G4Poisson(ax);
139 if(p > 0) { eloss += ((p + 1) - 2.*rndm->flat())*ex; }
140 }
141}
G4long G4Poisson(G4double mean)
Definition: G4Poisson.hh:50
int G4int
Definition: G4Types.hh:85
virtual double flat()=0

Referenced by SampleGlandz(), and G4UrbanFluctuation::SampleGlandz().

◆ Dispersion()

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

Implements G4VEmFluctuationModel.

Definition at line 244 of file G4UniversalFluctuation.cc.

250{
251 if(dp->GetDefinition() != particle) { InitialiseMe(dp->GetDefinition()); }
252 const G4double beta = dp->GetBeta();
253 return (tmax/(beta*beta) - 0.5*tcut) * CLHEP::twopi_mc2_rcl2 * length
254 * material->GetElectronDensity() * chargeSquare;
255}
G4ParticleDefinition * GetDefinition() const
G4double GetBeta() const
G4double GetElectronDensity() const
Definition: G4Material.hh:212
const G4ParticleDefinition * particle
void InitialiseMe(const G4ParticleDefinition *) override

◆ InitialiseMe()

void G4UniversalFluctuation::InitialiseMe ( const G4ParticleDefinition part)
overridevirtual

Reimplemented from G4VEmFluctuationModel.

Definition at line 74 of file G4UniversalFluctuation.cc.

75{
76 particle = part;
77 particleMass = part->GetPDGMass();
78 const G4double q = part->GetPDGCharge()/CLHEP::eplus;
79
80 // Derived quantities
82 m_massrate = CLHEP::electron_mass_c2 * m_Inv_particleMass;
83 chargeSquare = q*q;
84}
G4double GetPDGCharge() const

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

◆ operator=()

G4UniversalFluctuation & G4UniversalFluctuation::operator= ( const G4UniversalFluctuation right)
delete

◆ SampleFluctuations()

G4double G4UniversalFluctuation::SampleFluctuations ( const G4MaterialCutsCouple couple,
const G4DynamicParticle dp,
const G4double  tcut,
const G4double  tmax,
const G4double  length,
const G4double  averageLoss 
)
overridevirtual

Implements G4VEmFluctuationModel.

Definition at line 89 of file G4UniversalFluctuation.cc.

95{
96 // Calculate actual loss from the mean loss.
97 // The model used to get the fluctuations is essentially the same
98 // as in Glandz in Geant3 (Cern program library W5013, phys332).
99 // L. Urban et al. NIM A362, p.416 (1995) and Geant4 Physics Reference Manual
100
101 // shortcut for very small loss or from a step nearly equal to the range
102 // (out of validity of the model)
103 //
104 if (averageLoss < minLoss) { return averageLoss; }
105 meanLoss = averageLoss;
106 const G4double tkin = dp->GetKineticEnergy();
107 //G4cout<< "Emean= "<< meanLoss<< " tmax= "<< tmax<< " L= "<<length<<G4endl;
108
109 if(dp->GetDefinition() != particle) { InitialiseMe(dp->GetDefinition()); }
110
111 CLHEP::HepRandomEngine* rndmEngineF = G4Random::getTheEngine();
112
113 const G4double gam = tkin * m_Inv_particleMass + 1.0;
114 const G4double gam2 = gam*gam;
115 const G4double beta = dp->GetBeta();
116 const G4double beta2 = beta*beta;
117
118 G4double loss(0.), siga(0.);
119
120 const G4Material* material = couple->GetMaterial();
121
122 // Gaussian regime
123 // for heavy particles only and conditions
124 // for Gauusian fluct. has been changed
125 //
126 if (particleMass > CLHEP::electron_mass_c2 &&
127 meanLoss >= minNumberInteractionsBohr*tcut && tmax <= 2.*tcut) {
128
129 siga = std::sqrt((tmax/beta2 - 0.5*tcut)*CLHEP::twopi_mc2_rcl2*
130 length*chargeSquare*material->GetElectronDensity());
131 const G4double sn = meanLoss/siga;
132
133 // thick target case
134 if (sn >= 2.0) {
135
136 const G4double twomeanLoss = meanLoss + meanLoss;
137 do {
138 loss = G4RandGauss::shoot(rndmEngineF, meanLoss, siga);
139 // Loop checking, 03-Aug-2015, Vladimir Ivanchenko
140 } while (0.0 > loss || twomeanLoss < loss);
141
142 // Gamma distribution
143 } else {
144
145 const G4double neff = sn*sn;
146 loss = meanLoss*G4RandGamma::shoot(rndmEngineF, neff, 1.0)/neff;
147 }
148 //G4cout << "Gauss: " << loss << G4endl;
149 return loss;
150 }
151
152 auto ioni = material->GetIonisation();
153 e0 = ioni->GetEnergy0fluct();
154
155 // very small step or low-density material
156 if(tcut <= e0) { return meanLoss; }
157
158 ipotFluct = ioni->GetMeanExcitationEnergy();
159 ipotLogFluct = ioni->GetLogMeanExcEnergy();
160
161 // width correction for small cuts
162 const G4double scaling = std::min(1.+0.5*CLHEP::keV/tcut, 1.50);
163 meanLoss /= scaling;
164
165 w2 = (tcut > ipotFluct) ?
166 G4Log(2.*CLHEP::electron_mass_c2*beta2*gam2)-beta2 : 0.0;
167 return SampleGlandz(rndmEngineF, material, tcut)*scaling;
168}
G4double G4Log(G4double x)
Definition: G4Log.hh:227
G4double GetKineticEnergy() const
const G4Material * GetMaterial() const
G4IonisParamMat * GetIonisation() const
Definition: G4Material.hh:221
virtual G4double SampleGlandz(CLHEP::HepRandomEngine *rndm, const G4Material *, const G4double tcut)

Referenced by G4IonFluctuations::SampleFluctuations().

◆ SampleGauss()

void G4UniversalFluctuation::SampleGauss ( CLHEP::HepRandomEngine rndm,
const G4double  eav,
const G4double  esig2,
G4double eloss 
)
inlineprotected

Definition at line 146 of file G4UniversalFluctuation.hh.

149{
150 G4double x = eav;
151 const G4double sig = std::sqrt(esig2);
152 if(eav < 0.25*sig) {
153 x += (2.*rndm->flat() - 1.)*eav;
154 } else {
155 do {
156 x = G4RandGauss::shoot(rndm, eav, sig);
157 } while (x < 0.0 || x > 2*eav);
158 // Loop checking, 23-Feb-2016, Vladimir Ivanchenko
159 }
160 eloss += x;
161}

Referenced by SampleGlandz(), and G4UrbanFluctuation::SampleGlandz().

◆ SampleGlandz()

G4double G4UniversalFluctuation::SampleGlandz ( CLHEP::HepRandomEngine rndm,
const G4Material ,
const G4double  tcut 
)
protectedvirtual

Reimplemented in G4UrbanFluctuation.

Definition at line 173 of file G4UniversalFluctuation.cc.

176{
177 G4double a1(0.0), a3(0.0);
178 G4double loss = 0.0;
179 G4double e1 = ipotFluct;
180
181 if(tcut > e1) {
182 a1 = meanLoss*(1.-rate)/e1;
183 if(a1 < a0) {
184 const G4double fwnow = 0.1+(fw-0.1)*std::sqrt(a1/a0);
185 a1 /= fwnow;
186 e1 *= fwnow;
187 } else {
188 a1 /= fw;
189 e1 *= fw;
190 }
191 }
192
193 const G4double w1 = tcut/e0;
194 a3 = rate*meanLoss*(tcut - e0)/(e0*tcut*G4Log(w1));
195 if(a1 <= 0.) { a3 /= rate; }
196
197 //'nearly' Gaussian fluctuation if a1>nmaxCont&&a2>nmaxCont&&a3>nmaxCont
198 G4double emean = 0.;
199 G4double sig2e = 0.;
200
201 // excitation of type 1
202 if(a1 > 0.0) { AddExcitation(rndmEngineF, a1, e1, emean, loss, sig2e); }
203
204 if(sig2e > 0.0) { SampleGauss(rndmEngineF, emean, sig2e, loss); }
205
206 // ionisation
207 if(a3 > 0.) {
208 emean = 0.;
209 sig2e = 0.;
210 G4double p3 = a3;
211 G4double alfa = 1.;
212 if(a3 > nmaxCont) {
213 alfa = w1*(nmaxCont+a3)/(w1*nmaxCont+a3);
214 const G4double alfa1 = alfa*G4Log(alfa)/(alfa-1.);
215 const G4double namean = a3*w1*(alfa-1.)/((w1-1.)*alfa);
216 emean += namean*e0*alfa1;
217 sig2e += e0*e0*namean*(alfa-alfa1*alfa1);
218 p3 = a3 - namean;
219 }
220
221 const G4double w3 = alfa*e0;
222 if(tcut > w3) {
223 const G4double w = (tcut-w3)/tcut;
224 const G4int nnb = (G4int)G4Poisson(p3);
225 if(nnb > 0) {
226 if(nnb > sizearray) {
227 sizearray = nnb;
228 delete [] rndmarray;
229 rndmarray = new G4double[nnb];
230 }
231 rndmEngineF->flatArray(nnb, rndmarray);
232 for (G4int k=0; k<nnb; ++k) { loss += w3/(1.-w*rndmarray[k]); }
233 }
234 }
235 if(sig2e > 0.0) { SampleGauss(rndmEngineF, emean, sig2e, loss); }
236 }
237 //G4cout << "### loss=" << loss << G4endl;
238 return loss;
239}
void AddExcitation(CLHEP::HepRandomEngine *rndm, const G4double ax, const G4double ex, G4double &eav, G4double &eloss, G4double &esig2)
void SampleGauss(CLHEP::HepRandomEngine *rndm, const G4double eav, const G4double esig2, G4double &eloss)

Referenced by SampleFluctuations().

◆ SetParticleAndCharge()

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

Reimplemented from G4VEmFluctuationModel.

Definition at line 260 of file G4UniversalFluctuation.cc.

262{
263 if(part != particle) {
264 particle = part;
265 particleMass = part->GetPDGMass();
266
267 // Derived quantities
269 m_massrate = CLHEP::electron_mass_c2 * m_Inv_particleMass;
270 }
271 chargeSquare = q2;
272}

Referenced by G4IonFluctuations::SetParticleAndCharge().

Member Data Documentation

◆ a0

G4double G4UniversalFluctuation::a0 = 42.0
protected

Definition at line 117 of file G4UniversalFluctuation.hh.

Referenced by SampleGlandz(), and G4UrbanFluctuation::SampleGlandz().

◆ chargeSquare

G4double G4UniversalFluctuation::chargeSquare = 1.0
protected

◆ e0

G4double G4UniversalFluctuation::e0 = 0.0
protected

◆ fw

G4double G4UniversalFluctuation::fw = 4.0
protected

Definition at line 116 of file G4UniversalFluctuation.hh.

Referenced by SampleGlandz(), and G4UrbanFluctuation::SampleGlandz().

◆ ipotFluct

G4double G4UniversalFluctuation::ipotFluct = 0.0
protected

◆ ipotLogFluct

G4double G4UniversalFluctuation::ipotLogFluct = 0.0
protected

◆ m_Inv_particleMass

G4double G4UniversalFluctuation::m_Inv_particleMass = DBL_MAX
protected

◆ m_massrate

G4double G4UniversalFluctuation::m_massrate = DBL_MAX
protected

Definition at line 103 of file G4UniversalFluctuation.hh.

Referenced by InitialiseMe(), and SetParticleAndCharge().

◆ meanLoss

G4double G4UniversalFluctuation::meanLoss = 0.0
protected

◆ minLoss

G4double G4UniversalFluctuation::minLoss
protected

Definition at line 113 of file G4UniversalFluctuation.hh.

Referenced by SampleFluctuations().

◆ minNumberInteractionsBohr

G4double G4UniversalFluctuation::minNumberInteractionsBohr = 10.0
protected

Definition at line 112 of file G4UniversalFluctuation.hh.

Referenced by SampleFluctuations().

◆ nmaxCont

G4double G4UniversalFluctuation::nmaxCont = 8.0
protected

◆ particle

const G4ParticleDefinition* G4UniversalFluctuation::particle = nullptr
protected

◆ particleMass

G4double G4UniversalFluctuation::particleMass = 0.0
protected

◆ rate

G4double G4UniversalFluctuation::rate = 0.56
protected

Definition at line 115 of file G4UniversalFluctuation.hh.

Referenced by SampleGlandz(), and G4UrbanFluctuation::SampleGlandz().

◆ rndmarray

G4double* G4UniversalFluctuation::rndmarray = nullptr
protected

◆ sizearray

G4int G4UniversalFluctuation::sizearray = 30
protected

◆ w2

G4double G4UniversalFluctuation::w2 = 0.0
protected

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