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 // 26 // 27 // ------------------------------------------- 27 // ------------------------------------------------------------------- 28 // 28 // 29 // 29 // 30 // GEANT4 Class header file 30 // GEANT4 Class header file 31 // 31 // 32 // 32 // 33 // File name: G4UrbanMscModel 33 // File name: G4UrbanMscModel 34 // 34 // 35 // Author: Laszlo Urban 35 // Author: Laszlo Urban 36 // 36 // 37 // Creation date: 19.02.2013 37 // Creation date: 19.02.2013 38 // 38 // 39 // Created from G4UrbanMscModel96 39 // Created from G4UrbanMscModel96 40 // 40 // 41 // New parametrization for theta0 41 // New parametrization for theta0 42 // Correction for very small step length 42 // Correction for very small step length 43 // 43 // 44 // Class Description: 44 // Class Description: 45 // 45 // 46 // Implementation of the model of multiple sca 46 // Implementation of the model of multiple scattering based on 47 // H.W.Lewis Phys Rev 78 (1950) 526 and L.Urba 47 // H.W.Lewis Phys Rev 78 (1950) 526 and L.Urban model 48 48 49 // ------------------------------------------- 49 // ------------------------------------------------------------------- 50 // 50 // 51 51 52 #ifndef G4UrbanMscModel_h 52 #ifndef G4UrbanMscModel_h 53 #define G4UrbanMscModel_h 1 53 #define G4UrbanMscModel_h 1 54 54 55 //....oooOO0OOooo........oooOO0OOooo........oo 55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 56 56 57 #include <CLHEP/Units/SystemOfUnits.h> 57 #include <CLHEP/Units/SystemOfUnits.h> 58 58 59 #include "G4VMscModel.hh" 59 #include "G4VMscModel.hh" 60 #include "G4MscStepLimitType.hh" 60 #include "G4MscStepLimitType.hh" 61 #include "G4Log.hh" 61 #include "G4Log.hh" 62 #include "G4Exp.hh" 62 #include "G4Exp.hh" 63 63 64 class G4ParticleChangeForMSC; 64 class G4ParticleChangeForMSC; 65 class G4SafetyHelper; 65 class G4SafetyHelper; >> 66 class G4LossTableManager; 66 67 67 //....oooOO0OOooo........oooOO0OOooo........oo 68 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 68 69 69 class G4UrbanMscModel : public G4VMscModel 70 class G4UrbanMscModel : public G4VMscModel 70 { 71 { 71 72 72 public: 73 public: 73 74 74 explicit G4UrbanMscModel(const G4String& nam 75 explicit G4UrbanMscModel(const G4String& nam = "UrbanMsc"); 75 76 76 ~G4UrbanMscModel() override; 77 ~G4UrbanMscModel() override; 77 78 78 void Initialise(const G4ParticleDefinition*, 79 void Initialise(const G4ParticleDefinition*, 79 const G4DataVector&) override; 80 const G4DataVector&) override; 80 81 81 void StartTracking(G4Track*) override; 82 void StartTracking(G4Track*) override; 82 83 83 G4double 84 G4double 84 ComputeCrossSectionPerAtom(const G4ParticleD 85 ComputeCrossSectionPerAtom(const G4ParticleDefinition* particle, 85 G4double KineticEnergy, 86 G4double KineticEnergy, 86 G4double AtomicNumber, 87 G4double AtomicNumber, 87 G4double AtomicWeight=0., 88 G4double AtomicWeight=0., 88 G4double cut =0., 89 G4double cut =0., 89 G4double emax=DBL_MAX) override; 90 G4double emax=DBL_MAX) override; 90 91 91 G4ThreeVector& SampleScattering(const G4Thre 92 G4ThreeVector& SampleScattering(const G4ThreeVector&, 92 G4double safety) override; 93 G4double safety) override; 93 94 94 G4double ComputeTruePathLengthLimit(const G4 95 G4double ComputeTruePathLengthLimit(const G4Track& track, 95 G4double& currentMinimalSt 96 G4double& currentMinimalStep) override; 96 97 97 G4double ComputeGeomPathLength(G4double true 98 G4double ComputeGeomPathLength(G4double truePathLength) override; 98 99 99 G4double ComputeTrueStepLength(G4double geom 100 G4double ComputeTrueStepLength(G4double geomStepLength) override; 100 101 101 G4double ComputeTheta0(G4double truePathLeng 102 G4double ComputeTheta0(G4double truePathLength, G4double KineticEnergy); 102 103 103 inline void SetDisplacementAlgorithm96(const << 104 << 105 inline void SetPositronCorrection(const G4bo << 106 << 107 // hide assignment operator 104 // hide assignment operator 108 G4UrbanMscModel & operator=(const G4UrbanMs 105 G4UrbanMscModel & operator=(const G4UrbanMscModel &right) = delete; 109 G4UrbanMscModel(const G4UrbanMscModel&) = d 106 G4UrbanMscModel(const G4UrbanMscModel&) = delete; 110 107 111 private: 108 private: 112 109 113 G4double SampleCosineTheta(G4double trueStep 110 G4double SampleCosineTheta(G4double trueStepLength, G4double KineticEnergy); 114 111 115 void SampleDisplacement(G4double sinTheta, G 112 void SampleDisplacement(G4double sinTheta, G4double phi); 116 113 117 void SampleDisplacementNew(G4double sinTheta 114 void SampleDisplacementNew(G4double sinTheta, G4double phi); 118 115 119 void InitialiseModelCache(); 116 void InitialiseModelCache(); 120 117 121 inline void SetParticle(const G4ParticleDefi 118 inline void SetParticle(const G4ParticleDefinition*); 122 119 123 inline G4double Randomizetlimit(); 120 inline G4double Randomizetlimit(); 124 121 125 inline G4double SimpleScattering(); << 122 inline G4double SimpleScattering(G4double xmeanth, G4double x2meanth); 126 123 127 inline G4double ComputeStepmin(); 124 inline G4double ComputeStepmin(); 128 125 129 inline G4double ComputeTlimitmin(); 126 inline G4double ComputeTlimitmin(); 130 127 131 CLHEP::HepRandomEngine* rndmEngineMod; << 128 CLHEP::HepRandomEngine* rndmEngineMod; 132 129 133 const G4ParticleDefinition* particle = nullp << 130 const G4ParticleDefinition* particle; 134 const G4ParticleDefinition* positron; 131 const G4ParticleDefinition* positron; 135 G4ParticleChangeForMSC* fParticleChange = nu << 132 G4ParticleChangeForMSC* fParticleChange; 136 const G4MaterialCutsCouple* couple = nullptr << 133 >> 134 const G4MaterialCutsCouple* couple; >> 135 G4LossTableManager* theManager; 137 136 138 G4double mass; 137 G4double mass; 139 G4double charge,chargeSquare; << 138 G4double charge,ChargeSquare; 140 G4double masslimite,fr; 139 G4double masslimite,fr; 141 140 142 G4double taubig; 141 G4double taubig; 143 G4double tausmall; 142 G4double tausmall; 144 G4double taulim; 143 G4double taulim; 145 G4double currentTau; 144 G4double currentTau; 146 G4double tlimit; 145 G4double tlimit; 147 G4double tlimitmin; 146 G4double tlimitmin; 148 G4double tlimitminfix,tlimitminfix2; 147 G4double tlimitminfix,tlimitminfix2; 149 G4double tgeom; 148 G4double tgeom; 150 149 151 G4double geombig; 150 G4double geombig; 152 G4double geommin; 151 G4double geommin; 153 G4double geomlimit; 152 G4double geomlimit; 154 G4double skindepth; 153 G4double skindepth; 155 G4double smallstep; 154 G4double smallstep; 156 155 157 G4double presafety; 156 G4double presafety; 158 157 159 G4double lambda0; 158 G4double lambda0; 160 G4double lambdaeff; 159 G4double lambdaeff; 161 G4double tPathLength; 160 G4double tPathLength; 162 G4double zPathLength; 161 G4double zPathLength; 163 G4double par1,par2,par3; 162 G4double par1,par2,par3; 164 163 165 G4double stepmin; 164 G4double stepmin; 166 165 167 G4double currentKinEnergy; 166 G4double currentKinEnergy; 168 G4double currentLogKinEnergy; 167 G4double currentLogKinEnergy; 169 G4double currentRange; 168 G4double currentRange; 170 G4double rangeinit; 169 G4double rangeinit; 171 G4double currentRadLength; 170 G4double currentRadLength; 172 171 >> 172 G4double rangecut; 173 G4double drr,finalr; 173 G4double drr,finalr; 174 174 175 G4double tlow; 175 G4double tlow; 176 G4double invmev; 176 G4double invmev; 177 G4double xmeanth = 0.0; << 178 G4double x2meanth = 1./3.; << 179 G4double rndmarray[2]; << 180 177 181 struct mscData { 178 struct mscData { 182 G4double Z23, sqrtZ, factmin; << 179 G4double ecut, Zeff, Z23, sqrtZ; 183 G4double coeffth1, coeffth2; 180 G4double coeffth1, coeffth2; 184 G4double coeffc1, coeffc2, coeffc3, coeffc 181 G4double coeffc1, coeffc2, coeffc3, coeffc4; 185 G4double stepmina, stepminb; 182 G4double stepmina, stepminb; 186 G4double doverra, doverrb; 183 G4double doverra, doverrb; 187 G4double posa, posb, posc, posd, pose; << 188 }; 184 }; 189 static std::vector<mscData*> msc; 185 static std::vector<mscData*> msc; 190 186 191 // index of G4MaterialCutsCouple 187 // index of G4MaterialCutsCouple 192 G4int idx = 0; << 188 G4int idx; 193 189 194 G4bool firstStep = true; << 190 G4bool firstStep; 195 G4bool insideskin = false; << 191 G4bool insideskin; >> 192 >> 193 G4bool latDisplasmentbackup; >> 194 G4bool dispAlg96; 196 195 197 G4bool latDisplasmentbackup = false; << 198 G4bool dispAlg96 = true; << 199 G4bool fPosiCorrection = true; << 200 G4bool isFirstInstance = false; << 201 }; 196 }; 202 197 203 //....oooOO0OOooo........oooOO0OOooo........oo 198 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 204 //....oooOO0OOooo........oooOO0OOooo........oo 199 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 205 200 206 inline 201 inline 207 void G4UrbanMscModel::SetParticle(const G4Part 202 void G4UrbanMscModel::SetParticle(const G4ParticleDefinition* p) 208 { 203 { 209 if (p != particle) { 204 if (p != particle) { 210 particle = p; 205 particle = p; 211 mass = p->GetPDGMass(); 206 mass = p->GetPDGMass(); 212 charge = p->GetPDGCharge()/CLHEP::eplus; 207 charge = p->GetPDGCharge()/CLHEP::eplus; 213 chargeSquare = charge*charge; << 208 ChargeSquare = charge*charge; 214 } 209 } 215 } 210 } 216 211 217 //....oooOO0OOooo........oooOO0OOooo........oo 212 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 218 213 219 inline G4double G4UrbanMscModel::Randomizetlim 214 inline G4double G4UrbanMscModel::Randomizetlimit() 220 { 215 { 221 G4double res = tlimitmin; 216 G4double res = tlimitmin; 222 if(tlimit > tlimitmin) 217 if(tlimit > tlimitmin) 223 { 218 { 224 res = G4RandGauss::shoot(rndmEngineMod,tli 219 res = G4RandGauss::shoot(rndmEngineMod,tlimit,0.1*(tlimit-tlimitmin)); 225 res = std::max(res, tlimitmin); 220 res = std::max(res, tlimitmin); 226 } 221 } 227 return res; 222 return res; 228 } 223 } 229 224 230 //....oooOO0OOooo........oooOO0OOooo........oo 225 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 231 226 232 inline G4double G4UrbanMscModel::SimpleScatter << 227 inline >> 228 G4double G4UrbanMscModel::SimpleScattering(G4double xmeanth, G4double x2meanth) 233 { 229 { 234 // 'large angle scattering' 230 // 'large angle scattering' 235 // 2 model functions with correct xmean and 231 // 2 model functions with correct xmean and x2mean 236 const G4double a = (2.*xmeanth+9.*x2meanth-3 << 232 G4double a = (2.*xmeanth+9.*x2meanth-3.)/(2.*xmeanth-3.*x2meanth+1.); 237 const G4double prob = (a+2.)*xmeanth/a; << 233 G4double prob = (a+2.)*xmeanth/a; 238 234 239 // sampling 235 // sampling 240 rndmEngineMod->flatArray(2, rndmarray); << 236 G4double rdm = rndmEngineMod->flat(); 241 return (rndmarray[1] < prob) ? << 237 G4double cth = (rndmEngineMod->flat() < prob) 242 -1.+2.*G4Exp(G4Log(rndmarray[0])/(a+1.)) : << 238 ? -1.+2.*G4Exp(G4Log(rdm)/(a+1.)) : -1.+2.*rdm; >> 239 return cth; 243 } 240 } 244 241 245 //....oooOO0OOooo........oooOO0OOooo........oo << 246 << 247 inline G4double G4UrbanMscModel::ComputeStepmi 242 inline G4double G4UrbanMscModel::ComputeStepmin() 248 { 243 { 249 // define stepmin using estimation of the ra 244 // define stepmin using estimation of the ratio 250 // of lambda_elastic/lambda_transport 245 // of lambda_elastic/lambda_transport 251 const G4double rat = currentKinEnergy*invmev << 246 G4double rat = currentKinEnergy*invmev; 252 return lambda0*msc[idx]->factmin/ << 247 return lambda0*1.e-3/(2.e-3+rat*(msc[idx]->stepmina+msc[idx]->stepminb*rat)); 253 (0.002 + rat*(msc[idx]->stepmina + msc[idx << 254 } 248 } 255 249 256 //....oooOO0OOooo........oooOO0OOooo........oo << 257 << 258 inline G4double G4UrbanMscModel::ComputeTlimit 250 inline G4double G4UrbanMscModel::ComputeTlimitmin() 259 { 251 { 260 G4double x = (particle == positron) ? 252 G4double x = (particle == positron) ? 261 0.7*msc[idx]->sqrtZ*stepmin : 0.87*msc[idx 253 0.7*msc[idx]->sqrtZ*stepmin : 0.87*msc[idx]->Z23*stepmin; 262 if(currentKinEnergy < tlow) { x *= 0.5*(1.+c 254 if(currentKinEnergy < tlow) { x *= 0.5*(1.+currentKinEnergy/tlow); } 263 return std::max(x, tlimitminfix); 255 return std::max(x, tlimitminfix); 264 } 256 } 265 257 266 //....oooOO0OOooo........oooOO0OOooo........oo 258 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 267 259 268 inline void G4UrbanMscModel::SetDisplacementAl << 269 { << 270 dispAlg96 = val; << 271 } << 272 << 273 //....oooOO0OOooo........oooOO0OOooo........oo << 274 << 275 inline void G4UrbanMscModel::SetPositronCorrec << 276 { << 277 fPosiCorrection = val; << 278 } << 279 << 280 //....oooOO0OOooo........oooOO0OOooo........oo << 281 260 282 #endif 261 #endif 283 262 284 263