File indexing completed on 2025-02-23 09:21:18
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
0030
0031 #include "F04SteppingAction.hh"
0032
0033 #include "F04UserTrackInformation.hh"
0034
0035 #include "G4LogicalVolumeStore.hh"
0036 #include "G4ParticleTypes.hh"
0037 #include "G4SteppingManager.hh"
0038 #include "G4Track.hh"
0039
0040
0041
0042 void F04SteppingAction::UserSteppingAction(const G4Step* theStep)
0043 {
0044 G4Track* theTrack = theStep->GetTrack();
0045
0046
0047 if (!fTargetVolume) {
0048 fTargetVolume = G4LogicalVolumeStore::GetInstance()->GetVolume("Target");
0049 fTestPlaneVolume = G4LogicalVolumeStore::GetInstance()->GetVolume("TestPlane");
0050 }
0051
0052 if (theTrack->GetParentID() == 0) {
0053
0054 G4LogicalVolume* theVolume =
0055 theStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume();
0056 if (theVolume != fTargetVolume) {
0057 theTrack->SetTrackStatus(fStopAndKill);
0058 return;
0059 }
0060 }
0061
0062
0063
0064
0065 G4StepPoint* thePrePoint = theStep->GetPreStepPoint();
0066 G4VPhysicalVolume* thePrePV = thePrePoint->GetPhysicalVolume();
0067 G4LogicalVolume* thePreLV = thePrePV->GetLogicalVolume();
0068
0069 G4LogicalVolume* thePostLV = nullptr;
0070 G4StepPoint* thePostPoint = theStep->GetPostStepPoint();
0071
0072 if (thePostPoint) {
0073 G4VPhysicalVolume* thePostPV = thePostPoint->GetPhysicalVolume();
0074 if (thePostPV) thePostLV = thePostPV->GetLogicalVolume();
0075 }
0076
0077 if (thePostLV == fTestPlaneVolume && thePreLV != fTestPlaneVolume) {
0078
0079
0080
0081 G4ThreeVector theMomentumDirection = theTrack->GetDynamicParticle()->GetMomentumDirection();
0082
0083
0084
0085
0086 theTrack->SetTrackStatus(fStopAndKill);
0087 return;
0088 }
0089
0090
0091
0092 auto trackInformation = (F04UserTrackInformation*)theTrack->GetUserInformation();
0093
0094 if (trackInformation->GetTrackStatusFlag() != reverse) {
0095 if (thePreLV != fTargetVolume) {
0096 if (theTrack->GetMomentumDirection().z() > 0.0
0097 && theTrack->GetVertexMomentumDirection().z() < 0.0)
0098 {
0099 trackInformation->SetTrackStatusFlag(reverse);
0100 }
0101 }
0102 }
0103
0104
0105 if (theTrack->GetTrackStatus() == fAlive) {
0106 return;
0107 }
0108
0109 if (thePostPoint->GetProcessDefinedStep() != nullptr) {
0110 if (thePostPoint->GetProcessDefinedStep()->GetProcessName() != "Decay") return;
0111 }
0112 }