Import Geant4 11.3.2 source tree

This commit is contained in:
Gabriele Cosmo
2025-04-28 13:52:33 +02:00
parent df176550b3
commit 20a218bbe1
266 changed files with 8007 additions and 7819 deletions
@@ -6,6 +6,23 @@ It must **not** be used as a substitute for writing good git commit messages!
-------------------------------------------------------------------------------
## 2025-04-22 Alberto Ribon (hadr-casc-V11-02-05)
- G4CascadeFinalStateAlgorithm, G4NucleiModel : introduced the possibility to
retrieve either the behavior of these classes as in Geant4 version 11.3
(default) or as in 11.2 according to the value of boolean flags in
G4HadronicParameters.
In the case that the behavior of the class G4CascadeFinalStateAlgorithm
is chosen as in Geant4 version 11.2, the change introduced in
hadr-casc-V11-02-02 is skipped; similarly, but independently, if the
behavior of the class G4NucleiModel is chosen as in Geant4 version 11.2,
the change introduced in hadr-casc-V11-02-00 is skipped.
( Note that the changes introduced in the two above classes in
hadr-casc-V11-02-02 and hadr-casc-V11-02-00 can be considered as real
improvements of the Bertini model, some degradation of thin-target data -
in particular for the pion production in HARP data - are observed.
This is likely due to the fact that a complete retuning of the parameters
of the Bertini model would have been necessary after these changes. )
## 2024-08-21 Gabriele Cosmo (hadr-casc-V11-02-04)
- Fixed reported Coverity defect in G4NucleiModel for use of std::move().
@@ -53,6 +53,7 @@
#include "G4TwoBodyAngularDist.hh"
#include "G4VMultiBodyMomDst.hh"
#include "G4VTwoBodyAngDst.hh"
#include "G4HadronicParameters.hh"
#include "Randomize.hh"
#include <vector>
#include <numeric>
@@ -60,7 +61,6 @@
using namespace G4InuclSpecialFunctions;
// Cut-offs and iteration limits for generation
const G4double G4CascadeFinalStateAlgorithm::maxCosTheta = 0.9999;
@@ -420,14 +420,43 @@ GenerateCosTheta(G4int ptype, G4double pmod) const {
}
// Throw multi-body distribution
if ( G4HadronicParameters::Instance()->IsBertiniAngularEmissionsAs11_2() ) {
G4double p0 = ptype<3 ? 0.36 : 0.25; // Nucleon vs. everything else
G4double alf = 1.0 / p0 / (p0 - (pmod+p0)*G4Exp(-pmod / p0));
G4double sinth = 2.0;
G4int itry1 = -1; /* Loop checking 08.06.2015 MHK */
while (std::fabs(sinth) > maxCosTheta && ++itry1 < itry_max) {
G4double s1 = pmod * G4UniformRand();
G4double s2 = alf * oneOverE * p0 * G4UniformRand();
G4double salf = s1 * alf * G4Exp(-s1 / p0);
if (GetVerboseLevel() > 3) {
G4cout << " s1 * alf * G4Exp(-s1 / p0) " << salf
<< " s2 " << s2 << G4endl;
}
if (salf > s2) sinth = s1 / pmod;
}
if (GetVerboseLevel() > 3) G4cout << " itry1 " << itry1 << " sinth " << sinth << G4endl;
if (itry1 == itry_max) {
if (GetVerboseLevel() > 2) G4cout << " high energy angles generation: itry1 " << itry1 << G4endl;
sinth = 0.5 * G4UniformRand();
}
// Convert generated sin(theta) to cos(theta) with random sign
G4double costh = std::sqrt(1.0 - sinth * sinth);
if (G4UniformRand() > 0.5) costh = -costh;
return costh;
} else {
// Sample costheta directly from exp(-a*pmod*(1 - costheta) )
// Previous method sampled from a*sintheta*exp(-a*sintheta),
// converted to costheta and (incorrectly) reflected around 180 degrees
//
G4double p0 = ptype < 3 ? 0.36 : 0.25; // 0.36 for nucleon, 0.25 for all others
G4double alf = 3.*pmod/p0;
return G4Log(G4UniformRand()*(G4Exp(2.*alf) - 1.) + 1.)/alf - 1.;
// Sample costheta directly from exp(-a*pmod*(1 - costheta) )
// Previous method sampled from a*sintheta*exp(-a*sintheta),
// converted to costheta and (incorrectly) reflected around 180 degrees
//
G4double p0 = ptype < 3 ? 0.36 : 0.25; // 0.36 for nucleon, 0.25 for all others
G4double alf = 3.*pmod/p0;
return G4Log(G4UniformRand()*(G4Exp(2.*alf) - 1.) + 1.)/alf - 1.;
}
}
@@ -183,6 +183,7 @@
#include "G4PhysicalConstants.hh"
#include "G4Proton.hh"
#include "G4SystemOfUnits.hh"
#include "G4HadronicParameters.hh"
#include <vector>
#include <algorithm>
#include <functional>
@@ -379,7 +380,7 @@ void G4NucleiModel::generateModel(G4int a, G4int z) {
zone_potentials.push_back(std::move(kp));
zone_potentials.push_back(std::move(hp));
setDinucleonDensityScale();
if ( ! G4HadronicParameters::Instance()->IsBertiniNucleiModelAs11_2() ) setDinucleonDensityScale();
nuclei_radius = zone_radii.back();
nuclei_volume = std::accumulate(zone_volumes.begin(),zone_volumes.end(),0.);
@@ -1439,8 +1440,8 @@ void G4NucleiModel::setDinucleonDensityScale() {
G4double G4NucleiModel::getCurrentDensity(G4int ip, G4int izone) const {
// const G4double pn_spec = 1.0; // Scale factor for pn vs. pp/nn
const G4double combinatoric_factor = 0.5;
const G4double combinatoric_factor =
( G4HadronicParameters::Instance()->IsBertiniNucleiModelAs11_2() ? 1.0 : 0.5 );
G4double dens = 0.;
if (ip < 100) dens = getDensity(ip,izone);