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 // ClassName: G4EnergyLossForExtrapolator 29 // ClassName: G4EnergyLossForExtrapolator 30 // 30 // 31 // Description: This class provide calculatio 31 // Description: This class provide calculation of energy loss, fluctuation, 32 // and msc angle 32 // and msc angle 33 // 33 // 34 // Author: 09.12.04 V.Ivanchenko 34 // Author: 09.12.04 V.Ivanchenko 35 // 35 // 36 // Modification: 36 // Modification: 37 // 08-04-05 Rename Propogator -> Extrapolator 37 // 08-04-05 Rename Propogator -> Extrapolator 38 // 16-03-06 Add muon tables 38 // 16-03-06 Add muon tables 39 // 21-03-06 Add verbosity defined in the const 39 // 21-03-06 Add verbosity defined in the constructor and Initialisation 40 // start only when first public metho 40 // start only when first public method is called (V.Ivanchenko) 41 // 03-05-06 Remove unused pointer G4Material* 41 // 03-05-06 Remove unused pointer G4Material* from number of methods (VI) 42 // 28-07-07 Add maxEnergyTransfer for computat 42 // 28-07-07 Add maxEnergyTransfer for computation of energy loss (VI) 43 // 43 // 44 //-------------------------------------------- 44 //---------------------------------------------------------------------------- 45 // 45 // 46 46 47 //....oooOO0OOooo........oooOO0OOooo........oo 47 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 48 48 49 #ifndef G4EnergyLossForExtrapolator_h 49 #ifndef G4EnergyLossForExtrapolator_h 50 #define G4EnergyLossForExtrapolator_h 1 50 #define G4EnergyLossForExtrapolator_h 1 51 51 52 #include <vector> 52 #include <vector> 53 #include <CLHEP/Units/PhysicalConstants.h> 53 #include <CLHEP/Units/PhysicalConstants.h> 54 54 55 #include "globals.hh" 55 #include "globals.hh" 56 #include "G4PhysicsTable.hh" 56 #include "G4PhysicsTable.hh" 57 #include "G4TablesForExtrapolator.hh" 57 #include "G4TablesForExtrapolator.hh" 58 #include "G4Log.hh" 58 #include "G4Log.hh" 59 #include "G4Threading.hh" 59 #include "G4Threading.hh" 60 60 61 class G4ParticleDefinition; 61 class G4ParticleDefinition; 62 class G4Material; 62 class G4Material; 63 class G4MaterialCutsCouple; 63 class G4MaterialCutsCouple; 64 64 65 //....oooOO0OOooo........oooOO0OOooo........oo 65 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 66 66 67 class G4EnergyLossForExtrapolator 67 class G4EnergyLossForExtrapolator 68 { 68 { 69 public: 69 public: 70 70 71 explicit G4EnergyLossForExtrapolator(G4int v 71 explicit G4EnergyLossForExtrapolator(G4int verb = 1); 72 72 73 ~G4EnergyLossForExtrapolator(); 73 ~G4EnergyLossForExtrapolator(); 74 74 75 void Initialisation(); << 75 G4double ComputeDEDX(G4double kinEnergy, const G4ParticleDefinition*); 76 << 77 G4double ComputeDEDX(G4double kinEnergy, con << 78 const G4Material*); << 79 76 80 G4double ComputeRange(G4double kinEnergy, co << 77 G4double ComputeRange(G4double kinEnergy, const G4ParticleDefinition*); 81 const G4Material*); << 82 78 83 G4double ComputeEnergy(G4double range, const << 79 G4double ComputeEnergy(G4double range, const G4ParticleDefinition*); 84 const G4Material*); << 85 80 86 G4double EnergyAfterStep(G4double kinEnergy, 81 G4double EnergyAfterStep(G4double kinEnergy, G4double step, 87 const G4Material*, const G4ParticleDe 82 const G4Material*, const G4ParticleDefinition*); 88 83 89 G4double EnergyBeforeStep(G4double kinEnergy 84 G4double EnergyBeforeStep(G4double kinEnergy, G4double step, 90 const G4Material*, const G4Par 85 const G4Material*, const G4ParticleDefinition*); 91 86 92 G4double TrueStepLength(G4double kinEnergy, 87 G4double TrueStepLength(G4double kinEnergy, G4double step, 93 const G4Material*, const G4ParticleDef 88 const G4Material*, const G4ParticleDefinition* part); 94 89 95 inline G4double EnergyAfterStep(G4double kin 90 inline G4double EnergyAfterStep(G4double kinEnergy, G4double step, 96 const G4Material*, 91 const G4Material*, 97 const G4Stri 92 const G4String& particleName); 98 93 99 inline G4double EnergyBeforeStep(G4double ki 94 inline G4double EnergyBeforeStep(G4double kinEnergy, G4double step, 100 const G4Material*, 95 const G4Material*, 101 const G4Str 96 const G4String& particleName); 102 97 103 G4double AverageScatteringAngle(G4double kin << 98 inline G4double AverageScatteringAngle(G4double kinEnergy, G4double step, 104 const G4Material*, << 99 const G4Material*, 105 const G4ParticleDefinition* part); << 100 const G4ParticleDefinition* part); 106 101 107 inline G4double AverageScatteringAngle(G4dou 102 inline G4double AverageScatteringAngle(G4double kinEnergy, G4double step, 108 const G4Material*, 103 const G4Material*, 109 const G4String& particleName); 104 const G4String& particleName); 110 105 111 inline G4double ComputeTrueStep(const G4Mate 106 inline G4double ComputeTrueStep(const G4Material*, 112 const G4ParticleDefinition* part, 107 const G4ParticleDefinition* part, 113 G4double kinEnergy, G4double stepLen 108 G4double kinEnergy, G4double stepLength); 114 109 115 G4double EnergyDispersion(G4double kinEnergy << 110 inline G4double EnergyDispersion(G4double kinEnergy, G4double step, 116 const G4Material*, << 111 const G4Material*, 117 const G4ParticleDefinition*); << 112 const G4ParticleDefinition*); 118 113 119 inline G4double EnergyDispersion(G4double ki 114 inline G4double EnergyDispersion(G4double kinEnergy, G4double step, 120 const G4Material*, 115 const G4Material*, 121 const G4Str 116 const G4String& particleName); 122 117 123 inline void SetVerbose(G4int val); 118 inline void SetVerbose(G4int val); 124 119 125 inline void SetMinKinEnergy(G4double); 120 inline void SetMinKinEnergy(G4double); 126 121 127 inline void SetMaxKinEnergy(G4double); 122 inline void SetMaxKinEnergy(G4double); 128 123 129 inline void SetMaxEnergyTransfer(G4double); 124 inline void SetMaxEnergyTransfer(G4double); 130 << 131 // hide assignment operator << 132 G4EnergyLossForExtrapolator & operator= << 133 (const G4EnergyLossForExtrapolator &right) = << 134 G4EnergyLossForExtrapolator(const G4EnergyLo << 135 125 136 private: 126 private: 137 127 >> 128 void Initialisation(); >> 129 >> 130 void BuildTables(); >> 131 138 G4bool SetupKinematics(const G4ParticleDefin 132 G4bool SetupKinematics(const G4ParticleDefinition*, const G4Material*, 139 G4double kinEnergy); 133 G4double kinEnergy); 140 134 141 const G4ParticleDefinition* FindParticle(con 135 const G4ParticleDefinition* FindParticle(const G4String& name); 142 136 143 inline G4double ComputeValue(G4double x, con 137 inline G4double ComputeValue(G4double x, const G4PhysicsTable* table, 144 size_t idxMat); << 138 size_t idx); 145 139 146 inline const G4PhysicsTable* GetPhysicsTable 140 inline const G4PhysicsTable* GetPhysicsTable(ExtTableType type) const; 147 141 >> 142 // hide assignment operator >> 143 G4EnergyLossForExtrapolator & operator=(const G4EnergyLossForExtrapolator &right); >> 144 G4EnergyLossForExtrapolator(const G4EnergyLossForExtrapolator&); >> 145 148 #ifdef G4MULTITHREADED 146 #ifdef G4MULTITHREADED 149 static G4Mutex extrMutex; << 147 static G4Mutex extrapolatorMutex; 150 #endif 148 #endif 151 static G4TablesForExtrapolator* tables; 149 static G4TablesForExtrapolator* tables; 152 150 153 const G4ParticleDefinition* currentParticle << 151 const G4ParticleDefinition* currentParticle; 154 const G4ParticleDefinition* electron = nullp << 152 const G4ParticleDefinition* electron; 155 const G4ParticleDefinition* positron = nullp << 153 const G4ParticleDefinition* positron; 156 const G4ParticleDefinition* muonPlus = nullp << 154 const G4ParticleDefinition* muonPlus; 157 const G4ParticleDefinition* muonMinus= nullp << 155 const G4ParticleDefinition* muonMinus; 158 const G4ParticleDefinition* proton = nullptr << 156 const G4ParticleDefinition* proton; 159 const G4Material* currentMaterial = nullptr; << 157 160 << 158 G4String currentParticleName; 161 G4double electronDensity = 0.0; << 159 162 G4double radLength = 0.0; << 160 size_t idxDedxElectron; 163 G4double charge2 = 0.0; << 161 size_t idxDedxPositron; 164 G4double kineticEnergy = 0.0; << 162 size_t idxDedxMuon; 165 G4double gam = 1.0; << 163 size_t idxDedxProton; 166 G4double bg2 = 0.0; << 164 size_t idxRangeElectron; 167 G4double beta2 = 0.0; << 165 size_t idxRangePositron; 168 G4double tmax = 0.0; << 166 size_t idxRangeMuon; 169 << 167 size_t idxRangeProton; 170 G4double linLossLimit = 0.01; << 168 size_t idxInvRangeElectron; 171 G4double emin = 0.0; << 169 size_t idxInvRangePositron; 172 G4double emax = 0.0; << 170 size_t idxInvRangeMuon; 173 G4double maxEnergyTransfer = 0.0; << 171 size_t idxInvRangeProton; 174 << 172 size_t idxMscElectron; 175 size_t index = 0; << 173 176 size_t nmat = 0; << 174 const G4Material* currentMaterial; 177 G4int nbins = 80; << 175 G4int index; 178 G4int verbose = 0; << 176 179 << 177 G4double electronDensity; 180 G4bool isMaster = false; << 178 G4double radLength; >> 179 G4double mass; >> 180 G4double charge2; >> 181 G4double kineticEnergy; >> 182 G4double gam; >> 183 G4double bg2; >> 184 G4double beta2; >> 185 G4double tmax; >> 186 >> 187 G4double linLossLimit; >> 188 G4double emin; >> 189 G4double emax; >> 190 G4double maxEnergyTransfer; >> 191 >> 192 G4int nbins; >> 193 G4int nmat; >> 194 G4int verbose; 181 }; 195 }; 182 196 183 //....oooOO0OOooo........oooOO0OOooo........oo 197 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 184 198 185 inline const G4PhysicsTable* 199 inline const G4PhysicsTable* 186 G4EnergyLossForExtrapolator::GetPhysicsTable(E 200 G4EnergyLossForExtrapolator::GetPhysicsTable(ExtTableType type) const 187 { 201 { 188 return tables->GetPhysicsTable(type); 202 return tables->GetPhysicsTable(type); 189 } 203 } 190 204 191 //....oooOO0OOooo........oooOO0OOooo........oo 205 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 192 206 193 inline G4double 207 inline G4double 194 G4EnergyLossForExtrapolator::EnergyAfterStep(G 208 G4EnergyLossForExtrapolator::EnergyAfterStep(G4double kinEnergy, 195 G4double step, 209 G4double step, 196 const G4Material* mat, 210 const G4Material* mat, 197 const G4String& name) 211 const G4String& name) 198 { 212 { 199 return EnergyAfterStep(kinEnergy,step,mat,Fi 213 return EnergyAfterStep(kinEnergy,step,mat,FindParticle(name)); 200 } 214 } 201 215 202 //....oooOO0OOooo........oooOO0OOooo........oo 216 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 203 217 204 inline G4double 218 inline G4double 205 G4EnergyLossForExtrapolator::EnergyBeforeStep( 219 G4EnergyLossForExtrapolator::EnergyBeforeStep(G4double kinEnergy, 206 G4double step, 220 G4double step, 207 const G4Material* mat, 221 const G4Material* mat, 208 const G4String& name) 222 const G4String& name) 209 { 223 { 210 return EnergyBeforeStep(kinEnergy,step,mat,F 224 return EnergyBeforeStep(kinEnergy,step,mat,FindParticle(name)); 211 } 225 } 212 226 213 //....oooOO0OOooo........oooOO0OOooo........oo 227 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 214 228 215 inline G4double 229 inline G4double 216 G4EnergyLossForExtrapolator::AverageScattering 230 G4EnergyLossForExtrapolator::AverageScatteringAngle(G4double kinEnergy, 217 G4double step, 231 G4double step, 218 const G4Material* mat, 232 const G4Material* mat, 219 const G4String& name) 233 const G4String& name) 220 { 234 { 221 return AverageScatteringAngle(kinEnergy,step 235 return AverageScatteringAngle(kinEnergy,step,mat,FindParticle(name)); 222 } 236 } 223 237 224 //....oooOO0OOooo........oooOO0OOooo........oo 238 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 225 239 226 inline G4double 240 inline G4double 227 G4EnergyLossForExtrapolator::EnergyDispersion( 241 G4EnergyLossForExtrapolator::EnergyDispersion(G4double kinEnergy, 228 G4double step, 242 G4double step, 229 const G4Material* mat, 243 const G4Material* mat, 230 const G4String& name) 244 const G4String& name) 231 { 245 { 232 return EnergyDispersion(kinEnergy,step,mat,F 246 return EnergyDispersion(kinEnergy,step,mat,FindParticle(name)); 233 } 247 } 234 248 235 //....oooOO0OOooo........oooOO0OOooo........oo 249 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 236 250 >> 251 inline G4double G4EnergyLossForExtrapolator::AverageScatteringAngle( >> 252 G4double kinEnergy, >> 253 G4double stepLength, >> 254 const G4Material* mat, >> 255 const G4ParticleDefinition* part) >> 256 { >> 257 G4double theta = 0.0; >> 258 if(SetupKinematics(part, mat, kinEnergy)) { >> 259 G4double t = stepLength/radLength; >> 260 G4double y = std::max(0.001, t); >> 261 theta = 19.23*CLHEP::MeV*std::sqrt(charge2*t)*(1.0 + 0.038*G4Log(y)) >> 262 /(beta2*gam*mass); >> 263 } >> 264 return theta; >> 265 } >> 266 >> 267 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 268 237 inline G4double 269 inline G4double 238 G4EnergyLossForExtrapolator::ComputeTrueStep(c 270 G4EnergyLossForExtrapolator::ComputeTrueStep(const G4Material* mat, 239 const G4ParticleDefinition* par 271 const G4ParticleDefinition* part, 240 G4double kinEnergy, 272 G4double kinEnergy, 241 G4double stepLength) 273 G4double stepLength) 242 { 274 { 243 G4double theta = AverageScatteringAngle(kinE 275 G4double theta = AverageScatteringAngle(kinEnergy,stepLength,mat,part); 244 return stepLength*std::sqrt(1.0 + 0.625*thet 276 return stepLength*std::sqrt(1.0 + 0.625*theta*theta); 245 } 277 } 246 278 247 //....oooOO0OOooo........oooOO0OOooo........oo 279 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 280 >> 281 inline G4double >> 282 G4EnergyLossForExtrapolator::EnergyDispersion(G4double kinEnergy, >> 283 G4double stepLength, >> 284 const G4Material* mat, >> 285 const G4ParticleDefinition* part) >> 286 { >> 287 G4double sig2 = 0.0; >> 288 if(SetupKinematics(part, mat, kinEnergy)) { >> 289 G4double step = ComputeTrueStep(mat,part,kinEnergy,stepLength); >> 290 sig2 = (1.0/beta2 - 0.5) >> 291 *CLHEP::twopi_mc2_rcl2*tmax*step*electronDensity*charge2; >> 292 } >> 293 return sig2; >> 294 } >> 295 >> 296 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 248 297 249 inline G4double 298 inline G4double 250 G4EnergyLossForExtrapolator::ComputeValue(G4do 299 G4EnergyLossForExtrapolator::ComputeValue(G4double x, 251 const G4PhysicsTable* table, 300 const G4PhysicsTable* table, 252 size_t idxMat) << 301 size_t idx) 253 { 302 { 254 return (nullptr != table) ? ((*table)[idxMat << 303 G4double res = 0.0; >> 304 if(table) { res = ((*table)[index])->Value(x, idx); } >> 305 return res; 255 } 306 } 256 307 257 //....oooOO0OOooo........oooOO0OOooo........oo 308 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 258 309 259 inline void G4EnergyLossForExtrapolator::SetVe 310 inline void G4EnergyLossForExtrapolator::SetVerbose(G4int val) 260 { 311 { 261 verbose = val; 312 verbose = val; 262 } 313 } 263 314 264 //....oooOO0OOooo........oooOO0OOooo........oo 315 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 265 316 266 inline void G4EnergyLossForExtrapolator::SetMi 317 inline void G4EnergyLossForExtrapolator::SetMinKinEnergy(G4double val) 267 { 318 { 268 emin = val; 319 emin = val; 269 } 320 } 270 321 271 //....oooOO0OOooo........oooOO0OOooo........oo 322 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 272 323 273 inline void G4EnergyLossForExtrapolator::SetMa 324 inline void G4EnergyLossForExtrapolator::SetMaxKinEnergy(G4double val) 274 { 325 { 275 emax = val; 326 emax = val; 276 } 327 } 277 328 278 //....oooOO0OOooo........oooOO0OOooo........oo 329 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 279 330 280 inline void G4EnergyLossForExtrapolator::SetMa 331 inline void G4EnergyLossForExtrapolator::SetMaxEnergyTransfer(G4double val) 281 { 332 { 282 maxEnergyTransfer = val; 333 maxEnergyTransfer = val; 283 } 334 } 284 335 285 //....oooOO0OOooo........oooOO0OOooo........oo 336 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 286 337 287 #endif 338 #endif 288 339 289 340