Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 25 26 #include "G4DNAUeharaScreenedRutherfordElastic 26 #include "G4DNAUeharaScreenedRutherfordElasticModel.hh" 27 #include "G4PhysicalConstants.hh" 27 #include "G4PhysicalConstants.hh" 28 #include "G4SystemOfUnits.hh" 28 #include "G4SystemOfUnits.hh" 29 #include "G4DNAMolecularMaterial.hh" 29 #include "G4DNAMolecularMaterial.hh" 30 #include "G4Exp.hh" 30 #include "G4Exp.hh" 31 31 32 //....oooOO0OOooo........oooOO0OOooo........oo 32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 33 33 34 using namespace std; 34 using namespace std; 35 35 36 // #define UEHARA_VERBOSE 36 // #define UEHARA_VERBOSE 37 37 38 //....oooOO0OOooo........oooOO0OOooo........oo 38 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 39 39 40 G4DNAUeharaScreenedRutherfordElasticModel:: 40 G4DNAUeharaScreenedRutherfordElasticModel:: 41 G4DNAUeharaScreenedRutherfordElasticModel(cons 41 G4DNAUeharaScreenedRutherfordElasticModel(const G4ParticleDefinition*, 42 cons 42 const G4String& nam) : G4VEmModel(nam) 43 { 43 { 44 // Energy limits of the models 44 // Energy limits of the models 45 intermediateEnergyLimit = 200. * eV; 45 intermediateEnergyLimit = 200. * eV; 46 iLowEnergyLimit = 9.*eV; 46 iLowEnergyLimit = 9.*eV; 47 iHighEnergyLimit = 1.*MeV; 47 iHighEnergyLimit = 1.*MeV; 48 48 49 verboseLevel = 0; 49 verboseLevel = 0; 50 // Verbosity scale: 50 // Verbosity scale: 51 // 0 = nothing 51 // 0 = nothing 52 // 1 = warning for energy non-conservation 52 // 1 = warning for energy non-conservation 53 // 2 = details of energy budget 53 // 2 = details of energy budget 54 // 3 = calculation of cross sections, file o 54 // 3 = calculation of cross sections, file openings, sampling of atoms 55 // 4 = entering in methods 55 // 4 = entering in methods 56 56 57 fasterCode = false; 57 fasterCode = false; 58 } 58 } 59 59 60 //....oooOO0OOooo........oooOO0OOooo........oo 60 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 61 61 62 void 62 void 63 G4DNAUeharaScreenedRutherfordElasticModel:: 63 G4DNAUeharaScreenedRutherfordElasticModel:: 64 Initialise(const G4ParticleDefinition* particl 64 Initialise(const G4ParticleDefinition* particle, 65 const G4DataVector& /*cuts*/) 65 const G4DataVector& /*cuts*/) 66 { 66 { 67 if(isInitialised) { return; } 67 if(isInitialised) { return; } 68 if (verboseLevel > 3) 68 if (verboseLevel > 3) 69 { 69 { 70 } 70 } 71 71 72 if(particle->GetParticleName() != "e-") 72 if(particle->GetParticleName() != "e-") 73 { 73 { 74 G4Exception("*** WARNING: the G4DNAUeharaS 74 G4Exception("*** WARNING: the G4DNAUeharaScreenedRutherfordElasticModel is " 75 "not intented to be used with 75 "not intented to be used with another particle than the electron", 76 "",FatalException,"") ; 76 "",FatalException,"") ; 77 } 77 } 78 78 79 79 80 if( verboseLevel>1 ) 80 if( verboseLevel>1 ) 81 { 81 { 82 G4cout << "G4DNAUeharaScreenedRutherfordEl 82 G4cout << "G4DNAUeharaScreenedRutherfordElasticModel::Initialise()" 83 << G4endl; 83 << G4endl; 84 G4cout << "Energy range: " 84 G4cout << "Energy range: " 85 << LowEnergyLimit() / eV << " eV - " 85 << LowEnergyLimit() / eV << " eV - " 86 << HighEnergyLimit() / MeV << " MeV" 86 << HighEnergyLimit() / MeV << " MeV" 87 << G4endl; 87 << G4endl; 88 } 88 } 89 // Constants for final state by Brenner & Za 89 // Constants for final state by Brenner & Zaider 90 // Note: the instantiation must be placed af 90 // Note: the instantiation must be placed after if (isInitialised) 91 91 92 betaCoeff= 92 betaCoeff= 93 { 93 { 94 7.51525, 94 7.51525, 95 -0.41912, 95 -0.41912, 96 7.2017E-3, 96 7.2017E-3, 97 -4.646E-5, 97 -4.646E-5, 98 1.02897E-7}; 98 1.02897E-7}; 99 99 100 deltaCoeff= 100 deltaCoeff= 101 { 101 { 102 2.9612, 102 2.9612, 103 -0.26376, 103 -0.26376, 104 4.307E-3, 104 4.307E-3, 105 -2.6895E-5, 105 -2.6895E-5, 106 5.83505E-8}; 106 5.83505E-8}; 107 107 108 gamma035_10Coeff= 108 gamma035_10Coeff= 109 { 109 { 110 -1.7013, 110 -1.7013, 111 -1.48284, 111 -1.48284, 112 0.6331, 112 0.6331, 113 -0.10911, 113 -0.10911, 114 8.358E-3, 114 8.358E-3, 115 -2.388E-4}; 115 -2.388E-4}; 116 116 117 gamma10_100Coeff = 117 gamma10_100Coeff = 118 { 118 { 119 -3.32517, 119 -3.32517, 120 0.10996, 120 0.10996, 121 -4.5255E-3, 121 -4.5255E-3, 122 5.8372E-5, 122 5.8372E-5, 123 -2.4659E-7}; 123 -2.4659E-7}; 124 124 125 gamma100_200Coeff= 125 gamma100_200Coeff= 126 { 126 { 127 2.4775E-2, 127 2.4775E-2, 128 -2.96264E-5, 128 -2.96264E-5, 129 -1.20655E-7}; 129 -1.20655E-7}; 130 130 131 // Initialize water density pointer 131 // Initialize water density pointer 132 fpWaterDensity = 132 fpWaterDensity = 133 G4DNAMolecularMaterial::Instance()-> 133 G4DNAMolecularMaterial::Instance()-> 134 GetNumMolPerVolTableFor(G4Material::GetMat 134 GetNumMolPerVolTableFor(G4Material::GetMaterial("G4_WATER")); 135 135 136 fParticleChangeForGamma = GetParticleChangeF 136 fParticleChangeForGamma = GetParticleChangeForGamma(); 137 isInitialised = true; 137 isInitialised = true; 138 } 138 } 139 139 140 //....oooOO0OOooo........oooOO0OOooo........oo 140 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 141 141 142 G4double 142 G4double 143 G4DNAUeharaScreenedRutherfordElasticModel:: 143 G4DNAUeharaScreenedRutherfordElasticModel:: 144 CrossSectionPerVolume(const G4Material* materi 144 CrossSectionPerVolume(const G4Material* material, 145 const G4ParticleDefiniti 145 const G4ParticleDefinition* /*particleDefinition*/, 146 G4double ekin, 146 G4double ekin, 147 G4double, 147 G4double, 148 G4double) 148 G4double) 149 { 149 { 150 #ifdef UEHARA_VERBOSE 150 #ifdef UEHARA_VERBOSE 151 if (verboseLevel > 3) 151 if (verboseLevel > 3) 152 { 152 { 153 G4cout 153 G4cout 154 << "Calling CrossSectionPerVolume() of G4D 154 << "Calling CrossSectionPerVolume() of G4DNAUeharaScreenedRutherfordElasticModel" 155 << G4endl; 155 << G4endl; 156 } 156 } 157 #endif 157 #endif 158 158 159 // Calculate total cross section for model 159 // Calculate total cross section for model 160 160 161 G4double sigma = 0.; 161 G4double sigma = 0.; 162 if(ekin < iLowEnergyLimit || ekin > iHighEne 162 if(ekin < iLowEnergyLimit || ekin > iHighEnergyLimit) { return sigma; } 163 163 164 G4double waterDensity = (*fpWaterDensity)[ma 164 G4double waterDensity = (*fpWaterDensity)[material->GetIndex()]; 165 165 166 G4double z = 7.42; // FROM PMB 37 (1992) 184 166 G4double z = 7.42; // FROM PMB 37 (1992) 1841-1858 p1842 167 G4double n = ScreeningFactor(ekin,z); 167 G4double n = ScreeningFactor(ekin,z); 168 G4double crossSection = RutherfordCrossSecti 168 G4double crossSection = RutherfordCrossSection(ekin, z); 169 sigma = pi * crossSection / (n * (n + 1.)); 169 sigma = pi * crossSection / (n * (n + 1.)); 170 170 171 #ifdef UEHARA_VERBOSE 171 #ifdef UEHARA_VERBOSE 172 if (verboseLevel > 2) 172 if (verboseLevel > 2) 173 { 173 { 174 G4cout << "_______________________________ 174 G4cout << "__________________________________" << G4endl; 175 G4cout << "=== G4DNAUeharaScreenedRutherfo 175 G4cout << "=== G4DNAUeharaScreenedRutherfordElasticModel - XS INFO START" 176 << G4endl; 176 << G4endl; 177 G4cout << "=== Kinetic energy(eV)=" << eki 177 G4cout << "=== Kinetic energy(eV)=" << ekin/eV 178 << " particle : " << particleDefini 178 << " particle : " << particleDefinition->GetParticleName() << G4endl; 179 G4cout << "=== Cross section per water mol 179 G4cout << "=== Cross section per water molecule (cm^2)=" << sigma/cm/cm 180 << G4endl; 180 << G4endl; 181 G4cout << "=== Cross section per water mol 181 G4cout << "=== Cross section per water molecule (cm^-1)=" 182 << sigma*waterDensity/(1./cm) << G4 182 << sigma*waterDensity/(1./cm) << G4endl; 183 G4cout << "=== G4DNAUeharaScreenedRutherfo 183 G4cout << "=== G4DNAUeharaScreenedRutherfordElasticModel - XS INFO END" 184 << G4endl; 184 << G4endl; 185 } 185 } 186 #endif 186 #endif 187 187 188 return sigma*waterDensity; 188 return sigma*waterDensity; 189 } 189 } 190 190 191 //....oooOO0OOooo........oooOO0OOooo........oo 191 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 192 192 193 G4double 193 G4double 194 G4DNAUeharaScreenedRutherfordElasticModel::Rut 194 G4DNAUeharaScreenedRutherfordElasticModel::RutherfordCrossSection(G4double k, 195 195 G4double z) 196 { 196 { 197 // 197 // 198 // e^4 198 // e^4 / K + m_e c^2 \^2 199 // sigma_Ruth(K) = Z (Z+1) ----------------- 199 // sigma_Ruth(K) = Z (Z+1) -------------------- | --------------------- | 200 // (4 pi epsilon_0) 200 // (4 pi epsilon_0)^2 \ K * (K + 2 m_e c^2) / 201 // 201 // 202 // Where K is the electron non-relativistic 202 // Where K is the electron non-relativistic kinetic energy 203 // 203 // 204 // NIM 155, pp. 145-156, 1978 204 // NIM 155, pp. 145-156, 1978 205 205 206 G4double length = (e_squared * (k + electron 206 G4double length = (e_squared * (k + electron_mass_c2)) 207 / (4 * pi * epsilon0 * k * (k + 2 * elec 207 / (4 * pi * epsilon0 * k * (k + 2 * electron_mass_c2)); 208 G4double cross = z * (z + 1) * length * leng 208 G4double cross = z * (z + 1) * length * length; 209 209 210 return cross; 210 return cross; 211 } 211 } 212 212 213 //....oooOO0OOooo........oooOO0OOooo........oo 213 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 214 214 215 G4double G4DNAUeharaScreenedRutherfordElasticM 215 G4double G4DNAUeharaScreenedRutherfordElasticModel::ScreeningFactor(G4double k, 216 216 G4double z) 217 { 217 { 218 // From Phys Med Biol 37 (1992) 1841-1858 218 // From Phys Med Biol 37 (1992) 1841-1858 219 // Z=7.42 for water 219 // Z=7.42 for water 220 220 221 const G4double constK(1.7E-5); 221 const G4double constK(1.7E-5); 222 222 223 G4double beta2; 223 G4double beta2; 224 beta2 = 1. - 1. / ((1. + k / electron_mass_c 224 beta2 = 1. - 1. / ((1. + k / electron_mass_c2) * (1. + k / electron_mass_c2)); 225 225 226 G4double etaC; 226 G4double etaC; 227 if (k < 50 * keV) 227 if (k < 50 * keV) 228 etaC = 1.198; 228 etaC = 1.198; 229 else 229 else 230 etaC = 1.13 + 3.76 * (z * z / (137 * 137 * 230 etaC = 1.13 + 3.76 * (z * z / (137 * 137 * beta2)); 231 231 232 G4double numerator = etaC * constK * std::po 232 G4double numerator = etaC * constK * std::pow(z, 2. / 3.); 233 233 234 k /= electron_mass_c2; 234 k /= electron_mass_c2; 235 235 236 G4double denominator = k * (2 + k); 236 G4double denominator = k * (2 + k); 237 237 238 G4double value = 0.; 238 G4double value = 0.; 239 if (denominator > 0.) 239 if (denominator > 0.) 240 value = numerator / denominator; // form 3 240 value = numerator / denominator; // form 3 241 241 242 return value; 242 return value; 243 } 243 } 244 244 245 //....oooOO0OOooo........oooOO0OOooo........oo 245 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 246 246 247 void 247 void 248 G4DNAUeharaScreenedRutherfordElasticModel:: 248 G4DNAUeharaScreenedRutherfordElasticModel:: 249 SampleSecondaries(std::vector<G4DynamicParticl 249 SampleSecondaries(std::vector<G4DynamicParticle*>* /*fvect*/, 250 const G4MaterialCutsCouple* 250 const G4MaterialCutsCouple* /*couple*/, 251 const G4DynamicParticle* aDy 251 const G4DynamicParticle* aDynamicElectron, 252 G4double, 252 G4double, 253 G4double) 253 G4double) 254 { 254 { 255 #ifdef UEHARA_VERBOSE 255 #ifdef UEHARA_VERBOSE 256 if (verboseLevel > 3) 256 if (verboseLevel > 3) 257 { 257 { 258 G4cout 258 G4cout 259 << "Calling SampleSecondaries() of G4D 259 << "Calling SampleSecondaries() of G4DNAUeharaScreenedRutherfordElasticModel" 260 << G4endl; 260 << G4endl; 261 } 261 } 262 #endif 262 #endif 263 263 264 G4double electronEnergy0 = aDynamicElectron- 264 G4double electronEnergy0 = aDynamicElectron->GetKineticEnergy(); 265 if(electronEnergy0 < iLowEnergyLimit || elec 265 if(electronEnergy0 < iLowEnergyLimit || electronEnergy0 > iHighEnergyLimit) 266 return; 266 return; 267 267 268 G4double cosTheta = 0.; 268 G4double cosTheta = 0.; 269 269 270 if (electronEnergy0<intermediateEnergyLimit) 270 if (electronEnergy0<intermediateEnergyLimit) 271 { 271 { 272 #ifdef UEHARA_VERBOSE 272 #ifdef UEHARA_VERBOSE 273 if (verboseLevel > 3) 273 if (verboseLevel > 3) 274 G4cout << "---> Using Brenner & Zaider m 274 G4cout << "---> Using Brenner & Zaider model" << G4endl; 275 #endif 275 #endif 276 cosTheta = BrennerZaiderRandomizeCosTheta( 276 cosTheta = BrennerZaiderRandomizeCosTheta(electronEnergy0); 277 } 277 } 278 else //if (electronEnergy0>=intermediateEner 278 else //if (electronEnergy0>=intermediateEnergyLimit) 279 { 279 { 280 #ifdef UEHARA_VERBOSE 280 #ifdef UEHARA_VERBOSE 281 if (verboseLevel > 3) 281 if (verboseLevel > 3) 282 G4cout << "---> Using Screened Rutherfor 282 G4cout << "---> Using Screened Rutherford model" << G4endl; 283 #endif 283 #endif 284 G4double z = 7.42; // FROM PMB 37 (1992) 284 G4double z = 7.42; // FROM PMB 37 (1992) 1841-1858 p1842 285 cosTheta = ScreenedRutherfordRandomizeCosT 285 cosTheta = ScreenedRutherfordRandomizeCosTheta(electronEnergy0,z); 286 } 286 } 287 287 288 G4double phi = 2. * pi * G4UniformRand(); 288 G4double phi = 2. * pi * G4UniformRand(); 289 289 290 G4ThreeVector zVers = aDynamicElectron->GetM 290 G4ThreeVector zVers = aDynamicElectron->GetMomentumDirection(); 291 G4ThreeVector xVers = zVers.orthogonal(); 291 G4ThreeVector xVers = zVers.orthogonal(); 292 G4ThreeVector yVers = zVers.cross(xVers); 292 G4ThreeVector yVers = zVers.cross(xVers); 293 293 294 G4double xDir = std::sqrt(1. - cosTheta*cosT 294 G4double xDir = std::sqrt(1. - cosTheta*cosTheta); 295 G4double yDir = xDir; 295 G4double yDir = xDir; 296 xDir *= std::cos(phi); 296 xDir *= std::cos(phi); 297 yDir *= std::sin(phi); 297 yDir *= std::sin(phi); 298 298 299 G4ThreeVector zPrimeVers((xDir*xVers + yDir* 299 G4ThreeVector zPrimeVers((xDir*xVers + yDir*yVers + cosTheta*zVers)); 300 300 301 fParticleChangeForGamma->ProposeMomentumDire 301 fParticleChangeForGamma->ProposeMomentumDirection(zPrimeVers.unit()); 302 302 303 fParticleChangeForGamma->SetProposedKineticE 303 fParticleChangeForGamma->SetProposedKineticEnergy(electronEnergy0); 304 } 304 } 305 305 306 //....oooOO0OOooo........oooOO0OOooo........oo 306 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 307 307 308 G4double 308 G4double 309 G4DNAUeharaScreenedRutherfordElasticModel:: 309 G4DNAUeharaScreenedRutherfordElasticModel:: 310 BrennerZaiderRandomizeCosTheta(G4double k) 310 BrennerZaiderRandomizeCosTheta(G4double k) 311 { 311 { 312 // d sigma_el 1 312 // d sigma_el 1 beta(K) 313 // ------------ (K) ~ ---------------------- 313 // ------------ (K) ~ --------------------------------- + --------------------------------- 314 // d Omega (1 + 2 gamma(K) - cos 314 // d Omega (1 + 2 gamma(K) - cos(theta))^2 (1 + 2 delta(K) + cos(theta))^2 315 // 315 // 316 // Maximum is < 1/(4 gamma(K)^2) + beta(K)/( 316 // Maximum is < 1/(4 gamma(K)^2) + beta(K)/((2+2delta(K))^2) 317 // 317 // 318 // Phys. Med. Biol. 29 N.4 (1983) 443-447 318 // Phys. Med. Biol. 29 N.4 (1983) 443-447 319 319 320 // gamma(K), beta(K) and delta(K) are polyno 320 // gamma(K), beta(K) and delta(K) are polynomials with coefficients for energy measured in eV 321 321 322 k /= eV; 322 k /= eV; 323 323 324 G4double beta = G4Exp(CalculatePolynomial(k, 324 G4double beta = G4Exp(CalculatePolynomial(k, betaCoeff)); 325 G4double delta = G4Exp(CalculatePolynomial(k 325 G4double delta = G4Exp(CalculatePolynomial(k, deltaCoeff)); 326 G4double gamma; 326 G4double gamma; 327 327 328 if (k > 100.) 328 if (k > 100.) 329 { 329 { 330 gamma = CalculatePolynomial(k, gamma100_20 330 gamma = CalculatePolynomial(k, gamma100_200Coeff); 331 // Only in this case it is not the exponen 331 // Only in this case it is not the exponent of the polynomial 332 } else 332 } else 333 { 333 { 334 if (k > 10) 334 if (k > 10) 335 { 335 { 336 gamma = G4Exp(CalculatePolynomial(k, gam 336 gamma = G4Exp(CalculatePolynomial(k, gamma10_100Coeff)); 337 } 337 } 338 else 338 else 339 { 339 { 340 gamma = G4Exp(CalculatePolynomial(k, gam 340 gamma = G4Exp(CalculatePolynomial(k, gamma035_10Coeff)); 341 } 341 } 342 } 342 } 343 343 344 // ***** Original method 344 // ***** Original method 345 345 346 if (!fasterCode) 346 if (!fasterCode) 347 { 347 { 348 G4double oneOverMax = 1. 348 G4double oneOverMax = 1. 349 / (1. / (4. * gamma * gamma) 349 / (1. / (4. * gamma * gamma) 350 + beta / ((2. + 2. * delta) * (2. + 2. 350 + beta / ((2. + 2. * delta) * (2. + 2. * delta))); 351 351 352 G4double cosTheta = 0.; 352 G4double cosTheta = 0.; 353 G4double leftDenominator = 0.; 353 G4double leftDenominator = 0.; 354 G4double rightDenominator = 0.; 354 G4double rightDenominator = 0.; 355 G4double fCosTheta = 0.; 355 G4double fCosTheta = 0.; 356 356 357 do 357 do 358 { 358 { 359 cosTheta = 2. * G4UniformRand()- 1.; 359 cosTheta = 2. * G4UniformRand()- 1.; 360 360 361 leftDenominator = (1. + 2.*gamma - cosTh 361 leftDenominator = (1. + 2.*gamma - cosTheta); 362 rightDenominator = (1. + 2.*delta + cosT 362 rightDenominator = (1. + 2.*delta + cosTheta); 363 if ( (leftDenominator * rightDenominator 363 if ( (leftDenominator * rightDenominator) != 0. ) 364 { 364 { 365 fCosTheta = oneOverMax * (1./(leftDeno 365 fCosTheta = oneOverMax * (1./(leftDenominator*leftDenominator) 366 + beta/(righ 366 + beta/(rightDenominator*rightDenominator)); 367 } 367 } 368 } 368 } 369 while (fCosTheta < G4UniformRand()); 369 while (fCosTheta < G4UniformRand()); 370 370 371 return cosTheta; 371 return cosTheta; 372 } 372 } 373 373 374 // ***** Alternative method using cumulative 374 // ***** Alternative method using cumulative probability 375 375 376 // if (fasterCode) 376 // if (fasterCode) 377 377 378 // 378 // 379 // modified by Shogo OKADA @ KEK, JP, 2016. 379 // modified by Shogo OKADA @ KEK, JP, 2016.2.27(Sat.) 380 // 380 // 381 // An integral of differential cross-sectio 381 // An integral of differential cross-section formula shown above this member function 382 // (integral variable: cos(theta), integral 382 // (integral variable: cos(theta), integral interval: [-1, x]) is as follows: 383 // 383 // 384 // 1.0 + x beta * ( 384 // 1.0 + x beta * (1 + x) 385 // I = --------------------- + ------------ 385 // I = --------------------- + ---------------------- (1) 386 // (a - x) * (a + 1.0) (b + x) * 386 // (a - x) * (a + 1.0) (b + x) * (b - 1.0) 387 // 387 // 388 // where a = 1.0 + 2.0 * gamma(K), b = 1.0 388 // where a = 1.0 + 2.0 * gamma(K), b = 1.0 + 2.0 * delta(K) 389 // 389 // 390 // Then, a cumulative probability (cp) is a 390 // Then, a cumulative probability (cp) is as follows: 391 // 391 // 392 // cp 1.0 + x beta * 392 // cp 1.0 + x beta * (1 + x) 393 // ---- = --------------------- + --------- 393 // ---- = --------------------- + ---------------------- (2) 394 // S (a - x) * (a + 1.0) (b + x) 394 // S (a - x) * (a + 1.0) (b + x) * (b - 1.0) 395 // 395 // 396 // where 1/S is the integral of differnetic 396 // where 1/S is the integral of differnetical cross-section (1) on interval [-1, 1] 397 // 397 // 398 // 1 2.0 2. 398 // 1 2.0 2.0 * beta 399 // --- = ----------------------- + ------- 399 // --- = ----------------------- + ----------------------- (3) 400 // S (a - 1.0) * (a + 1.0) (b + 1 400 // S (a - 1.0) * (a + 1.0) (b + 1.0) * (b - 1.0) 401 // 401 // 402 // x is calculated from the quadratic equat 402 // x is calculated from the quadratic equation derived from (2) and (3): 403 // 403 // 404 // A * x^2 + B * x + C = 0 404 // A * x^2 + B * x + C = 0 405 // 405 // 406 // where A, B, anc C are coefficients of th 406 // where A, B, anc C are coefficients of the equation: 407 // A = S * {(b - 1.0) - beta * (a + 1.0)} 407 // A = S * {(b - 1.0) - beta * (a + 1.0)} + cp * (a + 1.0) * (b - 1.0), 408 // B = S * {(b - 1.0) * (b + 1.0) + beta * 408 // B = S * {(b - 1.0) * (b + 1.0) + beta * (a - 1.0) * (a + 1.0)} - cp * (a + 1.0) * (b - 1.0) * (a - b) 409 // C = S * {b * (b - 1.0) + beta * a * (a 409 // C = S * {b * (b - 1.0) + beta * a * (a + 1.0)} - cp * (a + 1.0) * (b - 1.0) * ab 410 // 410 // 411 411 412 // sampling cumulative probability 412 // sampling cumulative probability 413 G4double cp = G4UniformRand(); 413 G4double cp = G4UniformRand(); 414 414 415 G4double a = 1.0 + 2.0 * gamma; 415 G4double a = 1.0 + 2.0 * gamma; 416 G4double b = 1.0 + 2.0 * delta; 416 G4double b = 1.0 + 2.0 * delta; 417 G4double a1 = a - 1.0; 417 G4double a1 = a - 1.0; 418 G4double a2 = a + 1.0; 418 G4double a2 = a + 1.0; 419 G4double b1 = b - 1.0; 419 G4double b1 = b - 1.0; 420 G4double b2 = b + 1.0; 420 G4double b2 = b + 1.0; 421 G4double c1 = a - b; 421 G4double c1 = a - b; 422 G4double c2 = a * b; 422 G4double c2 = a * b; 423 423 424 G4double S = 2.0 / (a1 * a2) + 2.0 * beta / 424 G4double S = 2.0 / (a1 * a2) + 2.0 * beta / (b1 * b2); S = 1.0 / S; 425 425 426 // coefficients for the quadratic equation 426 // coefficients for the quadratic equation 427 G4double A = S * (b1 - beta * a2) + cp * a2 427 G4double A = S * (b1 - beta * a2) + cp * a2 * b1; 428 G4double B = S * (b1 * b2 + beta * a1 * a2) 428 G4double B = S * (b1 * b2 + beta * a1 * a2) - cp * a2 * b1 * c1; 429 G4double C = S * (b * b1 + beta * a * a2) - 429 G4double C = S * (b * b1 + beta * a * a2) - cp * a2 * b1 * c2; 430 430 431 // calculate cos(theta) 431 // calculate cos(theta) 432 return (-1.0 * B + std::sqrt(B * B - 4.0 * 432 return (-1.0 * B + std::sqrt(B * B - 4.0 * A * C)) / (2.0 * A); 433 433 434 /* 434 /* 435 G4double cosTheta = -1; 435 G4double cosTheta = -1; 436 G4double cumul = 0; 436 G4double cumul = 0; 437 G4double value = 0; 437 G4double value = 0; 438 G4double leftDenominator = 0.; 438 G4double leftDenominator = 0.; 439 G4double rightDenominator = 0.; 439 G4double rightDenominator = 0.; 440 440 441 // Number of integration steps in the -1,1 441 // Number of integration steps in the -1,1 range 442 G4int iMax=200; 442 G4int iMax=200; 443 443 444 G4double random = G4UniformRand(); 444 G4double random = G4UniformRand(); 445 445 446 // Cumulate differential cross section 446 // Cumulate differential cross section 447 for (G4int i=0; i<iMax; i++) 447 for (G4int i=0; i<iMax; i++) 448 { 448 { 449 cosTheta = -1 + i*2./(iMax-1); 449 cosTheta = -1 + i*2./(iMax-1); 450 leftDenominator = (1. + 2.*gamma - cosTheta 450 leftDenominator = (1. + 2.*gamma - cosTheta); 451 rightDenominator = (1. + 2.*delta + cosThet 451 rightDenominator = (1. + 2.*delta + cosTheta); 452 if ( (leftDenominator * rightDenominator) ! 452 if ( (leftDenominator * rightDenominator) != 0. ) 453 { 453 { 454 cumul = cumul + (1./(leftDenominator*leftDe 454 cumul = cumul + (1./(leftDenominator*leftDenominator) + beta/(rightDenominator*rightDenominator)); 455 } 455 } 456 } 456 } 457 457 458 // Select cosTheta 458 // Select cosTheta 459 for (G4int i=0; i<iMax; i++) 459 for (G4int i=0; i<iMax; i++) 460 { 460 { 461 cosTheta = -1 + i*2./(iMax-1); 461 cosTheta = -1 + i*2./(iMax-1); 462 leftDenominator = (1. + 2.*gamma - cosTheta 462 leftDenominator = (1. + 2.*gamma - cosTheta); 463 rightDenominator = (1. + 2.*delta + cosThet 463 rightDenominator = (1. + 2.*delta + cosTheta); 464 if (cumul !=0 && (leftDenominator * rightDe 464 if (cumul !=0 && (leftDenominator * rightDenominator) != 0.) 465 value = value + (1./(leftDenominator*leftDe 465 value = value + (1./(leftDenominator*leftDenominator) + beta/(rightDenominator*rightDenominator)) / cumul; 466 if (random < value) break; 466 if (random < value) break; 467 } 467 } 468 468 469 return cosTheta; 469 return cosTheta; 470 */ 470 */ 471 471 472 472 473 //return 0.; 473 //return 0.; 474 474 475 } 475 } 476 476 477 //....oooOO0OOooo........oooOO0OOooo........oo 477 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 478 478 479 G4double 479 G4double 480 G4DNAUeharaScreenedRutherfordElasticModel:: 480 G4DNAUeharaScreenedRutherfordElasticModel:: 481 CalculatePolynomial(G4double k, 481 CalculatePolynomial(G4double k, 482 std::vector<G4double>& vec 482 std::vector<G4double>& vec) 483 { 483 { 484 // Sum_{i=0}^{size-1} vector_i k^i 484 // Sum_{i=0}^{size-1} vector_i k^i 485 // 485 // 486 // Phys. Med. Biol. 29 N.4 (1983) 443-447 486 // Phys. Med. Biol. 29 N.4 (1983) 443-447 487 487 488 G4double result = 0.; 488 G4double result = 0.; 489 size_t size = vec.size(); 489 size_t size = vec.size(); 490 490 491 while (size > 0) 491 while (size > 0) 492 { 492 { 493 size--; 493 size--; 494 494 495 result *= k; 495 result *= k; 496 result += vec[size]; 496 result += vec[size]; 497 } 497 } 498 498 499 return result; 499 return result; 500 } 500 } 501 501 502 //....oooOO0OOooo........oooOO0OOooo........oo 502 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 503 503 504 G4double 504 G4double 505 G4DNAUeharaScreenedRutherfordElasticModel:: 505 G4DNAUeharaScreenedRutherfordElasticModel:: 506 ScreenedRutherfordRandomizeCosTheta(G4double k 506 ScreenedRutherfordRandomizeCosTheta(G4double k, 507 G4double z 507 G4double z) 508 { 508 { 509 509 510 // d sigma_el sigma_Ruth(K) 510 // d sigma_el sigma_Ruth(K) 511 // ------------ (K) ~ ---------------------- 511 // ------------ (K) ~ ----------------------------- 512 // d Omega (1 + 2 n(K) - cos(the 512 // d Omega (1 + 2 n(K) - cos(theta))^2 513 // 513 // 514 // We extract cos(theta) distributed as (1 + 514 // We extract cos(theta) distributed as (1 + 2 n(K) - cos(theta))^-2 515 // 515 // 516 // Maximum is for theta=0: 1/(4 n(K)^2) (Whe 516 // Maximum is for theta=0: 1/(4 n(K)^2) (When n(K) is positive, that is always 517 // satisfied within the validity of the proc 517 // satisfied within the validity of the process) 518 // 518 // 519 // Phys. Med. Biol. 45 (2000) 3171-3194 519 // Phys. Med. Biol. 45 (2000) 3171-3194 520 520 521 // ***** Original method 521 // ***** Original method 522 522 523 if (!fasterCode) 523 if (!fasterCode) 524 { 524 { 525 G4double n = ScreeningFactor(k, z); 525 G4double n = ScreeningFactor(k, z); 526 526 527 G4double oneOverMax = (4. * n * n); 527 G4double oneOverMax = (4. * n * n); 528 528 529 G4double cosTheta = 0.; 529 G4double cosTheta = 0.; 530 G4double fCosTheta; 530 G4double fCosTheta; 531 531 532 do 532 do 533 { 533 { 534 cosTheta = 2. * G4UniformRand()- 1.; 534 cosTheta = 2. * G4UniformRand()- 1.; 535 fCosTheta = (1 + 2.*n - cosTheta); 535 fCosTheta = (1 + 2.*n - cosTheta); 536 if (fCosTheta !=0.) fCosTheta = oneOverM 536 if (fCosTheta !=0.) fCosTheta = oneOverMax / (fCosTheta*fCosTheta); 537 } 537 } 538 while (fCosTheta < G4UniformRand()); 538 while (fCosTheta < G4UniformRand()); 539 539 540 return cosTheta; 540 return cosTheta; 541 } 541 } 542 542 543 // ***** Alternative method using cumulative 543 // ***** Alternative method using cumulative probability 544 // if (fasterCode) 544 // if (fasterCode) 545 545 546 // 546 // 547 // modified by Shogo OKADA @ KEK, JP, 2016.2 547 // modified by Shogo OKADA @ KEK, JP, 2016.2.27(Sat.) 548 // 548 // 549 // The cumulative probability (cp) is calcul 549 // The cumulative probability (cp) is calculated by integrating 550 // the differential cross-section fomula wit 550 // the differential cross-section fomula with cos(theta): 551 // 551 // 552 // n(K) * (1.0 + cos(theta)) 552 // n(K) * (1.0 + cos(theta)) 553 // cp = --------------------------------- 553 // cp = --------------------------------- 554 // 1.0 + 2.0 * n(K) - cos(theta) 554 // 1.0 + 2.0 * n(K) - cos(theta) 555 // 555 // 556 // Then, cos(theta) is as follows: 556 // Then, cos(theta) is as follows: 557 // 557 // 558 // cp * (1.0 + 2.0 * n(K)) - n 558 // cp * (1.0 + 2.0 * n(K)) - n(K) 559 // cos(theta) = ---------------------------- 559 // cos(theta) = -------------------------------- 560 // n(k) + cp 560 // n(k) + cp 561 // 561 // 562 // where, K is kinetic energy, n(K) is scree 562 // where, K is kinetic energy, n(K) is screeing factor, and cp is cumulative probability 563 // 563 // 564 564 565 G4double n = ScreeningFactor(k, z); 565 G4double n = ScreeningFactor(k, z); 566 G4double cp = G4UniformRand(); 566 G4double cp = G4UniformRand(); 567 G4double numerator = cp * (1.0 + 2.0 * n) - 567 G4double numerator = cp * (1.0 + 2.0 * n) - n; 568 G4double denominator = n + cp; 568 G4double denominator = n + cp; 569 return numerator / denominator; 569 return numerator / denominator; 570 570 571 /* 571 /* 572 G4double cosTheta = -1; 572 G4double cosTheta = -1; 573 G4double cumul = 0; 573 G4double cumul = 0; 574 G4double value = 0; 574 G4double value = 0; 575 G4double n = ScreeningFactor(k, z); 575 G4double n = ScreeningFactor(k, z); 576 G4double fCosTheta; 576 G4double fCosTheta; 577 577 578 // Number of integration steps in the -1,1 578 // Number of integration steps in the -1,1 range 579 G4int iMax=200; 579 G4int iMax=200; 580 580 581 G4double random = G4UniformRand(); 581 G4double random = G4UniformRand(); 582 582 583 // Cumulate differential cross section 583 // Cumulate differential cross section 584 for (G4int i=0; i<iMax; i++) 584 for (G4int i=0; i<iMax; i++) 585 { 585 { 586 cosTheta = -1 + i*2./(iMax-1); 586 cosTheta = -1 + i*2./(iMax-1); 587 fCosTheta = (1 + 2.*n - cosTheta); 587 fCosTheta = (1 + 2.*n - cosTheta); 588 if (fCosTheta !=0.) cumul = cumul + 1./(fCo 588 if (fCosTheta !=0.) cumul = cumul + 1./(fCosTheta*fCosTheta); 589 } 589 } 590 590 591 // Select cosTheta 591 // Select cosTheta 592 for (G4int i=0; i<iMax; i++) 592 for (G4int i=0; i<iMax; i++) 593 { 593 { 594 cosTheta = -1 + i*2./(iMax-1); 594 cosTheta = -1 + i*2./(iMax-1); 595 fCosTheta = (1 + 2.*n - cosTheta); 595 fCosTheta = (1 + 2.*n - cosTheta); 596 if (cumul !=0.) value = value + (1./(fCosTh 596 if (cumul !=0.) value = value + (1./(fCosTheta*fCosTheta)) / cumul; 597 if (random < value) break; 597 if (random < value) break; 598 } 598 } 599 return cosTheta; 599 return cosTheta; 600 */ 600 */ 601 601 602 602 603 //return 0.; 603 //return 0.; 604 } 604 } 605 605