Geant4  10.02.p03
G4EmElementSelector Class Reference

#include <G4EmElementSelector.hh>

Collaboration diagram for G4EmElementSelector:

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
 
const G4MaterialGetMaterial () const
 

Private Member Functions

G4EmElementSelectoroperator= (const G4EmElementSelector &right)
 
 G4EmElementSelector (const G4EmElementSelector &)
 

Private Attributes

G4VEmModelmodel
 
const G4Materialmaterial
 
const G4ElementVectortheElementVector
 
G4int nElmMinusOne
 
G4int nbins
 
G4double cutEnergy
 
G4double lowEnergy
 
G4double highEnergy
 
std::vector< G4PhysicsLogVector * > xSections
 

Detailed Description

Definition at line 63 of file G4EmElementSelector.hh.

Constructor & Destructor Documentation

◆ G4EmElementSelector() [1/2]

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

Definition at line 55 of file G4EmElementSelector.cc.

60  :
61  model(mod), material(mat), nbins(bins), cutEnergy(-1.0),
62  lowEnergy(emin), highEnergy(emax)
63 {
65  nElmMinusOne = n - 1;
67  if(nElmMinusOne > 0) {
68  xSections.reserve(n);
70  xSections.push_back(v0);
71  v0->SetSpline(false);
72  for(G4int i=1; i<n; ++i) {
74  xSections.push_back(v);
75  }
76  }
77  /*
78  G4cout << "G4EmElementSelector for " << mat->GetName() << " n= " << n
79  << " nbins= " << nbins << " Emin= " << lowEnergy
80  << " Emax= " << highEnergy << G4endl;
81  */
82 }
const G4Material * material
int G4int
Definition: G4Types.hh:78
void SetSpline(G4bool)
Char_t n[5]
const G4ElementVector * theElementVector
static const G4double emax
size_t GetNumberOfElements() const
Definition: G4Material.hh:186
const G4ElementVector * GetElementVector() const
Definition: G4Material.hh:190
std::vector< G4PhysicsLogVector * > xSections
Here is the call graph for this function:

◆ ~G4EmElementSelector()

G4EmElementSelector::~G4EmElementSelector ( )

Definition at line 86 of file G4EmElementSelector.cc.

87 {
88  if(nElmMinusOne > 0) {
89  for(G4int i=0; i<=nElmMinusOne; ++i) { delete xSections[i]; }
90  }
91 }
int G4int
Definition: G4Types.hh:78
std::vector< G4PhysicsLogVector * > xSections

◆ G4EmElementSelector() [2/2]

G4EmElementSelector::G4EmElementSelector ( const G4EmElementSelector )
private

Member Function Documentation

◆ Dump()

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

Definition at line 152 of file G4EmElementSelector.cc.

153 {
154  G4cout << "======== G4EmElementSelector for the " << model->GetName();
155  if(part) G4cout << " and " << part->GetParticleName();
156  G4cout << " for " << material->GetName() << " ========" << G4endl;
157  if(0 < nElmMinusOne) {
158  for(G4int i=0; i<nElmMinusOne; i++) {
159  G4cout << " " << (*theElementVector)[i]->GetName() << " : " << G4endl;
160  G4cout << *(xSections[i]) << G4endl;
161  }
162  }
163  G4cout << "Last Element in element vector "
164  << (*theElementVector)[nElmMinusOne]->GetName()
165  << G4endl;
166  G4cout << G4endl;
167 }
const G4String & GetName() const
Definition: G4VEmModel.hh:795
const G4Material * material
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
TString part[npart]
#define G4endl
Definition: G4ios.hh:61
const G4String & GetName() const
Definition: G4Material.hh:178
std::vector< G4PhysicsLogVector * > xSections
Here is the call graph for this function:

◆ GetMaterial()

const G4Material * G4EmElementSelector::GetMaterial ( ) const
inline

Definition at line 121 of file G4EmElementSelector.hh.

122 {
123  return material;
124 }
const G4Material * material

◆ Initialise()

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

Definition at line 95 of file G4EmElementSelector.cc.

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

◆ operator=()

G4EmElementSelector& G4EmElementSelector::operator= ( const G4EmElementSelector right)
private

◆ SelectRandomAtom()

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

Definition at line 106 of file G4EmElementSelector.hh.

107 {
108  const G4Element* element = (*theElementVector)[nElmMinusOne];
109  if (nElmMinusOne > 0) {
111  for(G4int i=0; i<nElmMinusOne; ++i) {
112  if (x <= (xSections[i])->Value(e)) {
113  element = (*theElementVector)[i];
114  break;
115  }
116  }
117  }
118  return element;
119 }
int G4int
Definition: G4Types.hh:78
#define G4UniformRand()
Definition: Randomize.hh:97
double G4double
Definition: G4Types.hh:76
std::vector< G4PhysicsLogVector * > xSections

Member Data Documentation

◆ cutEnergy

G4double G4EmElementSelector::cutEnergy
private

Definition at line 95 of file G4EmElementSelector.hh.

◆ highEnergy

G4double G4EmElementSelector::highEnergy
private

Definition at line 97 of file G4EmElementSelector.hh.

◆ lowEnergy

G4double G4EmElementSelector::lowEnergy
private

Definition at line 96 of file G4EmElementSelector.hh.

◆ material

const G4Material* G4EmElementSelector::material
private

Definition at line 89 of file G4EmElementSelector.hh.

◆ model

G4VEmModel* G4EmElementSelector::model
private

Definition at line 88 of file G4EmElementSelector.hh.

◆ nbins

G4int G4EmElementSelector::nbins
private

Definition at line 93 of file G4EmElementSelector.hh.

◆ nElmMinusOne

G4int G4EmElementSelector::nElmMinusOne
private

Definition at line 92 of file G4EmElementSelector.hh.

◆ theElementVector

const G4ElementVector* G4EmElementSelector::theElementVector
private

Definition at line 90 of file G4EmElementSelector.hh.

◆ xSections

std::vector<G4PhysicsLogVector*> G4EmElementSelector::xSections
private

Definition at line 99 of file G4EmElementSelector.hh.


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