Import Geant4 11.0.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2021-06-25 16:12:29 +02:00
parent c968e26a39
commit 6399a014b6
4200 changed files with 207479 additions and 237366 deletions
@@ -74,18 +74,19 @@ public:
void Dump(const G4ParticleDefinition* p = nullptr);
const G4Element* SelectRandomAtom(const G4double kineticEnergy,
const G4double logEKin) const;
inline const G4Element* SelectRandomAtom(G4double kineticEnergy) const;
inline const G4Element* SelectRandomAtom(const G4double kineticEnergy,
const G4double logEKin) const;
inline const G4Material* GetMaterial() const;
private:
// hide assignment operator
G4EmElementSelector & operator=(const G4EmElementSelector &right) = delete;
G4EmElementSelector(const G4EmElementSelector&) = delete;
private:
G4VEmModel* model;
const G4Material* material;
const G4ElementVector* theElementVector;
@@ -120,41 +121,6 @@ inline const G4Element* G4EmElementSelector::SelectRandomAtom(G4double e) const
return element;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
inline const G4Element*
G4EmElementSelector::SelectRandomAtom(const G4double e,const G4double loge)const
{
const G4Element* element = (*theElementVector)[nElmMinusOne];
if (nElmMinusOne > 0) {
// 1. Determine energy index (only once)
const size_t nBins = (xSections[0])->GetVectorLength();
// handle cases below/above the enrgy grid (by ekin, idx that gives a=0/1)
// ekin = x[0] if e<=x[0] and idx will be 0 ^ a=0 => so y=y0
// ekin = x[N-1] if e>=x[N-1] and idx will be N-2 ^ a=1 => so y=y_{N-1}
const G4double ekin = std::max((xSections[0])->Energy(0),
std::min((xSections[0])->Energy(nBins-1),e));
// compute the lower index of the bin (idx \in [0,N-2] will be guaranted)
const size_t idx = (xSections[0])->ComputeLogVectorBin(loge);
// 2. Do the linear interp.(robust for corner cases through ekin, idx and a)
const G4double x1 = (xSections[0])->Energy(idx);
const G4double x2 = (xSections[0])->Energy(idx+1);
// note: all corner cases of the previous methods are covered and eventually
// gives a=0/1 that results in y=y0\y_{N-1} if e<=x[0]/e>=x[N-1] or
// y=y_i/y_{i+1} if e<x[i]/e>=x[i+1] due to small numerical errors
const G4double a = std::max(0., std::min(1., (ekin - x1)/(x2 - x1)));
const G4double urnd = G4UniformRand();
for (G4int i = 0; i < nElmMinusOne; ++i) {
const G4double y1 = (*xSections[i])[idx];
const G4double y2 = (*xSections[i])[idx+1];
if (urnd <= y1 + a*(y2-y1)) {
element = (*theElementVector)[i];
break;
}
}
}
return element;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
inline const G4Material* G4EmElementSelector::GetMaterial() const