File indexing completed on 2026-09-14 08:28:00
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 #include "F04SteppingAction.hh"
0030
0031 #include "F04UserTrackInformation.hh"
0032
0033 #include "G4LogicalVolumeStore.hh"
0034 #include "G4ParticleTypes.hh"
0035 #include "G4SteppingManager.hh"
0036 #include "G4Track.hh"
0037
0038
0039
0040 void F04SteppingAction::UserSteppingAction(const G4Step* theStep)
0041 {
0042 G4Track* theTrack = theStep->GetTrack();
0043
0044
0045 if (!fTargetVolume) {
0046 fTargetVolume = G4LogicalVolumeStore::GetInstance()->GetVolume("Target");
0047 fTestPlaneVolume = G4LogicalVolumeStore::GetInstance()->GetVolume("TestPlane");
0048 }
0049
0050 if (theTrack->GetParentID() == 0) {
0051
0052 G4LogicalVolume* theVolume =
0053 theStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume();
0054 if (theVolume != fTargetVolume) {
0055 theTrack->SetTrackStatus(fStopAndKill);
0056 return;
0057 }
0058 }
0059
0060
0061
0062
0063 G4StepPoint* thePrePoint = theStep->GetPreStepPoint();
0064 G4VPhysicalVolume* thePrePV = thePrePoint->GetPhysicalVolume();
0065 G4LogicalVolume* thePreLV = thePrePV->GetLogicalVolume();
0066
0067 G4LogicalVolume* thePostLV = nullptr;
0068 G4StepPoint* thePostPoint = theStep->GetPostStepPoint();
0069
0070 if (thePostPoint) {
0071 G4VPhysicalVolume* thePostPV = thePostPoint->GetPhysicalVolume();
0072 if (thePostPV) thePostLV = thePostPV->GetLogicalVolume();
0073 }
0074
0075 if (thePostLV == fTestPlaneVolume && thePreLV != fTestPlaneVolume) {
0076
0077
0078
0079 G4ThreeVector theMomentumDirection = theTrack->GetDynamicParticle()->GetMomentumDirection();
0080
0081
0082
0083
0084 theTrack->SetTrackStatus(fStopAndKill);
0085 return;
0086 }
0087
0088
0089
0090 auto trackInformation = (F04UserTrackInformation*)theTrack->GetUserInformation();
0091
0092 if (trackInformation->GetTrackStatusFlag() != reverse) {
0093 if (thePreLV != fTargetVolume) {
0094 if (theTrack->GetMomentumDirection().z() > 0.0
0095 && theTrack->GetVertexMomentumDirection().z() < 0.0)
0096 {
0097 trackInformation->SetTrackStatusFlag(reverse);
0098 }
0099 }
0100 }
0101
0102
0103 if (theTrack->GetTrackStatus() == fAlive) {
0104 return;
0105 }
0106
0107 if (thePostPoint->GetProcessDefinedStep() != nullptr) {
0108 if (thePostPoint->GetProcessDefinedStep()->GetProcessName() != "Decay") return;
0109 }
0110 }