Import Geant4 10.6.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2019-06-28 11:59:04 +02:00
parent 28a70706e0
commit d0f911957d
1056 changed files with 95168 additions and 78160 deletions
@@ -123,7 +123,7 @@ G4double G4AntiNuclElastic::SampleInvariantT(const G4ParticleDefinition* particl
G4LorentzVector lv(0.0,0.0,0.0,TargMass);
lv += Pproj;
G4double S = lv.mag2()/GeV/GeV;
G4double S = lv.mag2()/(GeV*GeV);
G4ThreeVector bst = lv.boostVector();
Pproj.boost(-bst);
@@ -135,7 +135,7 @@ G4double G4AntiNuclElastic::SampleInvariantT(const G4ParticleDefinition* particl
fptot= ptot;
fTmax = 4.0*ptot*ptot;
if(Plab/std::abs(particle->GetBaryonNumber()) < 100.*MeV) // Uzhi 24 Nov. 2011
if(Plab < (std::abs(particle->GetBaryonNumber())*100)*MeV) // Uzhi 24 Nov. 2011
{return fTmax*G4UniformRand();} // Uzhi 24 Nov. 2011
G4double Z1 = particle->GetPDGCharge();
@@ -372,11 +372,13 @@ G4double G4AntiNuclElastic::SampleInvariantT(const G4ParticleDefinition* particl
T*=3.893913e+4; // fm -> MeV^2
}
// VI: 29.04.2019 unnecessary computation of trigonometry
/*
G4double cosTet=1.0-T/(2.*ptot*ptot);
if(cosTet > 1.0 ) cosTet= 1.; // Uzhi 30 Nov.
if(cosTet < -1.0 ) cosTet=-1.; // Uzhi 30 Nov.
fTetaCMS=std::acos(cosTet);
*/
return T;
}
@@ -57,7 +57,6 @@ G4ChargeExchange::G4ChargeExchange() : G4HadronicInteraction("Charge Exchange")
SetMinEnergy( 0.0*GeV );
SetMaxEnergy( G4HadronicParameters::Instance()->GetMaxEnergy() );
lowEnergyRecoilLimit = 100.*keV;
lowestEnergyLimit = 1.*MeV;
theProton = G4Proton::Proton();
@@ -106,7 +105,7 @@ G4HadFinalState* G4ChargeExchange::ApplyYourself(
if(ekin <= lowestEnergyLimit || A < 3) {
theParticleChange.SetEnergyChange(ekin);
theParticleChange.SetMomentumChange(aTrack.Get4Momentum().vect().unit());
theParticleChange.SetMomentumChange(0.0,0.0,1.0);
return &theParticleChange;
}
@@ -129,9 +128,9 @@ G4HadFinalState* G4ChargeExchange::ApplyYourself(
<< " A= " << A << " N= " << N
<< G4endl;
G4ParticleDefinition * theDef = 0;
const G4ParticleDefinition* theDef = nullptr;
G4double mass2 = G4NucleiProperties::GetNuclearMass((G4double)A, (G4double)Z);
G4double mass2 = G4NucleiProperties::GetNuclearMass(A, Z);
G4LorentzVector lv1 = aParticle->Get4Momentum();
G4LorentzVector lv0(0.0,0.0,0.0,mass2);
@@ -142,8 +141,8 @@ G4HadFinalState* G4ChargeExchange::ApplyYourself(
// Sample final particles
G4bool theHyperon = false;
G4ParticleDefinition* theRecoil = 0;
G4ParticleDefinition* theSecondary = 0;
const G4ParticleDefinition* theRecoil = nullptr;
const G4ParticleDefinition* theSecondary = nullptr;
if(theParticle == theProton) {
theSecondary = theNeutron;
@@ -248,7 +247,7 @@ G4HadFinalState* G4ChargeExchange::ApplyYourself(
// kinematiacally impossible
if(etot < m11 + m21) {
theParticleChange.SetEnergyChange(ekin);
theParticleChange.SetMomentumChange(aTrack.Get4Momentum().vect().unit());
theParticleChange.SetMomentumChange(0.0,0.0,1.0);
return &theParticleChange;
}
@@ -262,10 +261,10 @@ G4HadFinalState* G4ChargeExchange::ApplyYourself(
G4double t = g2*SampleT(tmax/g2, A);
if(verboseLevel>1)
if(verboseLevel>1) {
G4cout <<"## G4ChargeExchange t= " << t << " tmax= " << tmax
<< " ptot= " << ptot << G4endl;
}
// Sampling in CM system
G4double phi = G4UniformRand()*twopi;
G4double cost = 1. - 2.0*t/tmax;
@@ -288,7 +287,7 @@ G4HadFinalState* G4ChargeExchange::ApplyYourself(
G4DynamicParticle * aSec = new G4DynamicParticle(theSecondary, nlv1);
theParticleChange.AddSecondary(aSec);
G4double erec = nlv0.e() - m21;
G4double erec = std::max(nlv0.e() - m21, 0.0);
//G4cout << "erec= " <<erec << " Esec= " << aSec->GetKineticEnergy() << G4endl;
@@ -297,28 +296,28 @@ G4HadFinalState* G4ChargeExchange::ApplyYourself(
aSec = new G4DynamicParticle();
aSec->SetDefinition(theRecoil);
aSec->SetKineticEnergy(0.0);
} else if(erec > lowEnergyRecoilLimit) {
} else if(erec > GetRecoilEnergyThreshold()) {
aSec = new G4DynamicParticle(theRecoil, nlv0);
theParticleChange.AddSecondary(aSec);
} else {
if(erec < 0.0) erec = 0.0;
theParticleChange.SetLocalEnergyDeposit(erec);
}
return &theParticleChange;
}
G4double G4ChargeExchange::SampleT(G4double tmax, G4double A)
G4double G4ChargeExchange::SampleT(G4double tmax, G4int A)
{
G4double aa, bb, cc, dd;
G4Pow* g4pow = G4Pow::GetInstance();
if (A <= 62.) {
aa = G4Pow::GetInstance()->powA(A, 1.63);
bb = 14.5*G4Pow::GetInstance()->powA(A, 0.66);
cc = 1.4*G4Pow::GetInstance()->powA(A, 0.33);
aa = g4pow->powZ(A, 1.63);
bb = 14.5*g4pow->powZ(A, 0.66);
cc = 1.4*g4pow->powZ(A, 0.33);
dd = 10.;
} else {
aa = G4Pow::GetInstance()->powA(A, 1.33);
bb = 60.*G4Pow::GetInstance()->powA(A, 0.33);
cc = 0.4*G4Pow::GetInstance()->powA(A, 0.40);
aa = g4pow->powZ(A, 1.33);
bb = 60.*g4pow->powZ(A, 0.33);
cc = 0.4*g4pow->powZ(A, 0.40);
dd = 10.;
}
G4double x1 = (1.0 - G4Exp(-tmax*bb))*aa/bb;
@@ -337,7 +336,6 @@ G4double G4ChargeExchange::SampleT(G4double tmax, G4double A)
if ( loopCounter >= maxNumberOfLoops ) {
t = 0.0;
}
return t;
}
File diff suppressed because it is too large Load Diff
@@ -64,14 +64,13 @@ G4HadronElastic::~G4HadronElastic()
void G4HadronElastic::ModelDescription(std::ostream& outFile) const
{
outFile << "G4HadronElastic is a hadron-nucleus elastic scattering\n"
<< "model which uses the Gheisha two-exponential momentum\n"
<< "transfer parameterization. The model is fully relativistic\n"
<< "as opposed to the original Gheisha model which was not.\n"
<< "This model may be used for all long-lived hadrons at all\n"
<< "incident energies.\n";
outFile << "G4HadronElastic is the base class for all hadron-nucleus\n"
<< "elastic scattering models except HP.\n"
<< "By default it uses the Gheisha two-exponential momentum\n"
<< "transfer parameterization. The model is fully relativistic\n"
<< "as opposed to the original Gheisha model which was not.\n"
<< "This model may be used for all long-lived hadrons at all\n"
<< "incident energies but fit the data only for relativistic scattering.\n";
}
G4HadFinalState* G4HadronElastic::ApplyYourself(
@@ -81,20 +80,21 @@ G4HadFinalState* G4HadronElastic::ApplyYourself(
const G4HadProjectile* aParticle = &aTrack;
G4double ekin = aParticle->GetKineticEnergy();
// no scattering below the limit
if(ekin <= lowestEnergyLimit) {
theParticleChange.SetEnergyChange(ekin);
theParticleChange.SetMomentumChange(aTrack.Get4Momentum().vect().unit());
theParticleChange.SetMomentumChange(0.,0.,1.);
return &theParticleChange;
}
G4int A = targetNucleus.GetA_asInt();
G4int Z = targetNucleus.GetZ_asInt();
G4double plab = aParticle->GetTotalMomentum();
// Scattered particle referred to axis of incident particle
const G4ParticleDefinition* theParticle = aParticle->GetDefinition();
G4double m1 = theParticle->GetPDGMass();
G4double plab = std::sqrt(ekin*(ekin + 2.0*m1));
if (verboseLevel>1) {
G4cout << "G4HadronElastic: "
@@ -107,33 +107,57 @@ G4HadFinalState* G4HadronElastic::ApplyYourself(
}
G4double mass2 = G4NucleiProperties::GetNuclearMass(A, Z);
G4LorentzVector lv1 = aParticle->Get4Momentum();
G4LorentzVector lv(0.0,0.0,0.0,mass2);
lv += lv1;
G4double e1 = m1 + ekin;
G4LorentzVector lv(0.0,0.0,plab,e1+mass2);
G4ThreeVector bst = lv.boostVector();
lv1.boost(-bst);
G4double momentumCMS = plab*mass2/std::sqrt(m1*m1 + mass2*mass2 + 2.*mass2*e1);
G4ThreeVector p1 = lv1.vect();
G4double momentumCMS = p1.mag();
G4double tmax = 4.0*momentumCMS*momentumCMS;
pLocalTmax = 4.0*momentumCMS*momentumCMS;
// Sampling in CM system
G4double t = SampleInvariantT(theParticle, plab, Z, A);
G4double phi = G4UniformRand()*CLHEP::twopi;
G4double cost = 1. - 2.0*t/tmax;
if(cost > 1.0) { cost = 1.0; }
else if(cost < -1.0) { cost = -1.0; }
G4double cost = 1. - 2.0*t/pLocalTmax;
// For the very rare cases where cos(theta) is greater than 1 or smaller than -1,
// print some debugging information via a "JustWarning" exception, and safely
// return (simply setting "cost=1.0" or "cost=-1.0" can sometimes cause a crash,
// due to numerical imprecisions, e.g. 3-momentum = (0.0, 0.0, 0.0) but
// Ekin very small but not 0.0).
if ( std::abs( cost ) > 1.0 ) {
G4ExceptionDescription ed;
ed << " LARGE cost ! cost=" << cost << " for " << aParticle->GetDefinition()->GetParticleName()
<< " ekin=" << ekin << " MeV" << " on (Z,A)=(" << Z << "," << A << ")" << G4endl;
if ( cost > 1.0 ) {
// We assume here no interaction and let the projectile keep going unchanged.
theParticleChange.SetEnergyChange( ekin );
theParticleChange.SetMomentumChange( aParticle->Get4Momentum().vect().unit() );
ed << "\t No interaction: the projectile keeps going unchanged!" << G4endl;
G4Exception( "G4HadronElastic::ApplyYourself", "hadEla001", JustWarning, ed );
return &theParticleChange;
} else { // cost < -1.0 ) {
// We assume here that the projectile stops and its energy is deposited locally
// (for simplicity, given that this condition should happen rarely, we neglect
// the recoil of the target nucleus).
theParticleChange.SetEnergyChange( 0.0 );
theParticleChange.SetLocalEnergyDeposit( ekin );
ed << "\t Projectile stops and its energy is deposited locally:" << G4endl
<< "\t neglected recoil of the target nucleus!" << G4endl;
G4Exception( "G4HadronElastic::ApplyYourself", "hadEla002", JustWarning, ed );
return &theParticleChange;
}
}
G4double sint = std::sqrt((1.0-cost)*(1.0+cost));
if (verboseLevel>1) {
G4cout << " t= " << t << " tmax(GeV^2)= " << tmax/(GeV*GeV)
G4cout << " t= " << t << " tmax(GeV^2)= " << pLocalTmax/(GeV*GeV)
<< " Pcms(GeV)= " << momentumCMS/GeV << " cos(t)=" << cost
<< " sin(t)=" << sint << G4endl;
}
G4ThreeVector v1(sint*std::cos(phi),sint*std::sin(phi),cost);
v1 *= momentumCMS;
G4LorentzVector nlv1(v1.x(),v1.y(),v1.z(),
G4LorentzVector nlv1(momentumCMS*sint*std::cos(phi),
momentumCMS*sint*std::sin(phi),
momentumCMS*cost,
std::sqrt(momentumCMS*momentumCMS + m1*m1));
nlv1.boost(bst);
@@ -141,33 +165,26 @@ G4HadFinalState* G4HadronElastic::ApplyYourself(
G4double eFinal = nlv1.e() - m1;
if (verboseLevel > 1) {
G4cout <<"G4HadronElastic: m= " << m1 << " Efin(MeV)= " << eFinal
<< " Proj: 4-mom " << lv1 << " Final: " << nlv1
<< " 4-M Final: " << nlv1
<< G4endl;
}
// precision lost in kinematics, only energy is changed
if (eFinal <= 0.0) {
G4double mom = nlv1.mag();
if(mom == 0.0) {
nlv1.set(0.0,0.0,0.0,m1);
theParticleChange.SetEnergyChange(0.0);
} else {
eFinal = mom*mom/(std::sqrt(m1*m1 + mom*mom) + m1);
theParticleChange.SetEnergyChange(eFinal);
theParticleChange.SetMomentumChange(nlv1.vect().unit());
}
if(eFinal <= 0.0) {
theParticleChange.SetMomentumChange(0.0,0.0,1.0);
theParticleChange.SetEnergyChange(0.0);
} else {
theParticleChange.SetMomentumChange(nlv1.vect().unit());
theParticleChange.SetEnergyChange(eFinal);
}
lv -= nlv1;
G4double erec = lv.e() - mass2;
G4double erec = std::max(lv.e() - mass2, 0.0);
if (verboseLevel > 1) {
G4cout << "Recoil: " <<" m= " << mass2 << " Erec(MeV)= " << erec
<< " 4-mom: " << lv
<< G4endl;
}
// the recoil is created if kinetic energy above the threshold
if(erec > GetRecoilEnergyThreshold()) {
G4ParticleDefinition * theDef = nullptr;
if(Z == 1 && A == 1) { theDef = theProton; }
@@ -179,9 +196,9 @@ G4HadFinalState* G4HadronElastic::ApplyYourself(
theDef =
G4ParticleTable::GetParticleTable()->GetIonTable()->GetIon(Z,A,0.0);
}
G4DynamicParticle * aSec = new G4DynamicParticle(theDef, lv);
G4DynamicParticle * aSec = new G4DynamicParticle(theDef, lv.vect().unit(), erec);
theParticleChange.AddSecondary(aSec);
} else if(erec > 0.0) {
} else {
theParticleChange.SetLocalEnergyDeposit(erec);
}
@@ -190,15 +207,13 @@ G4HadFinalState* G4HadronElastic::ApplyYourself(
// sample momentum transfer in the CMS system
G4double
G4HadronElastic::SampleInvariantT(const G4ParticleDefinition* p,
G4double plab,
G4int Z, G4int A)
G4HadronElastic::SampleInvariantT(const G4ParticleDefinition*,
G4double, G4int, G4int A)
{
static const G4double GeV2 = GeV*GeV;
G4double momentumCMS = ComputeMomentumCMS(p,plab,Z,A);
G4double tmax = 4.0*momentumCMS*momentumCMS/GeV2;
G4double tmax = pLocalTmax/GeV2;
G4double aa, bb, cc;
G4double dd = 10.;
static const G4double dd = 10.;
G4Pow* g4pow = G4Pow::GetInstance();
if (A <= 62) {
bb = 14.5*g4pow->Z23(A);
@@ -219,4 +234,3 @@ G4HadronElastic::SampleInvariantT(const G4ParticleDefinition* p,
}
return -GeV2*G4Log(1.0 - G4UniformRand()*q1)/bb;
}
@@ -0,0 +1,62 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// Geant4 class : G4LowEHadronElastic
//
// Author : V.Ivanchenko 10 May 2019
//
//
#include "G4LowEHadronElastic.hh"
#include "G4PhysicalConstants.hh"
#include "G4SystemOfUnits.hh"
#include "Randomize.hh"
#include "G4ios.hh"
G4LowEHadronElastic::G4LowEHadronElastic():G4HadronElastic("hLowEElastic")
{
plabLowLimit = 400*CLHEP::MeV;
plabHighLimit = 2000*CLHEP::MeV;
}
G4LowEHadronElastic::~G4LowEHadronElastic()
{}
G4double
G4LowEHadronElastic::SampleInvariantT(const G4ParticleDefinition* p,
G4double plab, G4int Z, G4int A)
{
return (IsResonanseScattering(p, plab, Z, A))
? G4UniformRand()*pLocalTmax
: G4HadronElastic::SampleInvariantT(p, plab, Z, A);
}
G4bool
G4LowEHadronElastic::IsResonanseScattering(const G4ParticleDefinition*,
G4double plab,
G4int, G4int)
{
return (plab < plabHighLimit);
}