Geant4  10.02.p01
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 // $Id: G4LossTableManager.hh 95476 2016-02-12 09:39:50Z gcosmo $
27 //
28 //
29 // -------------------------------------------------------------------
30 //
31 // GEANT4 Class header file
32 //
33 //
34 // File name: G4LossTableManager
35 //
36 // Author: Vladimir Ivanchenko on base of G4LossTables class
37 // and Maria Grazia Pia ideas
38 //
39 // Creation date: 03.01.2002
40 //
41 // Modifications:
42 //
43 // 20-01-03 Migrade to cut per region (V.Ivanchenko)
44 // 17-02-03 Fix problem of store/restore tables for ions (V.Ivanchenko)
45 // 10-03-03 Add Ion registration (V.Ivanchenko)
46 // 25-03-03 Add deregistration (V.Ivanchenko)
47 // 26-03-03 Add GetDEDXDispersion (V.Ivanchenko)
48 // 02-04-03 Change messenger (V.Ivanchenko)
49 // 23-07-03 Add exchange with G4EnergyLossTables (V.Ivanchenko)
50 // 05-10-03 Add G4VEmProcesses registration (V.Ivanchenko)
51 // 17-10-03 Add SetParameters method (V.Ivanchenko)
52 // 12-11-03 G4EnergyLossSTD -> G4EnergyLossProcess (V.Ivanchenko)
53 // 14-01-04 Activate precise range calculation (V.Ivanchenko)
54 // 08-11-04 Migration to new interface of Store/Retrieve tables (V.Ivantchenko)
55 // 10-01-06 PreciseRange -> CSDARange (V.Ivantchenko)
56 // 20-01-06 Introduce GetSubDEDX method (VI)
57 // 26-01-06 Rename GetRange -> GetRangeFromRestricteDEDX (V.Ivanchenko)
58 // 10-05-06 Add methods SetMscStepLimitation, FacRange and MscFlag (VI)
59 // 22-05-06 Add methods Set/Get bremsTh (VI)
60 // 12-02-07 Add SetSkin, SetLinearLossLimit (V.Ivanchenko)
61 // 18-06-07 Move definition of msc parameters to G4EmProcessOptions (V.Ivanchenko)
62 // 12-04-10 Added PreparePhsyicsTables and BuildPhysicsTables entries (V.Ivanchenko)
63 // 04-06-13 Adaptation for MT mode, new method LocalPhysicsTables (V.Ivanchenko)
64 //
65 // Class Description:
66 //
67 // A utility static class, responsable for the energy loss tables
68 // for each particle
69 //
70 // Energy loss processes have to register their tables with this
71 // class. The responsibility of creating and deleting the tables
72 // remains with the energy loss classes.
73 
74 // -------------------------------------------------------------------
75 //
76 
77 #ifndef G4LossTableManager_h
78 #define G4LossTableManager_h 1
79 
80 #include <map>
81 #include <vector>
82 #include "globals.hh"
84 #include "G4EmParameters.hh"
85 #include "G4VEnergyLossProcess.hh"
86 #include "G4EmCorrections.hh"
87 #include "G4LossTableBuilder.hh"
88 #include "G4VAtomDeexcitation.hh"
89 #include "G4VSubCutProducer.hh"
90 
91 class G4PhysicsTable;
95 class G4Region;
96 class G4EmSaturation;
97 class G4EmConfigurator;
98 class G4ElectronIonPair;
100 class G4VEmProcess;
101 
103 {
104 
106 
107 public:
108 
109  static G4LossTableManager* Instance();
110 
112 
113  //-------------------------------------------------
114  // called from destructor
115  //-------------------------------------------------
116 
117  void Clear();
118 
119  //-------------------------------------------------
120  // initialisation before a new run
121  //-------------------------------------------------
122 
123  void PreparePhysicsTable(const G4ParticleDefinition* aParticle,
124  G4VEnergyLossProcess* p, G4bool theMaster);
125 
126  void PreparePhysicsTable(const G4ParticleDefinition* aParticle,
127  G4VEmProcess* p, G4bool theMaster);
128 
129  void PreparePhysicsTable(const G4ParticleDefinition* aParticle,
130  G4VMultipleScattering* p, G4bool theMaster);
131 
132  void BuildPhysicsTable(const G4ParticleDefinition* aParticle);
133 
134  void BuildPhysicsTable(const G4ParticleDefinition* aParticle,
136 
137  void LocalPhysicsTables(const G4ParticleDefinition* aParticle,
139 
140  //-------------------------------------------------
141  // Run time access to DEDX, range, energy for a given particle,
142  // energy, and G4MaterialCutsCouple
143  //-------------------------------------------------
144 
145  inline G4double GetDEDX(
146  const G4ParticleDefinition *aParticle,
147  G4double kineticEnergy,
148  const G4MaterialCutsCouple *couple);
149 
150  inline G4double GetSubDEDX(
151  const G4ParticleDefinition *aParticle,
152  G4double kineticEnergy,
153  const G4MaterialCutsCouple *couple);
154 
155  inline G4double GetRange(
156  const G4ParticleDefinition *aParticle,
157  G4double kineticEnergy,
158  const G4MaterialCutsCouple *couple);
159 
160  inline G4double GetCSDARange(
161  const G4ParticleDefinition *aParticle,
162  G4double kineticEnergy,
163  const G4MaterialCutsCouple *couple);
164 
166  const G4ParticleDefinition *aParticle,
167  G4double kineticEnergy,
168  const G4MaterialCutsCouple *couple);
169 
170  inline G4double GetEnergy(
171  const G4ParticleDefinition *aParticle,
172  G4double range,
173  const G4MaterialCutsCouple *couple);
174 
176  const G4MaterialCutsCouple *couple,
177  const G4DynamicParticle* dp,
178  G4double& length);
179 
180  //-------------------------------------------------
181  // Methods to be called only at initialisation
182  //-------------------------------------------------
183 
185 
187 
189 
191 
192  void Register(G4VEmProcess* p);
193 
194  void DeRegister(G4VEmProcess* p);
195 
196  void Register(G4VEmModel* p);
197 
198  void DeRegister(G4VEmModel* p);
199 
201 
203 
204  void RegisterExtraParticle(const G4ParticleDefinition* aParticle,
206 
207  void SetLossFluctuations(G4bool val);
208 
209  void SetSubCutoff(G4bool val, const G4Region* r=0);
210 
211  void SetIntegral(G4bool val);
212 
213  void SetRandomStep(G4bool val);
214 
215  void SetMinSubRange(G4double val);
216 
217  void SetMinEnergy(G4double val);
218 
219  void SetMaxEnergy(G4double val);
220 
222 
223  void SetMaxEnergyForMuons(G4double val);
224 
225  void SetDEDXBinning(G4int val);
226 
228 
229  void SetLambdaBinning(G4int val);
230 
231  void SetStepFunction(G4double v1, G4double v2);
232 
233  void SetBuildCSDARange(G4bool val);
234 
235  void SetLinearLossLimit(G4double val);
236 
237  void SetVerbose(G4int val);
238 
240 
242 
243  //-------------------------------------------------
244  // Access methods
245  //-------------------------------------------------
246 
248 
249  inline G4bool BuildCSDARange() const;
250 
251  inline G4bool IsMaster() const;
252 
253  inline G4double MinKinEnergy() const;
254 
255  inline G4double MaxKinEnergy() const;
256 
257  inline G4int GetNumberOfBinsPerDecade() const;
258 
259  inline
261 
262  const std::vector<G4VEnergyLossProcess*>& GetEnergyLossProcessVector();
263 
264  const std::vector<G4VEmProcess*>& GetEmProcessVector();
265 
266  const std::vector<G4VMultipleScattering*>& GetMultipleScatteringVector();
267 
269 
271 
273 
274  inline G4EmCorrections* EmCorrections();
275 
277 
279 
281 
282 private:
283 
284  //-------------------------------------------------
285  // Private methods and members
286  //-------------------------------------------------
287 
289 
290  void ResetParameters();
291 
293 
294  void CopyTables(const G4ParticleDefinition* aParticle,
296 
297  void ParticleHaveNoLoss(const G4ParticleDefinition* aParticle);
298 
299  void SetParameters(const G4ParticleDefinition* aParticle,
301 
302  void CopyDEDXTables();
303 
305 
308 
310 
311  typedef const G4ParticleDefinition* PD;
312 
313  std::map<PD,G4VEnergyLossProcess*,std::less<PD> > loss_map;
314 
315  std::vector<G4VEnergyLossProcess*> loss_vector;
316  std::vector<PD> part_vector;
317  std::vector<PD> base_part_vector;
318  std::vector<G4bool> tables_are_built;
319  std::vector<G4bool> isActive;
320  std::vector<G4PhysicsTable*> dedx_vector;
321  std::vector<G4PhysicsTable*> range_vector;
322  std::vector<G4PhysicsTable*> inv_range_vector;
323  std::vector<G4VMultipleScattering*> msc_vector;
324  std::vector<G4VEmProcess*> emp_vector;
325  std::vector<G4VEmModel*> mod_vector;
326  std::vector<G4VEmFluctuationModel*> fmod_vector;
327 
328  // cash
334 
337 
340 
346 
349 
358 
360 
362 
363 };
364 
365 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
366 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
367 
368 inline G4VEnergyLossProcess*
370 {
371  //G4cout << "G4LossTableManager::GetEnergyLossProcess: "
372  // << aParticle << " " << currentParticle << " " << currentLoss << G4endl;
373  if(aParticle != currentParticle) {
374  currentParticle = aParticle;
375  std::map<PD,G4VEnergyLossProcess*,std::less<PD> >::const_iterator pos;
376  if ((pos = loss_map.find(aParticle)) != loss_map.end()) {
377  currentLoss = (*pos).second;
378  } else {
379  currentLoss = 0;
380  if ((pos = loss_map.find(theGenericIon)) != loss_map.end()) {
381  currentLoss = (*pos).second;
382  }
383  }
384  }
385  return currentLoss;
386 }
387 
388 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
389 
390 inline
392  G4double kineticEnergy,
393  const G4MaterialCutsCouple *couple)
394 {
395  if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); }
396  G4double x = 0.0;
397  if(currentLoss) { x = currentLoss->GetDEDX(kineticEnergy, couple); }
398  return x;
399 }
400 
401 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
402 
403 inline
405  G4double kineticEnergy,
406  const G4MaterialCutsCouple *couple)
407 {
408  if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); }
409  G4double x = 0.0;
410  if(currentLoss) { x = currentLoss->GetDEDXForSubsec(kineticEnergy, couple); }
411  return x;
412 }
413 
414 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
415 
416 inline
418  G4double kineticEnergy,
419  const G4MaterialCutsCouple *couple)
420 {
421  if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); }
422  G4double x = DBL_MAX;
423  if(currentLoss) { x = currentLoss->GetCSDARange(kineticEnergy, couple); }
424  return x;
425 }
426 
427 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
428 
429 inline
431  const G4ParticleDefinition *aParticle,
432  G4double kineticEnergy,
433  const G4MaterialCutsCouple *couple)
434 {
435  if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); }
436  G4double x = DBL_MAX;
437  if(currentLoss) { x = currentLoss->GetRangeForLoss(kineticEnergy, couple); }
438  return x;
439 }
440 
441 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
442 
443 inline
445  G4double kineticEnergy,
446  const G4MaterialCutsCouple *couple)
447 {
448  if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); }
449  G4double x = DBL_MAX;
450  if(currentLoss) {
451  x = currentLoss->GetRange(kineticEnergy, couple);
452  }
453  return x;
454 }
455 
456 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
457 
458 inline
460  G4double range,
461  const G4MaterialCutsCouple *couple)
462 {
463  if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); }
464  G4double x = 0;
465  if(currentLoss) { x = currentLoss->GetKineticEnergy(range, couple); }
466  return x;
467 }
468 
469 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
470 
471 inline
473  const G4MaterialCutsCouple *couple,
474  const G4DynamicParticle* dp,
475  G4double& length)
476 {
477  const G4ParticleDefinition* aParticle = dp->GetParticleDefinition();
478  if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); }
479  G4double x = 0.0;
480  if(currentLoss) { currentLoss->GetDEDXDispersion(couple, dp, length); }
481  return x;
482 }
483 
484 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
485 
487 {
488  return theParameters->BuildCSDARange();
489 }
490 
491 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
492 
494 {
495  return isMaster;
496 }
497 
498 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
499 
501 {
502  return theParameters->MinKinEnergy();
503 }
504 
505 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
506 
508 {
509  return theParameters->MaxKinEnergy();
510 }
511 
512 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
513 
515 {
517 }
518 
519 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
520 
522 {
523  return emCorrections;
524 }
525 
526 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
527 
529 {
530  return atomDeexcitation;
531 }
532 
533 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
534 
536 {
537  return subcutProducer;
538 }
539 
540 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
541 
543 {
544  return tableBuilder;
545 }
546 
547 #endif
548 
G4double GetKineticEnergy(G4double &range, const G4MaterialCutsCouple *)
G4VSubCutProducer * SubCutProducer()
G4EmConfigurator * EmConfigurator()
G4int NumberOfBinsPerDecade() const
void SetRandomStep(G4bool val)
G4double MaxKinEnergy() const
static G4LossTableManager * Instance()
G4VAtomDeexcitation * atomDeexcitation
G4double GetDEDX(const G4ParticleDefinition *aParticle, G4double kineticEnergy, const G4MaterialCutsCouple *couple)
G4VSubCutProducer * subcutProducer
G4double GetDEDX(G4double &kineticEnergy, const G4MaterialCutsCouple *)
std::vector< G4VEmModel * > mod_vector
G4double GetDEDXDispersion(const G4MaterialCutsCouple *couple, const G4DynamicParticle *dp, G4double &length)
G4ElectronIonPair * emElectronIonPair
void DeRegister(G4VEnergyLossProcess *p)
void SetLambdaBinning(G4int val)
G4EmSaturation * emSaturation
G4double GetSubDEDX(const G4ParticleDefinition *aParticle, G4double kineticEnergy, const G4MaterialCutsCouple *couple)
G4bool BuildCSDARange() const
static G4ThreadLocal G4LossTableManager * instance
G4double GetRangeForLoss(G4double &kineticEnergy, const G4MaterialCutsCouple *)
G4double GetCSDARange(G4double &kineticEnergy, const G4MaterialCutsCouple *)
G4EnergyLossMessenger * GetMessenger()
void CopyTables(const G4ParticleDefinition *aParticle, G4VEnergyLossProcess *)
std::vector< G4PhysicsTable * > range_vector
G4double GetDEDXForSubsec(G4double &kineticEnergy, const G4MaterialCutsCouple *)
#define G4ThreadLocal
Definition: tls.hh:89
const std::vector< G4VEmProcess * > & GetEmProcessVector()
int G4int
Definition: G4Types.hh:78
G4double GetCSDARange(const G4ParticleDefinition *aParticle, G4double kineticEnergy, const G4MaterialCutsCouple *couple)
G4LossTableBuilder * GetTableBuilder()
std::map< PD, G4VEnergyLossProcess *, std::less< PD > > loss_map
G4EmConfigurator * emConfigurator
void SetBuildCSDARange(G4bool val)
G4VEnergyLossProcess * BuildTables(const G4ParticleDefinition *aParticle)
G4bool BuildCSDARange() const
void ParticleHaveNoLoss(const G4ParticleDefinition *aParticle)
void SetSubCutProducer(G4VSubCutProducer *)
void SetParameters(const G4ParticleDefinition *aParticle, G4VEnergyLossProcess *)
G4double MinKinEnergy() const
std::vector< G4VEmFluctuationModel * > fmod_vector
bool G4bool
Definition: G4Types.hh:79
G4EmCorrections * EmCorrections()
G4VEnergyLossProcess * currentLoss
G4ElectronIonPair * ElectronIonPair()
G4EmSaturation * EmSaturation()
void SetMaxEnergyForCSDARange(G4double val)
G4bool IsMaster() const
void Register(G4VEnergyLossProcess *p)
G4double MinKinEnergy() const
const G4ParticleDefinition * GetParticleDefinition() const
void SetDEDXBinningForCSDARange(G4int val)
G4double GetEnergy(const G4ParticleDefinition *aParticle, G4double range, const G4MaterialCutsCouple *couple)
const std::vector< G4VEnergyLossProcess * > & GetEnergyLossProcessVector()
void SetSubCutoff(G4bool val, const G4Region *r=0)
G4double GetRangeFromRestricteDEDX(const G4ParticleDefinition *aParticle, G4double kineticEnergy, const G4MaterialCutsCouple *couple)
void RegisterExtraParticle(const G4ParticleDefinition *aParticle, G4VEnergyLossProcess *p)
G4LossTableManager & operator=(const G4LossTableManager &right)
std::vector< G4PhysicsTable * > inv_range_vector
const G4ParticleDefinition * PD
void SetMinSubRange(G4double val)
G4EmParameters * theParameters
G4EmCorrections * emCorrections
void SetMinEnergy(G4double val)
G4VEnergyLossProcess * GetEnergyLossProcess(const G4ParticleDefinition *)
void SetMaxEnergy(G4double val)
void SetStepFunction(G4double v1, G4double v2)
void BuildPhysicsTable(const G4ParticleDefinition *aParticle)
G4LossTableBuilder * tableBuilder
void SetLinearLossLimit(G4double val)
G4int GetNumberOfBinsPerDecade() const
std::vector< G4PhysicsTable * > dedx_vector
const G4double x[NPOINTSGL]
std::vector< G4VEnergyLossProcess * > loss_vector
void PreparePhysicsTable(const G4ParticleDefinition *aParticle, G4VEnergyLossProcess *p, G4bool theMaster)
G4double GetDEDXDispersion(const G4MaterialCutsCouple *couple, const G4DynamicParticle *dp, G4double length)
void PrintEWarning(G4String, G4double)
void SetVerbose(G4int val)
void LocalPhysicsTables(const G4ParticleDefinition *aParticle, G4VEnergyLossProcess *p)
void SetDEDXBinning(G4int val)
void SetMaxEnergyForMuons(G4double val)
std::vector< PD > part_vector
void SetIntegral(G4bool val)
void SetLossFluctuations(G4bool val)
std::vector< G4bool > isActive
G4VAtomDeexcitation * AtomDeexcitation()
std::vector< G4VEmProcess * > emp_vector
double G4double
Definition: G4Types.hh:76
std::vector< PD > base_part_vector
#define DBL_MAX
Definition: templates.hh:83
G4double MaxKinEnergy() const
G4double GetRange(const G4ParticleDefinition *aParticle, G4double kineticEnergy, const G4MaterialCutsCouple *couple)
std::vector< G4VMultipleScattering * > msc_vector
void SetAtomDeexcitation(G4VAtomDeexcitation *)
G4EnergyLossMessenger * theMessenger
static const G4double pos
const std::vector< G4VMultipleScattering * > & GetMultipleScatteringVector()
G4double GetRange(G4double &kineticEnergy, const G4MaterialCutsCouple *)
std::vector< G4bool > tables_are_built