Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
F04SteppingAction.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
28 //
29 //
30 #include "G4Track.hh"
31 
32 #include "F04SteppingAction.hh"
33 #include "G4SteppingManager.hh"
35 
36 #include "G4ParticleTypes.hh"
37 #include "G4LogicalVolumeStore.hh"
38 
40 
41 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
42 
45  fSteppingMessenger(0),
46  fTargetVolume(0),
47  fTestPlaneVolume(0)
48 {
49  fSteppingMessenger = new F04SteppingActionMessenger(this);
50 }
51 
52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
53 
55 {
56  delete fSteppingMessenger ;
57 }
58 
59 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
60 
62 {
63  G4Track* theTrack = theStep->GetTrack();
64 
65  // Get pointers to test volumes (only once)
66  if ( ! fTargetVolume ) {
67  fTargetVolume
69  fTestPlaneVolume
71  }
72 
73  if (theTrack->GetParentID()==0) {
74  //This is a primary track
75  G4LogicalVolume* theVolume
77  if (theVolume != fTargetVolume) {
78  theTrack->SetTrackStatus(fStopAndKill);
79  return;
80  }
81  }
82 
83 // G4ParticleDefinition* particleType = theTrack->GetDefinition();
84 
85  // check if it is entering the test volume
86  G4StepPoint* thePrePoint = theStep->GetPreStepPoint();
87  G4VPhysicalVolume* thePrePV = thePrePoint->GetPhysicalVolume();
88  G4LogicalVolume* thePreLV = thePrePV->GetLogicalVolume();
89 
90  G4LogicalVolume* thePostLV = 0;
91  G4StepPoint* thePostPoint = theStep->GetPostStepPoint();
92 
93  if (thePostPoint) {
94  G4VPhysicalVolume* thePostPV = thePostPoint->GetPhysicalVolume();
95  if (thePostPV) thePostLV = thePostPV->GetLogicalVolume();
96  }
97 
98  if (thePostLV == fTestPlaneVolume &&
99  thePreLV != fTestPlaneVolume) {
100 
101 // G4double x = theTrack->GetPosition().x();
102 // G4double y = theTrack->GetPosition().y();
103 
104  G4ThreeVector theMomentumDirection = theTrack->
105  GetDynamicParticle()->GetMomentumDirection();
106 // G4double theTotalMomentum = theTrack->GetDynamicParticle()->
107 // GetTotalMomentum();
108 
109  // then kill the track
110  theTrack->SetTrackStatus(fStopAndKill);
111  return;
112 
113  }
114 
115 // G4double z = theTrack->GetPosition().z();
116 
117  F04UserTrackInformation* trackInformation =
119 
120  if (trackInformation->GetTrackStatusFlag() != reverse) {
121  if (thePreLV != fTargetVolume ) {
122  if ( theTrack-> GetMomentumDirection().z()>0.0 &&
123  theTrack->GetVertexMomentumDirection().z()<0.0 )
124  {
125  trackInformation->SetTrackStatusFlag(reverse);
126  }
127  }
128  }
129 
130  // check if it is alive
131  if (theTrack->GetTrackStatus() == fAlive) { return; }
132 
133  if (thePostPoint->GetProcessDefinedStep() != 0) {
134  if (thePostPoint->GetProcessDefinedStep()->GetProcessName() != "Decay")
135  return;
136  }
137 
138 }