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
+16 -4
View File
@@ -16,17 +16,29 @@ committal in the CVS repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
- 09 April 2019 Gabriele Cosmo (particles-V10-04-13)
- 24 May 2019 Vladimir Ivanchenko (particles-V10-05-05)
G4DynamicParticle: make members of the class private; removed boolean
flag; alined class members 3-vectors, doubles, integer; added
initialisation of PDG code and polarization in all constructors;
added method SetPolarisation(const G4ThreeVector&); use CLHEP electron
mass; removed unused forward declarations and headers
- 09 April 2019 Gabriele Cosmo (particles-V10-05-04)
- Fixed typo in G4ElectronOccupancy::operator==().
- 13 Mar 2019 Makoto Asai
- 17 March 2019 Mihaly Novak (particles-V10-05-03)
- G4DynamicParticle: functionality to provide log-kinetic energy value (computed
only on demand if its stored value is not up-to-date with the kinetic energy).
- 13 Mar 2019 Makoto Asai (particles-V10-05-02)
- G4NuclideTableMessenger.cc : fixing a typo.
- 31 Jan 2019 Ivana Hrivnacova
- 31 Jan 2019 Ivana Hrivnacova (particles-V10-05-01)
- Merged GitHub PR #4: all Boolean operators now return G4bool.
- 14 Dec 2018 Makoto Asai
- 14 Dec 2018 Makoto Asai (particles-V10-05-00)
- G4PrimaryParticle.cc: Allowing absolute zero proper decay time.
Co-working with event-V10-05-00 and decay-V10-05-00.
- 09 Nov 2018 Gabriele Cosmo (particles-V10-04-12)
- G4PrimaryVertex: fixed typo in class description.
@@ -42,6 +42,8 @@
// 17 AUg. 1999 H.Kurashige
// Add thePreAssignedDecayTime 18 Jan. 2001 H.Kurashige
// Added MagneticMoment Mar. 2007
// Added GetLogKineticEnergy: the log-kinetic energy value is computed only
// on demand if its stored value is not up-to-date. 15 March 2019 M. Novak
// ------------------------------------------------------------
#ifndef G4DynamicParticle_h
@@ -49,6 +51,7 @@
#include <cmath>
#include <CLHEP/Units/SystemOfUnits.h>
#include <CLHEP/Units/PhysicalConstants.h>
#include "globals.hh"
#include "G4ios.hh"
@@ -56,6 +59,7 @@
#include "G4ParticleDefinition.hh"
#include "G4Allocator.hh"
#include "G4LorentzVector.hh"
#include "G4Log.hh"
#include "G4ParticleMomentum.hh"
// G4ParticleMomentum is "momentum direction" not "momentum vector"
@@ -64,10 +68,8 @@
#include "G4ElectronOccupancy.hh"
class G4PrimaryParticle;
class G4VProcess;
class G4DecayProducts;
class G4DecayProducts;
class G4DynamicParticle
{
@@ -130,7 +132,6 @@ class G4DynamicParticle
void Set4Momentum( const G4LorentzVector &momentum);
// Set the current particle energy-momentum 4vector
G4double GetTotalMomentum() const;
// Returns the module of the momentum vector
G4double GetTotalEnergy() const;
@@ -138,27 +139,28 @@ class G4DynamicParticle
G4double GetKineticEnergy() const;
// Returns the kinetic energy of a particle
G4double GetLogKineticEnergy() const;
// Returns:
// - natural logarithm of the particle kinetic energy (E_k) if E_k > 0
// - LOG_EKIN_MIN otherwise
void SetKineticEnergy(G4double aEnergy);
// Sets the kinetic energy of a particle
G4double GetProperTime() const;
// Returns the current particle proper time
void SetProperTime( G4double );
// Set the current particle Proper Time
const G4ThreeVector& GetPolarization() const;
void SetPolarization(const G4ThreeVector&);
void SetPolarization(G4double polX, G4double polY, G4double polZ);
// Set/Get polarization vector
G4double GetMass() const;
void SetMass(G4double mass);
// set/get dynamical mass
// the dynamical mass is set to PDG mass in default
G4double GetCharge() const;
void SetCharge(G4double charge);
void SetCharge(G4int chargeInUnitOfEplus);
@@ -176,7 +178,6 @@ class G4DynamicParticle
// set/get dynamical MagneticMoment
// the dynamical mass is set to PDG MagneticMoment in default
const G4ElectronOccupancy* GetElectronOccupancy() const;
// Get electron occupancy
// ElectronOccupancy is valid only if the particle is ion
@@ -184,15 +185,13 @@ class G4DynamicParticle
G4int GetOccupancy(G4int orbit) const;
void AddElectron(G4int orbit, G4int number = 1);
void RemoveElectron(G4int orbit, G4int number = 1);
const G4ParticleDefinition* GetParticleDefinition() const;
void SetDefinition(const G4ParticleDefinition * aParticleDefinition);
// Set/Get particle definition
// following method of GetDefinition remains
// because of backward compatiblity. It will be removed in future
G4ParticleDefinition* GetDefinition() const;
const G4DecayProducts *GetPreAssignedDecayProducts() const;
void SetPreAssignedDecayProducts(G4DecayProducts *aDecayProducts);
@@ -203,45 +202,15 @@ class G4DynamicParticle
// Set/Get pre-assigned proper time when the particle will decay
//- print out information
//- print out information
void DumpInfo(G4int mode= 0) const;
// mode 0 : default )(minimum)
// mode 1 : 0 + electron occupancy
protected:
protected:
void AllocateElectronOccupancy();
G4double GetElectronMass() const;
protected:
G4ThreeVector theMomentumDirection;
// The normalized momentum vector
const G4ParticleDefinition *theParticleDefinition;
// Contains the static information of this particle.
G4ThreeVector thePolarization;
G4double theKineticEnergy;
G4double theProperTime;
G4double theDynamicalMass;
G4double theDynamicalCharge;
G4double theDynamicalSpin;
G4double theDynamicalMagneticMoment;
G4ElectronOccupancy* theElectronOccupancy;
G4DecayProducts *thePreAssignedDecayProducts;
G4double thePreAssignedDecayTime;
protected:
G4int verboseLevel;
public: // With Description
void SetVerboseLevel(G4int value);
G4int GetVerboseLevel() const;
@@ -250,13 +219,6 @@ class G4DynamicParticle
// 1: Warning message
// 2: More
protected:
G4PrimaryParticle* primaryParticle;
// This void pointer is used by G4EventManager to maintain the
// link between pre-assigned decay products and corresponding
// primary particle.
public:
void SetPrimaryParticle(G4PrimaryParticle* p);
void SetPDGcode(G4int c);
@@ -273,7 +235,43 @@ class G4DynamicParticle
// corresponding primary particle or pre-assigned decay product will be
// returned if available. Otherwise (e.g. for geantino) returns 0.
protected:
private:
G4ThreeVector theMomentumDirection;
// The normalized momentum vector
G4ThreeVector thePolarization;
const G4ParticleDefinition *theParticleDefinition;
// Contains the static information of this particle.
G4ElectronOccupancy* theElectronOccupancy;
G4DecayProducts *thePreAssignedDecayProducts;
G4PrimaryParticle* primaryParticle;
// This void pointer is used by G4EventManager to maintain the
// link between pre-assigned decay products and corresponding
// primary particle.
G4double theKineticEnergy;
mutable G4double theLogKineticEnergy;
G4double theProperTime;
G4double theDynamicalMass;
G4double theDynamicalCharge;
G4double theDynamicalSpin;
G4double theDynamicalMagneticMoment;
G4double thePreAssignedDecayTime;
G4int verboseLevel;
G4int thePDGcode;
};
@@ -61,39 +61,31 @@ inline const G4ElectronOccupancy* G4DynamicParticle::GetElectronOccupancy() cons
inline G4int G4DynamicParticle::GetTotalOccupancy() const
{
G4int value = 0;
if ( theElectronOccupancy != 0) {
value = theElectronOccupancy->GetTotalOccupancy();
}
return value;
return (theElectronOccupancy) ? theElectronOccupancy->GetTotalOccupancy() : 0;
}
inline G4int G4DynamicParticle::GetOccupancy(G4int orbit) const
inline G4int G4DynamicParticle::GetOccupancy(G4int orbit) const
{
G4int value = 0;
if ( theElectronOccupancy != 0) {
value = theElectronOccupancy->GetOccupancy(orbit);
}
return value;
return (theElectronOccupancy) ? theElectronOccupancy->GetOccupancy(orbit) : 0;
}
inline void G4DynamicParticle::AddElectron(G4int orbit, G4int number )
{
if ( theElectronOccupancy == 0) AllocateElectronOccupancy();
if ( theElectronOccupancy != 0) {
G4int n = theElectronOccupancy->AddElectron(orbit, number );
if (!theElectronOccupancy) { AllocateElectronOccupancy(); }
if ( theElectronOccupancy) {
G4int n = theElectronOccupancy->AddElectron(orbit, number);
theDynamicalCharge -= CLHEP::eplus * n;
theDynamicalMass += GetElectronMass() * n;
theDynamicalMass += CLHEP::electron_mass_c2 * n;
}
}
inline void G4DynamicParticle::RemoveElectron(G4int orbit, G4int number)
inline void G4DynamicParticle::RemoveElectron(G4int orbit, G4int number)
{
if ( theElectronOccupancy == 0) AllocateElectronOccupancy();
if ( theElectronOccupancy != 0) {
if (!theElectronOccupancy) AllocateElectronOccupancy();
if ( theElectronOccupancy) {
G4int n = theElectronOccupancy->RemoveElectron(orbit, number );
theDynamicalCharge += CLHEP::eplus * n;
theDynamicalMass -= GetElectronMass() * n;
theDynamicalMass -= CLHEP::electron_mass_c2 * n;
}
}
@@ -128,7 +120,7 @@ inline void G4DynamicParticle::SetSpin(G4double spin)
theDynamicalSpin = spin;
}
inline void G4DynamicParticle::SetSpin(G4int spinInUnitOfHalfInteger)
inline void G4DynamicParticle::SetSpin(G4int spinInUnitOfHalfInteger)
{
theDynamicalSpin = spinInUnitOfHalfInteger * 0.5;
}
@@ -140,12 +132,12 @@ inline G4double G4DynamicParticle::GetMagneticMoment() const
inline void G4DynamicParticle::SetMagneticMoment(G4double magneticMoment)
{
theDynamicalMagneticMoment = magneticMoment;
theDynamicalMagneticMoment = magneticMoment;
}
inline const G4ThreeVector& G4DynamicParticle::GetMomentumDirection() const
{
return theMomentumDirection;
return theMomentumDirection;
}
inline G4ThreeVector G4DynamicParticle::GetMomentum() const
@@ -183,7 +175,7 @@ inline G4ParticleDefinition* G4DynamicParticle::GetDefinition() const
inline const G4ParticleDefinition* G4DynamicParticle::GetParticleDefinition() const
{
return const_cast<G4ParticleDefinition*>(theParticleDefinition);
return theParticleDefinition;
}
inline const G4ThreeVector& G4DynamicParticle::GetPolarization() const
@@ -206,6 +198,15 @@ inline G4double G4DynamicParticle::GetKineticEnergy() const
return theKineticEnergy;
}
inline G4double G4DynamicParticle::GetLogKineticEnergy() const
{
if (theLogKineticEnergy == DBL_MAX) {
theLogKineticEnergy = (theKineticEnergy > 0.) ?
G4Log(theKineticEnergy) : LOG_EKIN_MIN;
}
return theLogKineticEnergy;
}
inline void G4DynamicParticle::SetMomentumDirection(const G4ThreeVector &aDirection)
{
theMomentumDirection = aDirection;
@@ -218,6 +219,10 @@ inline void G4DynamicParticle::SetMomentumDirection(G4double px, G4double py, G4
theMomentumDirection.setZ(pz);
}
inline void G4DynamicParticle::SetPolarization(const G4ThreeVector & vp)
{
thePolarization = vp;
}
inline void G4DynamicParticle::SetPolarization(G4double polX, G4double polY, G4double polZ)
{
@@ -228,6 +233,7 @@ inline void G4DynamicParticle::SetPolarization(G4double polX, G4double polY, G4d
inline void G4DynamicParticle::SetKineticEnergy(G4double aEnergy)
{
theLogKineticEnergy = DBL_MAX;
theKineticEnergy = aEnergy;
}
@@ -259,33 +265,31 @@ inline void G4DynamicParticle::SetPreAssignedDecayProperTime(G4double aTime)
inline
void G4DynamicParticle::SetVerboseLevel(G4int value)
{
verboseLevel = value;
verboseLevel = value;
}
inline
G4int G4DynamicParticle::GetVerboseLevel() const
{
return verboseLevel;
return verboseLevel;
}
inline
void G4DynamicParticle::SetPrimaryParticle(G4PrimaryParticle* p)
{
primaryParticle=p;
primaryParticle=p;
}
inline
G4PrimaryParticle* G4DynamicParticle::GetPrimaryParticle() const
{
return primaryParticle;
return primaryParticle;
}
inline
G4int G4DynamicParticle::GetPDGcode() const
{
G4int code = theParticleDefinition->GetPDGEncoding();
if(code==0) code = thePDGcode;
return code;
return thePDGcode;
}
inline
@@ -61,12 +61,9 @@
//--------------------------------------------------------------
#include "G4DynamicParticle.hh"
#include "G4PhysicalConstants.hh"
#include "G4SystemOfUnits.hh"
#include "G4DecayProducts.hh"
#include "G4LorentzVector.hh"
#include "G4ParticleDefinition.hh"
#include "G4ParticleTable.hh"
#include "G4IonTable.hh"
#include "G4PrimaryParticle.hh"
@@ -76,23 +73,27 @@ G4Allocator<G4DynamicParticle>*& pDynamicParticleAllocator()
return _instance;
}
static const G4double EnergyMomentumRelationAllowance = 1.0e-2*keV;
static const G4double EnergyMomentumRelationAllowance = 1.0e-2*CLHEP::keV;
static const G4double EnergyMRA2 =
EnergyMomentumRelationAllowance*EnergyMomentumRelationAllowance;
////////////////////
G4DynamicParticle::G4DynamicParticle():
theMomentumDirection(0.0,0.0,1.0),
thePolarization(0.0,0.0,0.0),
theParticleDefinition(nullptr),
theElectronOccupancy(nullptr),
thePreAssignedDecayProducts(nullptr),
primaryParticle(nullptr),
theKineticEnergy(0.0),
theLogKineticEnergy(DBL_MAX),
theProperTime(0.0),
theDynamicalMass(0.0),
theDynamicalCharge(0.0),
theDynamicalSpin(0.0),
theDynamicalMagneticMoment(0.0),
theElectronOccupancy(nullptr),
thePreAssignedDecayProducts(nullptr),
thePreAssignedDecayTime(-1.0),
verboseLevel(1),
primaryParticle(nullptr),
thePDGcode(0)
{
}
@@ -104,18 +105,20 @@ G4DynamicParticle::G4DynamicParticle(const G4ParticleDefinition * aParticleDefin
const G4ThreeVector& aMomentumDirection,
G4double aKineticEnergy):
theMomentumDirection(aMomentumDirection),
thePolarization(0.0,0.0,0.0),
theParticleDefinition(aParticleDefinition),
theElectronOccupancy(nullptr),
thePreAssignedDecayProducts(nullptr),
primaryParticle(nullptr),
theKineticEnergy(aKineticEnergy),
theLogKineticEnergy(DBL_MAX),
theProperTime(0.0),
theDynamicalMass(aParticleDefinition->GetPDGMass()),
theDynamicalCharge(aParticleDefinition->GetPDGCharge()),
theDynamicalSpin(aParticleDefinition->GetPDGSpin()),
theDynamicalMagneticMoment(aParticleDefinition->GetPDGMagneticMoment()),
theElectronOccupancy(0),
thePreAssignedDecayProducts(nullptr),
thePreAssignedDecayTime(-1.0),
verboseLevel(1),
primaryParticle(0),
thePDGcode(0)
{
}
@@ -126,19 +129,21 @@ G4DynamicParticle::G4DynamicParticle(const G4ParticleDefinition * aParticleDefin
G4double aKineticEnergy,
const G4double dynamicalMass):
theMomentumDirection(aMomentumDirection),
thePolarization(0.0,0.0,0.0),
theParticleDefinition(aParticleDefinition),
theElectronOccupancy(nullptr),
thePreAssignedDecayProducts(nullptr),
primaryParticle(nullptr),
theKineticEnergy(aKineticEnergy),
theLogKineticEnergy(DBL_MAX),
theProperTime(0.0),
theDynamicalMass(aParticleDefinition->GetPDGMass()),
theDynamicalCharge(aParticleDefinition->GetPDGCharge()),
theDynamicalSpin(aParticleDefinition->GetPDGSpin()),
theDynamicalMagneticMoment(aParticleDefinition->GetPDGMagneticMoment()),
theElectronOccupancy(nullptr),
thePreAssignedDecayProducts(nullptr),
thePreAssignedDecayTime(-1.0),
verboseLevel(1),
primaryParticle(nullptr),
thePDGcode(0)
thePDGcode(aParticleDefinition->GetPDGEncoding())
{
if (std::abs(theDynamicalMass-dynamicalMass)> EnergyMomentumRelationAllowance) {
if (dynamicalMass>EnergyMomentumRelationAllowance) theDynamicalMass= dynamicalMass;
@@ -149,19 +154,21 @@ G4DynamicParticle::G4DynamicParticle(const G4ParticleDefinition * aParticleDefin
////////////////////
G4DynamicParticle::G4DynamicParticle(const G4ParticleDefinition * aParticleDefinition,
const G4ThreeVector& aParticleMomentum):
thePolarization(0.0,0.0,0.0),
theParticleDefinition(aParticleDefinition),
theElectronOccupancy(nullptr),
thePreAssignedDecayProducts(nullptr),
primaryParticle(nullptr),
theKineticEnergy(0.0),
theLogKineticEnergy(DBL_MAX),
theProperTime(0.0),
theDynamicalMass(aParticleDefinition->GetPDGMass()),
theDynamicalCharge(aParticleDefinition->GetPDGCharge()),
theDynamicalSpin(aParticleDefinition->GetPDGSpin()),
theDynamicalMagneticMoment(aParticleDefinition->GetPDGMagneticMoment()),
theElectronOccupancy(nullptr),
thePreAssignedDecayProducts(nullptr),
thePreAssignedDecayTime(-1.0),
verboseLevel(1),
primaryParticle(nullptr),
thePDGcode(0)
thePDGcode(aParticleDefinition->GetPDGEncoding())
{
SetMomentum(aParticleMomentum); // 3-dim momentum is given
}
@@ -170,19 +177,21 @@ G4DynamicParticle::G4DynamicParticle(const G4ParticleDefinition * aParticleDefin
////////////////////
G4DynamicParticle::G4DynamicParticle(const G4ParticleDefinition * aParticleDefinition,
const G4LorentzVector &aParticleMomentum):
thePolarization(0.0,0.0,0.0),
theParticleDefinition(aParticleDefinition),
theElectronOccupancy(nullptr),
thePreAssignedDecayProducts(nullptr),
primaryParticle(nullptr),
theKineticEnergy(0.0),
theLogKineticEnergy(DBL_MAX),
theProperTime(0.0),
theDynamicalMass(aParticleDefinition->GetPDGMass()),
theDynamicalCharge(aParticleDefinition->GetPDGCharge()),
theDynamicalSpin(aParticleDefinition->GetPDGSpin()),
theDynamicalMagneticMoment(aParticleDefinition->GetPDGMagneticMoment()),
theElectronOccupancy(nullptr),
thePreAssignedDecayProducts(nullptr),
thePreAssignedDecayTime(-1.0),
verboseLevel(1),
primaryParticle(nullptr),
thePDGcode(0)
thePDGcode(aParticleDefinition->GetPDGEncoding())
{
Set4Momentum(aParticleMomentum); // 4-momentum vector (Lorentz vector) is given
}
@@ -190,19 +199,21 @@ G4DynamicParticle::G4DynamicParticle(const G4ParticleDefinition * aParticleDefin
G4DynamicParticle::G4DynamicParticle(const G4ParticleDefinition * aParticleDefinition,
G4double totalEnergy,
const G4ThreeVector &aParticleMomentum):
thePolarization(0.0,0.0,0.0),
theParticleDefinition(aParticleDefinition),
theElectronOccupancy(nullptr),
thePreAssignedDecayProducts(nullptr),
primaryParticle(nullptr),
theKineticEnergy(0.0),
theLogKineticEnergy(DBL_MAX),
theProperTime(0.0),
theDynamicalMass(aParticleDefinition->GetPDGMass()),
theDynamicalCharge(aParticleDefinition->GetPDGCharge()),
theDynamicalSpin(aParticleDefinition->GetPDGSpin()),
theDynamicalMagneticMoment(aParticleDefinition->GetPDGMagneticMoment()),
theElectronOccupancy(nullptr),
thePreAssignedDecayProducts(nullptr),
thePreAssignedDecayTime(-1.0),
verboseLevel(1),
primaryParticle(nullptr),
thePDGcode(0)
thePDGcode(aParticleDefinition->GetPDGEncoding())
{
// total energy and 3-dim momentum are given
G4double pModule2 = aParticleMomentum.mag2();
@@ -210,13 +221,13 @@ G4DynamicParticle::G4DynamicParticle(const G4ParticleDefinition * aParticleDefin
G4double mass2 = totalEnergy*totalEnergy - pModule2;
G4double PDGmass2 = (aParticleDefinition->GetPDGMass())*(aParticleDefinition->GetPDGMass());
SetMomentumDirection(aParticleMomentum.unit());
if (mass2 < EnergyMomentumRelationAllowance*EnergyMomentumRelationAllowance) {
if (mass2 < EnergyMRA2) {
theDynamicalMass = 0.;
SetKineticEnergy(totalEnergy);
} else {
if (std::abs(PDGmass2-mass2)>EnergyMomentumRelationAllowance*EnergyMomentumRelationAllowance){
theDynamicalMass = std::sqrt(mass2);
SetKineticEnergy(totalEnergy-theDynamicalMass);
if (std::abs(PDGmass2-mass2)>EnergyMRA2){
theDynamicalMass = std::sqrt(mass2);
SetKineticEnergy(totalEnergy-theDynamicalMass);
} else {
SetKineticEnergy(totalEnergy-theDynamicalMass);
}
@@ -230,19 +241,20 @@ G4DynamicParticle::G4DynamicParticle(const G4ParticleDefinition * aParticleDefin
////////////////////
G4DynamicParticle::G4DynamicParticle(const G4DynamicParticle &right):
theMomentumDirection(right.theMomentumDirection),
theParticleDefinition(right.theParticleDefinition),
thePolarization(right.thePolarization),
theParticleDefinition(right.theParticleDefinition),
theElectronOccupancy(nullptr),
thePreAssignedDecayProducts(nullptr), // Do not copy preassignedDecayProducts
primaryParticle(right.primaryParticle),
theKineticEnergy(right.theKineticEnergy),
theProperTime(0.0),
theLogKineticEnergy(right.theLogKineticEnergy),
theProperTime(right.theProperTime),
theDynamicalMass(right.theDynamicalMass),
theDynamicalCharge(right.theDynamicalCharge),
theDynamicalSpin(right.theDynamicalSpin),
theDynamicalMagneticMoment(right.theDynamicalMagneticMoment),
theElectronOccupancy(nullptr),
thePreAssignedDecayProducts(nullptr), // Do not copy preassignedDecayProducts
thePreAssignedDecayTime(-1.0),
verboseLevel(right.verboseLevel),
primaryParticle(right.primaryParticle),
thePDGcode(right.thePDGcode)
{
if (right.theElectronOccupancy != nullptr) {
@@ -291,7 +303,7 @@ G4DynamicParticle & G4DynamicParticle::operator=(const G4DynamicParticle &right)
}
// thePreAssignedDecayProducts must not be copied.
thePreAssignedDecayProducts = 0;
thePreAssignedDecayProducts = nullptr;
thePreAssignedDecayTime = -1.0;
verboseLevel = right.verboseLevel;
@@ -324,11 +336,12 @@ void G4DynamicParticle::SetDefinition(const G4ParticleDefinition * aParticleDefi
theParticleDefinition = aParticleDefinition;
// set Dynamic mass/chrge
// set Dynamic mass/charge
theDynamicalMass = theParticleDefinition->GetPDGMass();
theDynamicalCharge = theParticleDefinition->GetPDGCharge();
theDynamicalSpin = theParticleDefinition->GetPDGSpin();
theDynamicalMagneticMoment = theParticleDefinition->GetPDGMagneticMoment();
thePDGcode = theParticleDefinition->GetPDGEncoding();
// Set electron orbits
if (theElectronOccupancy != nullptr) delete theElectronOccupancy;
@@ -376,7 +389,7 @@ void G4DynamicParticle::SetMomentum(const G4ThreeVector &momentum)
if (pModule2>0.0) {
G4double mass = theDynamicalMass;
SetMomentumDirection(momentum.unit());
SetKineticEnergy(std::sqrt(pModule2 + mass*mass)-mass);
SetKineticEnergy(pModule2/(std::sqrt(pModule2 + mass*mass)+mass));
} else {
SetMomentumDirection(1.0,0.0,0.0);
SetKineticEnergy(0.0);
@@ -392,9 +405,9 @@ void G4DynamicParticle::Set4Momentum(const G4LorentzVector &momentum )
G4double totalenergy = momentum.t();
G4double mass2 = totalenergy*totalenergy - pModule2;
G4double PDGmass2 = (theParticleDefinition->GetPDGMass())*(theParticleDefinition->GetPDGMass());
if (mass2 < EnergyMomentumRelationAllowance*EnergyMomentumRelationAllowance) {
if (mass2 < EnergyMRA2) {
theDynamicalMass = 0.;
} else if (std::abs(PDGmass2-mass2)>EnergyMomentumRelationAllowance*EnergyMomentumRelationAllowance){
} else if (std::abs(PDGmass2-mass2)>EnergyMRA2){
theDynamicalMass = std::sqrt(mass2);
}
SetKineticEnergy(totalenergy-theDynamicalMass);
@@ -404,7 +417,6 @@ void G4DynamicParticle::Set4Momentum(const G4LorentzVector &momentum )
}
}
////////////////////
// --- Dump Information --
////////////////////
@@ -415,19 +427,19 @@ void G4DynamicParticle::DumpInfo(G4int mode) const
G4cout << " G4DynamicParticle::DumpInfo():: !!!Particle type not defined !!!! " << G4endl;
} else {
G4cout << " Particle type - " << theParticleDefinition->GetParticleName() << G4endl
<< " mass: " << GetMass()/GeV << "[GeV]" <<G4endl
<< " charge: " << GetCharge()/eplus << "[e]" <<G4endl
<< " mass: " << GetMass()/CLHEP::GeV << "[GeV]" <<G4endl
<< " charge: " << GetCharge()/CLHEP::eplus << "[e]" <<G4endl
<< " Direction x: " << GetMomentumDirection().x() << ", y: "
<< GetMomentumDirection().y() << ", z: "
<< GetMomentumDirection().z() << G4endl
<< " Total Momentum = " << GetTotalMomentum() /GeV << "[GeV]" << G4endl
<< " Momentum: " << GetMomentum().x() /GeV << "[GeV]" << ", y: "
<< GetMomentum().y() /GeV << "[GeV]" << ", z: "
<< GetMomentum().z() /GeV << "[GeV]" << G4endl
<< " Total Energy = " << GetTotalEnergy()/GeV << "[GeV]" << G4endl
<< " Kinetic Energy = " << GetKineticEnergy() /GeV << "[GeV]" << G4endl
<< " MagneticMoment [MeV/T]: " << GetMagneticMoment()/MeV*tesla << G4endl
<< " ProperTime = " << GetProperTime() /ns << "[ns]" << G4endl;
<< " Total Momentum = " << GetTotalMomentum()/CLHEP::GeV << "[GeV]" << G4endl
<< " Momentum: " << GetMomentum().x() /CLHEP::GeV << "[GeV]" << ", y: "
<< GetMomentum().y() /CLHEP::GeV << "[GeV]" << ", z: "
<< GetMomentum().z() /CLHEP::GeV << "[GeV]" << G4endl
<< " Total Energy = " << GetTotalEnergy()/CLHEP::GeV << "[GeV]" << G4endl
<< " Kinetic Energy = " << GetKineticEnergy() /CLHEP::GeV << "[GeV]" << G4endl
<< " MagneticMoment [MeV/T]: " << GetMagneticMoment()/CLHEP::MeV*CLHEP::tesla << G4endl
<< " ProperTime = " << GetProperTime() /CLHEP::ns << "[ns]" << G4endl;
if (mode>0) {
if( theElectronOccupancy != nullptr) {
@@ -451,19 +463,8 @@ void G4DynamicParticle::SetMass(G4double newMass)
}
}
////////////////////////
G4double G4DynamicParticle::GetElectronMass() const
{
static G4ThreadLocal G4double electronMass = 0.0;
// check if electron exits and get the mass
if (electronMass<=0.0) {
G4ParticleDefinition* electron = G4ParticleTable::GetParticleTable()->FindParticle("e-");
if (electron == nullptr) {
G4Exception("G4DynamicParticle::GetElectronMass()","PART021",
FatalException,"G4DynamicParticle: G4Electron is not defined !!");
}
electronMass = electron->GetPDGMass();
}
return electronMass;
return CLHEP::electron_mass_c2;
}