Import Geant4 10.4.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2017-06-30 10:49:55 +02:00
parent 3a5407696b
commit 1a1316fea4
2180 changed files with 237880 additions and 59109 deletions
@@ -0,0 +1,290 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// $Id: G4NeutrinoElectronNcModel.cc 91806 2015-08-06 12:20:45Z gcosmo $
//
// Geant4 Header : G4NeutrinoElectronNcModel
//
// Author : V.Grichine 6.4.17
//
#include "G4NeutrinoElectronNcModel.hh"
#include "G4SystemOfUnits.hh"
#include "G4ParticleTable.hh"
#include "G4ParticleDefinition.hh"
#include "G4IonTable.hh"
#include "Randomize.hh"
#include "G4Electron.hh"
using namespace std;
using namespace CLHEP;
G4NeutrinoElectronNcModel::G4NeutrinoElectronNcModel(const G4String& name)
: G4HadronElastic(name)
{
SetMinEnergy( 0.0*GeV );
SetMaxEnergy( 100.*TeV );
SetLowestEnergyLimit(1.e-6*eV);
theElectron = G4Electron::Electron();
// PDG2016: sin^2 theta Weinberg
fSin2tW = 0.23129; // 0.2312;
fCutEnergy = 0.; // default value
}
G4NeutrinoElectronNcModel::~G4NeutrinoElectronNcModel()
{}
void G4NeutrinoElectronNcModel::ModelDescription(std::ostream& outFile) const
{
outFile << "G4NeutrinoElectronNcModel is a neutrino-electron (neutral current) elastic scattering\n"
<< "model which uses the standard model \n"
<< "transfer parameterization. The model is fully relativistic\n";
}
/////////////////////////////////////////////////////////
G4bool G4NeutrinoElectronNcModel::IsApplicable(const G4HadProjectile & aTrack,
G4Nucleus & targetNucleus)
{
G4bool result = false;
G4String pName = aTrack.GetDefinition()->GetParticleName();
G4double minEnergy = 0., energy = aTrack.GetTotalEnergy();
if( fCutEnergy > 0. ) // min detected recoil electron energy
{
minEnergy = 0.5*(fCutEnergy+sqrt(fCutEnergy*(fCutEnergy+2.*electron_mass_c2)));
}
if( ( pName == "nu_e" || pName == "anti_nu_e" ||
pName == "nu_mu" || pName == "anti_nu_nu" ||
pName == "nu_tau" || pName == "anti_nu_tau" ) &&
energy > minEnergy )
{
result = true;
}
G4int Z = targetNucleus.GetZ_asInt();
Z *= 1;
return result;
}
////////////////////////////////////////////////
//
//
G4HadFinalState* G4NeutrinoElectronNcModel::ApplyYourself(
const G4HadProjectile& aTrack, G4Nucleus& targetNucleus)
{
theParticleChange.Clear();
const G4HadProjectile* aParticle = &aTrack;
G4double nuTkin = aParticle->GetKineticEnergy();
if( nuTkin <= LowestEnergyLimit() )
{
theParticleChange.SetEnergyChange(nuTkin);
theParticleChange.SetMomentumChange(aTrack.Get4Momentum().vect().unit());
return &theParticleChange;
}
// sample and make final state in lab frame
G4double eTkin = SampleElectronTkin( aParticle );
if( eTkin > fCutEnergy )
{
G4double ePlab = sqrt( eTkin*(eTkin + 2.*electron_mass_c2) );
G4double cost2 = eTkin*(nuTkin + electron_mass_c2)*(nuTkin + electron_mass_c2);
cost2 /= nuTkin*nuTkin*(eTkin + 2.*electron_mass_c2);
if( cost2 > 1. ) cost2 = 1.;
if( cost2 < 0. ) cost2 = 0.;
G4double cost = sqrt(cost2);
G4double sint = std::sqrt( (1.0 - cost)*(1.0 + cost) );
G4double phi = G4UniformRand()*CLHEP::twopi;
G4ThreeVector eP( sint*std::cos(phi), sint*std::sin(phi), cost );
eP *= ePlab;
G4LorentzVector lvt2( eP, eTkin + electron_mass_c2 );
G4DynamicParticle * aSec = new G4DynamicParticle( theElectron, lvt2 );
theParticleChange.AddSecondary( aSec );
G4LorentzVector lvp1 = aParticle->Get4Momentum();
G4LorentzVector lvt1(0.,0.,0.,electron_mass_c2);
G4LorentzVector lvsum = lvp1+lvt1;
G4LorentzVector lvp2 = lvsum-lvt2;
G4double nuTkin2 = lvp2.e()-aParticle->GetDefinition()->GetPDGMass();
theParticleChange.SetEnergyChange(nuTkin2);
theParticleChange.SetMomentumChange(lvp2.vect().unit());
}
else if( eTkin > 0.0 )
{
theParticleChange.SetLocalEnergyDeposit( eTkin );
nuTkin -= eTkin;
if( nuTkin > 0. )
{
theParticleChange.SetEnergyChange( nuTkin );
theParticleChange.SetMomentumChange( aTrack.Get4Momentum().vect().unit() );
}
}
else
{
theParticleChange.SetEnergyChange( nuTkin );
theParticleChange.SetMomentumChange( aTrack.Get4Momentum().vect().unit() );
}
G4int Z = targetNucleus.GetZ_asInt();
Z *= 1;
return &theParticleChange;
}
//////////////////////////////////////////////////////
//
// sample recoil electron energy in lab frame
G4double G4NeutrinoElectronNcModel::SampleElectronTkin(const G4HadProjectile* aParticle)
{
G4double result = 0., xi, cofL, cofR, cofL2, cofR2, cofLR;
G4double energy = aParticle->GetTotalEnergy();
if( energy == 0.) return result; // vmg: < th?? as in xsc
G4String pName = aParticle->GetDefinition()->GetParticleName();
if( pName == "nu_e")
{
cofL = 0.5 + fSin2tW;
cofR = fSin2tW;
}
else if( pName == "anti_nu_e")
{
cofL = fSin2tW;
cofR = 0.5 + fSin2tW;
}
else if( pName == "nu_mu")
{
cofL = -0.5 + fSin2tW;
cofR = fSin2tW;
}
else if( pName == "anti_nu_mu")
{
cofL = fSin2tW;
cofR = -0.5 + fSin2tW;
}
else if( pName == "nu_tau") // vmg: nu_tau as nu_mu ???
{
cofL = -0.5 + fSin2tW;
cofR = fSin2tW;
}
else if( pName == "anti_nu_tau")
{
cofL = fSin2tW;
cofR = -0.5 + fSin2tW;
}
else
{
return result;
}
xi = 0.5*electron_mass_c2/energy;
cofL2 = cofL*cofL;
cofR2 = cofR*cofR;
cofLR = cofL*cofR;
// cofs of Tkin/Enu 3rd equation
G4double a = cofR2/3.;
G4double b = -(cofR2+cofLR*xi);
G4double c = cofL2+cofR2;
G4double xMax = 1./(1. + xi);
G4double xMax2 = xMax*xMax;
G4double xMax3 = xMax*xMax2;
G4double d = -( a*xMax3 + b*xMax2 + c*xMax );
d *= G4UniformRand();
// G4cout<<a<<" "<<b<<" "<<c<<" "<<d<<G4endl<<G4endl;
// cofs of the incomplete 3rd equation
G4double p = c/a;
p -= b*b/a/a/3.;
G4double q = d/a;
q -= b*c/a/a/3.;
q += 2*b*b*b/a/a/a/27.;
// cofs for the incomplete colutions
G4double D = p*p*p/3./3./3.;
D += q*q/2./2.;
// G4cout<<"D = "<<D<<G4endl;
// D = -D;
// G4complex A1 = G4complex(- q/2., std::sqrt(-D) );
// G4complex A = std::pow(A1,1./3.);
// G4complex B1 = G4complex(- q/2., -std::sqrt(-D) );
// G4complex B = std::pow(B1,1./3.);
G4double A1 = - q/2. + std::sqrt(D);
G4double A = std::pow(A1,1./3.);
G4double B1 = - q/2. - std::sqrt(D);
G4double B = std::pow(-B1,1./3.);
B = -B;
// roots of the incomplete 3rd equation
G4complex y1 = A + B;
// G4complex y2 = -0.5*(A + B) + 0.5*std::sqrt(3.)*(A - B)*G4complex(0.,1.);
// G4complex y3 = -0.5*(A + B) - 0.5*std::sqrt(3.)*(A - B)*G4complex(0.,1.);
G4complex x1 = y1 - b/a/3.;
// G4complex x2 = y2 - b/a/3.;
// G4complex x3 = y3 - b/a/3.;
// G4cout<<"re_x1 = "<<real(x1)<<"; re_x2 = "<<real(x2)<<"; re_x3 = "<<real(x3)<<G4endl;
// G4cout<<"im_x1 = "<<imag(x1)<<"; im_x2 = "<<imag(x2)<<"; im_x3 = "<<imag(x3)<<G4endl<<G4endl;
result = real(x1)*energy;
return result;
}
//
//
///////////////////////////
@@ -0,0 +1,372 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// $Id: G4NeutronElectronElModel.cc 91806 2015-08-06 12:20:45Z gcosmo $
//
// Geant4 Header : G4NeutronElectronElModel
//
// 16.5.17: V.Grichine
//
#include "G4NeutronElectronElModel.hh"
#include "G4SystemOfUnits.hh"
#include "G4ParticleTable.hh"
#include "G4ParticleDefinition.hh"
#include "G4IonTable.hh"
#include "Randomize.hh"
#include "G4Integrator.hh"
#include "G4Electron.hh"
#include "G4PhysicsTable.hh"
#include "G4PhysicsLogVector.hh"
#include "G4PhysicsFreeVector.hh"
using namespace std;
using namespace CLHEP;
G4NeutronElectronElModel::G4NeutronElectronElModel(const G4String& name)
: G4HadronElastic(name)
{
// neutron magneton squared
fM = neutron_mass_c2; // neutron mass
fM2 = fM*fM;
fme = electron_mass_c2;
fme2 = fme*fme;
fMv2 = 0.7056*GeV*GeV;
SetMinEnergy( 0.001*GeV );
SetMaxEnergy( 10.*TeV );
SetLowestEnergyLimit(1.e-6*eV);
theElectron = G4Electron::Electron();
// PDG2016: sin^2 theta Weinberg
fEnergyBin = 200;
fMinEnergy = 1.*MeV;
fMaxEnergy = 10000.*GeV;
fEnergyVector = new G4PhysicsLogVector(fMinEnergy, fMaxEnergy, fEnergyBin);
fAngleBin = 500;
fAngleTable = 0;
fCutEnergy = 0.; // default value
Initialise();
}
////////////////////////////////////////////////
G4NeutronElectronElModel::~G4NeutronElectronElModel()
{
if( fEnergyVector )
{
delete fEnergyVector;
fEnergyVector = 0;
}
if( fAngleTable )
{
fAngleTable->clearAndDestroy();
delete fAngleTable;
fAngleTable = nullptr;
}
}
/////////////////////////////////////////
void G4NeutronElectronElModel::ModelDescription(std::ostream& outFile) const
{
outFile << "G4NeutronElectronElModel is a neutrino-electron (neutral current) elastic scattering\n"
<< "model which uses the standard model \n"
<< "transfer parameterization. The model is fully relativistic\n";
}
/////////////////////////////////////////////////////////
G4bool G4NeutronElectronElModel::IsApplicable(const G4HadProjectile & aTrack,
G4Nucleus & targetNucleus)
{
G4bool result = false;
G4String pName = aTrack.GetDefinition()->GetParticleName();
// G4double minEnergy = 0.;
G4double energy = aTrack.GetTotalEnergy();
if( fCutEnergy > 0. ) // min detected recoil electron energy
{
// minEnergy = 0.5*(fCutEnergy+sqrt(fCutEnergy*(fCutEnergy+2.*electron_mass_c2)));
}
if( pName == "neutron" &&
energy >= fMinEnergy && energy <= fMaxEnergy )
{
result = true;
}
G4int Z = targetNucleus.GetZ_asInt();
Z *= 1;
return result;
}
////////////////////////////////////////////////////
void G4NeutronElectronElModel::Initialise()
{
G4double result = 0., sum, Tkin, dt, t1, t2;
G4int iTkin, jTransfer;
G4Integrator<G4NeutronElectronElModel, G4double(G4NeutronElectronElModel::*)(G4double)> integral;
fAngleTable = new G4PhysicsTable(fEnergyBin);
for( iTkin = 0; iTkin < fEnergyBin; iTkin++)
{
Tkin = fEnergyVector->GetLowEdgeEnergy(iTkin);
fAm = CalculateAm(Tkin);
dt = 1./fAngleBin;
G4PhysicsFreeVector* vectorT = new G4PhysicsFreeVector(fAngleBin);
sum = 0.;
for( jTransfer = 0; jTransfer < fAngleBin; jTransfer++)
{
t1 = dt*jTransfer;
t2 = t1 + dt;
result = integral.Legendre96( this, &G4NeutronElectronElModel::XscIntegrand, t1, t2 );
sum += result;
// G4cout<<sum<<", ";
vectorT->PutValue(jTransfer, t1, sum);
}
// G4cout<<G4endl;
fAngleTable->insertAt(iTkin,vectorT);
}
return;
}
//////////////////////////////////////////////////////
//
// sample recoil electron energy in lab frame
G4double G4NeutronElectronElModel::SampleSin2HalfTheta(G4double Tkin)
{
G4double result = 0., position;
G4int iTkin, iTransfer;
for( iTkin = 0; iTkin < fEnergyBin; iTkin++)
{
if( Tkin < fEnergyVector->GetLowEdgeEnergy(iTkin) ) break;
}
if ( iTkin >= fEnergyBin ) iTkin = fEnergyBin-1; // Tkin is more then theMaxEnergy
if ( iTkin < 0 ) iTkin = 0; // against negative index, Tkin < theMinEnergy
position = (*(*fAngleTable)(iTkin))(fAngleBin-1)*G4UniformRand();
// G4cout<<"position = "<<position<<G4endl;
for( iTransfer = 0; iTransfer < fAngleBin; iTransfer++)
{
if( position <= (*(*fAngleTable)(iTkin))(iTransfer) ) break;
}
if (iTransfer >= fAngleBin-1) iTransfer = fAngleBin-1;
// G4cout<<"iTransfer = "<<iTransfer<<G4endl;
result = GetTransfer(iTkin, iTransfer, position);
// G4cout<<"t = "<<t<<G4endl;
return result;
}
/////////////////////////////////////////////////
G4double
G4NeutronElectronElModel:: GetTransfer( G4int iTkin, G4int iTransfer, G4double position )
{
G4double x1, x2, y1, y2, randTransfer, delta, mean, epsilon = 1.e-6;
if( iTransfer == 0 || iTransfer == fAngleBin-1 )
{
randTransfer = (*fAngleTable)(iTkin)->GetLowEdgeEnergy(iTransfer);
// iTransfer++;
}
else
{
if ( iTransfer >= G4int((*fAngleTable)(iTkin)->GetVectorLength()) )
{
iTransfer = (*fAngleTable)(iTkin)->GetVectorLength() - 1;
}
y1 = (*(*fAngleTable)(iTkin))(iTransfer-1);
y2 = (*(*fAngleTable)(iTkin))(iTransfer);
x1 = (*fAngleTable)(iTkin)->GetLowEdgeEnergy(iTransfer-1);
x2 = (*fAngleTable)(iTkin)->GetLowEdgeEnergy(iTransfer);
delta = y2 - y1;
mean = y2 + y1;
if ( x1 == x2 ) randTransfer = x2;
else
{
// if ( y1 == y2 )
if ( delta < epsilon*mean )
{
randTransfer = x1 + ( x2 - x1 )*G4UniformRand();
}
else
{
randTransfer = x1 + ( position - y1 )*( x2 - x1 )/delta; // ( y2 - y1 );
}
}
}
return randTransfer;
}
//////////////////////////////////////////////////////////////
//
// Rosenbluth relation (ultra-relativistic!) in the neutron rest frame,
// x = sin^2(theta/2), theta is the electron scattering angle
// Magnetic form factor in the dipole approximation.
G4double G4NeutronElectronElModel::XscIntegrand(G4double x)
{
G4double result = 1., q2, znq2, znf, znf2, znf4;
znq2 = 1. + 2.*fee*x/fM;
q2 = 4.*fee2*x/znq2;
znf = 1 + q2/fMv2;
znf2 = znf*znf;
znf4 = znf2*znf2;
result /= ( x + fAm )*znq2*znq2*znf4;
result *= ( 1 - x )/( 1 + q2/4./fM2 ) + 2.*x;
return result;
}
////////////////////////////////////////////////
//
//
G4HadFinalState* G4NeutronElectronElModel::ApplyYourself(
const G4HadProjectile& aTrack, G4Nucleus& targetNucleus)
{
theParticleChange.Clear();
const G4HadProjectile* aParticle = &aTrack;
G4double Tkin = aParticle->GetKineticEnergy();
fAm = CalculateAm( Tkin);
// G4double En = aParticle->GetTotalEnergy();
if( Tkin <= LowestEnergyLimit() )
{
theParticleChange.SetEnergyChange(Tkin);
theParticleChange.SetMomentumChange(aTrack.Get4Momentum().vect().unit());
return &theParticleChange;
}
// sample e-scattering angle and make final state in lab frame
G4double sin2ht = SampleSin2HalfTheta( Tkin); // in n-rrest frame
// G4cout<<"sin2ht = "<<sin2ht<<G4endl;
G4double eTkin = fee; // fM;
eTkin /= 1.+2.*fee*sin2ht/fM; // fme/En + 2*sin2ht;
eTkin -= fme;
// G4cout<<"eTkin = "<<eTkin<<G4endl;
if( eTkin > fCutEnergy )
{
G4double ePlab = sqrt( eTkin*(eTkin + 2.*fme) );
// G4cout<<"ePlab = "<<ePlab<<G4endl;
G4double cost = 1. - 2*sin2ht;
if( cost > 1. ) cost = 1.;
if( cost < -1. ) cost = -1.;
G4double sint = std::sqrt( (1.0 - cost)*(1.0 + cost) );
G4double phi = G4UniformRand()*CLHEP::twopi;
G4ThreeVector eP( sint*std::cos(phi), sint*std::sin(phi), cost );
eP *= ePlab;
G4LorentzVector lvt2( eP, eTkin + electron_mass_c2 ); // recoil e- in n-rest frame
G4LorentzVector lvp1 = aParticle->Get4Momentum();
G4LorentzVector lvt1(0.,0.,0.,electron_mass_c2);
G4LorentzVector lvsum = lvp1+lvt1;
G4ThreeVector bst = lvp1.boostVector();
lvt2.boost(bst);
// G4cout<<"lvt2 = "<<lvt2<<G4endl;
G4DynamicParticle * aSec = new G4DynamicParticle( theElectron, lvt2 );
theParticleChange.AddSecondary( aSec );
G4LorentzVector lvp2 = lvsum-lvt2;
// G4cout<<"lvp2 = "<<lvp2<<G4endl;
G4double Tkin2 = lvp2.e()-aParticle->GetDefinition()->GetPDGMass();
theParticleChange.SetEnergyChange(Tkin2);
theParticleChange.SetMomentumChange(lvp2.vect().unit());
}
else if( eTkin > 0.0 )
{
theParticleChange.SetLocalEnergyDeposit( eTkin );
Tkin -= eTkin;
if( Tkin > 0. )
{
theParticleChange.SetEnergyChange( Tkin );
theParticleChange.SetMomentumChange( aTrack.Get4Momentum().vect().unit() );
}
}
else
{
theParticleChange.SetEnergyChange( Tkin );
theParticleChange.SetMomentumChange( aTrack.Get4Momentum().vect().unit() );
}
G4int Z = targetNucleus.GetZ_asInt();
Z *= 1;
return &theParticleChange;
}
//
//
///////////////////////////
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4NuclNuclDiffuseElastic.cc 98826 2016-08-12 12:36:07Z gcosmo $
// $Id: G4NuclNuclDiffuseElastic.cc 104887 2017-06-26 07:12:43Z gcosmo $
//
//
// Physics model class G4NuclNuclDiffuseElastic
@@ -115,8 +115,8 @@ G4NuclNuclDiffuseElastic::G4NuclNuclDiffuseElastic()
fNuclearRadius1 = fNuclearRadius2 = fNuclearRadiusSquare
= fRutherfordRatio = fCoulombPhase0 = fHalfRutThetaTg = fHalfRutThetaTg2
= fRutherfordTheta = fProfileLambda = fCofPhase = fCofFar = fCofAlphaMax
= fCofAlphaCoulomb = fSumSigma = fEtaRatio = fReZ = 0.0;
= fRutherfordTheta = fProfileLambda = fCofPhase = fCofFar
= fSumSigma = fEtaRatio = fReZ = 0.0;
fMaxL = 0;
fNuclearRadiusCof = 1.0;