Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4EmElementSelector Class Reference

#include <G4EmElementSelector.hh>

Public Member Functions

 G4EmElementSelector (G4VEmModel *, const G4Material *, G4int bins, G4double emin, G4double emax, G4bool spline=true)
 
 ~G4EmElementSelector ()
 
void Initialise (const G4ParticleDefinition *, G4double cut=0.0)
 
void Dump (const G4ParticleDefinition *p=0)
 
const G4ElementSelectRandomAtom (G4double kineticEnergy)
 
const G4MaterialGetMaterial () const
 

Detailed Description

Definition at line 63 of file G4EmElementSelector.hh.

Constructor & Destructor Documentation

◆ G4EmElementSelector()

G4EmElementSelector::G4EmElementSelector ( G4VEmModel mod,
const G4Material mat,
G4int  bins,
G4double  emin,
G4double  emax,
G4bool  spline = true 
)

Definition at line 54 of file G4EmElementSelector.cc.

59 :
60 model(mod), material(mat), nbins(bins), cutEnergy(-1.0),
61 lowEnergy(emin), highEnergy(emax)
62{
63 G4int n = material->GetNumberOfElements();
64 nElmMinusOne = n - 1;
65 theElementVector = material->GetElementVector();
66 element = (*theElementVector)[0];
67 if(nElmMinusOne > 0) {
68 xSections.reserve(n);
69 G4PhysicsLogVector* v0 = new G4PhysicsLogVector(lowEnergy,highEnergy,nbins);
70 xSections.push_back(v0);
71 v0->SetSpline(spline);
72 for(G4int i=1; i<n; ++i) {
74 xSections.push_back(v);
75 }
76 }
77 //G4cout << "G4EmElementSelector for " << mat->GetName() << " n= " << n << G4endl;
78}
int G4int
Definition: G4Types.hh:66
const G4ElementVector * GetElementVector() const
Definition: G4Material.hh:189
size_t GetNumberOfElements() const
Definition: G4Material.hh:185
void SetSpline(G4bool)

◆ ~G4EmElementSelector()

G4EmElementSelector::~G4EmElementSelector ( )

Definition at line 82 of file G4EmElementSelector.cc.

83{
84 if(nElmMinusOne > 0) {
85 for(G4int i=0; i<=nElmMinusOne; ++i) {
86 delete xSections[i];
87 }
88 }
89}

Member Function Documentation

◆ Dump()

void G4EmElementSelector::Dump ( const G4ParticleDefinition p = 0)

Definition at line 147 of file G4EmElementSelector.cc.

148{
149 G4cout << "======== G4EmElementSelector for the " << model->GetName();
150 if(part) G4cout << " and " << part->GetParticleName();
151 G4cout << " for " << material->GetName() << " ========" << G4endl;
152 if(0 < nElmMinusOne) {
153 for(G4int i=0; i<nElmMinusOne; i++) {
154 G4cout << " " << (*theElementVector)[i]->GetName() << " : " << G4endl;
155 G4cout << *(xSections[i]) << G4endl;
156 }
157 }
158 G4cout << "Last Element in element vector "
159 << (*theElementVector)[nElmMinusOne]->GetName()
160 << G4endl;
161 G4cout << G4endl;
162}
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
const G4String & GetName() const
Definition: G4Material.hh:177
const G4String & GetName() const
Definition: G4VEmModel.hh:655

◆ GetMaterial()

const G4Material * G4EmElementSelector::GetMaterial ( ) const
inline

Definition at line 122 of file G4EmElementSelector.hh.

123{
124 return material;
125}

◆ Initialise()

void G4EmElementSelector::Initialise ( const G4ParticleDefinition part,
G4double  cut = 0.0 
)

Definition at line 93 of file G4EmElementSelector.cc.

95{
96 //G4cout << "G4EmElementSelector initialise for " << material->GetName() << G4endl;
97 if(0 == nElmMinusOne || cut == cutEnergy) { return; }
98
99 cutEnergy = cut;
100 //G4cout << "cut(keV)= " << cut/keV << G4endl;
101 G4double cross;
102
103 const G4double* theAtomNumDensityVector = material->GetVecNbOfAtomsPerVolume();
104
105 // loop over bins
106 for(G4int j=0; j<=nbins; ++j) {
107 G4double e = (xSections[0])->Energy(j);
108 model->SetupForMaterial(part, material, e);
109 cross = 0.0;
110 //G4cout << "j= " << j << " e(MeV)= " << e/MeV << G4endl;
111 for (G4int i=0; i<=nElmMinusOne; ++i) {
112 cross += theAtomNumDensityVector[i]*
113 model->ComputeCrossSectionPerAtom(part, (*theElementVector)[i], e,
114 cutEnergy, e);
115 xSections[i]->PutValue(j, cross);
116 }
117 }
118
119 // xSections start from null, so use probabilities from the next bin
120 if(0.0 == (*xSections[nElmMinusOne])[0]) {
121 for (G4int i=0; i<=nElmMinusOne; ++i) {
122 xSections[i]->PutValue(0, (*xSections[i])[1]);
123 }
124 }
125 // xSections ends with null, so use probabilities from the previous bin
126 if(0.0 == (*xSections[nElmMinusOne])[nbins]) {
127 for (G4int i=0; i<=nElmMinusOne; ++i) {
128 xSections[i]->PutValue(nbins, (*xSections[i])[nbins-1]);
129 }
130 }
131 // perform normalization
132 for(G4int j=0; j<=nbins; ++j) {
133 cross = (*xSections[nElmMinusOne])[j];
134 // only for positive X-section
135 if(cross > 0.0) {
136 for (G4int i=0; i<nElmMinusOne; ++i) {
137 G4double x = (*xSections[i])[j]/cross;
138 xSections[i]->PutValue(j, x);
139 }
140 }
141 }
142 //G4cout << "======== G4EmElementSelector for the " << model->GetName();
143}
double G4double
Definition: G4Types.hh:64
const G4double * GetVecNbOfAtomsPerVolume() const
Definition: G4Material.hh:205
virtual G4double ComputeCrossSectionPerAtom(const G4ParticleDefinition *, G4double kinEnergy, G4double Z, G4double A=0., G4double cutEnergy=0.0, G4double maxEnergy=DBL_MAX)
Definition: G4VEmModel.cc:240
virtual void SetupForMaterial(const G4ParticleDefinition *, const G4Material *, G4double kineticEnergy)
Definition: G4VEmModel.cc:311

◆ SelectRandomAtom()

const G4Element * G4EmElementSelector::SelectRandomAtom ( G4double  kineticEnergy)
inline

Definition at line 107 of file G4EmElementSelector.hh.

108{
109 if (nElmMinusOne > 0) {
111 element = (*theElementVector)[nElmMinusOne];
112 for(G4int i=0; i<nElmMinusOne; ++i) {
113 if (x <= (xSections[i])->Value(e)) {
114 element = (*theElementVector)[i];
115 break;
116 }
117 }
118 }
119 return element;
120}
#define G4UniformRand()
Definition: Randomize.hh:53

The documentation for this class was generated from the following files: