Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4LossTableManager.hh
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26// -------------------------------------------------------------------
27//
28// GEANT4 Class header file
29//
30//
31// File name: G4LossTableManager
32//
33// Author: Vladimir Ivanchenko on base of G4LossTables class
34// and Maria Grazia Pia ideas
35//
36// Creation date: 03.01.2002
37//
38// Modifications by V.Ivanchenko
39//
40// Class Description:
41//
42// A utility static class, responsable for the energy loss tables
43// for each particle
44//
45// Energy loss processes have to register their tables with this
46// class. The responsibility of creating and deleting the tables
47// remains with the energy loss classes.
48
49// -------------------------------------------------------------------
50//
51
52#ifndef G4LossTableManager_h
53#define G4LossTableManager_h 1
54
55#include <map>
56#include <vector>
57#include "globals.hh"
60#include "G4EmParameters.hh"
61
62class G4PhysicsTable;
65class G4Region;
66class G4EmSaturation;
71class G4VEmProcess;
72class G4EmCorrections;
76class G4VXRayModel;
77
79{
80
82
83public:
84
86
88
89 //-------------------------------------------------
90 // initialisation before a new run
91 //-------------------------------------------------
92
93 void PreparePhysicsTable(const G4ParticleDefinition* aParticle,
95
96 void PreparePhysicsTable(const G4ParticleDefinition* aParticle,
97 G4VEmProcess* p);
98
99 void PreparePhysicsTable(const G4ParticleDefinition* aParticle,
101
102 void BuildPhysicsTable(const G4ParticleDefinition* aParticle);
103
104 void BuildPhysicsTable(const G4ParticleDefinition* aParticle,
106
107 void LocalPhysicsTables(const G4ParticleDefinition* aParticle,
109
110 void DumpHtml();
111
112 //-------------------------------------------------
113 // Run time access to DEDX, range, energy for a given particle,
114 // energy, and G4MaterialCutsCouple
115 //-------------------------------------------------
116
117 inline G4double GetDEDX(
118 const G4ParticleDefinition *aParticle,
119 G4double kineticEnergy,
120 const G4MaterialCutsCouple *couple);
121
122 inline G4double GetRange(
123 const G4ParticleDefinition *aParticle,
124 G4double kineticEnergy,
125 const G4MaterialCutsCouple *couple);
126
127 inline G4double GetCSDARange(
128 const G4ParticleDefinition *aParticle,
129 G4double kineticEnergy,
130 const G4MaterialCutsCouple *couple);
131
133 const G4ParticleDefinition *aParticle,
134 G4double kineticEnergy,
135 const G4MaterialCutsCouple *couple);
136
137 inline G4double GetEnergy(
138 const G4ParticleDefinition *aParticle,
139 G4double range,
140 const G4MaterialCutsCouple *couple);
141
143 const G4MaterialCutsCouple *couple,
144 const G4DynamicParticle* dp,
145 G4double& length);
146
147 //-------------------------------------------------
148 // Methods to be called only at initialisation
149 // and at the end of the job
150 //-------------------------------------------------
151
153
155
157
159
160 void Register(G4VEmProcess* p);
161
162 void DeRegister(G4VEmProcess* p);
163
164 void Register(G4VProcess* p);
165
166 void DeRegister(G4VProcess* p);
167
168 void Register(G4VEmModel* p);
169
170 void DeRegister(G4VEmModel* p);
171
173
175
176 void Register(G4VXRayModel* p);
177
178 void DeRegister(G4VXRayModel* p);
179
180 void RegisterExtraParticle(const G4ParticleDefinition* aParticle,
182
183 void SetVerbose(G4int val);
184
185 void ResetParameters();
186
188
190
192
193 //-------------------------------------------------
194 // Access methods
195 //-------------------------------------------------
196
197 inline G4bool IsMaster() const;
198
200
201 const std::vector<G4VEnergyLossProcess*>& GetEnergyLossProcessVector();
202
203 const std::vector<G4VEmProcess*>& GetEmProcessVector();
204
205 const std::vector<G4VMultipleScattering*>& GetMultipleScatteringVector();
206
208
210
212
214
216
218
220
222
224
226
228
230
232
234
237
238private:
239
240 //-------------------------------------------------
241 // Private methods and members
242 //-------------------------------------------------
243
245
246 void Clear();
247
248 G4VEnergyLossProcess* BuildTables(const G4ParticleDefinition* aParticle);
249
250 void CopyTables(const G4ParticleDefinition* aParticle,
252
253 void ParticleHaveNoLoss(const G4ParticleDefinition* aParticle);
254
255 void CopyDEDXTables();
256
257 void PrintEWarning(G4String, G4double);
258
259 static G4ThreadLocal G4LossTableManager* instance;
260
261 typedef const G4ParticleDefinition* PD;
262
263 // cache
264 G4VEnergyLossProcess* currentLoss{nullptr};
265 PD currentParticle{nullptr};
266 PD theElectron;
267 PD theGenericIon{nullptr};
268 PD firstParticle{nullptr};
269
270 G4LossTableBuilder* tableBuilder;
271 G4EmCorrections* emCorrections;
272 G4EmConfigurator* emConfigurator{nullptr};
273 G4ElectronIonPair* emElectronIonPair{nullptr};
274 G4NIELCalculator* nielCalculator{nullptr};
275 G4VAtomDeexcitation* atomDeexcitation{nullptr};
276 G4VSubCutProducer* subcutProducer{nullptr};
277
278 G4EmParameters* theParameters;
279 G4VEmProcess* gGeneral{nullptr};
280 G4VEmProcess* eGeneral{nullptr};
281 G4VEmProcess* pGeneral{nullptr};
282
283 G4int verbose;
284 G4int n_loss{0};
285 G4int run{-1};
286
287 G4bool all_tables_are_built{false};
288 G4bool startInitialisation{false};
289 G4bool resetParam{true};
290 G4bool isMaster{false};
291
292 std::vector<G4VEnergyLossProcess*> loss_vector;
293 std::vector<PD> part_vector;
294 std::vector<PD> base_part_vector;
295 std::vector<G4PhysicsTable*> dedx_vector;
296 std::vector<G4PhysicsTable*> range_vector;
297 std::vector<G4PhysicsTable*> inv_range_vector;
298 std::vector<G4bool> tables_are_built;
299 std::vector<G4bool> isActive;
300 std::vector<G4VMultipleScattering*> msc_vector;
301 std::vector<G4VEmProcess*> emp_vector;
302 std::vector<G4VEmModel*> mod_vector;
303 std::vector<G4VEmFluctuationModel*> fmod_vector;
304 std::vector<G4VXRayModel*> xray_vector;
305 std::vector<G4VProcess*> p_vector;
306
307 std::map<PD,G4VEnergyLossProcess*,std::less<PD> > loss_map;
308};
309
310//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
311//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
312
313inline
315 G4double kineticEnergy,
316 const G4MaterialCutsCouple *couple)
317{
318 if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); }
319 return currentLoss ? currentLoss->GetDEDX(kineticEnergy, couple) : 0.0;
320}
321
322//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
323
324inline
326 G4double kineticEnergy,
327 const G4MaterialCutsCouple *couple)
328{
329 if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); }
330 return currentLoss ? currentLoss->GetCSDARange(kineticEnergy, couple) : DBL_MAX;
331}
332
333//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
334
335inline
337 const G4ParticleDefinition *aParticle,
338 G4double kineticEnergy,
339 const G4MaterialCutsCouple *couple)
340{
341 if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); }
342 return currentLoss ? currentLoss->GetRange(kineticEnergy, couple) : DBL_MAX;
343}
344
345//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
346
347inline
349 G4double kineticEnergy,
350 const G4MaterialCutsCouple *couple)
351{
352 if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); }
353 return currentLoss ? currentLoss->GetRange(kineticEnergy, couple) : DBL_MAX;
354}
355
356//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
357
358inline
360 G4double range,
361 const G4MaterialCutsCouple *couple)
362{
363 if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); }
364 return currentLoss ? currentLoss->GetKineticEnergy(range, couple) : 0.0;
365}
366
367//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
368
369inline
371 const G4MaterialCutsCouple *couple,
372 const G4DynamicParticle* dp,
373 G4double& length)
374{
375 const G4ParticleDefinition* aParticle = dp->GetParticleDefinition();
376 if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); }
377 return currentLoss ? currentLoss->GetDEDXDispersion(couple, dp, length) : 0.0;
378}
379
380//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
381
383{
384 return isMaster;
385}
386
387//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
388
390{
391 return emCorrections;
392}
393
394//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
395
397{
398 return atomDeexcitation;
399}
400
401//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
402
404{
405 return subcutProducer;
406}
407
408//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
409
411{
412 return tableBuilder;
413}
414
415//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
416
418{
419 gGeneral = ptr;
420}
421
422//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
423
425{
426 return gGeneral;
427}
428
429//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
430
432{
433 eGeneral = ptr;
434}
435
436//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
437
439{
440 return eGeneral;
441}
442
443//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
444
446{
447 pGeneral = ptr;
448}
449
450//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
451
453{
454 return pGeneral;
455}
456//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
457
458#endif
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
const G4ParticleDefinition * GetParticleDefinition() const
void SetAtomDeexcitation(G4VAtomDeexcitation *)
static G4LossTableManager * Instance()
const std::vector< G4VEmProcess * > & GetEmProcessVector()
G4double GetCSDARange(const G4ParticleDefinition *aParticle, G4double kineticEnergy, const G4MaterialCutsCouple *couple)
G4VEnergyLossProcess * GetEnergyLossProcess(const G4ParticleDefinition *)
void SetGammaGeneralProcess(G4VEmProcess *)
void LocalPhysicsTables(const G4ParticleDefinition *aParticle, G4VEnergyLossProcess *p)
G4LossTableBuilder * GetTableBuilder()
void BuildPhysicsTable(const G4ParticleDefinition *aParticle)
void SetPositronGeneralProcess(G4VEmProcess *)
G4VSubCutProducer * SubCutProducer()
G4double GetEnergy(const G4ParticleDefinition *aParticle, G4double range, const G4MaterialCutsCouple *couple)
const std::vector< G4VMultipleScattering * > & GetMultipleScatteringVector()
G4VEmProcess * GetGammaGeneralProcess()
void SetVerbose(G4int val)
void DeRegister(G4VEnergyLossProcess *p)
G4NIELCalculator * NIELCalculator()
void SetNIELCalculator(G4NIELCalculator *)
G4VEmProcess * GetPositronGeneralProcess()
G4EmConfigurator * EmConfigurator()
void Register(G4VEnergyLossProcess *p)
G4ElectronIonPair * ElectronIonPair()
void SetElectronGeneralProcess(G4VEmProcess *)
G4EmSaturation * EmSaturation()
G4VEmProcess * GetElectronGeneralProcess()
const std::vector< G4VEnergyLossProcess * > & GetEnergyLossProcessVector()
G4VAtomDeexcitation * AtomDeexcitation()
G4double GetRangeFromRestricteDEDX(const G4ParticleDefinition *aParticle, G4double kineticEnergy, const G4MaterialCutsCouple *couple)
G4LossTableManager & operator=(const G4LossTableManager &right)=delete
void PreparePhysicsTable(const G4ParticleDefinition *aParticle, G4VEnergyLossProcess *p)
G4EmCorrections * EmCorrections()
void SetSubCutProducer(G4VSubCutProducer *)
G4double GetDEDXDispersion(const G4MaterialCutsCouple *couple, const G4DynamicParticle *dp, G4double &length)
void RegisterExtraParticle(const G4ParticleDefinition *aParticle, G4VEnergyLossProcess *p)
G4double GetRange(const G4ParticleDefinition *aParticle, G4double kineticEnergy, const G4MaterialCutsCouple *couple)
G4LossTableManager(G4LossTableManager &)=delete
G4double GetDEDX(const G4ParticleDefinition *aParticle, G4double kineticEnergy, const G4MaterialCutsCouple *couple)
G4Region defines a region or a group of regions in the detector geometry setup, sharing properties as...
Definition G4Region.hh:90
#define DBL_MAX
Definition templates.hh:62
#define G4ThreadLocal
Definition tls.hh:77