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: G4VMscModel.hh,v 1.10 2010-09-07 16:05:33 vnivanch Exp $ >> 27 // GEANT4 tag $Name: not supported by cvs2svn $ >> 28 // 26 // ------------------------------------------- 29 // ------------------------------------------------------------------- 27 // 30 // 28 // GEANT4 Class header file 31 // GEANT4 Class header file 29 // 32 // 30 // 33 // 31 // File name: G4VMscModel 34 // File name: G4VMscModel 32 // 35 // 33 // Author: Vladimir Ivanchenko 36 // Author: Vladimir Ivanchenko 34 // 37 // 35 // Creation date: 07.03.2008 38 // Creation date: 07.03.2008 36 // 39 // 37 // Modifications: 40 // Modifications: 38 // 07.04.2009 V.Ivanchenko moved msc methods f 41 // 07.04.2009 V.Ivanchenko moved msc methods from G4VEmModel to G4VMscModel 39 // 26.03.2012 V.Ivanchenko added transport x-s << 40 // 42 // 41 // Class Description: 43 // Class Description: 42 // 44 // 43 // General interface to msc models 45 // General interface to msc models 44 46 45 // ------------------------------------------- 47 // ------------------------------------------------------------------- 46 // 48 // >> 49 47 #ifndef G4VMscModel_h 50 #ifndef G4VMscModel_h 48 #define G4VMscModel_h 1 51 #define G4VMscModel_h 1 49 52 50 #include <CLHEP/Units/SystemOfUnits.h> << 51 << 52 #include "G4VEmModel.hh" 53 #include "G4VEmModel.hh" 53 #include "G4MscStepLimitType.hh" 54 #include "G4MscStepLimitType.hh" 54 #include "globals.hh" 55 #include "globals.hh" 55 #include "G4ThreeVector.hh" 56 #include "G4ThreeVector.hh" 56 #include "G4Track.hh" 57 #include "G4Track.hh" 57 #include "G4SafetyHelper.hh" 58 #include "G4SafetyHelper.hh" 58 #include "G4PhysicsTable.hh" << 59 #include "G4VEnergyLossProcess.hh" 59 #include "G4ThreeVector.hh" << 60 #include <vector> << 61 60 62 class G4ParticleChangeForMSC; 61 class G4ParticleChangeForMSC; 63 class G4ParticleDefinition; << 64 class G4VEnergyLossProcess; << 65 62 66 class G4VMscModel : public G4VEmModel 63 class G4VMscModel : public G4VEmModel 67 { 64 { 68 65 69 public: 66 public: 70 67 71 explicit G4VMscModel(const G4String& nam); << 68 G4VMscModel(const G4String& nam); 72 69 73 ~G4VMscModel() override; << 70 virtual ~G4VMscModel(); 74 71 75 virtual G4double ComputeTruePathLengthLimit( 72 virtual G4double ComputeTruePathLengthLimit(const G4Track& track, 76 G4double& stepLimit) = 0; << 73 G4PhysicsTable*, >> 74 G4double currentMinimalStep); 77 75 78 virtual G4double ComputeGeomPathLength(G4dou << 76 virtual G4double ComputeGeomPathLength(G4double truePathLength); 79 77 80 virtual G4double ComputeTrueStepLength(G4dou << 78 virtual G4double ComputeTrueStepLength(G4double geomPathLength); 81 79 82 virtual G4ThreeVector& SampleScattering(cons << 80 virtual void SampleScattering(const G4DynamicParticle*, 83 G4double safety) = 0; << 81 G4double safety); 84 << 82 85 void InitialiseParameters(const G4ParticleDe << 83 // empty 86 << 84 virtual void SampleSecondaries(std::vector<G4DynamicParticle*>*, 87 void DumpParameters(std::ostream& out) const << 85 const G4MaterialCutsCouple*, 88 << 86 const G4DynamicParticle*, 89 // empty method << 87 G4double tmin, 90 void SampleSecondaries(std::vector<G4Dynamic << 88 G4double tmax); 91 const G4MaterialCutsCouple*, << 92 const G4DynamicParticle*, << 93 G4double tmin, G4double tmax) override; << 94 89 95 //========================================== 90 //================================================================ 96 // Set parameters of multiple scattering mo 91 // Set parameters of multiple scattering models 97 //========================================== 92 //================================================================ 98 93 99 inline void SetStepLimitType(G4MscStepLimitT 94 inline void SetStepLimitType(G4MscStepLimitType); 100 95 101 inline void SetLateralDisplasmentFlag(G4bool 96 inline void SetLateralDisplasmentFlag(G4bool val); 102 97 103 inline void SetRangeFactor(G4double); 98 inline void SetRangeFactor(G4double); 104 99 105 inline void SetGeomFactor(G4double); 100 inline void SetGeomFactor(G4double); 106 101 107 inline void SetSkin(G4double); 102 inline void SetSkin(G4double); 108 103 109 inline void SetLambdaLimit(G4double); << 110 << 111 inline void SetSafetyFactor(G4double); << 112 << 113 inline void SetSampleZ(G4bool); 104 inline void SetSampleZ(G4bool); 114 105 115 //========================================== << 116 // Get/Set access to Physics Tables << 117 //========================================== << 118 << 119 inline G4VEnergyLossProcess* GetIonisation() 106 inline G4VEnergyLossProcess* GetIonisation() const; 120 107 121 inline void SetIonisation(G4VEnergyLossProce << 108 inline void SetIonisation(G4VEnergyLossProcess*); 122 const G4ParticleDefinition* part); << 123 << 124 //========================================== << 125 // Run time methods << 126 //========================================== << 127 109 128 protected: 110 protected: 129 111 130 // initialisation of the ParticleChange for 112 // initialisation of the ParticleChange for the model 131 // initialisation of interface with geometry 113 // initialisation of interface with geometry and ionisation 132 G4ParticleChangeForMSC* << 114 G4ParticleChangeForMSC* GetParticleChangeForMSC(); 133 GetParticleChangeForMSC(const G4ParticleDefi << 134 << 135 // convert true length to geometry length << 136 inline G4double ConvertTrueToGeom(G4double& << 137 115 138 // should be set before initialisation << 116 // shift point of the track PostStep 139 inline void SetUseSplineForMSC(G4bool val); << 117 void ComputeDisplacement(G4ParticleChangeForMSC*, 140 << 118 const G4ThreeVector& displDir, 141 public: << 119 G4double displacement, >> 120 G4double postsafety); 142 121 143 // compute safety 122 // compute safety 144 inline G4double ComputeSafety(const G4ThreeV << 123 inline G4double ComputeSafety(const G4ThreeVector& position, G4double limit); 145 G4double limit= DBL_MAX); << 146 124 147 // compute linear distance to a geometry bou 125 // compute linear distance to a geometry boundary 148 inline G4double ComputeGeomLimit(const G4Tra << 126 inline G4double ComputeGeomLimit(const G4Track& position, G4double& presafety, 149 G4double limit); 127 G4double limit); 150 128 151 G4double GetDEDX(const G4ParticleDefinition* << 129 inline G4double GetRange(const G4ParticleDefinition* part, 152 G4double kineticEner << 153 const G4MaterialCuts << 154 << 155 G4double GetDEDX(const G4ParticleDefinition* << 156 G4double kineticEner << 157 const G4MaterialCuts << 158 G4double logKineticE << 159 << 160 G4double GetRange(const G4ParticleDefinition << 161 G4double kineticEne << 162 const G4MaterialCut << 163 << 164 G4double GetRange(const G4ParticleDefinition << 165 G4double kineticEne 130 G4double kineticEnergy, 166 const G4MaterialCut << 131 const G4MaterialCutsCouple* couple); 167 G4double logKinetic << 168 132 169 G4double GetEnergy(const G4ParticleDefinitio << 133 inline G4double GetEnergy(const G4ParticleDefinition* part, 170 G4double range, 134 G4double range, 171 const G4MaterialCutsCouple* couple); 135 const G4MaterialCutsCouple* couple); 172 136 173 // G4MaterialCutsCouple should be defined be << 137 private: 174 inline << 175 G4double GetTransportMeanFreePath(const G4Pa << 176 G4double k << 177 << 178 inline << 179 G4double GetTransportMeanFreePath(const G4Pa << 180 G4double k << 181 G4double l << 182 138 183 // hide assignment operator 139 // hide assignment operator 184 G4VMscModel & operator=(const G4VMscModel & << 140 G4VMscModel & operator=(const G4VMscModel &right); 185 G4VMscModel(const G4VMscModel&) = delete; << 141 G4VMscModel(const G4VMscModel&); 186 142 187 private: << 143 G4SafetyHelper* safetyHelper; >> 144 G4VEnergyLossProcess* ionisation; 188 145 189 G4SafetyHelper* safetyHelper = nullptr; << 146 G4double dedx; 190 G4VEnergyLossProcess* ionisation = nullptr; << 147 G4double localtkin; 191 const G4ParticleDefinition* currentPart = nu << 148 G4double localrange; 192 << 193 G4double dedx = 0.0; << 194 G4double localtkin = 0.0; << 195 G4double localrange = DBL_MAX; << 196 149 197 protected: 150 protected: 198 151 199 G4double facrange = 0.04; << 152 G4double facrange; 200 G4double facgeom = 2.5; << 153 G4double facgeom; 201 G4double facsafety = 0.6; << 154 G4double facsafety; 202 G4double skin = 1.0; << 155 G4double skin; 203 G4double dtrl = 0.05; << 156 G4double dtrl; 204 G4double lambdalimit; 157 G4double lambdalimit; 205 G4double geomMin; 158 G4double geomMin; 206 G4double geomMax; 159 G4double geomMax; 207 160 208 G4ThreeVector fDisplacement; << 209 G4MscStepLimitType steppingAlgorithm; 161 G4MscStepLimitType steppingAlgorithm; 210 162 211 G4bool samplez = false; << 163 G4bool samplez; 212 G4bool latDisplasment = true; << 164 G4bool latDisplasment; 213 165 214 private: << 215 << 216 G4bool useSpline = true; << 217 }; 166 }; 218 167 219 //....oooOO0OOooo........oooOO0OOooo........oo 168 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 220 //....oooOO0OOooo........oooOO0OOooo........oo 169 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 221 170 222 inline void G4VMscModel::SetLateralDisplasment 171 inline void G4VMscModel::SetLateralDisplasmentFlag(G4bool val) 223 { 172 { 224 if(!IsLocked()) { latDisplasment = val; } << 173 latDisplasment = val; 225 } 174 } 226 175 227 //....oooOO0OOooo........oooOO0OOooo........oo 176 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 228 177 229 inline void G4VMscModel::SetSkin(G4double val) 178 inline void G4VMscModel::SetSkin(G4double val) 230 { 179 { 231 if(!IsLocked()) { skin = val; } << 180 skin = val; 232 } 181 } 233 182 234 //....oooOO0OOooo........oooOO0OOooo........oo 183 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 235 184 236 inline void G4VMscModel::SetRangeFactor(G4doub 185 inline void G4VMscModel::SetRangeFactor(G4double val) 237 { 186 { 238 if(!IsLocked()) { facrange = val; } << 187 facrange = val; 239 } 188 } 240 189 241 //....oooOO0OOooo........oooOO0OOooo........oo 190 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 242 191 243 inline void G4VMscModel::SetGeomFactor(G4doubl 192 inline void G4VMscModel::SetGeomFactor(G4double val) 244 { 193 { 245 if(!IsLocked()) { facgeom = val; } << 194 facgeom = val; 246 } << 247 << 248 //....oooOO0OOooo........oooOO0OOooo........oo << 249 << 250 inline void G4VMscModel::SetLambdaLimit(G4doub << 251 { << 252 if(!IsLocked()) { lambdalimit = val; } << 253 } << 254 << 255 //....oooOO0OOooo........oooOO0OOooo........oo << 256 << 257 inline void G4VMscModel::SetSafetyFactor(G4dou << 258 { << 259 if(!IsLocked()) { facsafety = val; } << 260 } 195 } 261 196 262 //....oooOO0OOooo........oooOO0OOooo........oo 197 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 263 198 264 inline void G4VMscModel::SetStepLimitType(G4Ms 199 inline void G4VMscModel::SetStepLimitType(G4MscStepLimitType val) 265 { 200 { 266 if(!IsLocked()) { steppingAlgorithm = val; } << 201 steppingAlgorithm = val; 267 } 202 } 268 203 269 //....oooOO0OOooo........oooOO0OOooo........oo 204 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 270 205 271 inline void G4VMscModel::SetSampleZ(G4bool val 206 inline void G4VMscModel::SetSampleZ(G4bool val) 272 { 207 { 273 if(!IsLocked()) { samplez = val; } << 208 samplez = val; 274 } 209 } 275 210 276 //....oooOO0OOooo........oooOO0OOooo........oo 211 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 277 212 278 inline G4double G4VMscModel::ComputeSafety(con 213 inline G4double G4VMscModel::ComputeSafety(const G4ThreeVector& position, 279 G4double limit) << 214 G4double) 280 { 215 { 281 return safetyHelper->ComputeSafety(position << 216 return safetyHelper->ComputeSafety(position); 282 } << 283 << 284 //....oooOO0OOooo........oooOO0OOooo........oo << 285 << 286 inline G4double G4VMscModel::ConvertTrueToGeom << 287 G4double& glength) << 288 { << 289 glength = ComputeGeomPathLength(tlength); << 290 // should return true length << 291 return tlength; << 292 } 217 } 293 218 294 //....oooOO0OOooo........oooOO0OOooo........oo 219 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 295 220 296 inline G4double G4VMscModel::ComputeGeomLimit( 221 inline G4double G4VMscModel::ComputeGeomLimit(const G4Track& track, 297 G4double& presafety, 222 G4double& presafety, 298 G4double limit) 223 G4double limit) 299 { 224 { 300 return safetyHelper->CheckNextStep( << 225 G4double res = geomMax; >> 226 if(track.GetVolume() != safetyHelper->GetWorldVolume()) { >> 227 res = safetyHelper->CheckNextStep( 301 track.GetStep()->GetPreStepPoint()-> 228 track.GetStep()->GetPreStepPoint()->GetPosition(), 302 track.GetMomentumDirection(), 229 track.GetMomentumDirection(), 303 limit, presafety); 230 limit, presafety); 304 } << 231 } 305 << 232 return res; 306 //....oooOO0OOooo........oooOO0OOooo........oo << 307 << 308 inline G4VEnergyLossProcess* G4VMscModel::GetI << 309 { << 310 return ionisation; << 311 } << 312 << 313 //....oooOO0OOooo........oooOO0OOooo........oo << 314 << 315 inline void G4VMscModel::SetIonisation(G4VEner << 316 const G4ParticleDefinition* par << 317 { << 318 ionisation = p; << 319 currentPart = part; << 320 } 233 } 321 234 322 //....oooOO0OOooo........oooOO0OOooo........oo 235 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 323 236 324 inline G4double 237 inline G4double 325 G4VMscModel::GetTransportMeanFreePath(const G4 << 238 G4VMscModel::GetRange(const G4ParticleDefinition* part, 326 G4double << 239 G4double kinEnergy, const G4MaterialCutsCouple* couple) 327 { 240 { 328 G4double x; << 241 localrange = DBL_MAX; 329 if (nullptr != xSectionTable) { << 242 localtkin = kinEnergy; 330 x = pFactor*(*xSectionTable)[basedCoupleIn << 243 if(ionisation) { localrange = ionisation->GetRangeForLoss(localtkin, couple); } 331 } else { << 244 else { 332 x = pFactor*CrossSectionPerVolume(pBaseMat << 245 G4double q = part->GetPDGCharge()/eplus; >> 246 localrange = kinEnergy/(dedx*q*q*couple->GetMaterial()->GetDensity()); 333 } 247 } 334 return (x > 0.0) ? 1.0/x : DBL_MAX; << 248 return localrange; 335 } 249 } 336 250 337 //....oooOO0OOooo........oooOO0OOooo........oo 251 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 338 252 339 inline G4double 253 inline G4double 340 G4VMscModel::GetTransportMeanFreePath(const G4 << 254 G4VMscModel::GetEnergy(const G4ParticleDefinition* part, 341 G4double << 255 G4double range, const G4MaterialCutsCouple* couple) 342 { 256 { 343 G4double x; << 257 G4double e = localtkin; 344 if (nullptr != xSectionTable) { << 258 if(ionisation) { e = ionisation->GetKineticEnergy(range, couple); } 345 x = pFactor*(*xSectionTable)[basedCoupleIn << 259 else { 346 } else { << 260 G4double q = part->GetPDGCharge()/eplus; 347 x = pFactor*CrossSectionPerVolume(pBaseMat << 261 if(localrange > range) { >> 262 e -= (localrange - range)*dedx*q*q*couple->GetMaterial()->GetDensity(); >> 263 } 348 } 264 } 349 return (x > 0.0) ? 1.0/x : DBL_MAX; << 265 if(e < 0.0) { e = 0.0; } >> 266 return e; 350 } 267 } 351 268 352 //....oooOO0OOooo........oooOO0OOooo........oo << 269 inline G4VEnergyLossProcess* G4VMscModel::GetIonisation() const >> 270 { >> 271 return ionisation; >> 272 } 353 273 354 inline void G4VMscModel::SetUseSplineForMSC(G4 << 274 inline void G4VMscModel::SetIonisation(G4VEnergyLossProcess* p) 355 { 275 { 356 useSpline = val; << 276 ionisation = p; 357 } 277 } 358 278 359 //....oooOO0OOooo........oooOO0OOooo........oo 279 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 360 280 361 #endif 281 #endif >> 282 362 283