source: trunk/source/processes/electromagnetic/utils/include/G4LossTableManager.hh@ 1347

Last change on this file since 1347 was 1340, checked in by garnier, 15 years ago

update ti head

File size: 15.2 KB
Line 
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,v 1.61 2010/09/03 10:09:45 vnivanch Exp $
27// GEANT4 tag $Name: emutils-V09-03-23 $
28//
29//
30// -------------------------------------------------------------------
31//
32// GEANT4 Class header file
33//
34//
35// File name: G4LossTableManager
36//
37// Author: Vladimir Ivanchenko on base of G4LossTables class
38// and Maria Grazia Pia ideas
39//
40// Creation date: 03.01.2002
41//
42// Modifications:
43//
44// 20-01-03 Migrade to cut per region (V.Ivanchenko)
45// 17-02-03 Fix problem of store/restore tables for ions (V.Ivanchenko)
46// 10-03-03 Add Ion registration (V.Ivanchenko)
47// 25-03-03 Add deregistration (V.Ivanchenko)
48// 26-03-03 Add GetDEDXDispersion (V.Ivanchenko)
49// 02-04-03 Change messenger (V.Ivanchenko)
50// 23-07-03 Add exchange with G4EnergyLossTables (V.Ivanchenko)
51// 05-10-03 Add G4VEmProcesses registration (V.Ivanchenko)
52// 17-10-03 Add SetParameters method (V.Ivanchenko)
53// 12-11-03 G4EnergyLossSTD -> G4EnergyLossProcess (V.Ivanchenko)
54// 14-01-04 Activate precise range calculation (V.Ivanchenko)
55// 08-11-04 Migration to new interface of Store/Retrieve tables (V.Ivantchenko)
56// 10-01-06 PreciseRange -> CSDARange (V.Ivantchenko)
57// 20-01-06 Introduce GetSubDEDX method (VI)
58// 26-01-06 Rename GetRange -> GetRangeFromRestricteDEDX (V.Ivanchenko)
59// 10-05-06 Add methods SetMscStepLimitation, FacRange and MscFlag (VI)
60// 22-05-06 Add methods Set/Get bremsTh (VI)
61// 12-02-07 Add SetSkin, SetLinearLossLimit (V.Ivanchenko)
62// 18-06-07 Move definition of msc parameters to G4EmProcessOptions (V.Ivanchenko)
63// 12-04-10 Added PreparePhsyicsTables and BuildPhysicsTables entries (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"
83#include "G4VEnergyLossProcess.hh"
84#include "G4EnergyLossTables.hh"
85
86class G4PhysicsTable;
87class G4MaterialCutsCouple;
88class G4EnergyLossMessenger;
89class G4ParticleDefinition;
90class G4VMultipleScattering;
91class G4VEmProcess;
92class G4EmCorrections;
93class G4EmSaturation;
94class G4EmConfigurator;
95class G4ElectronIonPair;
96class G4LossTableBuilder;
97class G4VAtomDeexcitation;
98class G4Region;
99
100class G4LossTableManager
101{
102
103public:
104
105 static G4LossTableManager* Instance();
106
107 ~G4LossTableManager();
108
109 //-------------------------------------------------
110 // called from destructor
111 //-------------------------------------------------
112
113 void Clear();
114
115 //-------------------------------------------------
116 // initialisation before a new run
117 //-------------------------------------------------
118
119 void PreparePhysicsTable(const G4ParticleDefinition* aParticle,
120 G4VEnergyLossProcess* p);
121 void PreparePhysicsTable(const G4ParticleDefinition* aParticle,
122 G4VEmProcess* p);
123 void PreparePhysicsTable(const G4ParticleDefinition* aParticle,
124 G4VMultipleScattering* p);
125 void BuildPhysicsTable(const G4ParticleDefinition* aParticle);
126 void BuildPhysicsTable(const G4ParticleDefinition* aParticle,
127 G4VEnergyLossProcess* p);
128
129 //-------------------------------------------------
130 // Run time access to DEDX, range, energy for a given particle,
131 // energy, and G4MaterialCutsCouple
132 //-------------------------------------------------
133
134 inline G4double GetDEDX(
135 const G4ParticleDefinition *aParticle,
136 G4double kineticEnergy,
137 const G4MaterialCutsCouple *couple);
138
139 inline G4double GetSubDEDX(
140 const G4ParticleDefinition *aParticle,
141 G4double kineticEnergy,
142 const G4MaterialCutsCouple *couple);
143
144 inline G4double GetRange(
145 const G4ParticleDefinition *aParticle,
146 G4double kineticEnergy,
147 const G4MaterialCutsCouple *couple);
148
149 inline G4double GetCSDARange(
150 const G4ParticleDefinition *aParticle,
151 G4double kineticEnergy,
152 const G4MaterialCutsCouple *couple);
153
154 inline G4double GetRangeFromRestricteDEDX(
155 const G4ParticleDefinition *aParticle,
156 G4double kineticEnergy,
157 const G4MaterialCutsCouple *couple);
158
159 inline G4double GetEnergy(
160 const G4ParticleDefinition *aParticle,
161 G4double range,
162 const G4MaterialCutsCouple *couple);
163
164 inline G4double GetDEDXDispersion(
165 const G4MaterialCutsCouple *couple,
166 const G4DynamicParticle* dp,
167 G4double& length);
168
169 //-------------------------------------------------
170 // Methods to be called only at initialisation
171 //-------------------------------------------------
172
173 void Register(G4VEnergyLossProcess* p);
174
175 void DeRegister(G4VEnergyLossProcess* p);
176
177 void Register(G4VMultipleScattering* p);
178
179 void DeRegister(G4VMultipleScattering* p);
180
181 void Register(G4VEmProcess* p);
182
183 void DeRegister(G4VEmProcess* p);
184
185 void Register(G4VEmModel* p);
186
187 void DeRegister(G4VEmModel* p);
188
189 void Register(G4VEmFluctuationModel* p);
190
191 void DeRegister(G4VEmFluctuationModel* p);
192
193 void RegisterIon(const G4ParticleDefinition* aParticle,
194 G4VEnergyLossProcess* p);
195
196 void RegisterExtraParticle(const G4ParticleDefinition* aParticle,
197 G4VEnergyLossProcess* p);
198
199 void SetLossFluctuations(G4bool val);
200
201 void SetSubCutoff(G4bool val, const G4Region* r=0);
202
203 void SetIntegral(G4bool val);
204
205 void SetRandomStep(G4bool val);
206
207 void SetMinSubRange(G4double val);
208
209 void SetMinEnergy(G4double val);
210
211 void SetMaxEnergy(G4double val);
212
213 void SetMaxEnergyForCSDARange(G4double val);
214
215 void SetMaxEnergyForMuons(G4double val);
216
217 void SetDEDXBinning(G4int val);
218
219 void SetDEDXBinningForCSDARange(G4int val);
220
221 void SetLambdaBinning(G4int val);
222
223 G4int GetNumberOfBinsPerDecade() const;
224
225 void SetStepFunction(G4double v1, G4double v2);
226
227 void SetBuildCSDARange(G4bool val);
228
229 void SetLPMFlag(G4bool val);
230
231 void SetSplineFlag(G4bool val);
232
233 void SetLinearLossLimit(G4double val);
234
235 void SetBremsstrahlungTh(G4double val);
236
237 void SetFactorForAngleLimit(G4double val);
238
239 void SetVerbose(G4int val);
240
241 //-------------------------------------------------
242 // Access methods
243 //-------------------------------------------------
244
245 G4EnergyLossMessenger* GetMessenger();
246
247 G4bool BuildCSDARange() const;
248
249 G4bool LPMFlag() const;
250
251 G4bool SplineFlag() const;
252
253 G4double BremsstrahlungTh() const;
254
255 G4double FactorForAngleLimit() const;
256
257 const std::vector<G4VEnergyLossProcess*>& GetEnergyLossProcessVector();
258
259 const std::vector<G4VEmProcess*>& GetEmProcessVector();
260
261 const std::vector<G4VMultipleScattering*>& GetMultipleScatteringVector();
262
263 inline
264 G4VEnergyLossProcess* GetEnergyLossProcess(const G4ParticleDefinition*);
265
266 G4EmCorrections* EmCorrections();
267
268 G4EmSaturation* EmSaturation();
269
270 G4EmConfigurator* EmConfigurator();
271
272 G4ElectronIonPair* ElectronIonPair();
273
274 G4VAtomDeexcitation* AtomDeexcitation();
275
276 void SetAtomDeexcitation(G4VAtomDeexcitation*);
277
278private:
279
280 //-------------------------------------------------
281 // Private methods and members
282 //-------------------------------------------------
283
284 G4LossTableManager();
285
286 G4VEnergyLossProcess* BuildTables(const G4ParticleDefinition* aParticle);
287
288 void CopyTables(const G4ParticleDefinition* aParticle,
289 G4VEnergyLossProcess*);
290
291 void ParticleHaveNoLoss(const G4ParticleDefinition* aParticle);
292
293 void SetParameters(const G4ParticleDefinition* aParticle,
294 G4VEnergyLossProcess*);
295
296 void CopyDEDXTables();
297
298 static G4LossTableManager* theInstance;
299
300 typedef const G4ParticleDefinition* PD;
301
302 std::map<PD,G4VEnergyLossProcess*,std::less<PD> > loss_map;
303
304 std::vector<G4VEnergyLossProcess*> loss_vector;
305 std::vector<PD> part_vector;
306 std::vector<PD> base_part_vector;
307 std::vector<G4bool> tables_are_built;
308 std::vector<G4bool> isActive;
309 std::vector<G4PhysicsTable*> dedx_vector;
310 std::vector<G4PhysicsTable*> range_vector;
311 std::vector<G4PhysicsTable*> inv_range_vector;
312 std::vector<G4VMultipleScattering*> msc_vector;
313 std::vector<G4VEmProcess*> emp_vector;
314 std::vector<G4VEmModel*> mod_vector;
315 std::vector<G4VEmFluctuationModel*> fmod_vector;
316
317 // cash
318 G4VEnergyLossProcess* currentLoss;
319 PD currentParticle;
320 PD theElectron;
321 PD firstParticle;
322
323 G4int n_loss;
324 G4int run;
325
326 G4bool all_tables_are_built;
327 G4bool startInitialisation;
328
329 G4bool lossFluctuationFlag;
330 G4bool subCutoffFlag;
331 G4bool rndmStepFlag;
332 G4bool integral;
333 G4bool integralActive;
334 G4bool buildCSDARange;
335 G4bool minEnergyActive;
336 G4bool maxEnergyActive;
337 G4bool maxEnergyForMuonsActive;
338 G4bool stepFunctionActive;
339 G4bool flagLPM;
340 G4bool splineFlag;
341
342 G4double minSubRange;
343 G4double maxRangeVariation;
344 G4double maxFinalStep;
345 G4double minKinEnergy;
346 G4double maxKinEnergy;
347 G4double maxKinEnergyForMuons;
348 G4double bremsTh;
349 G4double factorForAngleLimit;
350
351 G4LossTableBuilder* tableBuilder;
352 G4EnergyLossMessenger* theMessenger;
353 G4EmCorrections* emCorrections;
354 G4EmSaturation* emSaturation;
355 G4EmConfigurator* emConfigurator;
356 G4ElectronIonPair* emElectronIonPair;
357 G4VAtomDeexcitation* atomDeexcitation;
358
359 G4int nbinsLambda;
360 G4int nbinsPerDecade;
361 G4int verbose;
362
363};
364
365//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
366//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
367
368inline G4VEnergyLossProcess* G4LossTableManager::GetEnergyLossProcess(
369 const G4ParticleDefinition *aParticle)
370{
371 if(aParticle != currentParticle) {
372 currentParticle = aParticle;
373 std::map<PD,G4VEnergyLossProcess*,std::less<PD> >::const_iterator pos;
374 if ((pos = loss_map.find(aParticle)) != loss_map.end()) {
375 currentLoss = (*pos).second;
376 } else {
377 currentLoss = 0;
378 // ParticleHaveNoLoss(aParticle);
379 }
380 }
381 return currentLoss;
382}
383
384//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
385
386inline G4double G4LossTableManager::GetDEDX(
387 const G4ParticleDefinition *aParticle,
388 G4double kineticEnergy,
389 const G4MaterialCutsCouple *couple)
390{
391 if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); }
392 G4double x;
393 if(currentLoss) { x = currentLoss->GetDEDX(kineticEnergy, couple); }
394 else { x = G4EnergyLossTables::GetDEDX(currentParticle,
395 kineticEnergy,couple,false); }
396 return x;
397}
398
399//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
400
401inline G4double G4LossTableManager::GetSubDEDX(
402 const G4ParticleDefinition *aParticle,
403 G4double kineticEnergy,
404 const G4MaterialCutsCouple *couple)
405{
406 if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); }
407 G4double x = 0.0;
408 if(currentLoss) { x = currentLoss->GetDEDXForSubsec(kineticEnergy, couple); }
409 return x;
410}
411
412//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
413
414inline G4double G4LossTableManager::GetCSDARange(
415 const G4ParticleDefinition *aParticle,
416 G4double kineticEnergy,
417 const G4MaterialCutsCouple *couple)
418{
419 if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); }
420 G4double x = DBL_MAX;
421 if(currentLoss) { x = currentLoss->GetCSDARange(kineticEnergy, couple); }
422 return x;
423}
424
425//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
426
427inline G4double G4LossTableManager::GetRangeFromRestricteDEDX(
428 const G4ParticleDefinition *aParticle,
429 G4double kineticEnergy,
430 const G4MaterialCutsCouple *couple)
431{
432 if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); }
433 G4double x;
434 if(currentLoss) { x = currentLoss->GetRangeForLoss(kineticEnergy, couple); }
435 else { x = G4EnergyLossTables::GetRange(currentParticle,kineticEnergy,
436 couple,false); }
437 return x;
438}
439
440//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
441
442inline G4double G4LossTableManager::GetRange(
443 const G4ParticleDefinition *aParticle,
444 G4double kineticEnergy,
445 const G4MaterialCutsCouple *couple)
446{
447 if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); }
448 G4double x;
449 if(currentLoss) { x = currentLoss->GetRange(kineticEnergy, couple); }
450 else { x = G4EnergyLossTables::GetRange(currentParticle,kineticEnergy,
451 couple,false); }
452 return x;
453}
454
455//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
456
457inline G4double G4LossTableManager::GetEnergy(
458 const G4ParticleDefinition *aParticle,
459 G4double range,
460 const G4MaterialCutsCouple *couple)
461{
462 if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); }
463 G4double x;
464 if(currentLoss) { x = currentLoss->GetKineticEnergy(range, couple); }
465 else { x = G4EnergyLossTables::GetPreciseEnergyFromRange(currentParticle,range,
466 couple,false); }
467 return x;
468}
469
470//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
471
472inline G4double G4LossTableManager::GetDEDXDispersion(
473 const G4MaterialCutsCouple *couple,
474 const G4DynamicParticle* dp,
475 G4double& length)
476{
477 const G4ParticleDefinition* aParticle = dp->GetParticleDefinition();
478 if(aParticle != currentParticle) {
479 std::map<PD,G4VEnergyLossProcess*,std::less<PD> >::const_iterator pos;
480 if ((pos = loss_map.find(aParticle)) != loss_map.end()) {
481 currentParticle = aParticle;
482 currentLoss = (*pos).second;
483 } else {
484 ParticleHaveNoLoss(aParticle);
485 }
486 }
487 return currentLoss->GetDEDXDispersion(couple, dp, length);
488}
489
490//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
491
492#endif
493
Note: See TracBrowser for help on using the repository browser.