Import Geant4 11.2.2 source tree

This commit is contained in:
Gabriele Cosmo
2024-06-21 15:46:33 +02:00
parent dda54bbdcf
commit f7b23877ed
411 changed files with 22817 additions and 21317 deletions
@@ -64,6 +64,7 @@ G4CrossSectionHP::G4CrossSectionHP(const G4ParticleDefinition* p,
G4int zmin, G4int zmax)
: G4VCrossSectionDataSet(nameData),
fParticle(p),
fNeutron(G4Neutron::Neutron()),
fManagerHP(G4ParticleHPManager::GetInstance()),
emax(emaxHP),
emaxT(fManagerHP->GetMaxEnergyDoppler()),
@@ -161,30 +162,35 @@ G4double G4CrossSectionHP::IsoCrossSection(const G4double ekin,
} else {
// Doppler broading
G4double lambda = 1.0/(CLHEP::k_Boltzmann*T);
G4double e0 = CLHEP::k_Boltzmann*T;
G4double mass = fParticle->GetPDGMass();
G4double massTarget = G4NucleiProperties::GetNuclearMass(A, Z);
G4LorentzVector lv(0., 0., 0., mass + ekin);
// projectile
G4LorentzVector lv(0., 0., std::sqrt(ekin*(ekin + 2*mass)), mass + ekin);
// limits of integration
const G4double lim = 1.01;
const G4int nmin = 3;
G4int i;
G4int ii = 0;
const G4int nn = 20;
G4double xs2 = 0.0;
for (i=1; i<nn; ++i) {
G4double erand = G4RandGamma::shoot(2.0, lambda);
for (G4int i=0; i<nn; ++i) {
G4double erand = G4RandGamma::shoot(2.0, e0);
auto mom = G4RandomDirection()*std::sqrt(2*massTarget*erand);
fLV.set(mom.x(), mom.y(), mom.z(), mass + erand);
fLV.set(mom.x(), mom.y(), mom.z(), massTarget + erand);
fBoost = fLV.boostVector();
G4double e = lv.boost(fBoost).e() - mass;
fLV = lv.boost(fBoost);
if (fLV.pz() <= 0.0) { continue; }
++ii;
G4double e = fLV.e() - mass;
G4double y = pv->Value(e, index);
xs += y;
xs2 += y*y;
if (i >= nmin && i*xs2 <= lim*xs*xs) { break; }
if (ii >= nmin && ii*xs2 <= lim*xs*xs) { break; }
}
xs /= (G4double)std::min(i, nn-1);
if (ii > 0) { xs /= (G4double)(ii); }
}
#ifdef G4VERBOSE
if (verboseLevel > 1) {
@@ -317,8 +323,7 @@ void G4CrossSectionHP::DumpPhysicsTable(const G4ParticleDefinition&)
const G4ElementTable* table = G4Element::GetElementTable();
for ( auto const & elm : *table ) {
G4int Z = elm->GetZasInt();
if (Z >= minZ && Z <= maxZ &&
nullptr != fData->GetElementData(Z - minZ)) {
if (Z >= minZ && Z <= maxZ && nullptr != fData->GetElementData(Z - minZ)) {
G4cout << "---------------------------------------------------" << G4endl;
G4cout << elm->GetName() << G4endl;
std::size_t n = fData->GetNumberOfComponents(Z);
@@ -369,31 +374,36 @@ void G4CrossSectionHP::Initialise(const G4int Z)
G4bool noComp = true;
for (G4int A=amin[Z]; A<=amax[Z]; ++A) {
std::ostringstream ost;
ost << fDataDirectory << Z << "_";
if (6 == Z && 12 == A) {
ost << "nat_";
ost << fDataDirectory;
// first check special cases
if (6 == Z && 12 == A && fParticle == fNeutron) {
ost << Z << "_nat_" << elementName[Z];
} else if (18 == Z && 40 != A) {
continue;
} else if (27 == Z && 62 == A) {
ost << "62m1_";
ost << Z << "_62m1_" << elementName[Z];
} else if (47 == Z && 106 == A) {
ost << "106m1_";
ost << Z << "_106m1_" << elementName[Z];
} else if (48 == Z && 115 == A) {
ost << "115m1_";
ost << Z << "_115m1_" << elementName[Z];
} else if (52 == Z && 127 == A) {
ost << "127m1_";
ost << Z << "_127m1_" << elementName[Z];
} else if (52 == Z && 129 == A) {
ost << "129m1_";
ost << Z << "_129m1_" << elementName[Z];
} else if (52 == Z && 131 == A) {
ost << "131m1_";
ost << Z << "_131m1_" << elementName[Z];
} else if (61 == Z && 145 == A) {
ost << Z << "_147_" << elementName[Z];
} else if (67 == Z && 166 == A) {
ost << "166m1_";
ost << Z << "_166m1_" << elementName[Z];
} else if (73 == Z && 180 == A) {
ost << "180m1_";
ost << Z << "_180m1_" << elementName[Z];
} else if ((Z == 85 && A == 210) || (Z == 86 && A == 222) || (Z == 87 && A == 223)) {
ost << "84_209_" << elementName[84];
} else {
ost << A << "_";
// the main file name
ost << Z << "_" << A << "_" << elementName[Z];
}
ost << elementName[Z];
std::ifstream filein(ost.str().c_str());
//G4cout << "File: " << ost.str() << " " << G4endl;
std::istringstream theXSData(tnam, std::ios::in);
fManagerHP->GetDataStream(ost.str().c_str(), theXSData);
if (theXSData) {
@@ -408,11 +418,11 @@ void G4CrossSectionHP::Initialise(const G4int Z)
for (G4int i=0; i<n; ++i) {
theXSData >> x >> y;
x *= CLHEP::eV;
y *= CLHEP::barn;
y *= CLHEP::barn;
//G4cout << " e=" << x << " xs=" << y << G4endl;
v->PutValues((std::size_t)i, x, y);
}
v->EnableLogBinSearch(2);
v->EnableLogBinSearch(binSearch);
if (noComp) {
G4int nmax = amax[Z] - A + 1;
fData->InitialiseForComponent(Z - minZ, nmax);
@@ -112,14 +112,15 @@ G4bool G4ParticleHPChannel::Register(G4ParticleHPFinalState* theFS)
G4int Z = theElement->GetZasInt();
niso = (G4int)theElement->GetNumberOfIsotopes();
const std::size_t nsize = niso > 0 ? niso : 1;
delete[] theIsotopeWiseData;
theIsotopeWiseData = new G4ParticleHPIsoData[niso];
theIsotopeWiseData = new G4ParticleHPIsoData[nsize];
delete[] active;
active = new G4bool[niso];
active = new G4bool[nsize];
delete[] theFinalStates;
theFinalStates = new G4ParticleHPFinalState*[niso];
theFinalStates = new G4ParticleHPFinalState*[nsize];
delete theChannelData;
theChannelData = new G4ParticleHPVector;
for (G4int i = 0; i < niso; ++i) {
@@ -93,7 +93,8 @@ G4ParticleHPContAngularPar::G4ParticleHPContAngularPar(G4ParticleHPContAngularPa
theDiscreteEnergiesOwn = val.theDiscreteEnergiesOwn;
toBeCached v;
fCache.Put(v);
theAngular = new G4ParticleHPList[nEnergies];
const std::size_t esize = nEnergies > 0 ? nEnergies : 1;
theAngular = new G4ParticleHPList[esize];
for (G4int ie = 0; ie < nEnergies; ++ie) {
theAngular[ie].SetLabel(val.theAngular[ie].GetLabel());
for (G4int ip = 0; ip < nAngularParameters; ++ip) {
@@ -116,7 +117,8 @@ void G4ParticleHPContAngularPar::Init(std::istream& aDataFile, const G4ParticleD
aDataFile >> theEnergy >> nEnergies >> nDiscreteEnergies >> nAngularParameters;
theEnergy *= eV;
theAngular = new G4ParticleHPList[nEnergies];
const std::size_t esize = nEnergies > 0 ? nEnergies : 1;
theAngular = new G4ParticleHPList[esize];
G4double sEnergy;
for (G4int i = 0; i < nEnergies; ++i) {
aDataFile >> sEnergy;
@@ -840,7 +842,8 @@ void G4ParticleHPContAngularPar::BuildByInterpolation(G4double anEnergy,
nEnergies = nDiscreteEnergies + (G4int)theEnergiesTransformed.size();
// Create final array of angular parameters
auto theNewAngular = new G4ParticleHPList[nEnergies];
const std::size_t esize = nEnergies > 0 ? nEnergies : 1;
auto theNewAngular = new G4ParticleHPList[esize];
// Copy discrete energies and interpolated parameters to new array
@@ -54,7 +54,8 @@ G4ParticleHPContEnergyAngular::~G4ParticleHPContEnergyAngular()
void G4ParticleHPContEnergyAngular::Init(std::istream& aDataFile)
{
aDataFile >> theTargetCode >> theAngularRep >> theInterpolation >> nEnergy;
theAngular = new G4ParticleHPContAngularPar[nEnergy];
const std::size_t esize = nEnergy > 0 ? nEnergy : 1;
theAngular = new G4ParticleHPContAngularPar[esize];
theManager.Init(aDataFile);
for (G4int i = 0; i < nEnergy; ++i) {
theAngular[i].Init(aDataFile, theProjectile);
@@ -63,8 +63,9 @@ void G4ParticleHPDiscreteTwoBody::Init(std::istream& aDataFile)
{
aDataFile >> nEnergy;
theManager.Init(aDataFile);
theCoeff = new G4ParticleHPLegendreTable[nEnergy];
for (G4int i = 0; i < nEnergy; i++) {
const std::size_t tsize = nEnergy > 0 ? nEnergy : 1;
theCoeff = new G4ParticleHPLegendreTable[tsize];
for (std::size_t i = 0; i < tsize; ++i) {
G4double energy;
G4int aRep, nCoeff;
aDataFile >> energy >> aRep >> nCoeff;
@@ -60,7 +60,8 @@ void G4ParticleHPElementData::Init(G4Element* theElement,
{
auto nIso = (G4int)theElement->GetNumberOfIsotopes();
auto Z = theElement->GetZasInt();
theIsotopeWiseData = new G4ParticleHPIsoData[nIso];
const std::size_t dsize = nIso > 0 ? nIso : 1;
theIsotopeWiseData = new G4ParticleHPIsoData[dsize];
for (G4int i1 = 0; i1 < nIso; ++i1) {
G4int A = theElement->GetIsotope(i1)->GetN();
@@ -63,10 +63,9 @@ void G4ParticleHPEnAngCorrelation::Init(std::istream& aDataFile)
{
inCharge = true;
aDataFile >> targetMass >> frameFlag >> nProducts;
//G4cout << "G4ParticleHPEnAngCorrelation::Init " << theProjectile->GetParticleName()
// << " frameFlag=" << frameFlag << " N=" << nProducts << " Mass=" << targetMass << G4endl;
theProducts = new G4ParticleHPProduct[nProducts];
for (G4int i = 0; i < nProducts; ++i) {
const std::size_t psize = nProducts > 0 ? nProducts : 1;
theProducts = new G4ParticleHPProduct[psize];
for (std::size_t i = 0; i < psize; ++i) {
theProducts[i].Init(aDataFile, theProjectile);
}
}
@@ -91,9 +91,9 @@ G4double G4ParticleHPField::GetY(G4double e, G4int j)
void G4ParticleHPField::Dump()
{
G4cout << nEntries << G4endl;
for (G4int i = 0; i < nEntries; i++) {
for (G4int i = 0; i < nEntries; ++i) {
G4cout << theData[i].GetX() << " ";
for (G4int j = 0; j < theData[i].GetDepth(); j++) {
for (G4int j = 0; j < theData[i].GetDepth(); ++j) {
G4cout << theData[i].GetY(j) << " ";
}
G4cout << G4endl;
@@ -107,12 +107,11 @@ void G4ParticleHPField::Check(G4int i)
"Skipped some index numbers in G4ParticleHPField");
if (i == nPoints) {
nPoints += 50;
auto buff = new G4ParticleHPFieldPoint[nPoints];
// G4cout << "copying 1"<<G4endl;
for (G4int j = 0; j < nEntries; j++) {
const std::size_t fsize = nPoints > 0 ? nPoints : 1;
auto buff = new G4ParticleHPFieldPoint[fsize];
for (G4int j = 0; j < nEntries; ++j) {
buff[j] = theData[j];
}
// G4cout << "copying 2"<<G4endl;
delete[] theData;
theData = buff;
}
@@ -52,18 +52,20 @@ void G4ParticleHPLabAngularEnergy::Init(std::istream& aDataFile)
{
aDataFile >> nEnergies;
theManager.Init(aDataFile);
theEnergies = new G4double[nEnergies];
nCosTh = new G4int[nEnergies];
theData = new G4ParticleHPVector*[nEnergies];
theSecondManager = new G4InterpolationManager[nEnergies];
for (G4int i = 0; i < nEnergies; i++) {
const std::size_t esize = nEnergies > 0 ? nEnergies : 1;
theEnergies = new G4double[esize];
nCosTh = new G4int[esize];
theData = new G4ParticleHPVector*[esize];
theSecondManager = new G4InterpolationManager[esize];
for (G4int i = 0; i < nEnergies; ++i) {
aDataFile >> theEnergies[i];
theEnergies[i] *= eV;
aDataFile >> nCosTh[i];
theSecondManager[i].Init(aDataFile);
theData[i] = new G4ParticleHPVector[nCosTh[i]];
const std::size_t dsize = nCosTh[i] > 0 ? nCosTh[i] : 1;
theData[i] = new G4ParticleHPVector[dsize];
G4double label;
for (G4int ii = 0; ii < nCosTh[i]; ii++) {
for (std::size_t ii = 0; ii < dsize; ++ii) {
aDataFile >> label;
theData[i][ii].SetLabel(label);
theData[i][ii].Init(aDataFile, eV);
@@ -72,7 +72,7 @@ G4ParticleHPManager::G4ParticleHPManager()
// path may be defined by two environment variables
// it is not mandatory to access PHP data - path may be not defined
const char* ttp = G4FindDataDir("G4PARTICLEHPDATA");
G4String tendl = (nullptr == ttp) ? "" : G4String(ttp);
G4String tendl = (nullptr == ttp) ? G4String("") : G4String(ttp);
const char* ssp = G4FindDataDir("G4PROTONHPDATA");
fDataPath[1] = (nullptr == ssp) ? tendl + "/Proton" : G4String(ssp);
@@ -78,7 +78,7 @@ G4ParticleHPNames::G4ParticleHPNames(G4int maxOffSet) : theMaxOffSet(maxOffSet)
G4String G4ParticleHPNames::GetName(G4int i)
{
return (i > 0 && i < 100) ? theString[i] : "";
return (i > 0 && i < 100) ? theString[i] : G4String("");
}
G4String G4ParticleHPNames::itoa(G4int current)
@@ -61,11 +61,12 @@ G4bool G4ParticleHPPhotonDist::InitMean(std::istream& aDataFile)
if (repFlag == 1) {
// multiplicities
aDataFile >> nDiscrete;
disType = new G4int[nDiscrete];
energy = new G4double[nDiscrete];
// actualMult = new G4int[nDiscrete];
theYield = new G4ParticleHPVector[nDiscrete];
for (G4int i = 0; i < nDiscrete; ++i) {
const std::size_t msize = nDiscrete > 0 ? nDiscrete : 1;
disType = new G4int[msize];
energy = new G4double[msize];
// actualMult = new G4int[msize];
theYield = new G4ParticleHPVector[msize];
for (std::size_t i = 0; i < msize; ++i) {
aDataFile >> disType[i] >> energy[i];
energy[i] *= eV;
theYield[i].Init(aDataFile, eV);
@@ -77,11 +78,12 @@ G4bool G4ParticleHPPhotonDist::InitMean(std::istream& aDataFile)
theBaseEnergy *= eV;
aDataFile >> theInternalConversionFlag;
aDataFile >> nGammaEnergies;
theLevelEnergies = new G4double[nGammaEnergies];
theTransitionProbabilities = new G4double[nGammaEnergies];
const std::size_t esize = nGammaEnergies > 0 ? nGammaEnergies : 1;
theLevelEnergies = new G4double[esize];
theTransitionProbabilities = new G4double[esize];
if (theInternalConversionFlag == 2)
thePhotonTransitionFraction = new G4double[nGammaEnergies];
for (G4int ii = 0; ii < nGammaEnergies; ++ii) {
thePhotonTransitionFraction = new G4double[esize];
for (std::size_t ii = 0; ii < esize; ++ii) {
if (theInternalConversionFlag == 1) {
aDataFile >> theLevelEnergies[ii] >> theTransitionProbabilities[ii];
theLevelEnergies[ii] *= eV;
@@ -146,8 +148,9 @@ void G4ParticleHPPhotonDist::InitAngular(std::istream& aDataFile)
vct_pXS_par.push_back(hpv);
}
}
if (theGammas == nullptr) theGammas = new G4double[nDiscrete2];
if (theShells == nullptr) theShells = new G4double[nDiscrete2];
const std::size_t psize = nDiscrete2 > 0 ? nDiscrete2 : 1;
if (theGammas == nullptr) theGammas = new G4double[psize];
if (theShells == nullptr) theShells = new G4double[psize];
for (i = 0; i < nIso; ++i) // isotropic photons
{
@@ -155,15 +158,17 @@ void G4ParticleHPPhotonDist::InitAngular(std::istream& aDataFile)
theGammas[i] *= eV;
theShells[i] *= eV;
}
nNeu = new G4int[nDiscrete2 - nIso];
if (tabulationType == 1) theLegendre = new G4ParticleHPLegendreTable*[nDiscrete2 - nIso];
if (tabulationType == 2) theAngular = new G4ParticleHPAngularP*[nDiscrete2 - nIso];
const std::size_t tsize = nDiscrete2 - nIso > 0 ? nDiscrete2 - nIso : 1;
nNeu = new G4int[tsize];
if (tabulationType == 1) theLegendre = new G4ParticleHPLegendreTable*[tsize];
if (tabulationType == 2) theAngular = new G4ParticleHPAngularP*[tsize];
for (i = nIso; i < nDiscrete2; ++i) {
if (tabulationType == 1) {
aDataFile >> theGammas[i] >> theShells[i] >> nNeu[i - nIso];
theGammas[i] *= eV;
theShells[i] *= eV;
theLegendre[i - nIso] = new G4ParticleHPLegendreTable[nNeu[i - nIso]];
const std::size_t lsize = nNeu[i - nIso] > 0 ? nNeu[i - nIso] : 1;
theLegendre[i - nIso] = new G4ParticleHPLegendreTable[lsize];
theLegendreManager.Init(aDataFile);
for (ii = 0; ii < nNeu[i - nIso]; ++ii) {
theLegendre[i - nIso][ii].Init(aDataFile);
@@ -173,7 +178,8 @@ void G4ParticleHPPhotonDist::InitAngular(std::istream& aDataFile)
aDataFile >> theGammas[i] >> theShells[i] >> nNeu[i - nIso];
theGammas[i] *= eV;
theShells[i] *= eV;
theAngular[i - nIso] = new G4ParticleHPAngularP[nNeu[i - nIso]];
const std::size_t asize = nNeu[i - nIso] > 0 ? nNeu[i - nIso] : 1;
theAngular[i - nIso] = new G4ParticleHPAngularP[asize];
for (ii = 0; ii < nNeu[i - nIso]; ++ii) {
theAngular[i - nIso][ii].Init(aDataFile);
}
@@ -213,9 +219,10 @@ void G4ParticleHPPhotonDist::InitEnergies(std::istream& aDataFile)
}
if (energyDistributionsNeeded == 0) return;
aDataFile >> nPartials;
distribution = new G4int[nPartials];
probs = new G4ParticleHPVector[nPartials];
partials = new G4ParticleHPPartial*[nPartials];
const std::size_t dsize = nPartials > 0 ? nPartials : 1;
distribution = new G4int[dsize];
probs = new G4ParticleHPVector[dsize];
partials = new G4ParticleHPPartial*[dsize];
G4int nen;
G4int dummy;
for (i = 0; i < nPartials; ++i) {
@@ -236,13 +243,13 @@ void G4ParticleHPPhotonDist::InitPartials(std::istream& aDataFile, G4ParticleHPV
if (nDiscrete != 1) {
theTotalXsec.Init(aDataFile, eV);
}
G4int i;
theGammas = new G4double[nDiscrete];
theShells = new G4double[nDiscrete];
isPrimary = new G4int[nDiscrete];
disType = new G4int[nDiscrete];
thePartialXsec = new G4ParticleHPVector[nDiscrete];
for (i = 0; i < nDiscrete; ++i) {
const std::size_t dsize = nDiscrete > 0 ? nDiscrete : 1;
theGammas = new G4double[dsize];
theShells = new G4double[dsize];
isPrimary = new G4int[dsize];
disType = new G4int[dsize];
thePartialXsec = new G4ParticleHPVector[dsize];
for (std::size_t i = 0; i < dsize; ++i) {
aDataFile >> theGammas[i] >> theShells[i] >> isPrimary[i] >> disType[i];
theGammas[i] *= eV;
theShells[i] *= eV;