Import Geant4 11.4.0 source tree

This commit is contained in:
Gabriele Cosmo
2025-12-05 08:54:02 +01:00
parent a499fb82e9
commit b4a16de652
6484 changed files with 232674 additions and 221097 deletions
@@ -368,34 +368,23 @@ G4double G4AntiNuclElastic::SampleInvariantT(const G4ParticleDefinition* particl
G4double G4AntiNuclElastic::SampleThetaCMS(const G4ParticleDefinition* p, G4double plab,
G4int Z, G4int A)
{
G4double T;
T = SampleInvariantT( p, plab, Z, A);
G4double T = SampleInvariantT( p, plab, Z, A);
if (T <= 0.0 || fTmax <= 0.0) { return 1.0; }
// NaN finder
if(!(T < 0.0 || T >= 0.0))
// NaN finder substituted by simple check
if (T > fTmax)
{
if (verboseLevel > 0)
{
G4cout << "G4DiffuseElastic:WARNING: A = " << A
<< " mom(GeV)= " << plab/GeV
<< " S-wave will be sampled"
G4cout << "G4AntiNuclElastic::SampleThetaCMS WARNING: A = " << A
<< " mom(GeV)=" << plab/GeV << " t(GeV2)=" << T/(GeV*GeV)
<< " > Tmax(GeV2)=" << fTmax/(GeV*GeV) << " S-wave will be sampled"
<< G4endl;
}
T = G4UniformRand()*fTmax;
}
if(fptot > 0.)
{
G4double cosTet=1.0-T/(2.*fptot*fptot);
if(cosTet > 1.0 ) cosTet= 1.;
if(cosTet < -1.0 ) cosTet=-1.;
fTetaCMS=std::acos(cosTet);
return fTetaCMS;
} else
{
return 2.*G4UniformRand()-1.;
}
G4double cosTet = 1.0 - 2*T/fTmax;
return cosTet;
}
@@ -404,42 +393,25 @@ G4double G4AntiNuclElastic::SampleInvariantT(const G4ParticleDefinition* particl
G4double G4AntiNuclElastic::SampleThetaLab(const G4ParticleDefinition* p, G4double plab,
G4int Z, G4int A)
{
G4double T;
T = SampleInvariantT( p, plab, Z, A);
G4double T = SampleInvariantT( p, plab, Z, A);
if (T <= 0.0 || fTmax <= 0.0) { return 1.0; }
// NaN finder
if(!(T < 0.0 || T >= 0.0))
// NaN finder substituted by simple check
if (T > fTmax)
{
if (verboseLevel > 0)
if (verboseLevel > 0)
{
G4cout << "G4DiffuseElastic:WARNING: A = " << A
<< " mom(GeV)= " << plab/GeV
<< " S-wave will be sampled"
G4cout << "G4AntiNuclElastic::SampleThetaLab WARNING: A = " << A
<< " mom(GeV)=" << plab/GeV << " t(GeV2)=" << T/(GeV*GeV)
<< " > Tmax(GeV2)=" << fTmax/(GeV*GeV) << " S-wave will be sampled"
<< G4endl;
}
T = G4UniformRand()*fTmax;
}
G4double phi = G4UniformRand()*twopi;
G4double cost(1.);
if(fTmax > 0.) {cost = 1. - 2.0*T/fTmax;}
G4double sint;
if( cost >= 1.0 )
{
cost = 1.0;
sint = 0.0;
}
else if( cost <= -1.0)
{
cost = -1.0;
sint = 0.0;
}
else
{
sint = std::sqrt((1.0-cost)*(1.0+cost));
}
G4double cost = 1.0 - 2*T/fTmax;
G4double phi = G4UniformRand()*twopi;
G4double sint = std::sqrt((1.0-cost)*(1.0+cost));
G4double m1 = p->GetPDGMass();
G4ThreeVector v(sint*std::cos(phi),sint*std::sin(phi),cost);
@@ -89,14 +89,13 @@ G4HadFinalState* G4ChargeExchange::ApplyYourself(
G4int A = targetNucleus.GetA_asInt();
G4int Z = targetNucleus.GetZ_asInt();
if (ekin <= lowEnergyLimit) {
return &theParticleChange;
}
theParticleChange.SetWeightChange(fXSWeightFactor);
G4int projPDG = part->GetPDGEncoding();
// for hydrogen targets and positive projectile change exchange
// is not possible on proton, only on deuteron
if (1 == Z && (211 == projPDG || 321 == projPDG)) { A = 2; }
@@ -196,14 +195,20 @@ G4HadFinalState* G4ChargeExchange::ApplyYourself(
// not possible kinematically
if (!ok) { return &theParticleChange; }
// tmax = 4*momCMS^2
G4double e2 = (m0*m0 + mass2*mass2 - mass3*mass3)/(2*m0);
G4double momentumCMS = std::sqrt(e2*e2 - mass2*mass2);
G4double tmax = 4*(momentumCMS*momentumCMS);
G4double t = SampleT(theSecondary, A, tmax);
G4double phi = G4UniformRand()*CLHEP::twopi;
G4double tmax = 4*momentumCMS*momentumCMS;
// for projectile pion t depends on final state
G4double t;
if (fXSection->isPion()) {
t = fXSection->SampleTforPion(aTrack.GetTotalEnergy(), tmax);
}
else {
t = SampleT(theSecondary, A, tmax);
}
G4double phi = G4UniformRand()*CLHEP::twopi;
G4double cost = 1. - 2.0*t/tmax;
// if cos(theta) negative, there is a numerical problem
@@ -211,7 +216,7 @@ G4HadFinalState* G4ChargeExchange::ApplyYourself(
// no scattering
if (std::abs(cost) > 1.0) { cost = 1.0; }
G4double sint = std::sqrt((1.0-cost)*(1.0+cost));
G4double sint = std::sqrt((1.0 - cost)*(1.0 + cost));
if (verboseLevel > 1) {
G4cout << " t= " << t << " tmax(GeV^2)= " << tmax/(GeV*GeV)
@@ -1158,9 +1158,10 @@ G4DiffuseElastic::SampleThetaLab( const G4HadProjectile* aParticle,
//
t = SampleT( theParticle, ptot, A);
if (t <= 0.0) { return 0.0; }
// NaN finder
if(!(t < 0.0 || t >= 0.0))
// NaN finder substituted
if (t > tmax)
{
if (verboseLevel > 0)
{
@@ -1180,22 +1181,8 @@ G4DiffuseElastic::SampleThetaLab( const G4HadProjectile* aParticle,
G4double phi = G4UniformRand()*twopi;
G4double cost = 1. - 2.0*t/tmax;
G4double sint;
if( cost >= 1.0 )
{
cost = 1.0;
sint = 0.0;
}
else if( cost <= -1.0)
{
cost = -1.0;
sint = 0.0;
}
else
{
sint = std::sqrt((1.0-cost)*(1.0+cost));
}
G4double sint = std::sqrt((1.0-cost)*(1.0+cost));
if (verboseLevel>1)
{
G4cout << "cos(t)=" << cost << " std::sin(t)=" << sint << G4endl;
@@ -1119,13 +1119,9 @@ G4NuclNuclDiffuseElastic:: GetScatteringAngle( G4int iMomentum, G4int iAngle, G4
}
////////////////////////////////////////////////////////////////////////////
//
// Return scattering angle sampled in lab system (target at rest)
G4double
G4NuclNuclDiffuseElastic::SampleThetaLab( const G4HadProjectile* aParticle,
G4double tmass, G4double A)
@@ -1145,15 +1141,15 @@ G4NuclNuclDiffuseElastic::SampleThetaLab( const G4HadProjectile* aParticle,
G4double tmax = 4.0*ptot*ptot;
G4double t = 0.0;
//
// Sample t
//
t = SampleT( theParticle, ptot, A);
if (t <= 0.0) { return 0.0; }
// NaN finder
if(!(t < 0.0 || t >= 0.0))
if (t > tmax)
{
if (verboseLevel > 0)
{
@@ -1173,22 +1169,8 @@ G4NuclNuclDiffuseElastic::SampleThetaLab( const G4HadProjectile* aParticle,
G4double phi = G4UniformRand()*twopi;
G4double cost = 1. - 2.0*t/tmax;
G4double sint;
G4double sint = std::sqrt((1.0-cost)*(1.0+cost));
if( cost >= 1.0 )
{
cost = 1.0;
sint = 0.0;
}
else if( cost <= -1.0)
{
cost = -1.0;
sint = 0.0;
}
else
{
sint = std::sqrt((1.0-cost)*(1.0+cost));
}
if (verboseLevel>1)
{
G4cout << "cos(t)=" << cost << " std::sin(t)=" << sint << G4endl;