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