// GLG4DeferTrackProc.cc
// Contact person: Phil Jones
// See GLG4DeferTrackProc.hh for more details
//———————————————————————//
#include "GLG4DeferTrackProc.hh"
#include "G4Step.hh"
#include "G4VParticleChange.hh"
#include "G4EnergyLossTables.hh"
#include "G4GeometryTolerance.hh"
class G4UImessenger; // for G4ProcessTable.hh
#include "G4ProcessTable.hh"
#include
using namespace CLHEP;
#include "GLG4PrimaryGeneratorAction.hh"
////////////////////////////////////////////////////////////////
GLG4DeferTrackProc::GLG4DeferTrackProc(const G4String& aName)
: G4VProcess(aName)
{
if (verboseLevel>0) {
G4cout << GetProcessName() << " is created "<< G4endl;
}
fGenerator= GLG4PrimaryGeneratorAction::GetTheGLG4PrimaryGeneratorAction();
if (fGenerator == 0) {
G4Exception(__FILE__, "No Primary Generator Action", FatalException, "GLG4DeferTrackProc:: no GLG4PrimaryGeneratorAction instance.");
}
}
GLG4DeferTrackProc::~GLG4DeferTrackProc()
{}
////////////////////////////////////////////////////////////////
GLG4DeferTrackProc::GLG4DeferTrackProc(GLG4DeferTrackProc& right)
: G4VProcess(right)
{}
////////////////////////////////////////////////////////////////
G4double GLG4DeferTrackProc::PostStepGetPhysicalInteractionLength(
const G4Track& aTrack,
G4double /* previousStepSize */,
G4ForceCondition* condition
)
{
// condition is set to "Not Forced"
*condition = NotForced;
// apply maximum time limit
G4double dTime= (fGenerator->GetEventWindow() - aTrack.GetGlobalTime());
if (dTime <= 0.0) {
return G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
}
G4double beta = (aTrack.GetDynamicParticle()->GetTotalMomentum())/(aTrack.GetTotalEnergy());
return beta*c_light*dTime;
}
////////////////////////////////////////////////////////////////
G4VParticleChange* GLG4DeferTrackProc::PostStepDoIt(
const G4Track& aTrack,
const G4Step& /* aStep */
)
{
fGenerator->DeferTrackToLaterEvent(&aTrack);
aParticleChange.Initialize(aTrack);
aParticleChange.ProposeTrackStatus(fStopAndKill);
return &aParticleChange;
}
////////////////////////////////////////////////////////////////