48#ifndef G4EmElementSelector_h
49#define G4EmElementSelector_h 1
100 std::vector<G4PhysicsLogVector*> xSections;
109 const G4Element* element = (*theElementVector)[nElmMinusOne];
110 if (nElmMinusOne > 0) {
113 for(
G4int i=0; i<nElmMinusOne; ++i) {
114 if (x <= (xSections[i])->Value(e, idx)) {
115 element = (*theElementVector)[i];
127 const G4Element* element = (*theElementVector)[nElmMinusOne];
128 if (nElmMinusOne > 0) {
130 const size_t nBins = (xSections[0])->GetVectorLength();
134 const G4double ekin = std::max((xSections[0])->Energy(0),
135 std::min((xSections[0])->Energy(nBins-1),e));
137 const size_t idx = (xSections[0])->ComputeLogVectorBin(loge);
139 const G4double x1 = (xSections[0])->Energy(idx);
140 const G4double x2 = (xSections[0])->Energy(idx+1);
144 const G4double a = std::max(0., std::min(1., (ekin - x1)/(x2 - x1)));
146 for (
G4int i = 0; i < nElmMinusOne; ++i) {
147 const G4double y1 = (*xSections[i])[idx];
148 const G4double y2 = (*xSections[i])[idx+1];
149 if (urnd <= y1 + a*(y2-y1)) {
150 element = (*theElementVector)[i];
std::vector< G4Element * > G4ElementVector
void Initialise(const G4ParticleDefinition *, G4double cut=0.0)
void Dump(const G4ParticleDefinition *p=nullptr)
const G4Element * SelectRandomAtom(G4double kineticEnergy) const
const G4Material * GetMaterial() const