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: G4VEmModel.cc,v 1.27 2009/05/26 15:00:49 vnivanch Exp $ |
---|
27 | // GEANT4 tag $Name: geant4-09-03-beta-cand-01 $ |
---|
28 | // |
---|
29 | // ------------------------------------------------------------------- |
---|
30 | // |
---|
31 | // GEANT4 Class file |
---|
32 | // |
---|
33 | // |
---|
34 | // File name: G4VEmModel |
---|
35 | // |
---|
36 | // Author: Vladimir Ivanchenko |
---|
37 | // |
---|
38 | // Creation date: 25.07.2005 |
---|
39 | // |
---|
40 | // Modifications: |
---|
41 | // 25.10.2005 Set default highLimit=100.TeV (V.Ivanchenko) |
---|
42 | // 06.02.2006 add method ComputeMeanFreePath() (mma) |
---|
43 | // 16.02.2009 Move implementations of virtual methods to source (VI) |
---|
44 | // |
---|
45 | // |
---|
46 | // Class Description: |
---|
47 | // |
---|
48 | // Abstract interface to energy loss models |
---|
49 | |
---|
50 | // ------------------------------------------------------------------- |
---|
51 | // |
---|
52 | |
---|
53 | #include "G4VEmModel.hh" |
---|
54 | #include "G4LossTableManager.hh" |
---|
55 | #include "G4ProductionCutsTable.hh" |
---|
56 | #include "G4ParticleChangeForLoss.hh" |
---|
57 | #include "G4ParticleChangeForGamma.hh" |
---|
58 | |
---|
59 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
60 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
61 | |
---|
62 | G4VEmModel::G4VEmModel(const G4String& nam): |
---|
63 | fluc(0), name(nam), lowLimit(0.1*keV), highLimit(100.0*TeV), |
---|
64 | polarAngleLimit(0.0),secondaryThreshold(DBL_MAX),theLPMflag(false), |
---|
65 | pParticleChange(0),nuclearStopping(false), |
---|
66 | currentCouple(0),currentElement(0), |
---|
67 | nsec(5),flagDeexcitation(false) |
---|
68 | { |
---|
69 | xsec.resize(nsec); |
---|
70 | nSelectors = 0; |
---|
71 | G4LossTableManager::Instance()->Register(this); |
---|
72 | } |
---|
73 | |
---|
74 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
75 | |
---|
76 | G4VEmModel::~G4VEmModel() |
---|
77 | { |
---|
78 | G4LossTableManager::Instance()->DeRegister(this); |
---|
79 | G4int n = elmSelectors.size(); |
---|
80 | if(n > 0) { |
---|
81 | for(G4int i=0; i<n; i++) { |
---|
82 | delete elmSelectors[i]; |
---|
83 | } |
---|
84 | } |
---|
85 | } |
---|
86 | |
---|
87 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
88 | |
---|
89 | G4ParticleChangeForLoss* G4VEmModel::GetParticleChangeForLoss() |
---|
90 | { |
---|
91 | G4ParticleChangeForLoss* p = 0; |
---|
92 | if (pParticleChange) { |
---|
93 | p = static_cast<G4ParticleChangeForLoss*>(pParticleChange); |
---|
94 | } else { |
---|
95 | p = new G4ParticleChangeForLoss(); |
---|
96 | } |
---|
97 | return p; |
---|
98 | } |
---|
99 | |
---|
100 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
101 | |
---|
102 | G4ParticleChangeForGamma* G4VEmModel::GetParticleChangeForGamma() |
---|
103 | { |
---|
104 | G4ParticleChangeForGamma* p = 0; |
---|
105 | if (pParticleChange) { |
---|
106 | p = static_cast<G4ParticleChangeForGamma*>(pParticleChange); |
---|
107 | } else { |
---|
108 | p = new G4ParticleChangeForGamma(); |
---|
109 | } |
---|
110 | return p; |
---|
111 | } |
---|
112 | |
---|
113 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
114 | |
---|
115 | void G4VEmModel::InitialiseElementSelectors(const G4ParticleDefinition* p, |
---|
116 | const G4DataVector& cuts) |
---|
117 | { |
---|
118 | // initialise before run |
---|
119 | flagDeexcitation = false; |
---|
120 | |
---|
121 | G4int nbins = G4int(std::log10(highLimit/lowLimit) + 0.5); |
---|
122 | if(nbins < 3) nbins = 3; |
---|
123 | G4bool spline = G4LossTableManager::Instance()->SplineFlag(); |
---|
124 | |
---|
125 | G4ProductionCutsTable* theCoupleTable= |
---|
126 | G4ProductionCutsTable::GetProductionCutsTable(); |
---|
127 | G4int numOfCouples = theCoupleTable->GetTableSize(); |
---|
128 | |
---|
129 | // prepare vector |
---|
130 | if(numOfCouples > nSelectors) elmSelectors.reserve(numOfCouples); |
---|
131 | |
---|
132 | // initialise vector |
---|
133 | for(G4int i=0; i<numOfCouples; i++) { |
---|
134 | const G4MaterialCutsCouple* couple = |
---|
135 | theCoupleTable->GetMaterialCutsCouple(i); |
---|
136 | const G4Material* material = couple->GetMaterial(); |
---|
137 | G4int idx = couple->GetIndex(); |
---|
138 | |
---|
139 | // selector already exist check if should be deleted |
---|
140 | G4bool create = true; |
---|
141 | if(i < nSelectors) { |
---|
142 | if(elmSelectors[i]) { |
---|
143 | if(material == elmSelectors[i]->GetMaterial()) create = false; |
---|
144 | else delete elmSelectors[i]; |
---|
145 | } |
---|
146 | } else { |
---|
147 | nSelectors++; |
---|
148 | elmSelectors.push_back(0); |
---|
149 | } |
---|
150 | if(create) { |
---|
151 | elmSelectors[i] = new G4EmElementSelector(this,material,nbins, |
---|
152 | lowLimit,highLimit,spline); |
---|
153 | } |
---|
154 | elmSelectors[i]->Initialise(p, cuts[idx]); |
---|
155 | //elmSelectors[i]->Dump(p); |
---|
156 | } |
---|
157 | } |
---|
158 | |
---|
159 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
160 | |
---|
161 | G4double G4VEmModel::ComputeDEDXPerVolume(const G4Material*, |
---|
162 | const G4ParticleDefinition*, |
---|
163 | G4double,G4double) |
---|
164 | { |
---|
165 | return 0.0; |
---|
166 | } |
---|
167 | |
---|
168 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
169 | |
---|
170 | G4double G4VEmModel::CrossSectionPerVolume(const G4Material* material, |
---|
171 | const G4ParticleDefinition* p, |
---|
172 | G4double ekin, |
---|
173 | G4double emin, |
---|
174 | G4double emax) |
---|
175 | { |
---|
176 | SetupForMaterial(p, material, ekin); |
---|
177 | G4double cross = 0.0; |
---|
178 | const G4ElementVector* theElementVector = material->GetElementVector(); |
---|
179 | const G4double* theAtomNumDensityVector = material->GetVecNbOfAtomsPerVolume(); |
---|
180 | G4int nelm = material->GetNumberOfElements(); |
---|
181 | if(nelm > nsec) { |
---|
182 | xsec.resize(nelm); |
---|
183 | nsec = nelm; |
---|
184 | } |
---|
185 | for (G4int i=0; i<nelm; i++) { |
---|
186 | cross += theAtomNumDensityVector[i]* |
---|
187 | ComputeCrossSectionPerAtom(p,(*theElementVector)[i],ekin,emin,emax); |
---|
188 | xsec[i] = cross; |
---|
189 | } |
---|
190 | return cross; |
---|
191 | } |
---|
192 | |
---|
193 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
194 | |
---|
195 | G4double G4VEmModel::ComputeCrossSectionPerAtom(const G4ParticleDefinition*, |
---|
196 | G4double, G4double, G4double, |
---|
197 | G4double, G4double) |
---|
198 | { |
---|
199 | return 0.0; |
---|
200 | } |
---|
201 | |
---|
202 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
203 | |
---|
204 | G4double G4VEmModel::MinEnergyCut(const G4ParticleDefinition*, |
---|
205 | const G4MaterialCutsCouple*) |
---|
206 | { |
---|
207 | return 0.0; |
---|
208 | } |
---|
209 | |
---|
210 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
211 | |
---|
212 | G4double G4VEmModel::GetChargeSquareRatio(const G4ParticleDefinition* p, |
---|
213 | const G4Material*, G4double) |
---|
214 | { |
---|
215 | G4double q = p->GetPDGCharge()/CLHEP::eplus; |
---|
216 | return q*q; |
---|
217 | } |
---|
218 | |
---|
219 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
220 | |
---|
221 | G4double G4VEmModel::GetParticleCharge(const G4ParticleDefinition* p, |
---|
222 | const G4Material*, G4double) |
---|
223 | { |
---|
224 | return p->GetPDGCharge(); |
---|
225 | } |
---|
226 | |
---|
227 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
228 | |
---|
229 | void G4VEmModel::CorrectionsAlongStep(const G4MaterialCutsCouple*, |
---|
230 | const G4DynamicParticle*, |
---|
231 | G4double&,G4double&,G4double) |
---|
232 | {} |
---|
233 | |
---|
234 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
235 | |
---|
236 | void G4VEmModel::SampleDeexcitationAlongStep(const G4Material*, |
---|
237 | const G4Track&, |
---|
238 | G4double& ) |
---|
239 | {} |
---|
240 | |
---|
241 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
242 | |
---|
243 | G4double G4VEmModel::MaxSecondaryEnergy(const G4ParticleDefinition*, |
---|
244 | G4double kineticEnergy) |
---|
245 | { |
---|
246 | return kineticEnergy; |
---|
247 | } |
---|
248 | |
---|
249 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
250 | |
---|
251 | void G4VEmModel::DefineForRegion(const G4Region*) |
---|
252 | {} |
---|
253 | |
---|
254 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
255 | |
---|
256 | void G4VEmModel::SetupForMaterial(const G4ParticleDefinition*, |
---|
257 | const G4Material*, G4double) |
---|
258 | {} |
---|
259 | |
---|
260 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|