Import Geant4 11.1.0 source tree

This commit is contained in:
Gabriele Cosmo
2022-12-09 14:43:28 +01:00
parent c07cea1fe0
commit 9f34590941
3810 changed files with 200490 additions and 182326 deletions
+22 -130
View File
@@ -31,74 +31,13 @@
#include "G4ParticleChangeForLoss.hh"
#include "G4SystemOfUnits.hh"
#include "G4Track.hh"
#include "G4Step.hh"
#include "G4DynamicParticle.hh"
#include "G4ExceptionSeverity.hh"
// --------------------------------------------------------------------
G4ParticleChangeForLoss::G4ParticleChangeForLoss()
: G4VParticleChange()
, lowEnergyLimit(1.0 * eV)
{
theSteppingControlFlag = NormalCondition;
// Disable flag that is enabled in G4VParticleChange if G4VERBOSE.
debugFlag = false;
}
// --------------------------------------------------------------------
G4ParticleChangeForLoss::~G4ParticleChangeForLoss()
{
}
// --------------------------------------------------------------------
G4ParticleChangeForLoss::G4ParticleChangeForLoss(
const G4ParticleChangeForLoss& right)
: G4VParticleChange(right)
{
currentTrack = right.currentTrack;
proposedKinEnergy = right.proposedKinEnergy;
lowEnergyLimit = right.lowEnergyLimit;
currentCharge = right.currentCharge;
proposedMomentumDirection = right.proposedMomentumDirection;
}
// --------------------------------------------------------------------
G4ParticleChangeForLoss& G4ParticleChangeForLoss::operator=(
const G4ParticleChangeForLoss& right)
{
if(this != &right)
{
if(theNumberOfSecondaries > 0)
{
for(G4int index = 0; index < theNumberOfSecondaries; ++index)
{
if((*theListOfSecondaries)[index])
delete(*theListOfSecondaries)[index];
}
}
delete theListOfSecondaries;
theListOfSecondaries = new G4TrackFastVector();
theNumberOfSecondaries = right.theNumberOfSecondaries;
for(G4int index = 0; index < theNumberOfSecondaries; ++index)
{
G4Track* newTrack = new G4Track(*((*right.theListOfSecondaries)[index]));
theListOfSecondaries->SetElement(index, newTrack);
}
theStatusChange = right.theStatusChange;
theLocalEnergyDeposit = right.theLocalEnergyDeposit;
theSteppingControlFlag = right.theSteppingControlFlag;
theParentWeight = right.theParentWeight;
isParentWeightProposed = right.isParentWeightProposed;
fSetSecondaryWeightByProcess = right.fSetSecondaryWeightByProcess;
currentTrack = right.currentTrack;
proposedKinEnergy = right.proposedKinEnergy;
currentCharge = right.currentCharge;
proposedMomentumDirection = right.proposedMomentumDirection;
}
return *this;
debugFlag = false;
}
// --------------------------------------------------------------------
@@ -107,7 +46,9 @@ void G4ParticleChangeForLoss::DumpInfo() const
// use base-class DumpInfo
G4VParticleChange::DumpInfo();
G4int oldprc = G4cout.precision(3);
G4long oldprc = G4cout.precision(8);
G4cout << " -----------------------------------------------" << G4endl;
G4cout << " G4ParticleChangeForLoss proposes: " << G4endl;
G4cout << " Charge (eplus) : " << std::setw(20)
<< currentCharge / eplus << G4endl;
G4cout << " Kinetic Energy (MeV): " << std::setw(20)
@@ -121,82 +62,32 @@ void G4ParticleChangeForLoss::DumpInfo() const
G4cout.precision(oldprc);
}
// --------------------------------------------------------------------
G4bool G4ParticleChangeForLoss::CheckIt(const G4Track& aTrack)
{
G4bool itsOK = true;
G4bool exitWithError = false;
G4double accuracy;
// Energy should not be lager than initial value
accuracy = (proposedKinEnergy - aTrack.GetKineticEnergy()) / MeV;
if(accuracy > accuracyForWarning)
{
itsOK = false;
exitWithError = (accuracy > accuracyForException);
#ifdef G4VERBOSE
G4cout << "G4ParticleChangeForLoss::CheckIt: ";
G4cout << "KinEnergy become larger than the initial value!"
<< " Difference: " << accuracy << "[MeV] " << G4endl;
G4cout << aTrack.GetDefinition()->GetParticleName()
<< " E=" << aTrack.GetKineticEnergy() / MeV
<< " pos=" << aTrack.GetPosition().x() / m << ", "
<< aTrack.GetPosition().y() / m << ", "
<< aTrack.GetPosition().z() / m << G4endl;
#endif
}
// dump out information of this particle change
#ifdef G4VERBOSE
if(!itsOK) { DumpInfo(); }
#endif
// exit with error
if(exitWithError)
{
G4Exception("G4ParticleChangeForLoss::CheckIt()", "TRACK004",
EventMustBeAborted, "energy was illegal");
}
// correction
if(!itsOK)
{
proposedKinEnergy = aTrack.GetKineticEnergy();
}
itsOK = (itsOK) && G4VParticleChange::CheckIt(aTrack);
return itsOK;
}
// --------------------------------------------------------------------
G4Step* G4ParticleChangeForLoss::UpdateStepForAlongStep(G4Step* pStep)
{
const G4StepPoint* pPreStepPoint = pStep->GetPreStepPoint();
G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
G4StepPoint* pPreStepPoint = pStep->GetPreStepPoint();
G4Track* pTrack = pStep->GetTrack();
// accumulate change of the kinetic energy
G4double preKinEnergy = pPreStepPoint->GetKineticEnergy();
G4double kinEnergy =
pPostStepPoint->GetKineticEnergy() + (proposedKinEnergy - preKinEnergy);
// update kinetic energy and charge
if(kinEnergy < lowEnergyLimit)
pPostStepPoint->SetCharge(currentCharge);
// calculate velocity
if(kinEnergy > 0.0)
{
theLocalEnergyDeposit += kinEnergy;
kinEnergy = 0.0;
pPostStepPoint->SetKineticEnergy(kinEnergy);
// assuming that mass>0, zero mass particles do not have energy loss
pPostStepPoint->SetVelocity(CLHEP::c_light*ComputeBeta(kinEnergy));
}
else
{
pPostStepPoint->SetKineticEnergy(0.0);
pPostStepPoint->SetVelocity(0.0);
}
else
{
pPostStepPoint->SetCharge(currentCharge);
// calculate velocity
pTrack->SetKineticEnergy(kinEnergy);
pPostStepPoint->SetVelocity(pTrack->CalculateVelocity());
pTrack->SetKineticEnergy(preKinEnergy);
}
pPostStepPoint->SetKineticEnergy(kinEnergy);
if(isParentWeightProposed)
{
@@ -212,18 +103,19 @@ G4Step* G4ParticleChangeForLoss::UpdateStepForAlongStep(G4Step* pStep)
G4Step* G4ParticleChangeForLoss::UpdateStepForPostStep(G4Step* pStep)
{
G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
G4Track* pTrack = pStep->GetTrack();
pPostStepPoint->SetCharge(currentCharge);
pPostStepPoint->SetMomentumDirection(proposedMomentumDirection);
pPostStepPoint->SetKineticEnergy(proposedKinEnergy);
pTrack->SetKineticEnergy(proposedKinEnergy);
if(proposedKinEnergy > 0.0)
{
pPostStepPoint->SetVelocity(pTrack->CalculateVelocity());
pPostStepPoint->SetKineticEnergy(proposedKinEnergy);
// assuming that mass>0, zero mass particles do not have energy loss
pPostStepPoint->SetVelocity(CLHEP::c_light*ComputeBeta(proposedKinEnergy));
}
else
{
pPostStepPoint->SetKineticEnergy(0.0);
pPostStepPoint->SetVelocity(0.0);
}
pPostStepPoint->SetPolarization(proposedPolarization);