Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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
75 G4double e1, G4double e2)
76 : emin(e1), emax(e2), verbose(verb), nbins(bins)
77{
78 electron = G4Electron::Electron();
79 positron = G4Positron::Positron();
80 proton = G4Proton::Proton();
81 muonPlus = G4MuonPlus::MuonPlus();
82 muonMinus= G4MuonMinus::MuonMinus();
83}
84
85//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
86
88{
89 if(nullptr != dedxElectron) {
90 dedxElectron->clearAndDestroy();
91 delete dedxElectron;
92 }
93 if(nullptr != dedxPositron) {
94 dedxPositron->clearAndDestroy();
95 delete dedxPositron;
96 }
97 if(nullptr != dedxProton) {
98 dedxProton->clearAndDestroy();
99 delete dedxProton;
100 }
101 if(nullptr != dedxMuon) {
102 dedxMuon->clearAndDestroy();
103 delete dedxMuon;
104 }
105 if(nullptr != rangeElectron) {
106 rangeElectron->clearAndDestroy();
107 delete rangeElectron;
108 }
109 if(nullptr != rangePositron) {
110 rangePositron->clearAndDestroy();
111 delete rangePositron;
112 }
113 if(nullptr != rangeProton) {
114 rangeProton->clearAndDestroy();
115 delete rangeProton;
116 }
117 if(nullptr != rangeMuon) {
118 rangeMuon->clearAndDestroy();
119 delete rangeMuon;
120 }
121 if(nullptr != invRangeElectron) {
122 invRangeElectron->clearAndDestroy();
123 delete invRangeElectron;
124 }
125 if(nullptr != invRangePositron) {
126 invRangePositron->clearAndDestroy();
127 delete invRangePositron;
128 }
129 if(nullptr != invRangeProton) {
130 invRangeProton->clearAndDestroy();
131 delete invRangeProton;
132 }
133 if(nullptr != invRangeMuon) {
134 invRangeMuon->clearAndDestroy();
135 delete invRangeMuon;
136 }
137 if(nullptr != mscElectron) {
138 mscElectron->clearAndDestroy();
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;
205 cuts.resize(nmat, DBL_MAX);
206 couples.resize(nmat, nullptr);
207
209 if(!pcuts) { pcuts = new G4ProductionCuts(); }
210
211 for(G4int i=0; i<nmat; ++i) {
212 couples[i] = new G4MaterialCutsCouple((*mtable)[i],pcuts);
213 }
214
215 dedxElectron = PrepareTable(dedxElectron);
216 dedxPositron = PrepareTable(dedxPositron);
217 dedxMuon = PrepareTable(dedxMuon);
218 dedxProton = PrepareTable(dedxProton);
219 rangeElectron = PrepareTable(rangeElectron);
220 rangePositron = PrepareTable(rangePositron);
221 rangeMuon = PrepareTable(rangeMuon);
222 rangeProton = PrepareTable(rangeProton);
223 invRangeElectron = PrepareTable(invRangeElectron);
224 invRangePositron = PrepareTable(invRangePositron);
225 invRangeMuon = PrepareTable(invRangeMuon);
226 invRangeProton = PrepareTable(invRangeProton);
227 mscElectron = PrepareTable(mscElectron);
228
229 builder = new G4LossTableBuilder(true);
230 builder->SetBaseMaterialActive(false);
231
232 if(verbose>1) {
233 G4cout << "### G4TablesForExtrapolator Builds electron tables"
234 << G4endl;
235 }
236 ComputeElectronDEDX(electron, dedxElectron);
237 builder->BuildRangeTable(dedxElectron,rangeElectron);
238 builder->BuildInverseRangeTable(rangeElectron, invRangeElectron);
239
240 if(verbose>1) {
241 G4cout << "### G4TablesForExtrapolator Builds positron tables"
242 << G4endl;
243 }
244 ComputeElectronDEDX(positron, dedxPositron);
245 builder->BuildRangeTable(dedxPositron, rangePositron);
246 builder->BuildInverseRangeTable(rangePositron, invRangePositron);
247
248 if(verbose>1) {
249 G4cout << "### G4TablesForExtrapolator Builds muon tables" << G4endl;
250 }
251 ComputeMuonDEDX(muonPlus, dedxMuon);
252 builder->BuildRangeTable(dedxMuon, rangeMuon);
253 builder->BuildInverseRangeTable(rangeMuon, invRangeMuon);
254
255 if(verbose>2) {
256 G4cout << "DEDX MUON" << G4endl;
257 G4cout << *dedxMuon << G4endl;
258 G4cout << "RANGE MUON" << G4endl;
259 G4cout << *rangeMuon << G4endl;
260 G4cout << "INVRANGE MUON" << G4endl;
261 G4cout << *invRangeMuon << G4endl;
262 }
263 if(verbose>1) {
264 G4cout << "### G4TablesForExtrapolator Builds proton tables"
265 << G4endl;
266 }
267 ComputeProtonDEDX(proton, dedxProton);
268 builder->BuildRangeTable(dedxProton, rangeProton);
269 builder->BuildInverseRangeTable(rangeProton, invRangeProton);
270
271 ComputeTrasportXS(electron, mscElectron);
272}
273
274//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
275
276G4PhysicsTable* G4TablesForExtrapolator::PrepareTable(G4PhysicsTable* ptr)
277{
278 G4PhysicsTable* table = ptr;
279 if(nullptr == ptr) { table = new G4PhysicsTable(); }
280 G4int n = (G4int)table->length();
281 for(G4int i=n; i<nmat; ++i) {
282 G4PhysicsVector* v = new G4PhysicsLogVector(emin, emax, nbins, splineFlag);
283 table->push_back(v);
284 }
285 return table;
286}
287
288//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
289
290void G4TablesForExtrapolator::ComputeElectronDEDX(
291 const G4ParticleDefinition* part,
292 G4PhysicsTable* table)
293{
296 ioni->Initialise(part, cuts);
297 brem->Initialise(part, cuts);
298 ioni->SetUseBaseMaterials(false);
299 brem->SetUseBaseMaterials(false);
300
301 mass = electron_mass_c2;
302 charge2 = 1.0;
303 currentParticle = part;
304
306 if(0<verbose) {
307 G4cout << "G4TablesForExtrapolator::ComputeElectronDEDX for "
308 << part->GetParticleName()
309 << G4endl;
310 }
311 for(G4int i=0; i<nmat; ++i) {
312
313 const G4Material* mat = (*mtable)[i];
314 if(1<verbose) {
315 G4cout << "i= " << i << " mat= " << mat->GetName() << G4endl;
316 }
317 G4PhysicsVector* aVector = (*table)[i];
318
319 for(G4int j=0; j<=nbins; ++j) {
320
321 G4double e = aVector->Energy(j);
322 G4double dedx = ioni->ComputeDEDXPerVolume(mat,part,e,e)
323 + brem->ComputeDEDXPerVolume(mat,part,e,e);
324 if(1<verbose) {
325 G4cout << "j= " << j
326 << " e(MeV)= " << e/MeV
327 << " dedx(Mev/cm)= " << dedx*cm/MeV
328 << " dedx(Mev.cm2/g)= "
329 << dedx/((MeV*mat->GetDensity())/(g/cm2))
330 << G4endl;
331 }
332 aVector->PutValue(j,dedx);
333 }
334 if(splineFlag) { aVector->FillSecondDerivatives(); }
335 }
336 delete ioni;
337 delete brem;
338}
339
340//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
341
342void
343G4TablesForExtrapolator::ComputeMuonDEDX(const G4ParticleDefinition* part,
344 G4PhysicsTable* table)
345{
349 ioni->Initialise(part, cuts);
350 pair->Initialise(part, cuts);
351 brem->Initialise(part, cuts);
352 ioni->SetUseBaseMaterials(false);
353 pair->SetUseBaseMaterials(false);
354 brem->SetUseBaseMaterials(false);
355
356 mass = part->GetPDGMass();
357 charge2 = 1.0;
358 currentParticle = part;
359
361
362 if(0<verbose) {
363 G4cout << "G4TablesForExtrapolator::ComputeMuonDEDX for "
364 << part->GetParticleName()
365 << G4endl;
366 }
367
368 for(G4int i=0; i<nmat; ++i) {
369
370 const G4Material* mat = (*mtable)[i];
371 if(1<verbose) {
372 G4cout << "i= " << i << " mat= " << mat->GetName() << G4endl;
373 }
374 G4PhysicsVector* aVector = (*table)[i];
375 for(G4int j=0; j<=nbins; ++j) {
376
377 G4double e = aVector->Energy(j);
378 G4double dedx = ioni->ComputeDEDXPerVolume(mat,part,e,e) +
379 pair->ComputeDEDXPerVolume(mat,part,e,e) +
380 brem->ComputeDEDXPerVolume(mat,part,e,e);
381 aVector->PutValue(j,dedx);
382 if(1<verbose) {
383 G4cout << "j= " << j
384 << " e(MeV)= " << e/MeV
385 << " dedx(Mev/cm)= " << dedx*cm/MeV
386 << " dedx(Mev/(g/cm2)= "
387 << dedx/((MeV*mat->GetDensity())/(g/cm2))
388 << G4endl;
389 }
390 }
391 if(splineFlag) { aVector->FillSecondDerivatives(); }
392 }
393 delete ioni;
394}
395
396//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
397
398void
399G4TablesForExtrapolator::ComputeProtonDEDX(const G4ParticleDefinition* part,
400 G4PhysicsTable* table)
401{
403 ioni->Initialise(part, cuts);
404 ioni->SetUseBaseMaterials(false);
405
406 mass = part->GetPDGMass();
407 charge2 = 1.0;
408 currentParticle = part;
409
411
412 if(0<verbose) {
413 G4cout << "G4TablesForExtrapolator::ComputeProtonDEDX for "
414 << part->GetParticleName()
415 << G4endl;
416 }
417
418 for(G4int i=0; i<nmat; ++i) {
419
420 const G4Material* mat = (*mtable)[i];
421 if(1<verbose)
422 G4cout << "i= " << i << " mat= " << mat->GetName() << G4endl;
423 G4PhysicsVector* aVector = (*table)[i];
424 for(G4int j=0; j<=nbins; ++j) {
425
426 G4double e = aVector->Energy(j);
427 G4double dedx = ioni->ComputeDEDXPerVolume(mat,part,e,e);
428 aVector->PutValue(j,dedx);
429 if(1<verbose) {
430 G4cout << "j= " << j
431 << " e(MeV)= " << e/MeV
432 << " dedx(Mev/cm)= " << dedx*cm/MeV
433 << " dedx(Mev.cm2/g)= " << dedx/((mat->GetDensity())/(g/cm2))
434 << G4endl;
435 }
436 }
437 if(splineFlag) { aVector->FillSecondDerivatives(); }
438 }
439 delete ioni;
440}
441
442//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
443
444void
445G4TablesForExtrapolator::ComputeTrasportXS(const G4ParticleDefinition* part,
446 G4PhysicsTable* table)
447{
449 msc->SetPolarAngleLimit(CLHEP::pi);
450 msc->Initialise(part, cuts);
451 msc->SetUseBaseMaterials(false);
452
453 mass = part->GetPDGMass();
454 charge2 = 1.0;
455 currentParticle = part;
456
458
459 if(0<verbose) {
460 G4cout << "G4TablesForExtrapolator::ComputeTransportXS for "
461 << part->GetParticleName()
462 << G4endl;
463 }
464
465 for(G4int i=0; i<nmat; ++i) {
466
467 const G4Material* mat = (*mtable)[i];
468 msc->SetCurrentCouple(couples[i]);
469 if(1<verbose)
470 G4cout << "i= " << i << " mat= " << mat->GetName() << G4endl;
471 G4PhysicsVector* aVector = (*table)[i];
472 for(G4int j=0; j<=nbins; ++j) {
473
474 G4double e = aVector->Energy(j);
475 G4double xs = msc->CrossSectionPerVolume(mat,part,e);
476 aVector->PutValue(j,xs);
477 if(1<verbose) {
478 G4cout << "j= " << j << " e(MeV)= " << e/MeV
479 << " xs(1/mm)= " << xs*mm << G4endl;
480 }
481 }
482 if(splineFlag) { aVector->FillSecondDerivatives(); }
483 }
484 delete msc;
485}
486
487//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
488
std::vector< G4Material * > G4MaterialTable
@ 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:175
static size_t GetNumberOfMaterials()
Definition: G4Material.cc:684
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:677
const G4String & GetName() const
Definition: G4Material.hh:172
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
G4TablesForExtrapolator(G4int verb, G4int bins, G4double e1, G4double e2)
const G4PhysicsTable * GetPhysicsTable(ExtTableType type) const
void SetPolarAngleLimit(G4double)
Definition: G4VEmModel.hh:781
virtual G4double CrossSectionPerVolume(const G4Material *, const G4ParticleDefinition *, G4double kineticEnergy, G4double cutEnergy=0.0, G4double maxEnergy=DBL_MAX)
Definition: G4VEmModel.cc:181
void SetCurrentCouple(const G4MaterialCutsCouple *)
Definition: G4VEmModel.hh:468
void SetUseBaseMaterials(G4bool val)
Definition: G4VEmModel.hh:732
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
#define DBL_MAX
Definition: templates.hh:62