Geant4-11
G4TablesForExtrapolator.cc
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// ClassName: G4TablesForExtrapolator
29//
30// Description: This class provide calculation of energy loss, fluctuation,
31// and msc angle
32//
33// Author: 09.12.04 V.Ivanchenko
34//
35// Modification:
36// 08-04-05 Rename Propogator -> Extrapolator (V.Ivanchenko)
37// 16-03-06 Add muon tables and fix bug in units (V.Ivanchenko)
38// 21-03-06 Add verbosity defined in the constructor and Initialisation
39// start only when first public method is called (V.Ivanchenko)
40// 03-05-06 Remove unused pointer G4Material* from number of methods (VI)
41// 12-05-06 SEt linLossLimit=0.001 (VI)
42//
43//----------------------------------------------------------------------------
44//
45
46//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
47
50#include "G4SystemOfUnits.hh"
51#include "G4LossTableManager.hh"
52#include "G4PhysicsLogVector.hh"
54#include "G4Material.hh"
56#include "G4Electron.hh"
57#include "G4Positron.hh"
58#include "G4Proton.hh"
59#include "G4MuonPlus.hh"
60#include "G4MuonMinus.hh"
61#include "G4EmParameters.hh"
63#include "G4BetheBlochModel.hh"
67#include "G4ProductionCuts.hh"
68#include "G4LossTableBuilder.hh"
69#include "G4WentzelVIModel.hh"
70#include "G4ios.hh"
71
72//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
73
76 : emin(e1), emax(e2), verbose(verb), nbins(bins)
77{
83}
84
85//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
86
88{
89 if(nullptr != dedxElectron) {
91 delete dedxElectron;
92 }
93 if(nullptr != dedxPositron) {
95 delete dedxPositron;
96 }
97 if(nullptr != dedxProton) {
99 delete dedxProton;
100 }
101 if(nullptr != dedxMuon) {
103 delete dedxMuon;
104 }
105 if(nullptr != rangeElectron) {
107 delete rangeElectron;
108 }
109 if(nullptr != rangePositron) {
111 delete rangePositron;
112 }
113 if(nullptr != rangeProton) {
115 delete rangeProton;
116 }
117 if(nullptr != rangeMuon) {
119 delete rangeMuon;
120 }
121 if(nullptr != invRangeElectron) {
123 delete invRangeElectron;
124 }
125 if(nullptr != invRangePositron) {
127 delete invRangePositron;
128 }
129 if(nullptr != invRangeProton) {
131 delete invRangeProton;
132 }
133 if(nullptr != invRangeMuon) {
135 delete invRangeMuon;
136 }
137 if(nullptr != mscElectron) {
139 delete mscElectron;
140 }
141 delete pcuts;
142 delete builder;
143}
144
145//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
146
147const G4PhysicsTable*
149{
150 const G4PhysicsTable* table = nullptr;
151 switch (type)
152 {
153 case fDedxElectron:
154 table = dedxElectron;
155 break;
156 case fDedxPositron:
157 table = dedxPositron;
158 break;
159 case fDedxProton:
160 table = dedxProton;
161 break;
162 case fDedxMuon:
163 table = dedxMuon;
164 break;
165 case fRangeElectron:
166 table = rangeElectron;
167 break;
168 case fRangePositron:
169 table = rangePositron;
170 break;
171 case fRangeProton:
172 table = rangeProton;
173 break;
174 case fRangeMuon:
175 table = rangeMuon;
176 break;
178 table = invRangeElectron;
179 break;
181 table = invRangePositron;
182 break;
183 case fInvRangeProton:
184 table = invRangeProton;
185 break;
186 case fInvRangeMuon:
187 table = invRangeMuon;
188 break;
189 case fMscElectron:
190 table = mscElectron;
191 }
192 return table;
193}
194
195//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
196
198{
199 if(verbose>1) {
200 G4cout << "### G4TablesForExtrapolator::Initialisation" << G4endl;
201 }
203 if(nmat == num) { return; }
204 nmat = num;
206 cuts.resize(nmat, DBL_MAX);
207 couples.resize(nmat, nullptr);
208
210 if(!pcuts) { pcuts = new G4ProductionCuts(); }
211
212 for(G4int i=0; i<nmat; ++i) {
213 couples[i] = new G4MaterialCutsCouple((*mtable)[i],pcuts);
214 }
215
229
230 builder = new G4LossTableBuilder(true);
232
233 if(verbose>1) {
234 G4cout << "### G4TablesForExtrapolator Builds electron tables"
235 << G4endl;
236 }
240
241 if(verbose>1) {
242 G4cout << "### G4TablesForExtrapolator Builds positron tables"
243 << G4endl;
244 }
248
249 if(verbose>1) {
250 G4cout << "### G4TablesForExtrapolator Builds muon tables" << G4endl;
251 }
255
256 if(verbose>2) {
257 G4cout << "DEDX MUON" << G4endl;
258 G4cout << *dedxMuon << G4endl;
259 G4cout << "RANGE MUON" << G4endl;
260 G4cout << *rangeMuon << G4endl;
261 G4cout << "INVRANGE MUON" << G4endl;
263 }
264 if(verbose>1) {
265 G4cout << "### G4TablesForExtrapolator Builds proton tables"
266 << G4endl;
267 }
271
273}
274
275//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
276
278{
279 G4PhysicsTable* table = ptr;
280 if(nullptr == ptr) { table = new G4PhysicsTable(); }
281 G4int n = table->length();
282 for(G4int i=n; i<nmat; ++i) {
284 table->push_back(v);
285 }
286 return table;
287}
288
289//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
290
292 const G4ParticleDefinition* part,
293 G4PhysicsTable* table)
294{
297 ioni->Initialise(part, cuts);
298 brem->Initialise(part, cuts);
299 ioni->SetUseBaseMaterials(false);
300 brem->SetUseBaseMaterials(false);
301
303 charge2 = 1.0;
304 currentParticle = part;
305
307 if(0<verbose) {
308 G4cout << "G4TablesForExtrapolator::ComputeElectronDEDX for "
309 << part->GetParticleName()
310 << G4endl;
311 }
312 for(G4int i=0; i<nmat; ++i) {
313
314 const G4Material* mat = (*mtable)[i];
315 if(1<verbose) {
316 G4cout << "i= " << i << " mat= " << mat->GetName() << G4endl;
317 }
318 G4PhysicsVector* aVector = (*table)[i];
319
320 for(G4int j=0; j<=nbins; ++j) {
321
322 G4double e = aVector->Energy(j);
323 G4double dedx = ioni->ComputeDEDXPerVolume(mat,part,e,e)
324 + brem->ComputeDEDXPerVolume(mat,part,e,e);
325 if(1<verbose) {
326 G4cout << "j= " << j
327 << " e(MeV)= " << e/MeV
328 << " dedx(Mev/cm)= " << dedx*cm/MeV
329 << " dedx(Mev.cm2/g)= "
330 << dedx/((MeV*mat->GetDensity())/(g/cm2))
331 << G4endl;
332 }
333 aVector->PutValue(j,dedx);
334 }
335 if(splineFlag) { aVector->FillSecondDerivatives(); }
336 }
337 delete ioni;
338 delete brem;
339}
340
341//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
342
343void
345 G4PhysicsTable* table)
346{
350 ioni->Initialise(part, cuts);
351 pair->Initialise(part, cuts);
352 brem->Initialise(part, cuts);
353 ioni->SetUseBaseMaterials(false);
354 pair->SetUseBaseMaterials(false);
355 brem->SetUseBaseMaterials(false);
356
357 mass = part->GetPDGMass();
358 charge2 = 1.0;
359 currentParticle = part;
360
362
363 if(0<verbose) {
364 G4cout << "G4TablesForExtrapolator::ComputeMuonDEDX for "
365 << part->GetParticleName()
366 << G4endl;
367 }
368
369 for(G4int i=0; i<nmat; ++i) {
370
371 const G4Material* mat = (*mtable)[i];
372 if(1<verbose) {
373 G4cout << "i= " << i << " mat= " << mat->GetName() << G4endl;
374 }
375 G4PhysicsVector* aVector = (*table)[i];
376 for(G4int j=0; j<=nbins; ++j) {
377
378 G4double e = aVector->Energy(j);
379 G4double dedx = ioni->ComputeDEDXPerVolume(mat,part,e,e) +
380 pair->ComputeDEDXPerVolume(mat,part,e,e) +
381 brem->ComputeDEDXPerVolume(mat,part,e,e);
382 aVector->PutValue(j,dedx);
383 if(1<verbose) {
384 G4cout << "j= " << j
385 << " e(MeV)= " << e/MeV
386 << " dedx(Mev/cm)= " << dedx*cm/MeV
387 << " dedx(Mev/(g/cm2)= "
388 << dedx/((MeV*mat->GetDensity())/(g/cm2))
389 << G4endl;
390 }
391 }
392 if(splineFlag) { aVector->FillSecondDerivatives(); }
393 }
394 delete ioni;
395}
396
397//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
398
399void
401 G4PhysicsTable* table)
402{
404 ioni->Initialise(part, cuts);
405 ioni->SetUseBaseMaterials(false);
406
407 mass = part->GetPDGMass();
408 charge2 = 1.0;
409 currentParticle = part;
410
412
413 if(0<verbose) {
414 G4cout << "G4TablesForExtrapolator::ComputeProtonDEDX for "
415 << part->GetParticleName()
416 << G4endl;
417 }
418
419 for(G4int i=0; i<nmat; ++i) {
420
421 const G4Material* mat = (*mtable)[i];
422 if(1<verbose)
423 G4cout << "i= " << i << " mat= " << mat->GetName() << G4endl;
424 G4PhysicsVector* aVector = (*table)[i];
425 for(G4int j=0; j<=nbins; ++j) {
426
427 G4double e = aVector->Energy(j);
428 G4double dedx = ioni->ComputeDEDXPerVolume(mat,part,e,e);
429 aVector->PutValue(j,dedx);
430 if(1<verbose) {
431 G4cout << "j= " << j
432 << " e(MeV)= " << e/MeV
433 << " dedx(Mev/cm)= " << dedx*cm/MeV
434 << " dedx(Mev.cm2/g)= " << dedx/((mat->GetDensity())/(g/cm2))
435 << G4endl;
436 }
437 }
438 if(splineFlag) { aVector->FillSecondDerivatives(); }
439 }
440 delete ioni;
441}
442
443//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
444
445void
447 G4PhysicsTable* table)
448{
451 msc->Initialise(part, cuts);
452 msc->SetUseBaseMaterials(false);
453
454 mass = part->GetPDGMass();
455 charge2 = 1.0;
456 currentParticle = part;
457
459
460 if(0<verbose) {
461 G4cout << "G4TablesForExtrapolator::ComputeTransportXS for "
462 << part->GetParticleName()
463 << G4endl;
464 }
465
466 for(G4int i=0; i<nmat; ++i) {
467
468 const G4Material* mat = (*mtable)[i];
469 msc->SetCurrentCouple(couples[i]);
470 if(1<verbose)
471 G4cout << "i= " << i << " mat= " << mat->GetName() << G4endl;
472 G4PhysicsVector* aVector = (*table)[i];
473 for(G4int j=0; j<=nbins; ++j) {
474
475 G4double e = aVector->Energy(j);
476 G4double xs = msc->CrossSectionPerVolume(mat,part,e);
477 aVector->PutValue(j,xs);
478 if(1<verbose) {
479 G4cout << "j= " << j << " e(MeV)= " << e/MeV
480 << " xs(1/mm)= " << xs*mm << G4endl;
481 }
482 }
483 if(splineFlag) { aVector->FillSecondDerivatives(); }
484 }
485 delete msc;
486}
487
488//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
489
static const G4double e1[44]
static const G4double e2[44]
static const G4double emax
std::vector< G4Material * > G4MaterialTable
static constexpr double cm2
Definition: G4SIunits.hh:100
static constexpr double mm
Definition: G4SIunits.hh:95
static constexpr double g
Definition: G4SIunits.hh:168
static constexpr double MeV
Definition: G4SIunits.hh:200
static constexpr double cm
Definition: G4SIunits.hh:99
@ fInvRangeElectron
@ fInvRangePositron
double G4double
Definition: G4Types.hh:83
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
void Initialise(const G4ParticleDefinition *, const G4DataVector &) override
G4double ComputeDEDXPerVolume(const G4Material *, const G4ParticleDefinition *, G4double kineticEnergy, G4double cutEnergy) override
static G4Electron * Electron()
Definition: G4Electron.cc:93
void BuildRangeTable(const G4PhysicsTable *dedxTable, G4PhysicsTable *rangeTable)
void BuildInverseRangeTable(const G4PhysicsTable *rangeTable, G4PhysicsTable *invRangeTable)
void SetBaseMaterialActive(G4bool flag)
G4double GetDensity() const
Definition: G4Material.hh:176
static size_t GetNumberOfMaterials()
Definition: G4Material.cc:679
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:672
const G4String & GetName() const
Definition: G4Material.hh:173
G4double ComputeDEDXPerVolume(const G4Material *, const G4ParticleDefinition *, G4double kineticEnergy, G4double cutEnergy) override
void Initialise(const G4ParticleDefinition *, const G4DataVector &) override
void Initialise(const G4ParticleDefinition *, const G4DataVector &) override
G4double ComputeDEDXPerVolume(const G4Material *, const G4ParticleDefinition *, G4double kineticEnergy, G4double cutEnergy) override
void Initialise(const G4ParticleDefinition *, const G4DataVector &) override
G4double ComputeDEDXPerVolume(const G4Material *, const G4ParticleDefinition *, G4double kineticEnergy, G4double cutEnergy) override
static G4MuonMinus * MuonMinus()
Definition: G4MuonMinus.cc:99
static G4MuonPlus * MuonPlus()
Definition: G4MuonPlus.cc:98
const G4String & GetParticleName() const
void push_back(G4PhysicsVector *)
void clearAndDestroy()
std::size_t length() const
void PutValue(const std::size_t index, const G4double value)
G4double Energy(const std::size_t index) const
void FillSecondDerivatives(const G4SplineType=G4SplineType::Base, const G4double dir1=0.0, const G4double dir2=0.0)
static G4Positron * Positron()
Definition: G4Positron.cc:93
static G4Proton * Proton()
Definition: G4Proton.cc:92
const G4ParticleDefinition * proton
const G4ParticleDefinition * muonMinus
std::vector< const G4MaterialCutsCouple * > couples
void ComputeTrasportXS(const G4ParticleDefinition *part, G4PhysicsTable *table)
const G4ParticleDefinition * electron
G4TablesForExtrapolator(G4int verb, G4int bins, G4double e1, G4double e2)
void ComputeMuonDEDX(const G4ParticleDefinition *part, G4PhysicsTable *table)
const G4ParticleDefinition * currentParticle
const G4ParticleDefinition * muonPlus
void ComputeProtonDEDX(const G4ParticleDefinition *part, G4PhysicsTable *table)
G4PhysicsTable * PrepareTable(G4PhysicsTable *)
void ComputeElectronDEDX(const G4ParticleDefinition *part, G4PhysicsTable *table)
const G4PhysicsTable * GetPhysicsTable(ExtTableType type) const
const G4ParticleDefinition * positron
void SetPolarAngleLimit(G4double)
Definition: G4VEmModel.hh:802
virtual G4double CrossSectionPerVolume(const G4Material *, const G4ParticleDefinition *, G4double kineticEnergy, G4double cutEnergy=0.0, G4double maxEnergy=DBL_MAX)
Definition: G4VEmModel.cc:237
void SetCurrentCouple(const G4MaterialCutsCouple *)
Definition: G4VEmModel.hh:472
void SetUseBaseMaterials(G4bool val)
Definition: G4VEmModel.hh:753
void Initialise(const G4ParticleDefinition *, const G4DataVector &) override
G4double ComputeDEDXPerVolume(const G4Material *, const G4ParticleDefinition *, G4double ekin, G4double cutEnergy) override
void Initialise(const G4ParticleDefinition *, const G4DataVector &) override
static constexpr double pi
Definition: SystemOfUnits.h:55
float electron_mass_c2
Definition: hepunit.py:273
#define DBL_MAX
Definition: templates.hh:62