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