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 | // |
---|
27 | // $Id: G4CrossSectionIonisationBornPartial.cc,v 1.3 2007/11/09 20:11:04 pia Exp $ |
---|
28 | // GEANT4 tag $Name: $ |
---|
29 | // |
---|
30 | // Contact Author: Maria Grazia Pia (Maria.Grazia.Pia@cern.ch) |
---|
31 | // |
---|
32 | // Reference: TNS Geant4-DNA paper |
---|
33 | // Reference for implementation model: NIM. 155, pp. 145-156, 1978 |
---|
34 | |
---|
35 | // History: |
---|
36 | // ----------- |
---|
37 | // Date Name Modification |
---|
38 | // 28 Apr 2007 M.G. Pia Created in compliance with design described in TNS paper |
---|
39 | // |
---|
40 | // ------------------------------------------------------------------- |
---|
41 | |
---|
42 | // Class description: |
---|
43 | // Geant4-DNA Cross total cross section for electron elastic scattering in water |
---|
44 | // Reference: TNS Geant4-DNA paper |
---|
45 | // S. Chauvie et al., Geant4 physics processes for microdosimetry simulation: |
---|
46 | // design foundation and implementation of the first set of models, |
---|
47 | // IEEE Trans. Nucl. Sci., vol. 54, no. 6, Dec. 2007. |
---|
48 | // Further documentation available from http://www.ge.infn.it/geant4/dna |
---|
49 | |
---|
50 | // ------------------------------------------------------------------- |
---|
51 | |
---|
52 | |
---|
53 | #include "G4CrossSectionIonisationBornPartial.hh" |
---|
54 | #include "G4ParticleDefinition.hh" |
---|
55 | #include "G4Electron.hh" |
---|
56 | #include "G4Proton.hh" |
---|
57 | #include "G4Track.hh" |
---|
58 | #include "G4LogLogInterpolation.hh" |
---|
59 | #include "G4SystemOfUnits.hh" |
---|
60 | |
---|
61 | #include "Randomize.hh" |
---|
62 | |
---|
63 | #include <utility> |
---|
64 | |
---|
65 | G4CrossSectionIonisationBornPartial::G4CrossSectionIonisationBornPartial() |
---|
66 | { |
---|
67 | |
---|
68 | name = "IonisationBorn"; |
---|
69 | |
---|
70 | // Default energy limits (defined for protection against anomalous behaviour only) |
---|
71 | name = "IonisationBornPartial"; |
---|
72 | lowEnergyLimitDefault = 25 * eV; |
---|
73 | highEnergyLimitDefault = 30 * keV; |
---|
74 | |
---|
75 | G4String fileElectron("dna/sigma_ionisation_e_born"); |
---|
76 | G4String fileProton("dna/sigma_ionisation_p_born"); |
---|
77 | |
---|
78 | G4ParticleDefinition* electronDef = G4Electron::ElectronDefinition(); |
---|
79 | G4ParticleDefinition* protonDef = G4Proton::ProtonDefinition(); |
---|
80 | |
---|
81 | G4String electron; |
---|
82 | G4String proton; |
---|
83 | |
---|
84 | // Factor to scale microscopic/macroscopic cross section data in water |
---|
85 | // ---- MGP ---- Hardcoded (taken from prototype code); to be replaced with proper calculation |
---|
86 | G4double scaleFactor = (1.e-22 / 3.343) * m*m; |
---|
87 | |
---|
88 | |
---|
89 | // Data members for electrons |
---|
90 | |
---|
91 | if (electronDef != 0) |
---|
92 | { |
---|
93 | electron = electronDef->GetParticleName(); |
---|
94 | tableFile[electron] = fileElectron; |
---|
95 | |
---|
96 | // Energy limits |
---|
97 | lowEnergyLimit[electron] = 25. * eV; |
---|
98 | highEnergyLimit[electron] = 30. * keV; |
---|
99 | |
---|
100 | // Create data set with electron cross section data and load values stored in file |
---|
101 | G4DNACrossSectionDataSet* tableE = new G4DNACrossSectionDataSet(new G4LogLogInterpolation, eV,scaleFactor ); |
---|
102 | tableE->LoadData(fileElectron); |
---|
103 | |
---|
104 | // Insert key-table pair in map |
---|
105 | tableData[electron] = tableE; |
---|
106 | } |
---|
107 | else |
---|
108 | { |
---|
109 | G4Exception("G4CrossSectionIonisationBornPartial Constructor: electron is not defined"); |
---|
110 | } |
---|
111 | |
---|
112 | // Data members for protons |
---|
113 | |
---|
114 | if (protonDef != 0) |
---|
115 | { |
---|
116 | proton = protonDef->GetParticleName(); |
---|
117 | tableFile[proton] = fileProton; |
---|
118 | |
---|
119 | // Energy limits |
---|
120 | lowEnergyLimit[proton] = 500. * keV; |
---|
121 | highEnergyLimit[proton] = 10. * MeV; |
---|
122 | |
---|
123 | // Create data set with proton cross section data and load values stored in file |
---|
124 | G4DNACrossSectionDataSet* tableP = new G4DNACrossSectionDataSet(new G4LogLogInterpolation, eV,scaleFactor ); |
---|
125 | tableP->LoadData(fileProton); |
---|
126 | |
---|
127 | // Insert key-table pair in map |
---|
128 | tableData[proton] = tableP; |
---|
129 | } |
---|
130 | else |
---|
131 | { |
---|
132 | G4Exception("G4CrossSectionIonisationBornPartial Constructor: proton is not defined"); |
---|
133 | } |
---|
134 | } |
---|
135 | |
---|
136 | |
---|
137 | G4CrossSectionIonisationBornPartial::~G4CrossSectionIonisationBornPartial() |
---|
138 | { |
---|
139 | // Destroy the content of the map |
---|
140 | std::map< G4String,G4DNACrossSectionDataSet*,std::less<G4String> >::iterator pos; |
---|
141 | for (pos = tableData.begin(); pos != tableData.end(); ++pos) |
---|
142 | { |
---|
143 | G4DNACrossSectionDataSet* table = pos->second; |
---|
144 | delete table; |
---|
145 | } |
---|
146 | } |
---|
147 | |
---|
148 | |
---|
149 | G4int G4CrossSectionIonisationBornPartial::RandomSelect(G4double k, const G4String& particle ) |
---|
150 | { |
---|
151 | |
---|
152 | G4int level = 0; |
---|
153 | |
---|
154 | // Retrieve data table corresponding to the current particle type |
---|
155 | |
---|
156 | std::map< G4String,G4DNACrossSectionDataSet*,std::less<G4String> >::iterator pos; |
---|
157 | pos = tableData.find(particle); |
---|
158 | |
---|
159 | if (pos != tableData.end()) |
---|
160 | { |
---|
161 | G4DNACrossSectionDataSet* table = pos->second; |
---|
162 | |
---|
163 | if (table != 0) |
---|
164 | { |
---|
165 | // C-style arrays are used in G4DNACrossSectionDataSet: this design feature was |
---|
166 | // introduced without authorization and should be replaced by the use of STL containers |
---|
167 | |
---|
168 | G4double* valuesBuffer = new G4double[table->NumberOfComponents()]; |
---|
169 | |
---|
170 | const size_t n(table->NumberOfComponents()); |
---|
171 | size_t i(n); |
---|
172 | G4double value = 0.; |
---|
173 | |
---|
174 | while (i>0) |
---|
175 | { |
---|
176 | i--; |
---|
177 | valuesBuffer[i] = table->GetComponent(i)->FindValue(k); |
---|
178 | value += valuesBuffer[i]; |
---|
179 | } |
---|
180 | |
---|
181 | value *= G4UniformRand(); |
---|
182 | |
---|
183 | i = n; |
---|
184 | |
---|
185 | while (i > 0) |
---|
186 | { |
---|
187 | i--; |
---|
188 | |
---|
189 | if (valuesBuffer[i] > value) |
---|
190 | { |
---|
191 | delete[] valuesBuffer; |
---|
192 | return i; |
---|
193 | } |
---|
194 | value -= valuesBuffer[i]; |
---|
195 | } |
---|
196 | |
---|
197 | // It should never end up here |
---|
198 | |
---|
199 | // ---- MGP ---- Is the following line really necessary? |
---|
200 | if (valuesBuffer) delete[] valuesBuffer; |
---|
201 | |
---|
202 | } |
---|
203 | } |
---|
204 | else |
---|
205 | { |
---|
206 | G4Exception("G4CrossSectionIonisationBornPartial: attempting to calculate cross section for wrong particle"); |
---|
207 | } |
---|
208 | |
---|
209 | return level; |
---|
210 | } |
---|
211 | |
---|
212 | |
---|
213 | G4double G4CrossSectionIonisationBornPartial::CrossSection(const G4Track& track ) |
---|
214 | { |
---|
215 | G4double sigma = 0.; |
---|
216 | |
---|
217 | const G4DynamicParticle* particle = track.GetDynamicParticle(); |
---|
218 | G4double k = particle->GetKineticEnergy(); |
---|
219 | |
---|
220 | // Cross section = 0 outside the energy validity limits set in the constructor |
---|
221 | // ---- MGP ---- Better handling of these limits to be set in a following design iteration |
---|
222 | |
---|
223 | G4double lowLim = lowEnergyLimitDefault; |
---|
224 | G4double highLim = highEnergyLimitDefault; |
---|
225 | |
---|
226 | const G4String& particleName = particle->GetDefinition()->GetParticleName(); |
---|
227 | |
---|
228 | // Retrieve energy limits for the current particle type |
---|
229 | |
---|
230 | std::map< G4String,G4double,std::less<G4String> >::iterator pos1; |
---|
231 | pos1 = lowEnergyLimit.find(particleName); |
---|
232 | |
---|
233 | // Lower limit |
---|
234 | if (pos1 != lowEnergyLimit.end()) |
---|
235 | { |
---|
236 | lowLim = pos1->second; |
---|
237 | } |
---|
238 | |
---|
239 | // Upper limit |
---|
240 | std::map< G4String,G4double,std::less<G4String> >::iterator pos2; |
---|
241 | pos2 = highEnergyLimit.find(particleName); |
---|
242 | |
---|
243 | if (pos2 != highEnergyLimit.end()) |
---|
244 | { |
---|
245 | highLim = pos2->second; |
---|
246 | } |
---|
247 | |
---|
248 | // Verify that the current track is within the energy limits of validity of the cross section model |
---|
249 | if (k > lowLim && k < highLim) |
---|
250 | { |
---|
251 | std::map< G4String,G4DNACrossSectionDataSet*,std::less<G4String> >::iterator pos; |
---|
252 | pos = tableData.find(particleName); |
---|
253 | |
---|
254 | if (pos != tableData.end()) |
---|
255 | { |
---|
256 | G4DNACrossSectionDataSet* table = pos->second; |
---|
257 | if (table != 0) |
---|
258 | { |
---|
259 | // ---- MGP ---- Temporary |
---|
260 | // table->PrintData(); |
---|
261 | |
---|
262 | // Cross section |
---|
263 | sigma = table->FindValue(k); |
---|
264 | } |
---|
265 | } |
---|
266 | else |
---|
267 | { |
---|
268 | // The track corresponds to a not pertinent particle |
---|
269 | G4Exception("G4CrossSectionIonisationBornPartial: attempting to calculate cross section for wrong particle"); |
---|
270 | } |
---|
271 | } |
---|
272 | |
---|
273 | return sigma; |
---|
274 | } |
---|
275 | |
---|
276 | |
---|
277 | G4double G4CrossSectionIonisationBornPartial::Sum(G4double /* energy */, const G4String& /* particle */) |
---|
278 | { |
---|
279 | |
---|
280 | return 0; |
---|
281 | } |
---|