#include "ReflectorProcess.hh" MyReflectorProcess::MyReflectorProcess(const G4String& processName) : G4VDiscreteProcess(processName) { } MyReflectorProcess::~MyReflectorProcess() { } G4double MyReflectorProcess::GetMeanFreePath(const G4Track&, G4double, G4ForceCondition* condition) { *condition = Forced; return DBL_MAX; } G4VParticleChange* MyReflectorProcess::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep) { aParticleChange.Initialize(aTrack); const G4Step* pStep = &aStep; const G4Step* hStep = G4ParallelWorldProcess::GetHyperStep(); if(hStep != nullptr) pStep = hStep; const G4Track* pTrack = &aTrack; G4StepPoint* PreS = pStep->GetPreStepPoint(); G4StepPoint* PostS = pStep->GetPostStepPoint(); if (PreS->GetPhysicalVolume()->GetName()!="physBoxIn") { return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep); } if (PostS->GetStepStatus()!=fGeomBoundary) { return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep); } G4ThreeVector PrePos = PreS->GetPosition(); G4ThreeVector PostPos = PostS->GetPosition(); G4ThreeVector fOldMomentum = PostS->GetMomentumDirection(); G4ThreeVector fNewMomentum = PostS->GetMomentumDirection(); G4bool valid = false; G4Navigator* trackNavigator = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking(); G4ThreeVector normal = trackNavigator->GetGlobalExitNormal(PostPos, &valid); G4ThreeVector pPerp = normal*(fNewMomentum.dot(normal)); fNewMomentum = fNewMomentum - 2*pPerp; aParticleChange.ProposeMomentumDirection(fNewMomentum); return G4VDiscreteProcess::PostStepDoIt(aTrack,aStep); }