File indexing completed on 2025-09-16 08:56:25
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052 #ifndef G4LossTableManager_h
0053 #define G4LossTableManager_h 1
0054
0055 #include <map>
0056 #include <vector>
0057 #include "globals.hh"
0058 #include "G4ThreadLocalSingleton.hh"
0059 #include "G4VEnergyLossProcess.hh"
0060 #include "G4EmParameters.hh"
0061
0062 class G4PhysicsTable;
0063 class G4MaterialCutsCouple;
0064 class G4ParticleDefinition;
0065 class G4Region;
0066 class G4EmSaturation;
0067 class G4EmConfigurator;
0068 class G4ElectronIonPair;
0069 class G4NIELCalculator;
0070 class G4VMultipleScattering;
0071 class G4VEmProcess;
0072 class G4EmCorrections;
0073 class G4LossTableBuilder;
0074 class G4VAtomDeexcitation;
0075 class G4VSubCutProducer;
0076
0077 class G4LossTableManager
0078 {
0079
0080 friend class G4ThreadLocalSingleton<G4LossTableManager>;
0081
0082 public:
0083
0084 static G4LossTableManager* Instance();
0085
0086 ~G4LossTableManager();
0087
0088
0089
0090
0091
0092 void PreparePhysicsTable(const G4ParticleDefinition* aParticle,
0093 G4VEnergyLossProcess* p);
0094
0095 void PreparePhysicsTable(const G4ParticleDefinition* aParticle,
0096 G4VEmProcess* p);
0097
0098 void PreparePhysicsTable(const G4ParticleDefinition* aParticle,
0099 G4VMultipleScattering* p);
0100
0101 void BuildPhysicsTable(const G4ParticleDefinition* aParticle);
0102
0103 void BuildPhysicsTable(const G4ParticleDefinition* aParticle,
0104 G4VEnergyLossProcess* p);
0105
0106 void LocalPhysicsTables(const G4ParticleDefinition* aParticle,
0107 G4VEnergyLossProcess* p);
0108
0109 void DumpHtml();
0110
0111
0112
0113
0114
0115
0116 inline G4double GetDEDX(
0117 const G4ParticleDefinition *aParticle,
0118 G4double kineticEnergy,
0119 const G4MaterialCutsCouple *couple);
0120
0121 inline G4double GetRange(
0122 const G4ParticleDefinition *aParticle,
0123 G4double kineticEnergy,
0124 const G4MaterialCutsCouple *couple);
0125
0126 inline G4double GetCSDARange(
0127 const G4ParticleDefinition *aParticle,
0128 G4double kineticEnergy,
0129 const G4MaterialCutsCouple *couple);
0130
0131 inline G4double GetRangeFromRestricteDEDX(
0132 const G4ParticleDefinition *aParticle,
0133 G4double kineticEnergy,
0134 const G4MaterialCutsCouple *couple);
0135
0136 inline G4double GetEnergy(
0137 const G4ParticleDefinition *aParticle,
0138 G4double range,
0139 const G4MaterialCutsCouple *couple);
0140
0141 inline G4double GetDEDXDispersion(
0142 const G4MaterialCutsCouple *couple,
0143 const G4DynamicParticle* dp,
0144 G4double& length);
0145
0146
0147
0148
0149
0150
0151 void Register(G4VEnergyLossProcess* p);
0152
0153 void DeRegister(G4VEnergyLossProcess* p);
0154
0155 void Register(G4VMultipleScattering* p);
0156
0157 void DeRegister(G4VMultipleScattering* p);
0158
0159 void Register(G4VEmProcess* p);
0160
0161 void DeRegister(G4VEmProcess* p);
0162
0163 void Register(G4VProcess* p);
0164
0165 void DeRegister(G4VProcess* p);
0166
0167 void Register(G4VEmModel* p);
0168
0169 void DeRegister(G4VEmModel* p);
0170
0171 void Register(G4VEmFluctuationModel* p);
0172
0173 void DeRegister(G4VEmFluctuationModel* p);
0174
0175 void RegisterExtraParticle(const G4ParticleDefinition* aParticle,
0176 G4VEnergyLossProcess* p);
0177
0178 void SetVerbose(G4int val);
0179
0180 void ResetParameters();
0181
0182 void SetAtomDeexcitation(G4VAtomDeexcitation*);
0183
0184 void SetSubCutProducer(G4VSubCutProducer*);
0185
0186 void SetNIELCalculator(G4NIELCalculator*);
0187
0188
0189
0190
0191
0192 inline G4bool IsMaster() const;
0193
0194 G4VEnergyLossProcess* GetEnergyLossProcess(const G4ParticleDefinition*);
0195
0196 const std::vector<G4VEnergyLossProcess*>& GetEnergyLossProcessVector();
0197
0198 const std::vector<G4VEmProcess*>& GetEmProcessVector();
0199
0200 const std::vector<G4VMultipleScattering*>& GetMultipleScatteringVector();
0201
0202 G4EmSaturation* EmSaturation();
0203
0204 G4EmConfigurator* EmConfigurator();
0205
0206 G4ElectronIonPair* ElectronIonPair();
0207
0208 G4NIELCalculator* NIELCalculator();
0209
0210 inline G4EmCorrections* EmCorrections();
0211
0212 inline G4VAtomDeexcitation* AtomDeexcitation();
0213
0214 inline G4VSubCutProducer* SubCutProducer();
0215
0216 inline G4LossTableBuilder* GetTableBuilder();
0217
0218 inline void SetGammaGeneralProcess(G4VEmProcess*);
0219
0220 inline G4VEmProcess* GetGammaGeneralProcess();
0221
0222 inline void SetElectronGeneralProcess(G4VEmProcess*);
0223
0224 inline G4VEmProcess* GetElectronGeneralProcess();
0225
0226 inline void SetPositronGeneralProcess(G4VEmProcess*);
0227
0228 inline G4VEmProcess* GetPositronGeneralProcess();
0229
0230 G4LossTableManager(G4LossTableManager &) = delete;
0231 G4LossTableManager & operator=(const G4LossTableManager &right) = delete;
0232
0233 private:
0234
0235
0236
0237
0238
0239 G4LossTableManager();
0240
0241 void Clear();
0242
0243 G4VEnergyLossProcess* BuildTables(const G4ParticleDefinition* aParticle);
0244
0245 void CopyTables(const G4ParticleDefinition* aParticle,
0246 G4VEnergyLossProcess*);
0247
0248 void ParticleHaveNoLoss(const G4ParticleDefinition* aParticle);
0249
0250 void CopyDEDXTables();
0251
0252 void PrintEWarning(G4String, G4double);
0253
0254 static G4ThreadLocal G4LossTableManager* instance;
0255
0256 typedef const G4ParticleDefinition* PD;
0257
0258
0259 G4VEnergyLossProcess* currentLoss{nullptr};
0260 PD currentParticle{nullptr};
0261 PD theElectron;
0262 PD theGenericIon{nullptr};
0263 PD firstParticle{nullptr};
0264
0265 G4LossTableBuilder* tableBuilder;
0266 G4EmCorrections* emCorrections;
0267 G4EmConfigurator* emConfigurator{nullptr};
0268 G4ElectronIonPair* emElectronIonPair{nullptr};
0269 G4NIELCalculator* nielCalculator{nullptr};
0270 G4VAtomDeexcitation* atomDeexcitation{nullptr};
0271 G4VSubCutProducer* subcutProducer{nullptr};
0272
0273 G4EmParameters* theParameters;
0274 G4VEmProcess* gGeneral{nullptr};
0275 G4VEmProcess* eGeneral{nullptr};
0276 G4VEmProcess* pGeneral{nullptr};
0277
0278 G4int verbose;
0279 G4int n_loss{0};
0280 G4int run{-1};
0281
0282 G4bool all_tables_are_built{false};
0283 G4bool startInitialisation{false};
0284 G4bool resetParam{true};
0285 G4bool isMaster{false};
0286
0287 std::vector<G4VEnergyLossProcess*> loss_vector;
0288 std::vector<PD> part_vector;
0289 std::vector<PD> base_part_vector;
0290 std::vector<G4PhysicsTable*> dedx_vector;
0291 std::vector<G4PhysicsTable*> range_vector;
0292 std::vector<G4PhysicsTable*> inv_range_vector;
0293 std::vector<G4bool> tables_are_built;
0294 std::vector<G4bool> isActive;
0295 std::vector<G4VMultipleScattering*> msc_vector;
0296 std::vector<G4VEmProcess*> emp_vector;
0297 std::vector<G4VEmModel*> mod_vector;
0298 std::vector<G4VEmFluctuationModel*> fmod_vector;
0299 std::vector<G4VProcess*> p_vector;
0300
0301 std::map<PD,G4VEnergyLossProcess*,std::less<PD> > loss_map;
0302 };
0303
0304
0305
0306
0307 inline
0308 G4double G4LossTableManager::GetDEDX(const G4ParticleDefinition *aParticle,
0309 G4double kineticEnergy,
0310 const G4MaterialCutsCouple *couple)
0311 {
0312 if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); }
0313 return currentLoss ? currentLoss->GetDEDX(kineticEnergy, couple) : 0.0;
0314 }
0315
0316
0317
0318 inline
0319 G4double G4LossTableManager::GetCSDARange(const G4ParticleDefinition *aParticle,
0320 G4double kineticEnergy,
0321 const G4MaterialCutsCouple *couple)
0322 {
0323 if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); }
0324 return currentLoss ? currentLoss->GetCSDARange(kineticEnergy, couple) : DBL_MAX;
0325 }
0326
0327
0328
0329 inline
0330 G4double G4LossTableManager::GetRangeFromRestricteDEDX(
0331 const G4ParticleDefinition *aParticle,
0332 G4double kineticEnergy,
0333 const G4MaterialCutsCouple *couple)
0334 {
0335 if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); }
0336 return currentLoss ? currentLoss->GetRange(kineticEnergy, couple) : DBL_MAX;
0337 }
0338
0339
0340
0341 inline
0342 G4double G4LossTableManager::GetRange(const G4ParticleDefinition *aParticle,
0343 G4double kineticEnergy,
0344 const G4MaterialCutsCouple *couple)
0345 {
0346 if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); }
0347 return currentLoss ? currentLoss->GetRange(kineticEnergy, couple) : DBL_MAX;
0348 }
0349
0350
0351
0352 inline
0353 G4double G4LossTableManager::GetEnergy(const G4ParticleDefinition *aParticle,
0354 G4double range,
0355 const G4MaterialCutsCouple *couple)
0356 {
0357 if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); }
0358 return currentLoss ? currentLoss->GetKineticEnergy(range, couple) : 0.0;
0359 }
0360
0361
0362
0363 inline
0364 G4double G4LossTableManager::GetDEDXDispersion(
0365 const G4MaterialCutsCouple *couple,
0366 const G4DynamicParticle* dp,
0367 G4double& length)
0368 {
0369 const G4ParticleDefinition* aParticle = dp->GetParticleDefinition();
0370 if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); }
0371 return currentLoss ? currentLoss->GetDEDXDispersion(couple, dp, length) : 0.0;
0372 }
0373
0374
0375
0376 inline G4bool G4LossTableManager::IsMaster() const
0377 {
0378 return isMaster;
0379 }
0380
0381
0382
0383 inline G4EmCorrections* G4LossTableManager::EmCorrections()
0384 {
0385 return emCorrections;
0386 }
0387
0388
0389
0390 inline G4VAtomDeexcitation* G4LossTableManager::AtomDeexcitation()
0391 {
0392 return atomDeexcitation;
0393 }
0394
0395
0396
0397 inline G4VSubCutProducer* G4LossTableManager::SubCutProducer()
0398 {
0399 return subcutProducer;
0400 }
0401
0402
0403
0404 inline G4LossTableBuilder* G4LossTableManager::GetTableBuilder()
0405 {
0406 return tableBuilder;
0407 }
0408
0409
0410
0411 inline void G4LossTableManager::SetGammaGeneralProcess(G4VEmProcess* ptr)
0412 {
0413 gGeneral = ptr;
0414 }
0415
0416
0417
0418 inline G4VEmProcess* G4LossTableManager::GetGammaGeneralProcess()
0419 {
0420 return gGeneral;
0421 }
0422
0423
0424
0425 inline void G4LossTableManager::SetElectronGeneralProcess(G4VEmProcess* ptr)
0426 {
0427 eGeneral = ptr;
0428 }
0429
0430
0431
0432 inline G4VEmProcess* G4LossTableManager::GetElectronGeneralProcess()
0433 {
0434 return eGeneral;
0435 }
0436
0437
0438
0439 inline void G4LossTableManager::SetPositronGeneralProcess(G4VEmProcess* ptr)
0440 {
0441 pGeneral = ptr;
0442 }
0443
0444
0445
0446 inline G4VEmProcess* G4LossTableManager::GetPositronGeneralProcess()
0447 {
0448 return pGeneral;
0449 }
0450
0451
0452 #endif