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