Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
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
 
const G4MaterialGetMaterial () const
 

Detailed Description

Definition at line 63 of file G4EmElementSelector.hh.

Constructor & Destructor Documentation

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

Definition at line 55 of file G4EmElementSelector.cc.

References G4Material::GetElementVector(), G4Material::GetNumberOfElements(), n, G4PhysicsVector::SetSpline(), and test::v.

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

Definition at line 87 of file G4EmElementSelector.cc.

88 {}

Member Function Documentation

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

Definition at line 148 of file G4EmElementSelector.cc.

References G4cout, G4endl, G4Material::GetName(), and G4ParticleDefinition::GetParticleName().

149 {
150  G4cout << "======== G4EmElementSelector for the " << model->GetName();
151  if(part) G4cout << " and " << part->GetParticleName();
152  G4cout << " for " << material->GetName() << " ========" << G4endl;
153  if(0 < nElmMinusOne) {
154  for(G4int i=0; i<nElmMinusOne; i++) {
155  G4cout << " " << (*theElementVector)[i]->GetName() << " : " << G4endl;
156  G4cout << *(xSections[i]) << G4endl;
157  }
158  }
159  G4cout << "Last Element in element vector "
160  << (*theElementVector)[nElmMinusOne]->GetName()
161  << G4endl;
162  G4cout << G4endl;
163 }
const G4String & GetName() const
Definition: G4Material.hh:176
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
const XML_Char XML_Content * model
#define G4endl
Definition: G4ios.hh:61
const G4Material * G4EmElementSelector::GetMaterial ( ) const
inline

Definition at line 121 of file G4EmElementSelector.hh.

122 {
123  return material;
124 }
void G4EmElementSelector::Initialise ( const G4ParticleDefinition part,
G4double  cut = 0.0 
)

Definition at line 92 of file G4EmElementSelector.cc.

References G4Material::GetVecNbOfAtomsPerVolume(), and test::x.

94 {
95  //G4cout << "G4EmElementSelector initialise for " << material->GetName()
96  // << 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  // << G4endl;
144 }
int G4int
Definition: G4Types.hh:78
const G4double * GetVecNbOfAtomsPerVolume() const
Definition: G4Material.hh:204
const XML_Char XML_Content * model
double G4double
Definition: G4Types.hh:76
const G4Element * G4EmElementSelector::SelectRandomAtom ( G4double  kineticEnergy) const
inline

Definition at line 106 of file G4EmElementSelector.hh.

References G4UniformRand, and test::x.

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:87
double G4double
Definition: G4Types.hh:76

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