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

#include <G4HadronXSDataTable.hh>

Public Member Functions

 G4HadElementSelector (G4DynamicParticle *, G4CrossSectionDataStore *, const G4Material *, G4int bins, G4double emin, G4double emax, G4bool spline)
 
 ~G4HadElementSelector ()
 
void Dump ()
 
const G4ElementSelectRandomAtom (G4double e) const
 

Detailed Description

Definition at line 58 of file G4HadronXSDataTable.hh.

Constructor & Destructor Documentation

◆ G4HadElementSelector()

G4HadElementSelector::G4HadElementSelector ( G4DynamicParticle dp,
G4CrossSectionDataStore xs,
const G4Material mat,
G4int  bins,
G4double  emin,
G4double  emax,
G4bool  spline 
)

Definition at line 51 of file G4HadronXSDataTable.cc.

56{
58 nElmMinusOne = n - 1;
59 theElementVector = mat->GetElementVector();
60 if(nElmMinusOne > 0) {
61 G4PhysicsVector* first = nullptr;
62 xSections.resize(n, first);
63 first = new G4PhysicsLogVector(emin,emax,bins);
64 first->SetSpline(spline);
65 xSections[0] = first;
66 for(G4int i=1; i<n; ++i) {
67 xSections[i] = new G4PhysicsVector(*first);
68 }
69 std::vector<double> temp;
70 temp.resize(n, 0.0);
71 for(G4int j=0; j<=bins; ++j) {
72 G4double cross = 0.0;
73 G4double e = first->Energy(j);
74 dp->SetKineticEnergy(e);
75 for(G4int i=0; i<n; ++i) {
76 cross += xs->GetCrossSection(dp, (*theElementVector)[i], mat);
77 temp[i] = cross;
78 }
79 G4double fact = (cross > 0.0) ? 1.0/cross : 0.0;
80 for(G4int i=0; i<n; ++i) {
81 G4double y = (i<n-1) ? temp[i]*fact : 1.0;
82 xSections[i]->PutValue(j, y);
83 }
84 }
85 }
86}
double G4double
Definition: G4Types.hh:83
int G4int
Definition: G4Types.hh:85
G4double GetCrossSection(const G4DynamicParticle *, const G4Material *)
void SetKineticEnergy(G4double aEnergy)
const G4ElementVector * GetElementVector() const
Definition: G4Material.hh:188
size_t GetNumberOfElements() const
Definition: G4Material.hh:184
G4double Energy(std::size_t index) const
void SetSpline(G4bool)

◆ ~G4HadElementSelector()

G4HadElementSelector::~G4HadElementSelector ( )

Definition at line 90 of file G4HadronXSDataTable.cc.

91{
92 if(nElmMinusOne > 0) {
93 for(G4int i=0; i<=nElmMinusOne; ++i) { delete xSections[i]; }
94 }
95}

Member Function Documentation

◆ Dump()

void G4HadElementSelector::Dump ( )

Definition at line 99 of file G4HadronXSDataTable.cc.

100{}

◆ SelectRandomAtom()

const G4Element * G4HadElementSelector::SelectRandomAtom ( G4double  e) const
inline

Definition at line 70 of file G4HadronXSDataTable.hh.

71 {
72 const G4Element* element = (*theElementVector)[nElmMinusOne];
73 if (nElmMinusOne > 0) {
75 for(G4int i=0; i<nElmMinusOne; ++i) {
76 if (x <= xSections[i]->Value(e)) {
77 element = (*theElementVector)[i];
78 break;
79 }
80 }
81 }
82 return element;
83 }
#define G4UniformRand()
Definition: Randomize.hh:52

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