Import Geant4 9.6.0 source tree
This commit is contained in:
@@ -24,8 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4ParticleChange.cc,v 1.32 2010-07-21 09:30:15 gcosmo Exp $
|
||||
// GEANT4 tag $Name: not supported by cvs2svn $
|
||||
// $Id$
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
@@ -44,6 +43,8 @@
|
||||
// --------------------------------------------------------------
|
||||
|
||||
#include "G4ParticleChange.hh"
|
||||
#include "G4PhysicalConstants.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4Track.hh"
|
||||
#include "G4Step.hh"
|
||||
#include "G4TrackFastVector.hh"
|
||||
@@ -51,8 +52,12 @@
|
||||
#include "G4ExceptionSeverity.hh"
|
||||
|
||||
G4ParticleChange::G4ParticleChange()
|
||||
: G4VParticleChange(), theEnergyChange(0.),
|
||||
: G4VParticleChange(),
|
||||
theMomentumDirectionChange(),
|
||||
thePolarizationChange(),
|
||||
theEnergyChange(0.),
|
||||
theVelocityChange(0.), isVelocityChanged(false),
|
||||
thePositionChange(),
|
||||
theGlobalTime0(0.), theLocalTime0(0.),
|
||||
theTimeChange(0.), theProperTimeChange(0.),
|
||||
theMassChange(0.), theChargeChange(0.),
|
||||
@@ -115,9 +120,12 @@ G4ParticleChange & G4ParticleChange::operator=(const G4ParticleChange &right)
|
||||
}
|
||||
delete theListOfSecondaries;
|
||||
|
||||
theListOfSecondaries = right.theListOfSecondaries;
|
||||
theSizeOftheListOfSecondaries = right.theSizeOftheListOfSecondaries;
|
||||
theNumberOfSecondaries = right.theNumberOfSecondaries;
|
||||
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;
|
||||
theCurrentTrack = right.theCurrentTrack;
|
||||
|
||||
@@ -161,7 +169,7 @@ void G4ParticleChange::AddSecondary(G4DynamicParticle* aParticle,
|
||||
G4bool IsGoodForTracking )
|
||||
{
|
||||
// create track
|
||||
G4Track* aTrack = new G4Track(aParticle, theTimeChange, thePositionChange);
|
||||
G4Track* aTrack = new G4Track(aParticle, GetGlobalTime(), thePositionChange);
|
||||
|
||||
// set IsGoodGorTrackingFlag
|
||||
if (IsGoodForTracking) aTrack->SetGoodForTrackingFlag();
|
||||
@@ -178,7 +186,7 @@ void G4ParticleChange::AddSecondary(G4DynamicParticle* aParticle,
|
||||
G4bool IsGoodForTracking )
|
||||
{
|
||||
// create track
|
||||
G4Track* aTrack = new G4Track(aParticle, theTimeChange, newPosition);
|
||||
G4Track* aTrack = new G4Track(aParticle, GetGlobalTime(), newPosition);
|
||||
|
||||
// set IsGoodGorTrackingFlag
|
||||
if (IsGoodForTracking) aTrack->SetGoodForTrackingFlag();
|
||||
@@ -314,20 +322,8 @@ G4Step* G4ParticleChange::UpdateStepForAlongStep(G4Step* pStep)
|
||||
pPostStepPoint->AddProperTime( theProperTimeChange
|
||||
- pPreStepPoint->GetProperTime());
|
||||
|
||||
if (isParentWeightProposed) {
|
||||
// update weight
|
||||
G4double newWeight= theParentWeight/(pPreStepPoint->GetWeight())
|
||||
* (pPostStepPoint->GetWeight());
|
||||
if (isParentWeightSetByProcess) pPostStepPoint->SetWeight( newWeight );
|
||||
|
||||
if (!fSetSecondaryWeightByProcess) {
|
||||
// Set weight of secondary tracks
|
||||
for (G4int index= 0; index<theNumberOfSecondaries; index++){
|
||||
if ( (*theListOfSecondaries)[index] ) {
|
||||
((*theListOfSecondaries)[index])->SetWeight(newWeight); ;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isParentWeightProposed ){
|
||||
pPostStepPoint->SetWeight( theParentWeight );
|
||||
}
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
@@ -348,7 +344,6 @@ G4Step* G4ParticleChange::UpdateStepForPostStep(G4Step* pStep)
|
||||
// momentum vector.
|
||||
|
||||
G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
|
||||
G4Track* aTrack = pStep->GetTrack();
|
||||
|
||||
// Set Mass/Charge
|
||||
pPostStepPoint->SetMass(theMassChange);
|
||||
@@ -370,20 +365,12 @@ G4Step* G4ParticleChange::UpdateStepForPostStep(G4Step* pStep)
|
||||
pPostStepPoint->SetLocalTime( theTimeChange );
|
||||
pPostStepPoint->SetProperTime( theProperTimeChange );
|
||||
|
||||
if (isParentWeightProposed) {
|
||||
// update weight
|
||||
if( isParentWeightSetByProcess) pPostStepPoint->SetWeight( theParentWeight );
|
||||
if (!fSetSecondaryWeightByProcess) {
|
||||
// Set weight of secondary tracks
|
||||
for (G4int index= 0; index<theNumberOfSecondaries; index++){
|
||||
if ( (*theListOfSecondaries)[index] ) {
|
||||
((*theListOfSecondaries)[index])->SetWeight(theParentWeight); ;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isParentWeightProposed ){
|
||||
pPostStepPoint->SetWeight( theParentWeight );
|
||||
}
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
G4Track* aTrack = pStep->GetTrack();
|
||||
if (debugFlag) CheckIt(*aTrack);
|
||||
#endif
|
||||
|
||||
@@ -397,7 +384,6 @@ G4Step* G4ParticleChange::UpdateStepForAtRest(G4Step* pStep)
|
||||
// A physics process always calculates the final state of the particle
|
||||
|
||||
G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
|
||||
G4Track* aTrack = pStep->GetTrack();
|
||||
|
||||
// Set Mass/Charge
|
||||
pPostStepPoint->SetMass(theMassChange);
|
||||
@@ -419,20 +405,12 @@ G4Step* G4ParticleChange::UpdateStepForAtRest(G4Step* pStep)
|
||||
pPostStepPoint->SetLocalTime( theTimeChange );
|
||||
pPostStepPoint->SetProperTime( theProperTimeChange );
|
||||
|
||||
if (isParentWeightProposed ) {
|
||||
// update weight
|
||||
if (isParentWeightSetByProcess) pPostStepPoint->SetWeight( theParentWeight );
|
||||
if (!fSetSecondaryWeightByProcess) {
|
||||
// Set weight of secondary tracks
|
||||
for (G4int index= 0; index<theNumberOfSecondaries; index++){
|
||||
if ( (*theListOfSecondaries)[index] ) {
|
||||
((*theListOfSecondaries)[index])->SetWeight(theParentWeight); ;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isParentWeightProposed ){
|
||||
pPostStepPoint->SetWeight( theParentWeight );
|
||||
}
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
G4Track* aTrack = pStep->GetTrack();
|
||||
if (debugFlag) CheckIt(*aTrack);
|
||||
#endif
|
||||
|
||||
@@ -509,24 +487,35 @@ G4bool G4ParticleChange::CheckIt(const G4Track& aTrack)
|
||||
{
|
||||
G4bool exitWithError = false;
|
||||
G4double accuracy;
|
||||
static G4int nError = 0;
|
||||
#ifdef G4VERBOSE
|
||||
const G4int maxError = 30;
|
||||
#endif
|
||||
|
||||
// No check in case of "fStopAndKill"
|
||||
if (GetTrackStatus() == fStopAndKill ) {
|
||||
return G4VParticleChange::CheckIt(aTrack);
|
||||
}
|
||||
if (GetTrackStatus() == fStopAndKill ) return G4VParticleChange::CheckIt(aTrack);
|
||||
|
||||
// MomentumDirection should be unit vector
|
||||
G4bool itsOKforMomentum = true;
|
||||
if ( theEnergyChange >0.) {
|
||||
accuracy = std::fabs(theMomentumDirectionChange.mag2()-1.0);
|
||||
if (accuracy > accuracyForWarning) {
|
||||
#ifdef G4VERBOSE
|
||||
G4cout << " G4ParticleChange::CheckIt : ";
|
||||
G4cout << "the Momentum Change is not unit vector !!" << G4endl;
|
||||
G4cout << " Difference: " << accuracy << G4endl;
|
||||
#endif
|
||||
itsOKforMomentum = false;
|
||||
if (accuracy > accuracyForException) exitWithError = true;
|
||||
nError += 1;
|
||||
exitWithError = exitWithError || (accuracy > accuracyForException);
|
||||
#ifdef G4VERBOSE
|
||||
if (nError < maxError) {
|
||||
G4cout << " G4ParticleChange::CheckIt : ";
|
||||
G4cout << "the Momentum Change is not unit vector !!"
|
||||
<< " Difference: " << accuracy << G4endl;
|
||||
G4cout << aTrack.GetDefinition()->GetParticleName()
|
||||
<< " E=" << aTrack.GetKineticEnergy()/MeV
|
||||
<< " pos=" << aTrack.GetPosition().x()/m
|
||||
<< ", " << aTrack.GetPosition().y()/m
|
||||
<< ", " << aTrack.GetPosition().z()/m
|
||||
<<G4endl;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -534,67 +523,118 @@ G4bool G4ParticleChange::CheckIt(const G4Track& aTrack)
|
||||
G4bool itsOKforGlobalTime = true;
|
||||
accuracy = (aTrack.GetLocalTime()- theTimeChange)/ns;
|
||||
if (accuracy > accuracyForWarning) {
|
||||
#ifdef G4VERBOSE
|
||||
G4cout << " G4ParticleChange::CheckIt : ";
|
||||
G4cout << "the local time goes back !!" << G4endl;
|
||||
G4cout << " Difference: " << accuracy << "[ns] " <<G4endl;
|
||||
#endif
|
||||
itsOKforGlobalTime = false;
|
||||
if (accuracy > accuracyForException) exitWithError = true;
|
||||
nError += 1;
|
||||
exitWithError = exitWithError || (accuracy > accuracyForException);
|
||||
#ifdef G4VERBOSE
|
||||
if (nError < maxError) {
|
||||
G4cout << " G4ParticleChange::CheckIt : ";
|
||||
G4cout << "the local time goes back !!"
|
||||
<< " Difference: " << accuracy << "[ns] " <<G4endl;
|
||||
G4cout << aTrack.GetDefinition()->GetParticleName()
|
||||
<< " E=" << aTrack.GetKineticEnergy()/MeV
|
||||
<< " pos=" << aTrack.GetPosition().x()/m
|
||||
<< ", " << aTrack.GetPosition().y()/m
|
||||
<< ", " << aTrack.GetPosition().z()/m
|
||||
<< " global time=" << aTrack.GetGlobalTime()/ns
|
||||
<< " local time=" << aTrack.GetLocalTime()/ns
|
||||
<< " proper time=" << aTrack.GetProperTime()/ns
|
||||
<< G4endl;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
G4bool itsOKforProperTime = true;
|
||||
accuracy = (aTrack.GetProperTime() - theProperTimeChange )/ns;
|
||||
if (accuracy > accuracyForWarning) {
|
||||
#ifdef G4VERBOSE
|
||||
G4cout << " G4ParticleChange::CheckIt : ";
|
||||
G4cout << "the proper time goes back !!" << G4endl;
|
||||
G4cout << " Difference: " << accuracy << "[ns] " <<G4endl;
|
||||
#endif
|
||||
itsOKforProperTime = false;
|
||||
if (accuracy > accuracyForException) exitWithError = true;
|
||||
nError += 1;
|
||||
exitWithError = exitWithError || (accuracy > accuracyForException);
|
||||
#ifdef G4VERBOSE
|
||||
if (nError < maxError) {
|
||||
G4cout << " G4ParticleChange::CheckIt : ";
|
||||
G4cout << "the proper time goes back !!"
|
||||
<< " Difference: " << accuracy << "[ns] " <<G4endl;
|
||||
G4cout << aTrack.GetDefinition()->GetParticleName()
|
||||
<< " E=" << aTrack.GetKineticEnergy()/MeV
|
||||
<< " pos=" << aTrack.GetPosition().x()/m
|
||||
<< ", " << aTrack.GetPosition().y()/m
|
||||
<< ", " << aTrack.GetPosition().z()/m
|
||||
<< " global time=" << aTrack.GetGlobalTime()/ns
|
||||
<< " local time=" << aTrack.GetLocalTime()/ns
|
||||
<< " proper time=" << aTrack.GetProperTime()/ns
|
||||
<<G4endl;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// Kinetic Energy should not be negative
|
||||
G4bool itsOKforEnergy = true;
|
||||
accuracy = -1.0*theEnergyChange/MeV;
|
||||
if (accuracy > accuracyForWarning) {
|
||||
#ifdef G4VERBOSE
|
||||
G4cout << " G4ParticleChange::CheckIt : ";
|
||||
G4cout << "the kinetic energy is negative !!" << G4endl;
|
||||
G4cout << " Difference: " << accuracy << "[MeV] " <<G4endl;
|
||||
#endif
|
||||
itsOKforEnergy = false;
|
||||
if (accuracy > accuracyForException) exitWithError = true;
|
||||
nError += 1;
|
||||
exitWithError = exitWithError || (accuracy > accuracyForException);
|
||||
#ifdef G4VERBOSE
|
||||
if (nError < maxError) {
|
||||
G4cout << " G4ParticleChange::CheckIt : ";
|
||||
G4cout << "the kinetic energy is negative !!"
|
||||
<< " 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
|
||||
}
|
||||
|
||||
// Velocity should not be less than c_light
|
||||
G4bool itsOKforVelocity = true;
|
||||
if (theVelocityChange < 0.) {
|
||||
#ifdef G4VERBOSE
|
||||
G4cout << " G4ParticleChange::CheckIt : ";
|
||||
G4cout << "the velocity is negative !!" << G4endl;
|
||||
G4cout << " Velocity: " << theVelocityChange/c_light <<G4endl;
|
||||
#endif
|
||||
itsOKforVelocity = false;
|
||||
nError += 1;
|
||||
exitWithError = true;
|
||||
#ifdef G4VERBOSE
|
||||
if (nError < maxError) {
|
||||
G4cout << " G4ParticleChange::CheckIt : ";
|
||||
G4cout << "the velocity is negative !!"
|
||||
<< " Velocity: " << theVelocityChange/c_light <<G4endl;
|
||||
G4cout << aTrack.GetDefinition()->GetParticleName()
|
||||
<< " E=" << aTrack.GetKineticEnergy()/MeV
|
||||
<< " pos=" << aTrack.GetPosition().x()/m
|
||||
<< ", " << aTrack.GetPosition().y()/m
|
||||
<< ", " << aTrack.GetPosition().z()/m
|
||||
<<G4endl;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
accuracy = theVelocityChange/c_light - 1.0;
|
||||
if (accuracy > accuracyForWarning) {
|
||||
#ifdef G4VERBOSE
|
||||
G4cout << " G4ParticleChange::CheckIt : ";
|
||||
G4cout << "the velocity is greater than c_light !!" << G4endl;
|
||||
G4cout << " Velocity: " << theVelocityChange/c_light <<G4endl;
|
||||
#endif
|
||||
itsOKforVelocity = false;
|
||||
if (accuracy > accuracyForException) exitWithError = true;
|
||||
}
|
||||
nError += 1;
|
||||
exitWithError = exitWithError || (accuracy > accuracyForException);
|
||||
#ifdef G4VERBOSE
|
||||
if (nError < maxError) {
|
||||
G4cout << " G4ParticleChange::CheckIt : ";
|
||||
G4cout << "the velocity is greater than c_light !!" << G4endl;
|
||||
G4cout << " Velocity: " << theVelocityChange/c_light <<G4endl;
|
||||
G4cout << aTrack.GetDefinition()->GetParticleName()
|
||||
<< " E=" << aTrack.GetKineticEnergy()/MeV
|
||||
<< " pos=" << aTrack.GetPosition().x()/m
|
||||
<< ", " << aTrack.GetPosition().y()/m
|
||||
<< ", " << aTrack.GetPosition().z()/m
|
||||
<<G4endl;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
G4bool itsOK = itsOKforMomentum && itsOKforEnergy && itsOKforVelocity && itsOKforProperTime && itsOKforGlobalTime;
|
||||
// dump out information of this particle change
|
||||
#ifdef G4VERBOSE
|
||||
if (!itsOK) {
|
||||
G4cout << " G4ParticleChange::CheckIt " <<G4endl;
|
||||
DumpInfo();
|
||||
}
|
||||
#endif
|
||||
@@ -611,7 +651,7 @@ G4bool G4ParticleChange::CheckIt(const G4Track& aTrack)
|
||||
theMomentumDirectionChange = (1./vmag)*theMomentumDirectionChange;
|
||||
}
|
||||
if (!itsOKforGlobalTime) {
|
||||
theTimeChange = aTrack.GetGlobalTime();
|
||||
theTimeChange = aTrack.GetLocalTime();
|
||||
}
|
||||
if (!itsOKforProperTime) {
|
||||
theProperTimeChange = aTrack.GetProperTime();
|
||||
@@ -626,6 +666,3 @@ G4bool G4ParticleChange::CheckIt(const G4Track& aTrack)
|
||||
itsOK = (itsOK) && G4VParticleChange::CheckIt(aTrack);
|
||||
return itsOK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user