Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4BohrFluctuations.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26// $Id$
27//
28// -------------------------------------------------------------------
29//
30// GEANT4 Class file
31//
32//
33// File name: G4BohrFluctuations
34//
35// Author: Vladimir Ivanchenko
36//
37// Creation date: 02.04.2003
38//
39// Modifications:
40//
41// 23-05-03 Add control on parthalogical cases (V.Ivanchenko)
42// 16-10-03 Changed interface to Initialisation (V.Ivanchenko)
43//
44// Class Description: Sampling of Gaussion fluctuations
45//
46// -------------------------------------------------------------------
47//
48
49//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
50//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
51
52#include "G4BohrFluctuations.hh"
54#include "G4SystemOfUnits.hh"
55#include "Randomize.hh"
56#include "G4Poisson.hh"
58
59//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
60
61using namespace std;
62
65 particle(0),
66 minNumberInteractionsBohr(2.0),
67 minFraction(0.2),
68 xmin(0.2),
69 minLoss(0.001*eV)
70{
71 particleMass = proton_mass_c2;
72 chargeSquare = 1.0;
73 kineticEnergy = 0.0;
74 beta2 = 0.0;
75}
76
77//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
78
80{}
81
82//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
83
85{
86 particle = part;
87 particleMass = part->GetPDGMass();
88 G4double q = part->GetPDGCharge()/eplus;
89 chargeSquare = q*q;
90}
91
92//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
93
95 const G4DynamicParticle* dp,
96 G4double& tmax,
97 G4double& length,
98 G4double& meanLoss)
99{
100 if(meanLoss <= minLoss) { return meanLoss; }
101 G4double siga = Dispersion(material,dp,tmax,length);
102 G4double loss = meanLoss;
103
104 G4double navr = meanLoss*meanLoss/siga;
105 //G4cout << "### meanLoss= " << meanLoss << " navr= " << navr << G4endl;
106 if (navr >= minNumberInteractionsBohr) {
107
108 // Increase fluctuations for big fractional energy loss
109 if ( meanLoss > minFraction*kineticEnergy ) {
110 G4double gam = (kineticEnergy - meanLoss)/particleMass + 1.0;
111 G4double b2 = 1.0 - 1.0/(gam*gam);
112 if(b2 < xmin*beta2) b2 = xmin*beta2;
113 G4double x = b2/beta2;
114 G4double x3 = 1.0/(x*x*x);
115 siga *= 0.25*(1.0 + x)*(x3 + (1.0/b2 - 0.5)/(1.0/beta2 - 0.5) );
116 }
117 siga = sqrt(siga);
118 G4double twomeanLoss = meanLoss + meanLoss;
119 //G4cout << "siga= " << siga << " 2edp= " << twomeanLoss <<G4endl;
120
121 if(twomeanLoss < siga) {
122 G4double x;
123 do {
124 loss = twomeanLoss*G4UniformRand();
125 x = (loss - meanLoss)/siga;
126 } while (1.0 - 0.5*x*x < G4UniformRand());
127 } else {
128 do {
129 loss = G4RandGauss::shoot(meanLoss,siga);
130 } while (0.0 > loss || loss > twomeanLoss);
131 }
132
133 // Poisson fluctuations
134 } else {
135 G4double n = (G4double)(G4Poisson(navr));
136 loss = meanLoss*n/navr;
137 }
138 //G4cout << "loss= " << loss << G4endl;
139
140 return loss;
141}
142
143//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
144
146 const G4DynamicParticle* dp,
147 G4double& tmax,
148 G4double& length)
149{
150 if(!particle) { InitialiseMe(dp->GetDefinition()); }
151
152 G4double electronDensity = material->GetElectronDensity();
153 kineticEnergy = dp->GetKineticEnergy();
154 G4double etot = kineticEnergy + particleMass;
155 beta2 = kineticEnergy*(kineticEnergy + 2.0*particleMass)/(etot*etot);
156 G4double siga = (1.0/beta2 - 0.5) * twopi_mc2_rcl2 * tmax * length
157 * electronDensity * chargeSquare;
158
159 return siga;
160}
161
162//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
163
164
G4long G4Poisson(G4double mean)
Definition: G4Poisson.hh:50
double G4double
Definition: G4Types.hh:64
#define G4UniformRand()
Definition: Randomize.hh:53
void InitialiseMe(const G4ParticleDefinition *)
G4double Dispersion(const G4Material *, const G4DynamicParticle *, G4double &, G4double &)
G4BohrFluctuations(const G4String &nam="BohrFluc")
G4double SampleFluctuations(const G4Material *, const G4DynamicParticle *, G4double &, G4double &, G4double &)
G4ParticleDefinition * GetDefinition() const
G4double GetKineticEnergy() const
G4double GetElectronDensity() const
Definition: G4Material.hh:216
G4double GetPDGCharge() const