Import Geant4 8.2.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 14:55:03 +02:00
parent 216a75eeb1
commit fe73f43734
6714 changed files with 118229 additions and 68144 deletions
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4CoulombScatteringModel.cc,v 1.2 2006/06/29 19:52:54 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
// $Id: G4CoulombScatteringModel.cc,v 1.7 2006/10/19 09:44:27 vnivanch Exp $
// GEANT4 tag $Name: geant4-08-02 $
//
// -------------------------------------------------------------------
//
@@ -38,6 +38,10 @@
// Creation date: 22.08.2005
//
// Modifications:
// 01.08.06 V.Ivanchenko extend upper limit of table to TeV and review the
// logic of building - only elements from G4ElementTable
// 08.08.06 V.Ivanchenko build internal table in ekin scale, introduce faclim
// 19.10.06 V.Ivanchenko use inheritance from G4eCoulombScatteringModel
//
// Class Description:
//
@@ -48,8 +52,6 @@
#include "G4CoulombScatteringModel.hh"
#include "Randomize.hh"
#include "G4DataVector.hh"
#include "G4PhysicsLogVector.hh"
#include "G4ParticleChangeForGamma.hh"
#include "G4NistManager.hh"
#include "G4ParticleTable.hh"
@@ -63,22 +65,8 @@ using namespace std;
G4CoulombScatteringModel::G4CoulombScatteringModel(
G4double thetaMin, G4double thetaMax, G4bool build,
G4double tlim, const G4String& nam)
: G4VEmModel(nam),
theCrossSectionTable(0),
cosThetaMin(cos(thetaMin)),
cosThetaMax(cos(thetaMax)),
lowMomentum(keV),
highMomentum(MeV),
q2Limit(tlim),
nbins(12),
nmax(100),
buildTable(build),
isInitialised(false)
: G4eCoulombScatteringModel(thetaMin,thetaMax,build,tlim,nam)
{
G4double p0 = hbarc/(Bohr_radius*0.885);
a0 = 0.25*p0*p0;
p0 = electron_mass_c2*classic_electr_radius;
coeff = twopi*p0*p0;
theMatManager = G4NistManager::Instance();
theParticleTable = G4ParticleTable::GetParticleTable();
theProton = G4Proton::Proton();
@@ -87,85 +75,42 @@ G4CoulombScatteringModel::G4CoulombScatteringModel(
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4CoulombScatteringModel::~G4CoulombScatteringModel()
{
if(theCrossSectionTable) {
theCrossSectionTable->clearAndDestroy();
delete theCrossSectionTable;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4CoulombScatteringModel::Initialise(const G4ParticleDefinition* p,
const G4DataVector&)
{
if(isInitialised) return;
isInitialised = true;
if(pParticleChange)
fParticleChange = reinterpret_cast<G4ParticleChangeForGamma*>(pParticleChange);
else
fParticleChange = new G4ParticleChangeForGamma();
if(!buildTable || p->GetParticleName() == "GenericIon") return;
// Compute cross section multiplied by Ptot^2*beta^2
G4double mass = p->GetPDGMass();
G4double mass2 = mass*mass;
theCrossSectionTable = new G4PhysicsTable(nmax);
G4PhysicsLogVector* ptrVector;
G4double mom2, value;
G4double pmin = lowMomentum*lowMomentum;
G4double pmax = highMomentum*highMomentum;
nbins = G4int(log10(pmax/pmin)/2.0) + 1;
for(G4int j=1; j<nmax; j++) {
ptrVector = new G4PhysicsLogVector(pmin, pmax, nbins);
for(G4int i=0; i<=nbins; i++) {
mom2 = ptrVector->GetLowEdgeEnergy( i ) ;
value = CalculateCrossSectionPerAtom(p, mom2, j);
value *= mom2*mom2/(mom2 + mass2);
ptrVector->PutValue( i, value );
}
theCrossSectionTable->insert(ptrVector);
}
}
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4CoulombScatteringModel::CalculateCrossSectionPerAtom(
const G4ParticleDefinition* p,
G4double mom2,
G4double kinEnergy,
G4double Z)
{
G4double cross= 0.0;
G4int iz = G4int(Z);
G4double m = p->GetPDGMass();
G4double mom2 = kinEnergy*(kinEnergy + 2.0*m);
G4double mass2= m*m;
G4double q = p->GetPDGCharge()/eplus;
G4double m1 = theMatManager->GetAtomicMassAmu(iz)*amu_c2;
G4double etot = sqrt(mom2 + mass2) + m1;
G4double etot = kinEnergy + m + m1;
G4double ptot = sqrt(mom2);
G4double bet = ptot/etot;
G4double gam = 1.0/sqrt((1.0 - bet)*(1.0 + bet));
G4double mom = gam*(ptot - bet*etot);
G4double momentum2 = mom*mom;
G4double costm = std::max(cosThetaMax, 1.0 - q2Limit/2.0*momentum2);
G4double momCM = gam*(ptot - bet*etot);
G4double momCM2 = momCM*momCM;
G4double costm = std::max(cosThetaMax, 1.0 - 0.5*q2Limit/momCM2);
if(1 == iz && p == theProton) costm = std::max(0.0, costm);
// Cross section in CM system
if(costm < cosThetaMin) {
G4double invbeta2 = 1.0 + mass2/momentum2;
G4double a = 2.0*pow(Z,0.666666667)*a0*
(1.13 + 3.76*invbeta2*Z*Z*fine_structure_const*fine_structure_const)/momentum2 + 1.0;
G4double f = q * Z * m1 /(m + m1);
cross = coeff*f*f*(cosThetaMin - costm)/((a - cosThetaMin)*(a - costm));
G4double q = p->GetPDGCharge()/eplus;
G4double q2 = q*q;
G4double invbeta2 = 1.0 + mass2/momCM2;
G4double A = ScreeningParameter(Z, q2, momCM2, invbeta2);
G4double a = 2.0*A + 1.0;
G4double f = q * m1 /(m + m1);
cross = coeff*f*f*Z*(Z + 1.0)*invbeta2*(cosThetaMin - costm)/
((a - cosThetaMin)*(a - costm)*momCM2);
}
//G4cout << "p= " << mom << " Z= " << Z << " a= " << a
//G4cout << "p= " << mom << " momCM= " << momCM << " Z= " << Z << " A= " << A
//<< " cross= " << cross << " m1(GeV)= " << m1/GeV <<G4endl;
return cross;
}
@@ -185,7 +130,8 @@ G4double G4CoulombScatteringModel::SelectIsotope(const G4Element* elm)
if (x <= 0.0) break;
}
if(idx >= ni) {
G4cout << "G4CoulombScatteringModel::SelectIsotope WARNING: abandance vector for"
G4cout << "G4CoulombScatteringModel::SelectIsotope WARNING: "
<< "abandance vector for"
<< elm->GetName() << " is not normalised to unit" << G4endl;
} else {
N = G4double(elm->GetIsotope(idx)->GetN());
@@ -206,7 +152,8 @@ std::vector<G4DynamicParticle*>* G4CoulombScatteringModel::SampleSecondaries(
const G4Material* aMaterial = couple->GetMaterial();
const G4ParticleDefinition* p = dp->GetDefinition();
const G4Element* elm = SelectRandomAtom(aMaterial, p, dp->GetKineticEnergy());
const G4Element* elm =
SelectRandomAtom(aMaterial, p, dp->GetKineticEnergy());
G4double Z = elm->GetZ();
G4double N = SelectIsotope(elm);
G4int iz = G4int(Z);
@@ -214,45 +161,52 @@ std::vector<G4DynamicParticle*>* G4CoulombScatteringModel::SampleSecondaries(
G4double m2 = theParticleTable->GetIonTable()->GetNucleusMass(iz, in);
G4double m1 = dp->GetMass();
G4double q = p->GetPDGCharge()/eplus;
G4double q2 = q*q;
// Transformation to CM system
G4LorentzVector lv1 = dp->Get4Momentum();
G4ThreeVector dir = dp->GetMomentumDirection();
G4LorentzVector lv2(0.0,0.0,0.0,m2);
G4LorentzVector lv = lv1 + lv2;
G4ThreeVector bst = lv.boostVector();
lv1.boost(-bst);
lv2.boost(-bst);
G4ThreeVector p1 = lv1.vect();
G4double momentum2 = p1.mag2();
G4double invbeta2 = 1.0 + m1*m1/momentum2;
G4double momCM2 = p1.mag2();
G4double invbeta2 = 1.0 + m1*m1/momCM2;
G4double A = ScreeningParameter(Z, q2, momCM2, invbeta2);
G4double a = 2.0*A + 1.0;
G4double a = 2.*pow(Z,0.666666667)*a0*
(1.13 + 3.76*invbeta2*Z*Z*fine_structure_const*fine_structure_const)/momentum2 + 1.0;
G4double costm = std::max(cosThetaMax, 1.0 - q2Limit/2.0*momentum2);
G4double costm = std::max(cosThetaMax, 1.0 - 0.5*q2Limit/momCM2);
if(1 == iz && p == theProton) costm = std::max(0.0, costm);
if(costm > cosThetaMin) return fvect;
G4double cost = a - (a - cosThetaMin)*(a - costm)/
(a - cosThetaMin + G4UniformRand()*(cosThetaMin - costm));
if(std::abs(cost) > 1.) {
G4cout << "G4CoulombScatteringModel::SampleSecondaries WARNING cost= " << cost << G4endl;
if(cost < -1.) cost = -1.0;
else cost = 1.0;
G4double x = G4UniformRand();
G4double y = (a + 1.0 - cosThetaMin)/(cosThetaMin - costm);
G4double st2 = 0.5*(y*(1.0 - costm) - a*x)/(y + x);
if(st2 < 0.0 || st2 > 1.0) {
G4cout << "G4CoulombScatteringModel::SampleSecondaries WARNING st2= "
<< st2 << G4endl;
st2 = 0.0;
}
G4double sint = sqrt((1.0 + cost)*(1.0 - cost));
G4double tet = 2.0*asin(sqrt(st2));
G4double cost= cos(tet);
G4double sint= sin(tet);
G4double phi = twopi * G4UniformRand();
G4ThreeVector v1(cos(phi)*sint,sin(phi)*sint,cost);
G4double p1tot = sqrt(momentum2);
v1.rotateUz(p1);
G4double p1tot = sqrt(momCM2);
// v1.rotateUz(p1);
G4LorentzVector lfv1(v1.x()*p1tot,v1.y()*p1tot,v1.z(),lv1.e());
G4LorentzVector lfv2 = lv1 + lv2 - lfv1;
lfv1.boost(bst);
lfv2.boost(bst);
fParticleChange->ProposeMomentumDirection(lfv1.vect().unit());
G4LorentzVector lfv2 = lv - lfv1;
G4ThreeVector newdir = lfv1.vect().unit();
fParticleChange->ProposeMomentumDirection(newdir);
G4double ekin = lfv1.e() - m1;
if(ekin < 0.0) ekin = 0.0;
fParticleChange->SetProposedKineticEnergy(ekin);
@@ -263,7 +217,9 @@ std::vector<G4DynamicParticle*>* G4CoulombScatteringModel::SampleSecondaries(
G4ParticleDefinition* ion = theParticleTable->GetIon(iz, in, 0.0);
G4DynamicParticle* newdp = new G4DynamicParticle(ion, lfv2);
fvect->push_back(newdp);
}
} else if(ekin > 0.0) {
fParticleChange->ProposeLocalEnergyDeposit(ekin);
}
return fvect;
}