Import Geant4 11.2.0 source tree

This commit is contained in:
Gabriele Cosmo
2023-12-08 10:43:34 +01:00
parent dd1f179cda
commit 860a2b92bf
3962 changed files with 139318 additions and 164259 deletions
@@ -25,7 +25,7 @@
//
// G4DynamicParticle inline implementation
//
// 17.08.1999 - H.Kurashige
// 17.08.1999 - H.Kurashige
// --------------------------------------------------------------------
extern G4PART_DLL G4Allocator<G4DynamicParticle>*& pDynamicParticleAllocator();
@@ -34,27 +34,24 @@ extern G4PART_DLL G4Allocator<G4DynamicParticle>*& pDynamicParticleAllocator();
// Inlined operators
// ------------------------
inline void * G4DynamicParticle::operator new(size_t)
inline void* G4DynamicParticle::operator new(size_t)
{
if (pDynamicParticleAllocator() == nullptr)
{
if (pDynamicParticleAllocator() == nullptr) {
pDynamicParticleAllocator() = new G4Allocator<G4DynamicParticle>;
}
return pDynamicParticleAllocator()->MallocSingle();
}
inline void G4DynamicParticle::operator delete(void * aDynamicParticle)
inline void G4DynamicParticle::operator delete(void* aDynamicParticle)
{
pDynamicParticleAllocator()
->FreeSingle((G4DynamicParticle *) aDynamicParticle);
pDynamicParticleAllocator()->FreeSingle((G4DynamicParticle*)aDynamicParticle);
}
// ------------------------
// Inlined functions
// ------------------------
inline const G4ElectronOccupancy*
G4DynamicParticle::GetElectronOccupancy() const
inline const G4ElectronOccupancy* G4DynamicParticle::GetElectronOccupancy() const
{
return theElectronOccupancy;
}
@@ -69,11 +66,12 @@ inline G4int G4DynamicParticle::GetOccupancy(G4int orbit) const
return (theElectronOccupancy) != nullptr ? theElectronOccupancy->GetOccupancy(orbit) : 0;
}
inline void G4DynamicParticle::AddElectron(G4int orbit, G4int number)
inline void G4DynamicParticle::AddElectron(G4int orbit, G4int number)
{
if (theElectronOccupancy == nullptr) { AllocateElectronOccupancy(); }
if (theElectronOccupancy != nullptr)
{
if (theElectronOccupancy == nullptr) {
AllocateElectronOccupancy();
}
if (theElectronOccupancy != nullptr) {
G4int n = theElectronOccupancy->AddElectron(orbit, number);
theDynamicalCharge -= CLHEP::eplus * n;
theDynamicalMass += CLHEP::electron_mass_c2 * n;
@@ -82,9 +80,10 @@ inline void G4DynamicParticle::AddElectron(G4int orbit, G4int number)
inline void G4DynamicParticle::RemoveElectron(G4int orbit, G4int number)
{
if (theElectronOccupancy == nullptr) { AllocateElectronOccupancy(); }
if (theElectronOccupancy != nullptr)
{
if (theElectronOccupancy == nullptr) {
AllocateElectronOccupancy();
}
if (theElectronOccupancy != nullptr) {
G4int n = theElectronOccupancy->RemoveElectron(orbit, number);
theDynamicalCharge += CLHEP::eplus * n;
theDynamicalMass -= CLHEP::electron_mass_c2 * n;
@@ -103,7 +102,7 @@ inline void G4DynamicParticle::SetCharge(G4double newCharge)
inline void G4DynamicParticle::SetCharge(G4int newCharge)
{
theDynamicalCharge = newCharge*CLHEP::eplus;
theDynamicalCharge = newCharge * CLHEP::eplus;
}
inline G4double G4DynamicParticle::GetMass() const
@@ -113,8 +112,7 @@ inline G4double G4DynamicParticle::GetMass() const
inline void G4DynamicParticle::SetMass(G4double newMass)
{
if(theDynamicalMass != newMass)
{
if (theDynamicalMass != newMass) {
theDynamicalMass = std::max(newMass, 0.0);
theBeta = -1.0;
}
@@ -125,14 +123,14 @@ inline G4double G4DynamicParticle::GetSpin() const
return theDynamicalSpin;
}
inline void G4DynamicParticle::SetSpin(G4double spin)
inline void G4DynamicParticle::SetSpin(G4double spin)
{
theDynamicalSpin = spin;
}
inline void G4DynamicParticle::SetSpin(G4int spinInUnitOfHalfInteger)
inline void G4DynamicParticle::SetSpin(G4int spinInUnitOfHalfInteger)
{
theDynamicalSpin = spinInUnitOfHalfInteger * 0.5;
theDynamicalSpin = spinInUnitOfHalfInteger * 0.5;
}
inline G4double G4DynamicParticle::GetMagneticMoment() const
@@ -140,9 +138,9 @@ inline G4double G4DynamicParticle::GetMagneticMoment() const
return theDynamicalMagneticMoment;
}
inline void G4DynamicParticle::SetMagneticMoment(G4double magneticMoment)
inline void G4DynamicParticle::SetMagneticMoment(G4double magneticMoment)
{
theDynamicalMagneticMoment = magneticMoment;
theDynamicalMagneticMoment = magneticMoment;
}
inline const G4ThreeVector& G4DynamicParticle::GetMomentumDirection() const
@@ -152,23 +150,20 @@ inline const G4ThreeVector& G4DynamicParticle::GetMomentumDirection() const
inline G4ThreeVector G4DynamicParticle::GetMomentum() const
{
G4double pModule = std::sqrt(theKineticEnergy*theKineticEnergy
+ 2*theKineticEnergy*theDynamicalMass);
G4ThreeVector pMomentum(theMomentumDirection.x()*pModule,
theMomentumDirection.y()*pModule,
theMomentumDirection.z()*pModule);
G4double pModule =
std::sqrt(theKineticEnergy * theKineticEnergy + 2 * theKineticEnergy * theDynamicalMass);
G4ThreeVector pMomentum(theMomentumDirection.x() * pModule, theMomentumDirection.y() * pModule,
theMomentumDirection.z() * pModule);
return pMomentum;
}
inline G4LorentzVector G4DynamicParticle::Get4Momentum() const
inline G4LorentzVector G4DynamicParticle::Get4Momentum() const
{
const G4double mass = theDynamicalMass;
const G4double energy = theKineticEnergy;
const G4double momentum = std::sqrt(energy*energy+2.0*mass*energy);
G4LorentzVector p4( theMomentumDirection.x()*momentum,
theMomentumDirection.y()*momentum,
theMomentumDirection.z()*momentum,
energy+mass );
const G4double mass = theDynamicalMass;
const G4double energy = theKineticEnergy;
const G4double momentum = std::sqrt(energy * energy + 2.0 * mass * energy);
G4LorentzVector p4(theMomentumDirection.x() * momentum, theMomentumDirection.y() * momentum,
theMomentumDirection.z() * momentum, energy + mass);
return p4;
}
@@ -176,7 +171,7 @@ inline G4double G4DynamicParticle::GetTotalMomentum() const
{
// The momentum is returned in energy equivalent
//
return std::sqrt((theKineticEnergy + 2.*theDynamicalMass)* theKineticEnergy);
return std::sqrt((theKineticEnergy + 2. * theDynamicalMass) * theKineticEnergy);
}
inline G4ParticleDefinition* G4DynamicParticle::GetDefinition() const
@@ -184,8 +179,7 @@ inline G4ParticleDefinition* G4DynamicParticle::GetDefinition() const
return const_cast<G4ParticleDefinition*>(theParticleDefinition);
}
inline const G4ParticleDefinition*
G4DynamicParticle::GetParticleDefinition() const
inline const G4ParticleDefinition* G4DynamicParticle::GetParticleDefinition() const
{
return theParticleDefinition;
}
@@ -202,7 +196,7 @@ inline G4double G4DynamicParticle::GetProperTime() const
inline G4double G4DynamicParticle::GetTotalEnergy() const
{
return (theKineticEnergy+theDynamicalMass);
return (theKineticEnergy + theDynamicalMass);
}
inline G4double G4DynamicParticle::GetKineticEnergy() const
@@ -212,22 +206,18 @@ inline G4double G4DynamicParticle::GetKineticEnergy() const
inline G4double G4DynamicParticle::GetLogKineticEnergy() const
{
if (theLogKineticEnergy == DBL_MAX)
{
theLogKineticEnergy = (theKineticEnergy > 0.)
? G4Log(theKineticEnergy) : LOG_EKIN_MIN;
if (theLogKineticEnergy == DBL_MAX) {
theLogKineticEnergy = (theKineticEnergy > 0.) ? G4Log(theKineticEnergy) : LOG_EKIN_MIN;
}
return theLogKineticEnergy;
}
inline void
G4DynamicParticle::SetMomentumDirection(const G4ThreeVector& aDirection)
inline void G4DynamicParticle::SetMomentumDirection(const G4ThreeVector& aDirection)
{
theMomentumDirection = aDirection;
}
inline void
G4DynamicParticle::SetMomentumDirection(G4double px, G4double py, G4double pz)
inline void G4DynamicParticle::SetMomentumDirection(G4double px, G4double py, G4double pz)
{
theMomentumDirection.setX(px);
theMomentumDirection.setY(py);
@@ -239,8 +229,7 @@ inline void G4DynamicParticle::SetPolarization(const G4ThreeVector& vp)
thePolarization = vp;
}
inline void
G4DynamicParticle::SetPolarization(G4double polX, G4double polY, G4double polZ)
inline void G4DynamicParticle::SetPolarization(G4double polX, G4double polY, G4double polZ)
{
thePolarization.setX(polX);
thePolarization.setY(polY);
@@ -249,7 +238,7 @@ G4DynamicParticle::SetPolarization(G4double polX, G4double polY, G4double polZ)
inline void G4DynamicParticle::SetKineticEnergy(G4double aEnergy)
{
if(aEnergy != theKineticEnergy) {
if (aEnergy != theKineticEnergy) {
theLogKineticEnergy = DBL_MAX;
theKineticEnergy = aEnergy;
theBeta = -1.0;
@@ -261,14 +250,12 @@ inline void G4DynamicParticle::SetProperTime(G4double atime)
theProperTime = atime;
}
inline const G4DecayProducts*
G4DynamicParticle::GetPreAssignedDecayProducts() const
inline const G4DecayProducts* G4DynamicParticle::GetPreAssignedDecayProducts() const
{
return thePreAssignedDecayProducts;
}
inline void
G4DynamicParticle::SetPreAssignedDecayProducts(G4DecayProducts* aDecayProducts)
inline void G4DynamicParticle::SetPreAssignedDecayProducts(G4DecayProducts* aDecayProducts)
{
thePreAssignedDecayProducts = aDecayProducts;
}
@@ -277,7 +264,7 @@ inline G4double G4DynamicParticle::GetPreAssignedDecayProperTime() const
{
return thePreAssignedDecayTime;
}
inline void G4DynamicParticle::SetPreAssignedDecayProperTime(G4double aTime)
{
thePreAssignedDecayTime = aTime;
@@ -293,17 +280,17 @@ inline G4int G4DynamicParticle::GetVerboseLevel() const
return verboseLevel;
}
inline void G4DynamicParticle::SetPrimaryParticle(G4PrimaryParticle* p)
inline void G4DynamicParticle::SetPrimaryParticle(G4PrimaryParticle* p)
{
primaryParticle = p;
}
inline G4PrimaryParticle* G4DynamicParticle::GetPrimaryParticle() const
inline G4PrimaryParticle* G4DynamicParticle::GetPrimaryParticle() const
{
return primaryParticle;
}
inline G4int G4DynamicParticle::GetPDGcode() const
inline G4int G4DynamicParticle::GetPDGcode() const
{
G4int code = theParticleDefinition->GetPDGEncoding();
return (code == 0) ? thePDGcode : code;
@@ -316,19 +303,20 @@ inline void G4DynamicParticle::SetPDGcode(G4int c)
inline void G4DynamicParticle::ComputeBeta() const
{
// ultra relativistic particles and particles with mass zero
// ultra relativistic particles and particles with mass zero
theBeta = 1.0;
// other particles
if(theDynamicalMass > 0.0 && theKineticEnergy < 1000*theDynamicalMass)
{
const G4double T = theKineticEnergy/theDynamicalMass;
theBeta = std::sqrt(T*(T+2.))/(T+1.0);
if (theDynamicalMass > 0.0 && theKineticEnergy < 1000 * theDynamicalMass) {
const G4double T = theKineticEnergy / theDynamicalMass;
theBeta = std::sqrt(T * (T + 2.)) / (T + 1.0);
}
}
inline G4double G4DynamicParticle::GetBeta() const
{
if(theBeta < 0.0) { ComputeBeta(); }
if (theBeta < 0.0) {
ComputeBeta();
}
return theBeta;
}