Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** 25 // 22 // >> 23 // >> 24 // 26 // ------------------------------------------- 25 // ------------------------------------------------------------------- 27 // 26 // 28 // GEANT4 Class header file 27 // GEANT4 Class header file 29 // 28 // 30 // 29 // 31 // File name: G4LossTableManager 30 // File name: G4LossTableManager 32 // 31 // 33 // Author: Vladimir Ivanchenko on base 32 // Author: Vladimir Ivanchenko on base of G4LossTables class 34 // and Maria Grazia Pia ideas 33 // and Maria Grazia Pia ideas 35 // 34 // 36 // Creation date: 03.01.2002 35 // Creation date: 03.01.2002 37 // 36 // 38 // Modifications by V.Ivanchenko << 37 // Modifications: >> 38 // >> 39 // 20-01-03 Migrade to cut per region (V.Ivanchenko) >> 40 // 17-02-03 Fix problem of store/restore tables for ions (V.Ivanchenko) >> 41 // 10-03-03 Add Ion registration (V.Ivanchenko) >> 42 // 25-03-03 Add deregistration (V.Ivanchenko) >> 43 // 26-03-03 Add GetDEDXDispersion (V.Ivanchenko) >> 44 // 02-04-03 Change messenger (V.Ivanchenko) 39 // 45 // 40 // Class Description: 46 // Class Description: 41 // 47 // 42 // A utility static class, responsable for the 48 // A utility static class, responsable for the energy loss tables 43 // for each particle 49 // for each particle 44 // 50 // 45 // Energy loss processes have to register thei 51 // Energy loss processes have to register their tables with this 46 // class. The responsibility of creating and d 52 // class. The responsibility of creating and deleting the tables 47 // remains with the energy loss classes. 53 // remains with the energy loss classes. 48 54 49 // ------------------------------------------- 55 // ------------------------------------------------------------------- 50 // 56 // 51 57 52 #ifndef G4LossTableManager_h 58 #ifndef G4LossTableManager_h 53 #define G4LossTableManager_h 1 59 #define G4LossTableManager_h 1 54 60 55 #include <map> << 61 56 #include <vector> << 62 #include "g4std/map" >> 63 #include "g4std/vector" 57 #include "globals.hh" 64 #include "globals.hh" 58 #include "G4ThreadLocalSingleton.hh" << 65 #include "G4LossTableBuilder.hh" 59 #include "G4VEnergyLossProcess.hh" << 66 #include "G4VEnergyLossSTD.hh" 60 #include "G4EmParameters.hh" << 61 67 62 class G4PhysicsTable; 68 class G4PhysicsTable; 63 class G4MaterialCutsCouple; 69 class G4MaterialCutsCouple; >> 70 class G4EnergyLossMessenger; 64 class G4ParticleDefinition; 71 class G4ParticleDefinition; 65 class G4Region; << 66 class G4EmSaturation; << 67 class G4EmConfigurator; << 68 class G4ElectronIonPair; << 69 class G4NIELCalculator; << 70 class G4VMultipleScattering; 72 class G4VMultipleScattering; 71 class G4VEmProcess; << 72 class G4EmCorrections; << 73 class G4LossTableBuilder; << 74 class G4VAtomDeexcitation; << 75 class G4VSubCutProducer; << 76 73 77 class G4LossTableManager 74 class G4LossTableManager 78 { 75 { 79 76 80 friend class G4ThreadLocalSingleton<G4LossTabl << 81 << 82 public: 77 public: 83 78 84 static G4LossTableManager* Instance(); 79 static G4LossTableManager* Instance(); 85 80 86 ~G4LossTableManager(); 81 ~G4LossTableManager(); 87 82 88 //------------------------------------------ << 83 void Clear(); 89 // initialisation before a new run << 90 //------------------------------------------ << 91 << 92 void PreparePhysicsTable(const G4ParticleDef << 93 G4VEnergyLossProces << 94 << 95 void PreparePhysicsTable(const G4ParticleDef << 96 G4VEmProcess* p); << 97 << 98 void PreparePhysicsTable(const G4ParticleDef << 99 G4VMultipleScatteri << 100 << 101 void BuildPhysicsTable(const G4ParticleDefin << 102 << 103 void BuildPhysicsTable(const G4ParticleDefin << 104 G4VEnergyLossProcess* << 105 << 106 void LocalPhysicsTables(const G4ParticleDefi << 107 G4VEnergyLossProcess << 108 << 109 void DumpHtml(); << 110 << 111 //------------------------------------------ << 112 // Run time access to DEDX, range, energy fo << 113 // energy, and G4MaterialCutsCouple << 114 //------------------------------------------ << 115 << 116 inline G4double GetDEDX( << 117 const G4ParticleDefinition *aParticle, << 118 G4double kineticEnergy, << 119 const G4MaterialCutsCouple *couple); << 120 << 121 inline G4double GetRange( << 122 const G4ParticleDefinition *aParticle, << 123 G4double kineticEnergy, << 124 const G4MaterialCutsCouple *couple); << 125 84 126 inline G4double GetCSDARange( << 85 // get the DEDX or the range for a given particle/energy/material >> 86 G4double GetDEDX( 127 const G4ParticleDefinition *aParticle, 87 const G4ParticleDefinition *aParticle, 128 G4double kineticEnergy, 88 G4double kineticEnergy, 129 const G4MaterialCutsCouple *couple); 89 const G4MaterialCutsCouple *couple); 130 90 131 inline G4double GetRangeFromRestricteDEDX( << 91 G4double GetRange( 132 const G4ParticleDefinition *aParticle, 92 const G4ParticleDefinition *aParticle, 133 G4double kineticEnergy, 93 G4double kineticEnergy, 134 const G4MaterialCutsCouple *couple); 94 const G4MaterialCutsCouple *couple); 135 95 136 inline G4double GetEnergy( << 96 G4double GetEnergy( 137 const G4ParticleDefinition *aParticle, 97 const G4ParticleDefinition *aParticle, 138 G4double range, 98 G4double range, 139 const G4MaterialCutsCouple *couple); 99 const G4MaterialCutsCouple *couple); 140 100 141 inline G4double GetDEDXDispersion( << 101 G4double GetDEDXDispersion( 142 const G4MaterialCutsCouple *couple, 102 const G4MaterialCutsCouple *couple, 143 const G4DynamicParticle* dp, 103 const G4DynamicParticle* dp, 144 G4double& length); 104 G4double& length); 145 105 146 //------------------------------------------ << 106 // to be called only by energy loss processes 147 // Methods to be called only at initialisati << 107 void Register(G4VEnergyLossSTD* p); 148 // and at the end of the job << 149 //------------------------------------------ << 150 108 151 void Register(G4VEnergyLossProcess* p); << 109 void DeRegister(G4VEnergyLossSTD* p); 152 << 153 void DeRegister(G4VEnergyLossProcess* p); << 154 110 155 void Register(G4VMultipleScattering* p); 111 void Register(G4VMultipleScattering* p); 156 112 157 void DeRegister(G4VMultipleScattering* p); 113 void DeRegister(G4VMultipleScattering* p); 158 114 159 void Register(G4VEmProcess* p); << 115 void RegisterIon(const G4ParticleDefinition* aParticle, G4VEnergyLossSTD* p); 160 << 161 void DeRegister(G4VEmProcess* p); << 162 << 163 void Register(G4VProcess* p); << 164 << 165 void DeRegister(G4VProcess* p); << 166 << 167 void Register(G4VEmModel* p); << 168 << 169 void DeRegister(G4VEmModel* p); << 170 116 171 void Register(G4VEmFluctuationModel* p); << 117 void BuildPhysicsTable(const G4ParticleDefinition* aParticle); 172 << 173 void DeRegister(G4VEmFluctuationModel* p); << 174 << 175 void RegisterExtraParticle(const G4ParticleD << 176 G4VEnergyLossProc << 177 << 178 void SetVerbose(G4int val); << 179 << 180 void ResetParameters(); << 181 << 182 void SetAtomDeexcitation(G4VAtomDeexcitation << 183 << 184 void SetSubCutProducer(G4VSubCutProducer*); << 185 << 186 void SetNIELCalculator(G4NIELCalculator*); << 187 << 188 //------------------------------------------ << 189 // Access methods << 190 //------------------------------------------ << 191 << 192 inline G4bool IsMaster() const; << 193 << 194 G4VEnergyLossProcess* GetEnergyLossProcess(c << 195 << 196 const std::vector<G4VEnergyLossProcess*>& Ge << 197 << 198 const std::vector<G4VEmProcess*>& GetEmProce << 199 << 200 const std::vector<G4VMultipleScattering*>& G << 201 << 202 G4EmSaturation* EmSaturation(); << 203 << 204 G4EmConfigurator* EmConfigurator(); << 205 << 206 G4ElectronIonPair* ElectronIonPair(); << 207 << 208 G4NIELCalculator* NIELCalculator(); << 209 << 210 inline G4EmCorrections* EmCorrections(); << 211 118 212 inline G4VAtomDeexcitation* AtomDeexcitation << 119 void RetrievePhysicsTables(const G4ParticleDefinition* aParticle, G4VEnergyLossSTD* em); 213 120 214 inline G4VSubCutProducer* SubCutProducer(); << 121 void SetLossFluctuations(G4bool val); 215 122 216 inline G4LossTableBuilder* GetTableBuilder() << 123 void SetSubCutoff(G4bool val); 217 124 218 inline void SetGammaGeneralProcess(G4VEmProc << 125 void SetIntegral(G4bool val); 219 126 220 inline G4VEmProcess* GetGammaGeneralProcess( << 127 void SetRandomStep(G4bool val); 221 128 222 inline void SetElectronGeneralProcess(G4VEmP << 129 void SetMinSubRange(G4double val); 223 130 224 inline G4VEmProcess* GetElectronGeneralProce << 131 void SetMinEnergy(G4double val); 225 132 226 inline void SetPositronGeneralProcess(G4VEmP << 133 void SetMaxEnergy(G4double val); 227 134 228 inline G4VEmProcess* GetPositronGeneralProce << 135 void SetStepLimits(G4double v1, G4double v2); 229 136 230 G4LossTableManager(G4LossTableManager &) = d << 137 G4EnergyLossMessenger* GetMessenger(); 231 G4LossTableManager & operator=(const G4LossT << 232 138 233 private: 139 private: 234 140 235 //------------------------------------------ << 236 // Private methods and members << 237 //------------------------------------------ << 238 << 239 G4LossTableManager(); 141 G4LossTableManager(); 240 142 241 void Clear(); << 143 void Initialise(const G4ParticleDefinition*); 242 144 243 G4VEnergyLossProcess* BuildTables(const G4Pa << 145 G4VEnergyLossSTD* BuildTables(const G4ParticleDefinition* aParticle); 244 << 245 void CopyTables(const G4ParticleDefinition* << 246 G4VEnergyLossProcess*); << 247 146 248 void ParticleHaveNoLoss(const G4ParticleDefi 147 void ParticleHaveNoLoss(const G4ParticleDefinition* aParticle); 249 148 250 void CopyDEDXTables(); << 149 private: 251 << 252 void PrintEWarning(G4String, G4double); << 253 150 254 static G4ThreadLocal G4LossTableManager* ins << 151 static G4LossTableManager* theInstance; 255 152 256 typedef const G4ParticleDefinition* PD; 153 typedef const G4ParticleDefinition* PD; >> 154 G4std::map<PD,G4VEnergyLossSTD*,G4std::less<PD> > loss_map; 257 155 258 // cache << 156 G4std::vector<G4VEnergyLossSTD*> loss_vector; 259 G4VEnergyLossProcess* currentLoss{nullptr}; << 157 G4std::vector<PD> part_vector; 260 PD currentParticle{nullptr}; << 158 G4std::vector<PD> base_part_vector; 261 PD theElectron; << 159 G4std::vector<G4bool> tables_are_built; 262 PD theGenericIon{nullptr}; << 160 G4std::vector<G4PhysicsTable*> dedx_vector; 263 PD firstParticle{nullptr}; << 161 G4std::vector<G4PhysicsTable*> range_vector; 264 << 162 G4std::vector<G4PhysicsTable*> inv_range_vector; 265 G4LossTableBuilder* tableBuilder; << 163 G4std::vector<G4VMultipleScattering*> msc_vector; 266 G4EmCorrections* emCorrections; << 164 267 G4EmConfigurator* emConfigurator{nullptr}; << 165 // cash 268 G4ElectronIonPair* emElectronIonPair{nullptr << 166 G4VEnergyLossSTD* currentLoss; 269 G4NIELCalculator* nielCalculator{nullptr}; << 167 PD currentParticle; 270 G4VAtomDeexcitation* atomDeexcitation{nullpt << 168 PD theElectron; 271 G4VSubCutProducer* subcutProducer{nullptr}; << 169 272 << 170 G4int n_loss; 273 G4EmParameters* theParameters; << 171 274 G4VEmProcess* gGeneral{nullptr}; << 172 G4bool all_tables_are_built; 275 G4VEmProcess* eGeneral{nullptr}; << 173 G4bool first_entry; 276 G4VEmProcess* pGeneral{nullptr}; << 174 G4bool electron_table_are_built; 277 << 175 G4bool lossFluctuationFlag; >> 176 G4bool subCutoffFlag; >> 177 G4bool rndmStepFlag; >> 178 G4bool integral; >> 179 G4bool all_tables_are_stored; >> 180 >> 181 G4double minSubRange; >> 182 G4double maxRangeVariation; >> 183 G4double maxFinalStep; >> 184 G4double minKinEnergy; >> 185 G4double maxKinEnergy; >> 186 >> 187 G4VEnergyLossSTD* eIonisation; >> 188 G4LossTableBuilder* tableBuilder; >> 189 G4EnergyLossMessenger* theMessenger; >> 190 const G4ParticleDefinition* firstParticle; 278 G4int verbose; 191 G4int verbose; 279 G4int n_loss{0}; << 280 G4int run{-1}; << 281 << 282 G4bool all_tables_are_built{false}; << 283 G4bool startInitialisation{false}; << 284 G4bool resetParam{true}; << 285 G4bool isMaster{false}; << 286 << 287 std::vector<G4VEnergyLossProcess*> loss_vect << 288 std::vector<PD> part_vector; << 289 std::vector<PD> base_part_vector; << 290 std::vector<G4PhysicsTable*> dedx_vector; << 291 std::vector<G4PhysicsTable*> range_vector; << 292 std::vector<G4PhysicsTable*> inv_range_vecto << 293 std::vector<G4bool> tables_are_built; << 294 std::vector<G4bool> isActive; << 295 std::vector<G4VMultipleScattering*> msc_vect << 296 std::vector<G4VEmProcess*> emp_vector; << 297 std::vector<G4VEmModel*> mod_vector; << 298 std::vector<G4VEmFluctuationModel*> fmod_vec << 299 std::vector<G4VProcess*> p_vector; << 300 192 301 std::map<PD,G4VEnergyLossProcess*,std::less< << 302 }; 193 }; 303 194 304 //....oooOO0OOooo........oooOO0OOooo........oo 195 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 305 //....oooOO0OOooo........oooOO0OOooo........oo << 306 << 307 inline << 308 G4double G4LossTableManager::GetDEDX(const G4P << 309 G4double << 310 const G4M << 311 { << 312 if(aParticle != currentParticle) { GetEnergy << 313 return currentLoss ? currentLoss->GetDEDX(ki << 314 } << 315 << 316 //....oooOO0OOooo........oooOO0OOooo........oo << 317 << 318 inline << 319 G4double G4LossTableManager::GetCSDARange(cons << 320 G4do << 321 cons << 322 { << 323 if(aParticle != currentParticle) { GetEnergy << 324 return currentLoss ? currentLoss->GetCSDARan << 325 } << 326 << 327 //....oooOO0OOooo........oooOO0OOooo........oo 196 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 328 197 329 inline << 198 inline G4double G4LossTableManager::GetDEDX( 330 G4double G4LossTableManager::GetRangeFromRestr << 199 const G4ParticleDefinition *aParticle, 331 const G4ParticleD << 200 G4double kineticEnergy, 332 G4double kineticE << 201 const G4MaterialCutsCouple *couple) 333 const G4MaterialC << 202 { 334 { << 203 if(aParticle != currentParticle) { 335 if(aParticle != currentParticle) { GetEnergy << 204 G4std::map<PD, G4VEnergyLossSTD*,G4std::less<PD> >::const_iterator pos; 336 return currentLoss ? currentLoss->GetRange(k << 205 if ((pos = loss_map.find(aParticle)) != loss_map.end()) { >> 206 currentParticle = aParticle; >> 207 currentLoss = (*pos).second; >> 208 } else { >> 209 ParticleHaveNoLoss(aParticle); >> 210 } >> 211 } >> 212 return currentLoss->GetDEDX(kineticEnergy, couple); 337 } 213 } 338 214 339 //....oooOO0OOooo........oooOO0OOooo........oo 215 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 340 216 341 inline << 217 inline G4double G4LossTableManager::GetRange( 342 G4double G4LossTableManager::GetRange(const G4 << 218 const G4ParticleDefinition *aParticle, 343 G4double << 219 G4double kineticEnergy, 344 const G4 << 220 const G4MaterialCutsCouple *couple) 345 { << 221 { 346 if(aParticle != currentParticle) { GetEnergy << 222 if(aParticle != currentParticle) { 347 return currentLoss ? currentLoss->GetRange(k << 223 G4std::map<PD, G4VEnergyLossSTD*, G4std::less<PD> >::const_iterator pos; >> 224 if ((pos = loss_map.find(aParticle)) != loss_map.end()) { >> 225 currentParticle = aParticle; >> 226 currentLoss = (*pos).second; >> 227 } else { >> 228 ParticleHaveNoLoss(aParticle); >> 229 } >> 230 } >> 231 return currentLoss->GetRange(kineticEnergy, couple); 348 } 232 } 349 233 350 //....oooOO0OOooo........oooOO0OOooo........oo 234 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 351 235 352 inline << 236 inline G4double G4LossTableManager::GetEnergy( 353 G4double G4LossTableManager::GetEnergy(const G << 237 const G4ParticleDefinition *aParticle, 354 G4doubl << 238 G4double range, 355 const G << 239 const G4MaterialCutsCouple *couple) 356 { << 240 { 357 if(aParticle != currentParticle) { GetEnergy << 241 if(aParticle != currentParticle) { 358 return currentLoss ? currentLoss->GetKinetic << 242 G4std::map<PD,G4VEnergyLossSTD*,G4std::less<PD> >::const_iterator pos; >> 243 if ((pos = loss_map.find(aParticle)) != loss_map.end()) { >> 244 currentParticle = aParticle; >> 245 currentLoss = (*pos).second; >> 246 } else { >> 247 ParticleHaveNoLoss(aParticle); >> 248 } >> 249 } >> 250 return currentLoss->GetKineticEnergy(range, couple); 359 } 251 } 360 252 361 //....oooOO0OOooo........oooOO0OOooo........oo 253 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 362 254 363 inline << 255 inline G4double G4LossTableManager::GetDEDXDispersion( 364 G4double G4LossTableManager::GetDEDXDispersion << 256 const G4MaterialCutsCouple *couple, 365 const G4MaterialC << 257 const G4DynamicParticle* dp, 366 const G4DynamicPa << 258 G4double& length) 367 G4double& length) << 368 { << 369 const G4ParticleDefinition* aParticle = dp-> << 370 if(aParticle != currentParticle) { GetEnergy << 371 return currentLoss ? currentLoss->GetDEDXDis << 372 } << 373 << 374 //....oooOO0OOooo........oooOO0OOooo........oo << 375 << 376 inline G4bool G4LossTableManager::IsMaster() c << 377 { 259 { 378 return isMaster; << 260 const G4ParticleDefinition* aParticle = dp->GetDefinition(); >> 261 if(aParticle != currentParticle) { >> 262 G4std::map<PD,G4VEnergyLossSTD*,G4std::less<PD> >::const_iterator pos; >> 263 if ((pos = loss_map.find(aParticle)) != loss_map.end()) { >> 264 currentParticle = aParticle; >> 265 currentLoss = (*pos).second; >> 266 } else { >> 267 ParticleHaveNoLoss(aParticle); >> 268 } >> 269 } >> 270 return currentLoss->GetDEDXDispersion(couple, dp, length); 379 } 271 } 380 272 381 //....oooOO0OOooo........oooOO0OOooo........oo 273 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 382 274 383 inline G4EmCorrections* G4LossTableManager::Em << 384 { << 385 return emCorrections; << 386 } << 387 << 388 //....oooOO0OOooo........oooOO0OOooo........oo << 389 << 390 inline G4VAtomDeexcitation* G4LossTableManager << 391 { << 392 return atomDeexcitation; << 393 } << 394 << 395 //....oooOO0OOooo........oooOO0OOooo........oo << 396 << 397 inline G4VSubCutProducer* G4LossTableManager:: << 398 { << 399 return subcutProducer; << 400 } << 401 << 402 //....oooOO0OOooo........oooOO0OOooo........oo << 403 << 404 inline G4LossTableBuilder* G4LossTableManager: << 405 { << 406 return tableBuilder; << 407 } << 408 << 409 //....oooOO0OOooo........oooOO0OOooo........oo << 410 << 411 inline void G4LossTableManager::SetGammaGenera << 412 { << 413 gGeneral = ptr; << 414 } << 415 << 416 //....oooOO0OOooo........oooOO0OOooo........oo << 417 << 418 inline G4VEmProcess* G4LossTableManager::GetGa << 419 { << 420 return gGeneral; << 421 } << 422 << 423 //....oooOO0OOooo........oooOO0OOooo........oo << 424 << 425 inline void G4LossTableManager::SetElectronGen << 426 { << 427 eGeneral = ptr; << 428 } << 429 << 430 //....oooOO0OOooo........oooOO0OOooo........oo << 431 << 432 inline G4VEmProcess* G4LossTableManager::GetEl << 433 { << 434 return eGeneral; << 435 } << 436 << 437 //....oooOO0OOooo........oooOO0OOooo........oo << 438 << 439 inline void G4LossTableManager::SetPositronGen << 440 { << 441 pGeneral = ptr; << 442 } << 443 << 444 //....oooOO0OOooo........oooOO0OOooo........oo << 445 << 446 inline G4VEmProcess* G4LossTableManager::GetPo << 447 { << 448 return pGeneral; << 449 } << 450 //....oooOO0OOooo........oooOO0OOooo........oo << 451 << 452 #endif 275 #endif >> 276 453 277