60 model(mod), material(mat), nbins(bins), cutEnergy(-1.0),
61 lowEnergy(emin), highEnergy(emax)
66 if(nElmMinusOne > 0) {
69 xSections.push_back(v0);
70 for(
G4int i=1; i<n; ++i) {
72 xSections.push_back(v);
86 if(nElmMinusOne > 0) {
87 for(
G4int i=0; i<=nElmMinusOne; ++i) {
delete xSections[i]; }
98 if(0 == nElmMinusOne || cut == cutEnergy) {
return; }
104 const G4double* theAtomNumDensityVector =
108 for(
G4int j=0; j<=nbins; ++j) {
109 G4double e = (xSections[0])->Energy(j);
113 for (
G4int i=0; i<=nElmMinusOne; ++i) {
114 cross += theAtomNumDensityVector[i]*
117 xSections[i]->PutValue(j, cross);
121 if(0.0 == (*xSections[nElmMinusOne])[0]) {
122 for (
G4int i=0; i<=nElmMinusOne; ++i) {
123 xSections[i]->PutValue(0, (*xSections[i])[1]);
127 if(0.0 == (*xSections[nElmMinusOne])[nbins]) {
128 for (
G4int i=0; i<=nElmMinusOne; ++i) {
129 xSections[i]->PutValue(nbins, (*xSections[i])[nbins-1]);
133 for(
G4int j=0; j<=nbins; ++j) {
134 cross = (*xSections[nElmMinusOne])[j];
137 for (
G4int i=0; i<nElmMinusOne; ++i) {
138 G4double x = (*xSections[i])[j]/cross;
139 xSections[i]->PutValue(j, x);
159 const G4Element* element = (*theElementVector)[nElmMinusOne];
160 if (nElmMinusOne > 0) {
167 if(e <= (xSections[0])->Energy(0)) {
168 ekin = (xSections[0])->Energy(0);
169 }
else if(e < (xSections[0])->GetMaxEnergy()) {
170 idx = (xSections[0])->ComputeLogVectorBin(loge);
172 ekin = (xSections[0])->GetMaxEnergy();
173 idx = (xSections[0])->GetVectorLength() - 2;
176 const G4double x1 = (xSections[0])->Energy(idx);
177 const G4double a = (ekin - x1)/((xSections[0])->Energy(idx+1) - x1);
179 for (
G4int i = 0; i < nElmMinusOne; ++i) {
180 const G4double y1 = (*xSections[i])[idx];
181 if (urnd <= y1 + a*((*xSections[i])[idx+1] - y1)) {
182 element = (*theElementVector)[i];
194 G4cout <<
"======== G4EmElementSelector for the " << model->
GetName();
197 if(0 < nElmMinusOne) {
198 for(
G4int i=0; i<nElmMinusOne; i++) {
199 G4cout <<
" " << (*theElementVector)[i]->GetName() <<
" : " <<
G4endl;
203 G4cout <<
"Last Element in element vector "
204 << (*theElementVector)[nElmMinusOne]->GetName()
G4GLOB_DLL std::ostream G4cout
void Initialise(const G4ParticleDefinition *, G4double cut=0.0)
void Dump(const G4ParticleDefinition *p=nullptr)
G4EmElementSelector(G4VEmModel *, const G4Material *, G4int bins, G4double emin, G4double emax, G4bool spline=true)
const G4Element * SelectRandomAtom(const G4double kineticEnergy, const G4double logEKin) const
const G4ElementVector * GetElementVector() const
size_t GetNumberOfElements() const
const G4double * GetVecNbOfAtomsPerVolume() const
const G4String & GetName() const
const G4String & GetParticleName() const
virtual G4double ComputeCrossSectionPerAtom(const G4ParticleDefinition *, G4double kinEnergy, G4double Z, G4double A=0., G4double cutEnergy=0.0, G4double maxEnergy=DBL_MAX)
virtual void SetupForMaterial(const G4ParticleDefinition *, const G4Material *, G4double kineticEnergy)
const G4String & GetName() const