Import Geant4 11.4.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2025-06-26 09:17:29 +02:00
parent 20a218bbe1
commit a499fb82e9
1941 changed files with 203285 additions and 95593 deletions
@@ -39,6 +39,7 @@
#include "G4FluoData.hh"
#include "G4AugerData.hh"
#include "G4AutoLock.hh"
namespace { G4Mutex AtomicTransitionManagerMutex = G4MUTEX_INITIALIZER; }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -48,7 +49,8 @@ G4AtomicTransitionManager* G4AtomicTransitionManager::instance = nullptr;
G4AtomicTransitionManager* G4AtomicTransitionManager::Instance()
{
if (instance == nullptr) {
instance = new G4AtomicTransitionManager();
static G4AtomicTransitionManager man;
instance = &man;
}
return instance;
}
@@ -65,29 +67,20 @@ G4AtomicTransitionManager::~G4AtomicTransitionManager()
{
delete augerData;
for (auto& pos : shellTable){
std::vector<G4AtomicShell*>vec = pos.second;
std::size_t vecSize = vec.size();
for (std::size_t i=0; i< vecSize; ++i){
G4AtomicShell* shell = vec[i];
delete shell;
}
for (auto const & pos : shellTable) {
std::vector<G4AtomicShell*> vec = pos.second;
for (auto const & p : vec) { delete p; }
}
for (auto& ppos : transitionTable)
{
std::vector<G4FluoTransition*>vec = ppos.second;
std::size_t vecSize=vec.size();
for (std::size_t i=0; i< vecSize; ++i){
G4FluoTransition* transition = vec[i];
delete transition;
}
}
for (auto const & ppos : transitionTable) {
std::vector<G4FluoTransition*> vec = ppos.second;
for (auto const & p : vec) { delete p; }
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4AtomicShell*
G4AtomicTransitionManager::Shell(G4int Z, size_t shellIndex) const
G4AtomicTransitionManager::Shell(G4int Z, std::size_t shellIndex) const
{
auto pos = shellTable.find(Z);
@@ -98,7 +91,7 @@ G4AtomicTransitionManager::Shell(G4int Z, size_t shellIndex) const
else
{
size_t lastShell = v.size();
std::size_t lastShell = v.size();
G4ExceptionDescription ed;
ed << "No de-excitation for Z= " << Z
<< " shellIndex= " << shellIndex
@@ -118,7 +111,7 @@ G4AtomicTransitionManager::Shell(G4int Z, size_t shellIndex) const
G4Exception("G4AtomicTransitionManager::Shell()","de0001",
FatalException,ed,"");
}
return 0;
return nullptr;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -127,7 +120,7 @@ G4AtomicTransitionManager::Shell(G4int Z, size_t shellIndex) const
// the vacancy is, the radiative transition that can happen (originating
// shell, energy, probability)
const G4FluoTransition*
G4AtomicTransitionManager::ReachableShell(G4int Z,size_t shellIndex) const
G4AtomicTransitionManager::ReachableShell(G4int Z, std::size_t shellIndex) const
{
auto pos = transitionTable.find(Z);
if (pos!= transitionTable.end())
@@ -215,7 +208,7 @@ G4int G4AtomicTransitionManager::NumberOfReachableAugerShells(G4int Z)const
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4AtomicTransitionManager::TotalRadiativeTransitionProbability(
G4int Z, size_t shellIndex) const
G4int Z, std::size_t shellIndex) const
{
auto pos = transitionTable.find(Z);
G4double totalRadTransProb = 0.0;
@@ -229,7 +222,7 @@ G4double G4AtomicTransitionManager::TotalRadiativeTransitionProbability(
G4FluoTransition* transition = v[shellIndex];
G4DataVector transProb = transition->TransitionProbabilities();
for (size_t j=0; j<transProb.size(); ++j)
for (std::size_t j=0; j<transProb.size(); ++j)
{
totalRadTransProb += transProb[j];
}
@@ -258,7 +251,7 @@ G4double G4AtomicTransitionManager::TotalRadiativeTransitionProbability(
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4AtomicTransitionManager::TotalNonRadiativeTransitionProbability(
G4int Z, size_t shellIndex) const
G4int Z, std::size_t shellIndex) const
{
G4double prob = 1.0 - TotalRadiativeTransitionProbability(Z, shellIndex);
if(prob > 1.0 || prob < 0.0) {
@@ -160,7 +160,7 @@ G4double G4FluoData::StartShellEnergy(G4int initIndex, G4int vacancyIndex) const
if (pos != energyMap.end())
{
G4DataVector dataSet = *((*pos).second);
G4int nData = (G4int)dataSet.size();
if (initIndex >= 0 && initIndex < nData)
{
@@ -189,7 +189,7 @@ G4double G4FluoData::StartShellProb(G4int initIndex, G4int vacancyIndex) const
if (pos != probabilityMap.end())
{
G4DataVector dataSet = *((*pos).second);
G4int nData = (G4int)dataSet.size();
if (initIndex >= 0 && initIndex < nData)
{
@@ -46,7 +46,6 @@
#include "G4SystemOfUnits.hh"
#include "G4VAtomDeexcitation.hh"
#include "G4EmParameters.hh"
#include <thread>
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -69,7 +68,8 @@ namespace
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4LivermorePhotoElectricModel::G4LivermorePhotoElectricModel(const G4String& nam) : G4VEmModel(nam)
G4LivermorePhotoElectricModel::G4LivermorePhotoElectricModel(const G4String& nam)
: G4VEmModel(nam)
{
verboseLevel = 0;
// Verbosity scale:
@@ -95,6 +95,21 @@ G4LivermorePhotoElectricModel::G4LivermorePhotoElectricModel(const G4String& nam
// For water
fSandiaCof.resize(4, 0.0);
FindDirectoryPath();
if (fCrossSection == nullptr) {
fCrossSection = new G4ElementData(ZMAXPE);
fCrossSection->SetName("PhotoEffXS");
fCrossSectionLE = new G4ElementData(ZMAXPE);
fCrossSectionLE->SetName("PhotoEffLowXS");
for (G4int i = 0; i < ZMAXPE; ++i) {
fParamHigh[i] = nullptr;
fParamLow[i] = nullptr;
fNShells[i] = 0;
fNShellsUsed[i] = 0;
}
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -103,14 +118,10 @@ G4LivermorePhotoElectricModel::~G4LivermorePhotoElectricModel()
{
if (isInitializer) {
for (G4int i = 0; i < ZMAXPE; ++i) {
if (fParamHigh[i]) {
delete fParamHigh[i];
fParamHigh[i] = nullptr;
}
if (fParamLow[i]) {
delete fParamLow[i];
fParamLow[i] = nullptr;
}
delete fParamHigh[i];
fParamHigh[i] = nullptr;
delete fParamLow[i];
fParamLow[i] = nullptr;
}
}
}
@@ -129,7 +140,6 @@ void G4LivermorePhotoElectricModel::Initialise(const G4ParticleDefinition*,
if (isInitializer) {
G4AutoLock l(&livPhotoeffMutex);
FindDirectoryPath();
if (fWater == nullptr) {
fWater = G4Material::GetMaterial("G4_WATER", false);
if (fWater == nullptr) {
@@ -140,13 +150,6 @@ void G4LivermorePhotoElectricModel::Initialise(const G4ParticleDefinition*,
}
}
if (fCrossSection == nullptr) {
fCrossSection = new G4ElementData(ZMAXPE);
fCrossSection->SetName("PhotoEffXS");
fCrossSectionLE = new G4ElementData(ZMAXPE);
fCrossSectionLE->SetName("PhotoEffLowXS");
}
const G4ElementTable* elemTable = G4Element::GetElementTable();
std::size_t numElems = (*elemTable).size();
for (std::size_t ie = 0; ie < numElems; ++ie) {
@@ -188,7 +191,8 @@ G4LivermorePhotoElectricModel::CrossSectionPerVolume(const G4Material* material,
G4double, G4double)
{
fCurrSection = 0.0;
if (fWater && (material == fWater || material->GetBaseMaterial() == fWater)) {
if (nullptr != fWater &&
(material == fWater || material->GetBaseMaterial() == fWater)) {
if (energy <= fWaterEnergyLimit) {
fWater->GetSandiaTable()->GetSandiaCofWater(energy, fSandiaCof);
@@ -475,7 +479,7 @@ void G4LivermorePhotoElectricModel::SampleSecondaries(std::vector<G4DynamicParti
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
const G4String& G4LivermorePhotoElectricModel::FindDirectoryPath()
void G4LivermorePhotoElectricModel::FindDirectoryPath()
{
// no check in this method - environment variable is check by utility
if (fDataDirectory.empty()) {
@@ -489,7 +493,6 @@ const G4String& G4LivermorePhotoElectricModel::FindDirectoryPath()
}
fDataDirectory = ost.str();
}
return fDataDirectory;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -512,13 +515,13 @@ void G4LivermorePhotoElectricModel::ReadData(G4int Z)
// spline for photoeffect total x-section above K-shell when using EPDL97
// but below the parameterized ones
G4bool spline = (G4EmParameters::Instance()->LivermoreDataDir() == "livermore");
G4int number = G4EmParameters::Instance()->NumberForFreeVector();
auto pv = new G4PhysicsFreeVector(spline);
auto param = G4EmParameters::Instance();
G4bool spline = (param->LivermoreDataDir() == "livermore");
G4int number = param->NumberForFreeVector();
// fDataDirectory will be defined after these lines
std::ostringstream ost;
ost << FindDirectoryPath() << "pe-cs-" << Z << ".dat";
ost << fDataDirectory << "pe-cs-" << Z << ".dat";
std::ifstream fin(ost.str().c_str());
if (!fin.is_open()) {
G4ExceptionDescription ed;
@@ -532,6 +535,7 @@ void G4LivermorePhotoElectricModel::ReadData(G4int Z)
G4cout << "File " << ost.str().c_str() << " is opened by G4LivermorePhotoElectricModel"
<< G4endl;
}
auto pv = new G4PhysicsFreeVector(spline);
pv->Retrieve(fin, true);
pv->ScaleVector(MeV, barn);
pv->FillSecondDerivatives();
@@ -540,7 +544,6 @@ void G4LivermorePhotoElectricModel::ReadData(G4int Z)
fin.close();
// read high-energy fit parameters
fParamHigh[Z] = new std::vector<G4double>;
G4int n1 = 0;
G4int n2 = 0;
G4double x;
@@ -581,6 +584,7 @@ void G4LivermorePhotoElectricModel::ReadData(G4int Z)
}
fNShells[Z] = n1;
fParamHigh[Z] = new std::vector<G4double>;
fParamHigh[Z]->reserve(7 * n1 + 1);
fParamHigh[Z]->push_back(x * MeV);
for (G4int i = 0; i < n1; ++i) {
@@ -598,7 +602,6 @@ void G4LivermorePhotoElectricModel::ReadData(G4int Z)
fin1.close();
// read low-energy fit parameters
fParamLow[Z] = new std::vector<G4double>;
G4int n1_low = 0;
G4int n2_low = 0;
G4double x_low;
@@ -639,6 +642,7 @@ void G4LivermorePhotoElectricModel::ReadData(G4int Z)
}
fNShells[Z] = n1_low;
fParamLow[Z] = new std::vector<G4double>;
fParamLow[Z]->reserve(7 * n1_low + 1);
fParamLow[Z]->push_back(x_low * MeV);
for (G4int i = 0; i < n1_low; ++i) {
@@ -706,6 +710,7 @@ void G4LivermorePhotoElectricModel::ReadData(G4int Z)
<< G4endl;
G4Exception("G4LivermorePhotoElectricModel::ReadData()", "em0003", FatalException, ed,
"G4LEDATA version should be G4EMLOW8.0 or later.");
delete pv1;
return;
}
if (verboseLevel > 3) {
@@ -744,20 +749,6 @@ G4double G4LivermorePhotoElectricModel::GetBindingEnergy(G4int Z, G4int shell)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void
G4LivermorePhotoElectricModel::InitialiseForElement(const G4ParticleDefinition*, G4int Z)
{
if (fCrossSection == nullptr) {
fCrossSection = new G4ElementData(ZMAXPE);
fCrossSection->SetName("PhotoEffXS");
fCrossSectionLE = new G4ElementData(ZMAXPE);
fCrossSectionLE->SetName("PhotoEffLowXS");
}
ReadData(Z);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4LivermorePhotoElectricModel::InitialiseOnFly(G4int Z)
{
if (fCrossSection->GetElementData(Z) == nullptr && Z > 0 && Z < ZMAXPE) {
@@ -605,7 +605,7 @@ G4double G4PenelopeBremsstrahlungFS::SampleGammaEnergy(G4double energy,const G4M
const G4double cut) const
{
std::pair<const G4Material*,G4double> theKey = std::make_pair(mat,cut);
if (!(fSamplingTable->count(theKey)) || !(fPBcut->count(theKey)) ||
if (!(fSamplingTable->count(theKey)) || !(fPBcut->count(theKey)) ||
!(fReducedXSTable->count(theKey)))
{
G4ExceptionDescription ed;
@@ -257,7 +257,7 @@ G4double G4PenelopeBremsstrahlungModel::CrossSectionPerVolume(const G4Material*
{
G4cout << "G4PenelopeBremsstrahlungModel " << G4endl;
G4cout << "Mean free path for gamma emission > " << cutEnergy/keV << " keV at " <<
energy/keV << " keV = " <<
energy/keV << " keV = " <<
(crossPerVolume? (1./crossPerVolume)/mm : DBL_MAX) << " mm" << G4endl;
}
@@ -236,7 +236,7 @@ G4double G4PenelopeComptonModel::CrossSectionPerVolume(const G4Material* materia
if (fVerboseLevel > 2)
G4cout << "Compton mean free path at " << energy/keV << " keV for material " <<
material->GetName() << " = " <<
material->GetName() << " = " <<
(csvolume ? (1./csvolume)/mm : DBL_MAX) << " mm" << G4endl;
return csvolume;
}
@@ -323,12 +323,12 @@ G4double G4PenelopeIonisationModel::CrossSectionPerVolume(const G4Material* mate
{
G4cout << "G4PenelopeIonisationModel " << G4endl;
G4cout << "Mean free path for delta emission > " << cutEnergy/keV << " keV at " <<
energy/keV << " keV = " <<
energy/keV << " keV = " <<
(crossPerVolume ? (1./crossPerVolume)/mm : DBL_MAX) << " mm" << G4endl;
if (theXS)
totalCross = (theXS->GetTotalCrossSection(energy))*moleculeDensity;
G4cout << "Total free path for ionisation (no threshold) at " <<
energy/keV << " keV = " <<
energy/keV << " keV = " <<
(totalCross ? (1./totalCross)/mm : DBL_MAX) << " mm" << G4endl;
}
return crossPerVolume;
@@ -108,7 +108,7 @@ const std::vector<G4double>& G4ShellData::ShellVector(G4int Z) const
{
if (Z < zMin || Z > zMax)
G4Exception("G4ShellData::ShellVector()","de0001",JustWarning,"Z outside boundaries");
auto pos = occupancyPdfMap.find(Z);
auto pos = occupancyPdfMap.find(Z);
std::vector<G4double>* dataSet = (*pos).second;
return *dataSet;
}
@@ -200,12 +200,12 @@ void G4ShellData::PrintData() const
G4int id = (G4int) (*ids)[i];
G4double e = (*energies)[i] / keV;
G4cout << i << ") ";
if (occupancyData)
if (occupancyData)
{
G4cout << " Occupancy: ";
}
else
else
{
G4cout << " Shell id: ";
}
@@ -213,7 +213,7 @@ void G4ShellData::PrintData() const
<< e << " keV ";
if (occupancyData)
{
auto posOcc = occupancyPdfMap.find(Z);
auto posOcc = occupancyPdfMap.find(Z);
G4double prob = 0.;
if (posOcc != occupancyPdfMap.end())
{
@@ -241,7 +241,7 @@ G4double G4hIonEffChargeSquare::IonEffChargeSquare(
} else {
// v1 is ion velocity in vF unit
G4double v1{0.0}, v2{0.0};
G4double v1{0.01}, v2{0.0};
if (vF > 0.0) {
v1 = std::sqrt( reducedEnergy / (25.0 * keV) )/ vF;
v2 = 1.0/ (vF*vF);