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: G4DNAChampionElasticModel.cc,v 1.5 2009/04/29 17:25:21 sincerti Exp $ |
---|
27 | // GEANT4 tag $Name: geant4-09-03-beta-cand-01 $ |
---|
28 | // |
---|
29 | |
---|
30 | #include "G4DNAChampionElasticModel.hh" |
---|
31 | |
---|
32 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
33 | |
---|
34 | using namespace std; |
---|
35 | |
---|
36 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
37 | |
---|
38 | G4DNAChampionElasticModel::G4DNAChampionElasticModel(const G4ParticleDefinition*, |
---|
39 | const G4String& nam) |
---|
40 | :G4VEmModel(nam),isInitialised(false) |
---|
41 | { |
---|
42 | |
---|
43 | killBelowEnergy = 8.23*eV; // Minimum e- energy for energy loss by excitation |
---|
44 | lowEnergyLimit = 0 * eV; |
---|
45 | lowEnergyLimitOfModel = 7 * eV; // The model lower energy is 7 eV |
---|
46 | highEnergyLimit = 10 * MeV; |
---|
47 | SetLowEnergyLimit(lowEnergyLimit); |
---|
48 | SetHighEnergyLimit(highEnergyLimit); |
---|
49 | |
---|
50 | verboseLevel= 0; |
---|
51 | // Verbosity scale: |
---|
52 | // 0 = nothing |
---|
53 | // 1 = warning for energy non-conservation |
---|
54 | // 2 = details of energy budget |
---|
55 | // 3 = calculation of cross sections, file openings, sampling of atoms |
---|
56 | // 4 = entering in methods |
---|
57 | |
---|
58 | G4cout << "Champion Elastic model is constructed " << G4endl |
---|
59 | << "Energy range: " |
---|
60 | << lowEnergyLimit / eV << " eV - " |
---|
61 | << highEnergyLimit / MeV << " MeV" |
---|
62 | << G4endl; |
---|
63 | |
---|
64 | } |
---|
65 | |
---|
66 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
67 | |
---|
68 | G4DNAChampionElasticModel::~G4DNAChampionElasticModel() |
---|
69 | { |
---|
70 | // For total cross section |
---|
71 | |
---|
72 | std::map< G4String,G4DNACrossSectionDataSet*,std::less<G4String> >::iterator pos; |
---|
73 | for (pos = tableData.begin(); pos != tableData.end(); ++pos) |
---|
74 | { |
---|
75 | G4DNACrossSectionDataSet* table = pos->second; |
---|
76 | delete table; |
---|
77 | } |
---|
78 | |
---|
79 | // For final state |
---|
80 | |
---|
81 | eVecm.clear(); |
---|
82 | |
---|
83 | } |
---|
84 | |
---|
85 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
86 | |
---|
87 | void G4DNAChampionElasticModel::Initialise(const G4ParticleDefinition* /*particle*/, |
---|
88 | const G4DataVector& /*cuts*/) |
---|
89 | { |
---|
90 | |
---|
91 | if (verboseLevel > 3) |
---|
92 | G4cout << "Calling G4DNAChampionElasticModel::Initialise()" << G4endl; |
---|
93 | |
---|
94 | // Energy limits |
---|
95 | |
---|
96 | if (LowEnergyLimit() < lowEnergyLimit) |
---|
97 | { |
---|
98 | G4cout << "G4DNAChampionElasticModel: low energy limit increased from " << |
---|
99 | LowEnergyLimit()/eV << " eV to " << lowEnergyLimit/eV << " eV" << G4endl; |
---|
100 | SetLowEnergyLimit(lowEnergyLimit); |
---|
101 | } |
---|
102 | |
---|
103 | if (HighEnergyLimit() > highEnergyLimit) |
---|
104 | { |
---|
105 | G4cout << "G4DNAChampionElasticModel: high energy limit decreased from " << |
---|
106 | HighEnergyLimit()/MeV << " MeV to " << highEnergyLimit/MeV << " MeV" << G4endl; |
---|
107 | SetHighEnergyLimit(highEnergyLimit); |
---|
108 | } |
---|
109 | |
---|
110 | // Reading of data files |
---|
111 | |
---|
112 | G4double scaleFactor = 1e-16*cm*cm; |
---|
113 | |
---|
114 | G4String fileElectron("dna/sigma_elastic_e_champion"); |
---|
115 | |
---|
116 | G4ParticleDefinition* electronDef = G4Electron::ElectronDefinition(); |
---|
117 | G4String electron; |
---|
118 | |
---|
119 | if (electronDef != 0) |
---|
120 | { |
---|
121 | // For total cross section |
---|
122 | |
---|
123 | electron = electronDef->GetParticleName(); |
---|
124 | |
---|
125 | tableFile[electron] = fileElectron; |
---|
126 | |
---|
127 | G4DNACrossSectionDataSet* tableE = new G4DNACrossSectionDataSet(new G4LogLogInterpolation, eV,scaleFactor ); |
---|
128 | tableE->LoadData(fileElectron); |
---|
129 | tableData[electron] = tableE; |
---|
130 | |
---|
131 | // For final state |
---|
132 | |
---|
133 | char *path = getenv("G4LEDATA"); |
---|
134 | |
---|
135 | if (!path) |
---|
136 | G4Exception("G4FinalStateElasticChampion::Initialise: G4LEDATA environment variable not set"); |
---|
137 | |
---|
138 | std::ostringstream eFullFileName; |
---|
139 | eFullFileName << path << "/dna/sigmadiff_elastic_e_champion.dat"; |
---|
140 | std::ifstream eDiffCrossSection(eFullFileName.str().c_str()); |
---|
141 | |
---|
142 | if (!eDiffCrossSection) G4Exception("G4DNAChampionElasticModel::Initialise: error opening electron DATA FILE"); |
---|
143 | |
---|
144 | eTdummyVec.push_back(0.); |
---|
145 | |
---|
146 | while(!eDiffCrossSection.eof()) |
---|
147 | { |
---|
148 | double tDummy; |
---|
149 | double eDummy; |
---|
150 | eDiffCrossSection>>tDummy>>eDummy; |
---|
151 | |
---|
152 | // SI : mandatory eVecm initialization |
---|
153 | if (tDummy != eTdummyVec.back()) |
---|
154 | { |
---|
155 | eTdummyVec.push_back(tDummy); |
---|
156 | eVecm[tDummy].push_back(0.); |
---|
157 | } |
---|
158 | |
---|
159 | eDiffCrossSection>>eDiffCrossSectionData[tDummy][eDummy]; |
---|
160 | |
---|
161 | // SI : only if not end of file reached ! |
---|
162 | if (!eDiffCrossSection.eof()) eDiffCrossSectionData[tDummy][eDummy]*=scaleFactor; |
---|
163 | |
---|
164 | if (eDummy != eVecm[tDummy].back()) eVecm[tDummy].push_back(eDummy); |
---|
165 | |
---|
166 | } |
---|
167 | |
---|
168 | // End final state |
---|
169 | |
---|
170 | } |
---|
171 | else G4Exception("G4DNAChampionElasticModel::Initialise: electron is not defined"); |
---|
172 | |
---|
173 | if (verboseLevel > 2) |
---|
174 | G4cout << "Loaded cross section files for Champion Elastic model" << G4endl; |
---|
175 | |
---|
176 | G4cout << "Champion Elastic model is initialized " << G4endl |
---|
177 | << "Energy range: " |
---|
178 | << LowEnergyLimit() / eV << " eV - " |
---|
179 | << HighEnergyLimit() / MeV << " MeV" |
---|
180 | << G4endl; |
---|
181 | |
---|
182 | if(!isInitialised) |
---|
183 | { |
---|
184 | isInitialised = true; |
---|
185 | |
---|
186 | if(pParticleChange) |
---|
187 | fParticleChangeForGamma = reinterpret_cast<G4ParticleChangeForGamma*>(pParticleChange); |
---|
188 | else |
---|
189 | fParticleChangeForGamma = new G4ParticleChangeForGamma(); |
---|
190 | } |
---|
191 | |
---|
192 | // InitialiseElementSelectors(particle,cuts); |
---|
193 | |
---|
194 | // Test if water material |
---|
195 | |
---|
196 | flagMaterialIsWater= false; |
---|
197 | densityWater = 0; |
---|
198 | |
---|
199 | const G4ProductionCutsTable* theCoupleTable = G4ProductionCutsTable::GetProductionCutsTable(); |
---|
200 | |
---|
201 | if(theCoupleTable) |
---|
202 | { |
---|
203 | G4int numOfCouples = theCoupleTable->GetTableSize(); |
---|
204 | |
---|
205 | if(numOfCouples>0) |
---|
206 | { |
---|
207 | for (G4int i=0; i<numOfCouples; i++) |
---|
208 | { |
---|
209 | const G4MaterialCutsCouple* couple = theCoupleTable->GetMaterialCutsCouple(i); |
---|
210 | const G4Material* material = couple->GetMaterial(); |
---|
211 | |
---|
212 | size_t j = material->GetNumberOfElements(); |
---|
213 | while (j>0) |
---|
214 | { |
---|
215 | j--; |
---|
216 | const G4Element* element(material->GetElement(j)); |
---|
217 | if (element->GetZ() == 8.) |
---|
218 | { |
---|
219 | G4double density = material->GetAtomicNumDensityVector()[j]; |
---|
220 | if (density > 0.) |
---|
221 | { |
---|
222 | flagMaterialIsWater = true; |
---|
223 | densityWater = density; |
---|
224 | |
---|
225 | if (verboseLevel > 3) |
---|
226 | G4cout << "Water material is found with density(cm^-3)=" << density/(cm*cm*cm) << G4endl; |
---|
227 | } |
---|
228 | } |
---|
229 | } |
---|
230 | |
---|
231 | } |
---|
232 | } // if(numOfCouples>0) |
---|
233 | |
---|
234 | } // if (theCoupleTable) |
---|
235 | |
---|
236 | } |
---|
237 | |
---|
238 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
239 | |
---|
240 | G4double G4DNAChampionElasticModel::CrossSectionPerVolume(const G4Material*, |
---|
241 | const G4ParticleDefinition* p, |
---|
242 | G4double ekin, |
---|
243 | G4double, |
---|
244 | G4double) |
---|
245 | { |
---|
246 | if (verboseLevel > 3) |
---|
247 | G4cout << "Calling CrossSectionPerVolume() of G4DNAChampionElasticModel" << G4endl; |
---|
248 | |
---|
249 | // Calculate total cross section for model |
---|
250 | |
---|
251 | G4double sigma=0; |
---|
252 | |
---|
253 | if (flagMaterialIsWater) |
---|
254 | { |
---|
255 | const G4String& particleName = p->GetParticleName(); |
---|
256 | |
---|
257 | if (ekin < highEnergyLimit) |
---|
258 | { |
---|
259 | //SI : XS must not be zero otherwise sampling of secondaries method ignored |
---|
260 | if (ekin < lowEnergyLimitOfModel) ekin = lowEnergyLimitOfModel; |
---|
261 | // |
---|
262 | |
---|
263 | std::map< G4String,G4DNACrossSectionDataSet*,std::less<G4String> >::iterator pos; |
---|
264 | pos = tableData.find(particleName); |
---|
265 | |
---|
266 | if (pos != tableData.end()) |
---|
267 | { |
---|
268 | G4DNACrossSectionDataSet* table = pos->second; |
---|
269 | if (table != 0) |
---|
270 | { |
---|
271 | sigma = table->FindValue(ekin); |
---|
272 | } |
---|
273 | } |
---|
274 | else |
---|
275 | { |
---|
276 | G4Exception("G4DNAChampionElasticModel::ComputeCrossSectionPerVolume: attempting to calculate cross section for wrong particle"); |
---|
277 | } |
---|
278 | } |
---|
279 | |
---|
280 | if (verboseLevel > 3) |
---|
281 | { |
---|
282 | G4cout << "---> Kinetic energy(eV)=" << ekin/eV << G4endl; |
---|
283 | G4cout << " - Cross section per water molecule (cm^2)=" << sigma/cm/cm << G4endl; |
---|
284 | G4cout << " - Cross section per water molecule (cm^-1)=" << sigma*densityWater/(1./cm) << G4endl; |
---|
285 | } |
---|
286 | |
---|
287 | } // if (flagMaterialIsWater) |
---|
288 | |
---|
289 | return sigma*densityWater; |
---|
290 | } |
---|
291 | |
---|
292 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
293 | |
---|
294 | void G4DNAChampionElasticModel::SampleSecondaries(std::vector<G4DynamicParticle*>* /*fvect*/, |
---|
295 | const G4MaterialCutsCouple* /*couple*/, |
---|
296 | const G4DynamicParticle* aDynamicElectron, |
---|
297 | G4double, |
---|
298 | G4double) |
---|
299 | { |
---|
300 | |
---|
301 | if (verboseLevel > 3) |
---|
302 | G4cout << "Calling SampleSecondaries() of G4DNAChampionElasticModel" << G4endl; |
---|
303 | |
---|
304 | G4double electronEnergy0 = aDynamicElectron->GetKineticEnergy(); |
---|
305 | |
---|
306 | if (electronEnergy0 < killBelowEnergy) |
---|
307 | { |
---|
308 | fParticleChangeForGamma->ProposeTrackStatus(fStopAndKill); |
---|
309 | fParticleChangeForGamma->ProposeLocalEnergyDeposit(electronEnergy0); |
---|
310 | return ; |
---|
311 | } |
---|
312 | |
---|
313 | if (electronEnergy0>= killBelowEnergy && electronEnergy0 < highEnergyLimit) |
---|
314 | { |
---|
315 | G4double cosTheta = RandomizeCosTheta(electronEnergy0); |
---|
316 | |
---|
317 | G4double phi = 2. * pi * G4UniformRand(); |
---|
318 | |
---|
319 | G4ThreeVector zVers = aDynamicElectron->GetMomentumDirection(); |
---|
320 | G4ThreeVector xVers = zVers.orthogonal(); |
---|
321 | G4ThreeVector yVers = zVers.cross(xVers); |
---|
322 | |
---|
323 | G4double xDir = std::sqrt(1. - cosTheta*cosTheta); |
---|
324 | G4double yDir = xDir; |
---|
325 | xDir *= std::cos(phi); |
---|
326 | yDir *= std::sin(phi); |
---|
327 | |
---|
328 | G4ThreeVector zPrimeVers((xDir*xVers + yDir*yVers + cosTheta*zVers)); |
---|
329 | |
---|
330 | fParticleChangeForGamma->ProposeMomentumDirection(zPrimeVers.unit()) ; |
---|
331 | |
---|
332 | fParticleChangeForGamma->SetProposedKineticEnergy(electronEnergy0); |
---|
333 | } |
---|
334 | |
---|
335 | } |
---|
336 | |
---|
337 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
338 | |
---|
339 | G4double G4DNAChampionElasticModel::DifferentialCrossSection |
---|
340 | (G4ParticleDefinition * particleDefinition, G4double k, G4double theta) |
---|
341 | { |
---|
342 | |
---|
343 | G4double sigma = 0.; |
---|
344 | G4double valueT1 = 0; |
---|
345 | G4double valueT2 = 0; |
---|
346 | G4double valueE21 = 0; |
---|
347 | G4double valueE22 = 0; |
---|
348 | G4double valueE12 = 0; |
---|
349 | G4double valueE11 = 0; |
---|
350 | G4double xs11 = 0; |
---|
351 | G4double xs12 = 0; |
---|
352 | G4double xs21 = 0; |
---|
353 | G4double xs22 = 0; |
---|
354 | |
---|
355 | //SI : ensure the correct computation of cross section at the 180*deg limit |
---|
356 | if (theta==180.) theta=theta-1e-9; |
---|
357 | |
---|
358 | if (particleDefinition == G4Electron::ElectronDefinition()) |
---|
359 | { |
---|
360 | std::vector<double>::iterator t2 = std::upper_bound(eTdummyVec.begin(),eTdummyVec.end(), k); |
---|
361 | std::vector<double>::iterator t1 = t2-1; |
---|
362 | |
---|
363 | std::vector<double>::iterator e12 = std::upper_bound(eVecm[(*t1)].begin(),eVecm[(*t1)].end(), theta); |
---|
364 | std::vector<double>::iterator e11 = e12-1; |
---|
365 | |
---|
366 | std::vector<double>::iterator e22 = std::upper_bound(eVecm[(*t2)].begin(),eVecm[(*t2)].end(), theta); |
---|
367 | std::vector<double>::iterator e21 = e22-1; |
---|
368 | |
---|
369 | valueT1 =*t1; |
---|
370 | valueT2 =*t2; |
---|
371 | valueE21 =*e21; |
---|
372 | valueE22 =*e22; |
---|
373 | valueE12 =*e12; |
---|
374 | valueE11 =*e11; |
---|
375 | |
---|
376 | xs11 = eDiffCrossSectionData[valueT1][valueE11]; |
---|
377 | xs12 = eDiffCrossSectionData[valueT1][valueE12]; |
---|
378 | xs21 = eDiffCrossSectionData[valueT2][valueE21]; |
---|
379 | xs22 = eDiffCrossSectionData[valueT2][valueE22]; |
---|
380 | |
---|
381 | } |
---|
382 | |
---|
383 | G4double xsProduct = xs11 * xs12 * xs21 * xs22; |
---|
384 | |
---|
385 | if (xs11==0 || xs12==0 ||xs21==0 ||xs22==0) return (0.); |
---|
386 | |
---|
387 | if (xsProduct != 0.) |
---|
388 | { |
---|
389 | sigma = QuadInterpolator( valueE11, valueE12, |
---|
390 | valueE21, valueE22, |
---|
391 | xs11, xs12, |
---|
392 | xs21, xs22, |
---|
393 | valueT1, valueT2, |
---|
394 | k, theta ); |
---|
395 | } |
---|
396 | |
---|
397 | return sigma; |
---|
398 | } |
---|
399 | |
---|
400 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
401 | |
---|
402 | G4double G4DNAChampionElasticModel::LinLogInterpolate(G4double e1, |
---|
403 | G4double e2, |
---|
404 | G4double e, |
---|
405 | G4double xs1, |
---|
406 | G4double xs2) |
---|
407 | { |
---|
408 | G4double d1 = std::log(xs1); |
---|
409 | G4double d2 = std::log(xs2); |
---|
410 | G4double value = std::exp(d1 + (d2 - d1)*(e - e1)/ (e2 - e1)); |
---|
411 | return value; |
---|
412 | } |
---|
413 | |
---|
414 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
415 | |
---|
416 | G4double G4DNAChampionElasticModel::LogLogInterpolate(G4double e1, |
---|
417 | G4double e2, |
---|
418 | G4double e, |
---|
419 | G4double xs1, |
---|
420 | G4double xs2) |
---|
421 | { |
---|
422 | G4double a = (std::log10(xs2)-std::log10(xs1)) / (std::log10(e2)-std::log10(e1)); |
---|
423 | G4double b = std::log10(xs2) - a*std::log10(e2); |
---|
424 | G4double sigma = a*std::log10(e) + b; |
---|
425 | G4double value = (std::pow(10.,sigma)); |
---|
426 | return value; |
---|
427 | } |
---|
428 | |
---|
429 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
430 | |
---|
431 | G4double G4DNAChampionElasticModel::QuadInterpolator(G4double e11, G4double e12, |
---|
432 | G4double e21, G4double e22, |
---|
433 | G4double xs11, G4double xs12, |
---|
434 | G4double xs21, G4double xs22, |
---|
435 | G4double t1, G4double t2, |
---|
436 | G4double t, G4double e) |
---|
437 | { |
---|
438 | // Log-Log |
---|
439 | /* |
---|
440 | G4double interpolatedvalue1 = LogLogInterpolate(e11, e12, e, xs11, xs12); |
---|
441 | G4double interpolatedvalue2 = LogLogInterpolate(e21, e22, e, xs21, xs22); |
---|
442 | G4double value = LogLogInterpolate(t1, t2, t, interpolatedvalue1, interpolatedvalue2); |
---|
443 | */ |
---|
444 | |
---|
445 | // Lin-Log |
---|
446 | G4double interpolatedvalue1 = LinLogInterpolate(e11, e12, e, xs11, xs12); |
---|
447 | G4double interpolatedvalue2 = LinLogInterpolate(e21, e22, e, xs21, xs22); |
---|
448 | G4double value = LinLogInterpolate(t1, t2, t, interpolatedvalue1, interpolatedvalue2); |
---|
449 | return value; |
---|
450 | } |
---|
451 | |
---|
452 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
453 | |
---|
454 | G4double G4DNAChampionElasticModel::RandomizeCosTheta(G4double k) |
---|
455 | { |
---|
456 | // ***** Similar method as for screened Rutherford scattering |
---|
457 | |
---|
458 | G4int iMax=180; |
---|
459 | G4double max=0; |
---|
460 | G4double tmp=0; |
---|
461 | |
---|
462 | // Look for maximum : |
---|
463 | for (G4int i=0; i<iMax; i++) |
---|
464 | { |
---|
465 | tmp = DifferentialCrossSection(G4Electron::ElectronDefinition(),k/eV,G4double(i)*180./(iMax-1)); |
---|
466 | if (tmp>max) max = tmp; |
---|
467 | } |
---|
468 | |
---|
469 | G4double oneOverMax=0; |
---|
470 | if (max!=0) oneOverMax = 1./max; |
---|
471 | |
---|
472 | G4double cosTheta = 0.; |
---|
473 | G4double fCosTheta = 0.; |
---|
474 | |
---|
475 | do |
---|
476 | { |
---|
477 | cosTheta = 2. * G4UniformRand() - 1.; |
---|
478 | fCosTheta = oneOverMax * DifferentialCrossSection(G4Electron::ElectronDefinition(),k/eV,std::acos(cosTheta)*180./pi); |
---|
479 | } |
---|
480 | while (fCosTheta < G4UniformRand()); |
---|
481 | |
---|
482 | if (verboseLevel > 3) |
---|
483 | { |
---|
484 | G4cout << "---> Cos(theta)=" << cosTheta << G4endl; |
---|
485 | } |
---|
486 | |
---|
487 | return cosTheta; |
---|
488 | } |
---|