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 // $Id: G4eCoulombScatteringModel.cc,v 1.10 2006/10/26 17:36:17 vnivanch Exp $ >> 27 // GEANT4 tag $Name: geant4-08-02 $ 26 // 28 // 27 // ------------------------------------------- 29 // ------------------------------------------------------------------- 28 // 30 // 29 // GEANT4 Class file 31 // GEANT4 Class file 30 // 32 // 31 // 33 // 32 // File name: G4eCoulombScatteringModel 34 // File name: G4eCoulombScatteringModel 33 // 35 // 34 // Author: Vladimir Ivanchenko 36 // Author: Vladimir Ivanchenko 35 // 37 // 36 // Creation date: 22.08.2005 38 // Creation date: 22.08.2005 37 // 39 // 38 // Modifications: V.Ivanchenko << 40 // Modifications: 39 // << 41 // 01.08.06 V.Ivanchenko extend upper limit of table to TeV and review the 40 // << 42 // logic of building - only elements from G4ElementTable >> 43 // 08.08.06 V.Ivanchenko build internal table in ekin scale, introduce faclim >> 44 // 19.08.06 V.Ivanchenko add inline function ScreeningParameter 41 // 45 // 42 // Class Description: 46 // Class Description: 43 // 47 // 44 // ------------------------------------------- 48 // ------------------------------------------------------------------- 45 // 49 // 46 //....oooOO0OOooo........oooOO0OOooo........oo 50 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 47 //....oooOO0OOooo........oooOO0OOooo........oo 51 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 48 52 49 #include "G4eCoulombScatteringModel.hh" 53 #include "G4eCoulombScatteringModel.hh" 50 #include "G4PhysicalConstants.hh" << 51 #include "G4SystemOfUnits.hh" << 52 #include "Randomize.hh" 54 #include "Randomize.hh" 53 #include "G4DataVector.hh" 55 #include "G4DataVector.hh" 54 #include "G4ElementTable.hh" 56 #include "G4ElementTable.hh" >> 57 #include "G4PhysicsLogVector.hh" 55 #include "G4ParticleChangeForGamma.hh" 58 #include "G4ParticleChangeForGamma.hh" 56 #include "G4Proton.hh" << 57 #include "G4ParticleTable.hh" << 58 #include "G4IonTable.hh" << 59 #include "G4ProductionCutsTable.hh" << 60 #include "G4NucleiProperties.hh" << 61 #include "G4Pow.hh" << 62 #include "G4NistManager.hh" << 63 59 64 //....oooOO0OOooo........oooOO0OOooo........oo 60 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 65 61 66 using namespace std; 62 using namespace std; 67 63 68 G4eCoulombScatteringModel::G4eCoulombScatterin << 64 G4eCoulombScatteringModel::G4eCoulombScatteringModel( 69 : G4VEmModel("eCoulombScattering"), isCombin << 65 G4double thetaMin, G4double thetaMax, G4bool build, 70 { << 66 G4double tlim, const G4String& nam) 71 fNistManager = G4NistManager::Instance(); << 67 : G4VEmModel(nam), 72 theIonTable = G4ParticleTable::GetParticleT << 68 cosThetaMin(cos(thetaMin)), 73 theProton = G4Proton::Proton(); << 69 cosThetaMax(cos(thetaMax)), 74 << 70 q2Limit(tlim), 75 wokvi = new G4WentzelOKandVIxSection(isCombi << 71 theCrossSectionTable(0), 76 << 72 lowKEnergy(keV), 77 mass = CLHEP::proton_mass_c2; << 73 highKEnergy(TeV), >> 74 alpha2(fine_structure_const*fine_structure_const), >> 75 faclim(100.0), >> 76 nbins(12), >> 77 nmax(100), >> 78 buildTable(build), >> 79 isInitialised(false) >> 80 { >> 81 a0 = alpha2*electron_mass_c2*electron_mass_c2/(0.885*0.885); >> 82 G4double p0 = electron_mass_c2*classic_electr_radius; >> 83 coeff = twopi*p0*p0; 78 } 84 } 79 85 80 //....oooOO0OOooo........oooOO0OOooo........oo 86 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 81 87 82 G4eCoulombScatteringModel::~G4eCoulombScatteri 88 G4eCoulombScatteringModel::~G4eCoulombScatteringModel() 83 { 89 { 84 delete wokvi; << 90 if(theCrossSectionTable) { >> 91 theCrossSectionTable->clearAndDestroy(); >> 92 delete theCrossSectionTable; >> 93 } 85 } 94 } 86 95 87 //....oooOO0OOooo........oooOO0OOooo........oo 96 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 88 97 89 void G4eCoulombScatteringModel::Initialise(con << 98 void G4eCoulombScatteringModel::Initialise(const G4ParticleDefinition* p, 90 const G4DataVector& cuts) << 99 const G4DataVector&) 91 { 100 { 92 SetupParticle(part); << 101 if(isInitialised) return; 93 currentCouple = nullptr; << 102 isInitialised = true; 94 103 95 G4double tet = PolarAngleLimit(); << 104 if(pParticleChange) >> 105 fParticleChange = >> 106 reinterpret_cast<G4ParticleChangeForGamma*>(pParticleChange); >> 107 else >> 108 fParticleChange = new G4ParticleChangeForGamma(); 96 109 97 // defined theta limit between single and mu << 110 if(!buildTable || p->GetParticleName() == "GenericIon") return; 98 if(isCombined) { << 99 if(tet >= CLHEP::pi) { cosThetaMin = -1.0; << 100 else if(tet > 0.0) { cosThetaMin = std::co << 101 << 102 // single scattering without multiple << 103 } else if(tet > 0.0) { << 104 cosThetaMin = std::cos(std::min(tet, CLHEP << 105 } << 106 111 107 wokvi->Initialise(part, cosThetaMin); << 112 // Compute cross section multiplied by Ptot^2*beta^2 108 pCuts = &cuts; << 113 theCrossSectionTable = new G4PhysicsTable(); 109 /* << 114 G4PhysicsLogVector* ptrVector; 110 G4cout << "G4eCoulombScatteringModel::Initia << 115 G4double e, value; 111 << part->GetParticleName() << " 1-cos(Tet << 116 nbins = 2*G4int(log10(highKEnergy/lowKEnergy)); 112 << " 1-cos(TetMax)= " << 1. - cosThetaMax << 113 G4cout << "cut[0]= " << (*pCuts)[0] << G4end << 114 */ << 115 if(nullptr == fParticleChange) { << 116 fParticleChange = GetParticleChangeForGamm << 117 } << 118 if(IsMaster() && mass < GeV && part->GetPart << 119 InitialiseElementSelectors(part, cuts); << 120 } << 121 } << 122 117 123 //....oooOO0OOooo........oooOO0OOooo........oo << 118 const G4ElementTable* elmt = G4Element::GetElementTable(); >> 119 size_t nelm = G4Element::GetNumberOfElements(); 124 120 125 void G4eCoulombScatteringModel::InitialiseLoca << 121 for(size_t j=0; j<nelm; j++) { 126 G4VEmModel* masterModel) << 127 { << 128 SetElementSelectors(masterModel->GetElementS << 129 } << 130 << 131 //....oooOO0OOooo........oooOO0OOooo........oo << 132 122 133 G4double << 123 ptrVector = new G4PhysicsLogVector(lowKEnergy, highKEnergy, nbins); 134 G4eCoulombScatteringModel::MinPrimaryEnergy(co << 124 const G4Element* elm = (*elmt)[j]; 135 const G4ParticleDefinition* part << 125 G4double Z = elm->GetZ(); 136 G4double) << 126 index[G4int(Z)] = j; 137 { << 127 for(G4int i=0; i<=nbins; i++) { 138 SetupParticle(part); << 128 e = ptrVector->GetLowEdgeEnergy( i ) ; >> 129 value = CalculateCrossSectionPerAtom(p, e, Z); >> 130 ptrVector->PutValue( i, log(value) ); >> 131 } 139 132 140 // define cut using cuts for proton << 133 theCrossSectionTable->insert(ptrVector); 141 G4double cut = << 142 std::max(recoilThreshold, (*pCuts)[Current << 143 << 144 // find out lightest element << 145 const G4ElementVector* theElementVector = ma << 146 std::size_t nelm = material->GetNumberOfElem << 147 << 148 // select lightest element << 149 G4int Z = 300; << 150 for (std::size_t j=0; j<nelm; ++j) { << 151 Z = std::min(Z,(*theElementVector)[j]->Get << 152 } 134 } 153 G4int A = G4lrint(fNistManager->GetAtomicMas << 154 G4double targetMass = G4NucleiProperties::Ge << 155 G4double t = std::max(cut, 0.5*(cut + sqrt(2 << 156 << 157 return t; << 158 } 135 } 159 136 160 //....oooOO0OOooo........oooOO0OOooo........oo << 137 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 161 138 162 G4double G4eCoulombScatteringModel::ComputeCro << 139 G4double G4eCoulombScatteringModel::CalculateCrossSectionPerAtom( 163 const G4ParticleDefinition* p, << 140 const G4ParticleDefinition* p, 164 G4double kinEnergy, << 141 G4double kinEnergy, 165 G4double Z, G4double, << 142 G4double Z) 166 G4double cutEnergy, G4double) << 167 { 143 { 168 /* << 169 G4cout << "### G4eCoulombScatteringModel::Co << 170 << p->GetParticleName()<<" Z= "<<Z<<" e(MeV << 171 << G4endl; << 172 */ << 173 G4double cross = 0.0; 144 G4double cross = 0.0; 174 elecRatio = 0.0; << 145 G4double m = p->GetPDGMass(); 175 if(p != particle) { SetupParticle(p); } << 146 G4double tkin = std::max(keV, kinEnergy); 176 << 147 G4double mom2 = tkin*(tkin + 2.0*m); 177 // cross section is set to zero to avoid pro << 148 G4double costm = std::max(cosThetaMax, 1.0 - 0.5*q2Limit/mom2); 178 if(kinEnergy <= 0.0) { return cross; } << 149 if(costm < cosThetaMin) { 179 DefineMaterial(CurrentCouple()); << 150 G4double q = p->GetPDGCharge()/eplus; 180 G4double costmin = wokvi->SetupKinematic(kin << 151 G4double q2 = q*q; 181 << 152 G4double invbeta2 = 1.0 + m*m/mom2; 182 //G4cout << "cosThetaMax= "<<cosThetaMax<<" << 153 G4double A = ScreeningParameter(Z, q2, mom2, invbeta2); 183 << 154 G4double a = 2.0*A + 1.0; 184 if(cosThetaMax < costmin) { << 155 cross = coeff*Z*(Z + 1.0)*q2*invbeta2*(cosThetaMin - costm)/ 185 G4int iz = G4lrint(Z); << 156 ((a - cosThetaMin)*(a - costm)*mom2); 186 G4double cut = (0.0 < fixedCut) ? fixedCut << 157 /* 187 costmin = wokvi->SetupTarget(iz, cut); << 158 if(Z == 13 || Z == 79) { 188 //G4cout << "SetupTarget: Z= " << iz << " << 159 G4cout << "## e= " << kinEnergy << " beta= " << sqrt (1.0/invbeta2) 189 // << costmin << G4endl; << 160 <<" Z= " << Z 190 G4double costmax = (1 == iz && particle == << 161 << " sig(bn)= " << cross/barn 191 ? 0.0 : cosThetaMax; << 162 << " cosMax= " << costm 192 if(costmin > costmax) { << 163 << " cosMin= " << cosThetaMin 193 cross = wokvi->ComputeNuclearCrossSectio << 164 << G4endl; 194 + wokvi->ComputeElectronCrossSection(c << 165 G4double atommass = 27.0; >> 166 if(Z == 79) atommass = 197.0; >> 167 G4double u0 = 1.e+6*atommass*cm2/(cross*Avogadro); >> 168 G4double u1 = 0.5*u0/( A* ( (1.0 + A)*log(1.0 + 1.0/A) -1.0 ) ); >> 169 G4cout << " l0= " << u0 << " l1= " << u1 >> 170 << " A= " << A << G4endl; 195 } 171 } 196 /* << 197 if(p->GetParticleName() == "e-") << 198 G4cout << "Z= " << Z << " e(MeV)= " << kin << 199 << " cross(b)= " << cross/barn << " 1-cos << 200 << " 1-costmax= " << 1-costmax << 201 << " 1-cosThetaMax= " << 1-cosThetaMax << 202 << " " << currentMaterial->GetName() << 203 << G4endl; << 204 */ 172 */ 205 } 173 } 206 //G4cout << "====== cross= " << cross << G4e << 174 return cross; 207 return cross; << 208 } 175 } 209 176 210 //....oooOO0OOooo........oooOO0OOooo........oo 177 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 211 178 212 void G4eCoulombScatteringModel::SampleSecondar << 179 std::vector<G4DynamicParticle*>* G4eCoulombScatteringModel::SampleSecondaries( 213 std::vector<G4DynamicParticle* << 180 const G4MaterialCutsCouple* couple, 214 const G4MaterialCutsCouple* couple, << 181 const G4DynamicParticle* dp, 215 const G4DynamicParticle* dp, << 182 G4double, 216 G4double cutEnergy, << 183 G4double) 217 G4double) << 218 { 184 { >> 185 const G4Material* aMaterial = couple->GetMaterial(); >> 186 const G4ParticleDefinition* p = dp->GetDefinition(); >> 187 >> 188 G4double mass = dp->GetMass(); 219 G4double kinEnergy = dp->GetKineticEnergy(); 189 G4double kinEnergy = dp->GetKineticEnergy(); 220 SetupParticle(dp->GetDefinition()); << 190 G4double mom2 = kinEnergy*(kinEnergy + 2.0*mass); 221 DefineMaterial(couple); << 222 /* << 223 G4cout << "G4eCoulombScatteringModel::Sample << 224 << kinEnergy << " " << particle->GetPart << 225 << " cut= " << cutEnergy<< G4endl; << 226 */ << 227 // Choose nucleus << 228 G4double cut = (0.0 < fixedCut) ? fixedCut : << 229 << 230 wokvi->SetupKinematic(kinEnergy, currentMate << 231 << 232 const G4Element* currentElement = SelectTarg << 233 dp->Get << 234 G4int iz = currentElement->GetZasInt(); << 235 << 236 G4double costmin = wokvi->SetupTarget(iz, cu << 237 G4double costmax = (1 == iz && particle == t << 238 ? 0.0 : cosThetaMax; << 239 if(costmin <= costmax) { return; } << 240 << 241 G4double cross = wokvi->ComputeNuclearCrossS << 242 G4double ecross = wokvi->ComputeElectronCros << 243 G4double ratio = ecross/(cross + ecross); << 244 << 245 G4int ia = SelectIsotopeNumber(currentElemen << 246 G4double targetMass = G4NucleiProperties::Ge << 247 wokvi->SetTargetMass(targetMass); << 248 << 249 G4ThreeVector newDirection = << 250 wokvi->SampleSingleScattering(costmin, cos << 251 G4double cost = newDirection.z(); << 252 /* << 253 G4cout << "SampleSec: e(MeV)= " << kinEn << 254 << " 1-costmin= " << 1-costmin << 255 << " 1-costmax= " << 1-costmax << 256 << " 1-cost= " << 1-cost << 257 << " ratio= " << ratio << 258 << G4endl; << 259 */ << 260 G4ThreeVector direction = dp->GetMomentumDir << 261 newDirection.rotateUz(direction); << 262 191 263 fParticleChange->ProposeMomentumDirection(ne << 192 const G4Element* elm = SelectRandomAtom(aMaterial, p, kinEnergy); >> 193 G4double Z = elm->GetZ(); >> 194 G4double q = p->GetPDGCharge()/eplus; >> 195 G4double q2 = q*q; 264 196 265 // recoil sampling assuming a small recoil << 197 G4double invbeta2 = 1.0 + mass*mass/mom2; 266 // and first order correction to primary 4-m << 198 G4double a = 2.*ScreeningParameter(Z, q2, mom2, invbeta2); 267 G4double mom2 = wokvi->GetMomentumSquare(); << 268 G4double trec = mom2*(1.0 - cost) << 269 /(targetMass + (mass + kinEnergy)*(1.0 - c << 270 << 271 // the check likely not needed << 272 trec = std::min(trec, kinEnergy); << 273 G4double finalT = kinEnergy - trec; << 274 G4double edep = 0.0; << 275 /* << 276 G4cout<<"G4eCoulombScatteringModel: finalT << 277 <<trec << " Z= " << iz << " A= " << ia << 278 << " tcut(keV)= " << (*pCuts)[currentMater << 279 */ << 280 G4double tcut = recoilThreshold; << 281 if(pCuts) { tcut= std::max(tcut,(*pCuts)[cur << 282 199 283 if(trec > tcut) { << 200 G4double costm = std::max(cosThetaMax, 1.0 - 0.5*q2Limit/mom2); 284 G4ParticleDefinition* ion = theIonTable->G << 201 if(costm >= cosThetaMin) return 0; 285 G4ThreeVector dir = (direction*sqrt(mom2) << 202 286 newDirection*sqrt(finalT*(2*mass + fina << 203 G4double x = G4UniformRand(); 287 auto newdp = new G4DynamicParticle(ion, di << 204 G4double y = (a + 1.0 - cosThetaMin)/(cosThetaMin - costm); 288 fvect->push_back(newdp); << 205 G4double st2 = 0.5*(y*(1.0 - costm) - a*x)/(y + x); 289 } else { << 206 if(st2 < 0.0 || st2 > 1.0) { 290 edep = trec; << 207 G4cout << "G4eCoulombScatteringModel::SampleSecondaries WARNING st2= " 291 fParticleChange->ProposeNonIonizingEnergyD << 208 << st2 << G4endl; >> 209 st2 = 0.0; 292 } 210 } 293 211 294 // finelize primary energy and energy bala << 212 G4double tet = 2.0*asin(sqrt(st2)); 295 // this threshold may be applied only beca << 213 G4double cost= cos(tet); 296 // e+e- msc model is applied << 214 G4double sint= sin(tet); 297 if(finalT < 0.0) { << 215 298 edep += finalT; << 216 G4double phi = twopi * G4UniformRand(); 299 finalT = 0.0; << 217 300 } << 218 G4ThreeVector direction = dp->GetMomentumDirection(); 301 edep = std::max(edep, 0.0); << 219 G4ThreeVector newDirection(cos(phi)*sint,sin(phi)*sint,cost); 302 fParticleChange->SetProposedKineticEnergy(fi << 220 newDirection.rotateUz(direction); 303 fParticleChange->ProposeLocalEnergyDeposit(e << 221 >> 222 fParticleChange->ProposeMomentumDirection(newDirection); >> 223 >> 224 return 0; 304 } 225 } 305 226 306 //....oooOO0OOooo........oooOO0OOooo........oo 227 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 228 >> 229 307 230