Import Geant4 10.1.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-10 12:08:39 +02:00
parent 286caacf06
commit c9b32a6c0a
5770 changed files with 1050949 additions and 367105 deletions
@@ -35,46 +35,11 @@
#include "G4ChargeState.hh"
G4ChargeState::G4ChargeState(G4double charge,
G4double spin,
G4double magnetic_dipole_moment,
G4double electric_dipole_moment,
G4double magnetic_charge)
{
fCharge = charge;
fSpin = spin;
fMagn_dipole = magnetic_dipole_moment;
fElec_dipole = electric_dipole_moment;
fMagneticCharge = magnetic_charge;
}
G4ChargeState::G4ChargeState( const G4ChargeState& right )
{
fCharge = right.fCharge;
fSpin = right.fSpin;
fMagn_dipole = right.fMagn_dipole;
fElec_dipole = right.fElec_dipole;
fMagneticCharge = right.fMagneticCharge;
}
G4ChargeState& G4ChargeState::operator = ( const G4ChargeState& right )
{
if (&right == this) return *this;
fCharge = right.fCharge;
fSpin = right.fSpin;
fMagn_dipole = right.fMagn_dipole;
fElec_dipole = right.fElec_dipole;
fMagneticCharge = right.fMagneticCharge;
return *this;
}
void G4ChargeState::SetChargeAndMoments(G4double charge,
G4double spin,
G4double magnetic_dipole_moment,
G4double electric_dipole_moment,
G4double magnetic_charge )
void G4ChargeState::SetChargeSpinMoments(G4double charge,
G4double spin,
G4double magnetic_dipole_moment,
G4double electric_dipole_moment,
G4double magnetic_charge )
// Revise the charge and potentially all moments.
// By default do not change mdm, edm, mag charge.
{
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4FieldTrack.cc 66356 2012-12-18 09:02:32Z gcosmo $
// $Id: G4FieldTrack.cc 81175 2014-05-22 07:39:10Z gcosmo $
//
// -------------------------------------------------------------------
@@ -36,12 +36,16 @@ std::ostream& operator<<( std::ostream& os, const G4FieldTrack& SixVec)
os << " ( ";
os << " X= " << SixV[0] << " " << SixV[1] << " "
<< SixV[2] << " "; // Position
os << " V= " << SixV[3] << " " << SixV[4] << " "
os << " P= " << SixV[3] << " " << SixV[4] << " "
<< SixV[5] << " "; // Momentum
os << " v2= "
os << " Pmag= "
<< G4ThreeVector(SixV[3], SixV[4], SixV[5]).mag(); // mom magnitude
os << " mdm= " << SixVec.fMomentumDir.mag();
os << " l= " << SixVec.GetCurveLength();
os << " Ekin= " << SixVec.fKineticEnergy ;
os << " m0= " << SixVec.fRestMass_c2;
os << " Pdir= " << SixVec.fMomentumDir.mag();
os << " l= " << SixVec.GetCurveLength();
os << " t_lab= " << SixVec.fLabTimeOfFlight;
os << " t_proper= " << SixVec.fProperTimeOfFlight ;
os << " ) ";
return os;
}
@@ -52,23 +56,26 @@ G4FieldTrack::G4FieldTrack( const G4ThreeVector& pPosition,
G4double kineticEnergy,
G4double restMass_c2,
G4double charge,
const G4ThreeVector& Spin,
const G4ThreeVector& vecPolarization,
G4double magnetic_dipole_moment,
G4double curve_length )
G4double curve_length,
G4double pdgSpin )
: fDistanceAlongCurve(curve_length),
fKineticEnergy(kineticEnergy),
fRestMass_c2(restMass_c2),
fLabTimeOfFlight(LaboratoryTimeOfFlight),
fProperTimeOfFlight(0.),
// fMomentumDir(pMomentumDirection),
fChargeState( charge, magnetic_dipole_moment )
fChargeState( charge, magnetic_dipole_moment, pdgSpin )
// fChargeState( charge, magnetic_dipole_moment ) ,
// fPDGSpin( pdgSpin )
{
UpdateFourMomentum( kineticEnergy, pMomentumDirection );
// Sets momentum direction as well.
SetPosition( pPosition );
InitialiseSpin( Spin );
SetPolarization( vecPolarization );
}
G4FieldTrack::G4FieldTrack( const G4ThreeVector& pPosition,
@@ -79,32 +86,33 @@ G4FieldTrack::G4FieldTrack( const G4ThreeVector& pPosition,
G4double, // velocity
G4double pLaboratoryTimeOfFlight,
G4double pProperTimeOfFlight,
const G4ThreeVector* pSpin)
const G4ThreeVector* pPolarization,
G4double pdgSpin )
: fDistanceAlongCurve(curve_length),
fKineticEnergy(kineticEnergy),
fRestMass_c2(restMass_c2),
fLabTimeOfFlight(pLaboratoryTimeOfFlight),
fProperTimeOfFlight(pProperTimeOfFlight),
// fMomentumDir(pMomentumDirection),
fChargeState( DBL_MAX ) // charge not set
fChargeState( DBL_MAX, DBL_MAX, -1.0 ) // charge not set
{
UpdateFourMomentum( kineticEnergy, pMomentumDirection );
// Sets momentum direction as well.
SetPosition( pPosition );
G4ThreeVector Spin(0.0, 0.0, 0.0);
if( pSpin ) Spin= *pSpin;
InitialiseSpin( Spin );
fChargeState.SetPDGSpin( pdgSpin );
G4ThreeVector PolarVec(0.0, 0.0, 0.0);
if( pPolarization ) { PolarVec= *pPolarization; }
SetPolarization( PolarVec );
}
G4FieldTrack::G4FieldTrack( char ) // Nothing is set !!
: fKineticEnergy(0.), fRestMass_c2(0.), fLabTimeOfFlight(0.),
fProperTimeOfFlight(0.), fChargeState( DBL_MAX )
fProperTimeOfFlight(0.), fChargeState( DBL_MAX , DBL_MAX, -1 )
{
G4ThreeVector Zero(0.0, 0.0, 0.0);
SetCurvePnt( Zero, Zero, 0.0 );
InitialiseSpin( Zero );
SetPolarization( Zero );
// fInitialMomentumMag= 0.00; // Invalid
// fLastMomentumMag= 0.0;
}
@@ -115,16 +123,68 @@ void G4FieldTrack::
G4double electric_dipole_moment, // ditto
G4double magnetic_charge ) // ditto
{
fChargeState.SetChargeAndMoments( charge, magnetic_dipole_moment,
electric_dipole_moment, magnetic_charge );
fChargeState.SetChargesAndMoments( charge,
magnetic_dipole_moment,
electric_dipole_moment,
magnetic_charge );
// fpChargeState->SetChargeAndMoments( charge, magnetic_dipole_moment,
// electric_dipole_moment, magnetic_charge );
// NOTE: Leaves Spin unchanged !
//
// G4double pdgSpin= fChargeState.GetSpin(); // New Property of ChargeState (not well documented! )
// TO-DO: Improve the implementation using handles
// IDEA: Improve the implementation using handles
// -- and handle to the old one (which can be shared by other copies) and
// must not be left to hang loose
//
// fpChargeState= new G4ChargeState( charge, magnetic_dipole_moment,
// electric_dipole_moment, magnetic_charge );
}
// Load values from array
//
// note that momentum direction must-be/is normalised
void G4FieldTrack::LoadFromArray(const G4double valArrIn[ncompSVEC],
G4int noVarsIntegrated)
{
G4int i;
// Fill the variables not integrated with zero -- so it's clear !!
G4double valArr[ncompSVEC];
for( i=0; i<noVarsIntegrated; i++){
valArr[i]= valArrIn[i];
}
for( i=noVarsIntegrated; i<ncompSVEC; i++) {
valArr[i]= 0.0;
}
SixVector[0]=valArr[0];
SixVector[1]=valArr[1];
SixVector[2]=valArr[2];
SixVector[3]=valArr[3];
SixVector[4]=valArr[4];
SixVector[5]=valArr[5];
G4ThreeVector Momentum(valArr[3],valArr[4],valArr[5]);
G4double momentum_square= Momentum.mag2();
fMomentumDir= Momentum.unit();
fKineticEnergy = momentum_square /
(std::sqrt(momentum_square+fRestMass_c2*fRestMass_c2)
+ fRestMass_c2 );
// The above equation is stable for small and large momenta
// The following components may or may not be
// integrated over -- integration is optional
// fKineticEnergy= valArr[6];
fLabTimeOfFlight=valArr[7];
fProperTimeOfFlight=valArr[8];
G4ThreeVector vecPolarization= G4ThreeVector(valArr[9],valArr[10],valArr[11]);
SetPolarization( vecPolarization );
// fMomentumDir=G4ThreeVector(valArr[13],valArr[14],valArr[15]);
// fDistanceAlongCurve= valArr[];
}
@@ -24,32 +24,12 @@
// ********************************************************************
//
//
// $Id: G4LineSection.cc 66356 2012-12-18 09:02:32Z gcosmo $
// $Id: G4LineSection.cc 85845 2014-11-05 15:43:58Z gcosmo $
//
// --------------------------------------------------------------------
#include "G4LineSection.hh"
G4LineSection::G4LineSection( const G4ThreeVector& PntA,
const G4ThreeVector& PntB )
: EndpointA(PntA),
VecAtoB(PntB-PntA)
{
fABdistanceSq = VecAtoB.mag2() ;
/*
G4double distABsquared = VecAtoB.mag2() ;
if ( distABsquared == 0.0)
{
G4Exception("G4LineSection::G4LineSection()", "GeomField0002",
FatalException, "Equal points in input (line->point) ?") ;
}
else
{
inverse_square_distAB=1.0 / distABsquared ;
}
*/
}
G4double G4LineSection::Dist( G4ThreeVector OtherPnt ) const
{
G4double dist_sq;
@@ -97,12 +77,3 @@ G4double G4LineSection::Dist( G4ThreeVector OtherPnt ) const
return std::sqrt(dist_sq) ;
}
G4double G4LineSection::Distline( const G4ThreeVector& OtherPnt,
const G4ThreeVector& LinePntA,
const G4ThreeVector& LinePntB )
{
G4LineSection LineAB( LinePntA, LinePntB ); // Line from A to B
return LineAB.Dist( OtherPnt );
}
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4MagIntegratorDriver.cc 66872 2013-01-15 01:25:57Z japost $
// $Id: G4MagIntegratorDriver.cc 81175 2014-05-22 07:39:10Z gcosmo $
//
//
//
@@ -553,7 +553,8 @@ G4MagInt_Driver::OneGoodStep( G4double y[], // InOut
const G4int max_trials=100;
G4ThreeVector Spin(y[9],y[10],y[11]);
G4bool hasSpin= (Spin.mag2() > 0.0);
G4double spin_mag2 =Spin.mag2() ;
G4bool hasSpin= (spin_mag2 > 0.0);
for (iter=0; iter<max_trials ;iter++)
{
@@ -569,8 +570,15 @@ G4MagInt_Driver::OneGoodStep( G4double y[], // InOut
errpos_sq *= inv_eps_pos_sq; // Scale relative to required tolerance
// Accuracy for momentum
errvel_sq = (sqr(yerr[3]) + sqr(yerr[4]) + sqr(yerr[5]) )
/ (sqr(y[3]) + sqr(y[4]) + sqr(y[5]) );
G4double magvel_sq= sqr(y[3]) + sqr(y[4]) + sqr(y[5]) ;
G4double sumerr_sq = sqr(yerr[3]) + sqr(yerr[4]) + sqr(yerr[5]) ;
if( magvel_sq > 0.0 ) {
errvel_sq = sumerr_sq / magvel_sq;
}else{
G4cerr << "** G4MagIntegrationDriver: found case of zero momentum."
<< " iteration= " << iter << " h= " << h << G4endl;
errvel_sq = sumerr_sq;
}
errvel_sq *= inv_eps_vel_sq;
errmax_sq = std::max( errpos_sq, errvel_sq ); // Square of maximum error
@@ -578,10 +586,10 @@ G4MagInt_Driver::OneGoodStep( G4double y[], // InOut
{
// Accuracy for spin
errspin_sq = ( sqr(yerr[9]) + sqr(yerr[10]) + sqr(yerr[11]) )
/ ( sqr(y[9]) + sqr(y[10]) + sqr(y[11]) );
/ spin_mag2; // ( sqr(y[9]) + sqr(y[10]) + sqr(y[11]) );
errspin_sq *= inv_eps_vel_sq;
errmax_sq = std::max( errmax_sq, errspin_sq );
}
}
if ( errmax_sq <= 1.0 ) { break; } // Step succeeded.
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4Mag_SpinEqRhs.cc 71664 2013-06-20 08:36:05Z gcosmo $
// $Id: G4Mag_SpinEqRhs.cc 78728 2014-01-20 12:57:20Z gcosmo $
//
// This is the standard right-hand side for equation of motion.
// This version of the right-hand side includes the three components
@@ -57,6 +57,8 @@ G4Mag_SpinEqRhs::SetChargeMomentumMass(G4ChargeState particleCharge,
G4double MomentumXc,
G4double particleMass)
{
G4Mag_EqRhs::SetChargeMomentumMass( particleCharge, MomentumXc, mass);
charge = particleCharge.GetCharge();
mass = particleMass;
magMoment = particleCharge.GetMagneticDipoleMoment();