Geant4  10.02.p01
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 //
26 // $Id: F04SteppingAction.cc 73014 2013-08-15 08:54:47Z gcosmo $
27 //
30 //
31 
32 #include "G4Track.hh"
33 
34 #include "F04SteppingAction.hh"
35 #include "G4SteppingManager.hh"
37 
38 #include "G4ParticleTypes.hh"
39 #include "G4LogicalVolumeStore.hh"
40 
42 
43 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
44 
47  fSteppingMessenger(0),
48  fTargetVolume(0),
49  fTestPlaneVolume(0)
50 {
52 }
53 
54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
55 
57 {
58  delete fSteppingMessenger ;
59 }
60 
61 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
62 
64 {
65  G4Track* theTrack = theStep->GetTrack();
66 
67  // Get pointers to test volumes (only once)
68  if ( ! fTargetVolume ) {
73  }
74 
75  if (theTrack->GetParentID()==0) {
76  //This is a primary track
77  G4LogicalVolume* theVolume
79  if (theVolume != fTargetVolume) {
80  theTrack->SetTrackStatus(fStopAndKill);
81  return;
82  }
83  }
84 
85 // G4ParticleDefinition* particleType = theTrack->GetDefinition();
86 
87  // check if it is entering the test volume
88  G4StepPoint* thePrePoint = theStep->GetPreStepPoint();
89  G4VPhysicalVolume* thePrePV = thePrePoint->GetPhysicalVolume();
90  G4LogicalVolume* thePreLV = thePrePV->GetLogicalVolume();
91 
92  G4LogicalVolume* thePostLV = 0;
93  G4StepPoint* thePostPoint = theStep->GetPostStepPoint();
94 
95  if (thePostPoint) {
96  G4VPhysicalVolume* thePostPV = thePostPoint->GetPhysicalVolume();
97  if (thePostPV) thePostLV = thePostPV->GetLogicalVolume();
98  }
99 
100  if (thePostLV == fTestPlaneVolume &&
101  thePreLV != fTestPlaneVolume) {
102 
103 // G4double x = theTrack->GetPosition().x();
104 // G4double y = theTrack->GetPosition().y();
105 
106  G4ThreeVector theMomentumDirection = theTrack->
107  GetDynamicParticle()->GetMomentumDirection();
108 // G4double theTotalMomentum = theTrack->GetDynamicParticle()->
109 // GetTotalMomentum();
110 
111  // then kill the track
112  theTrack->SetTrackStatus(fStopAndKill);
113  return;
114 
115  }
116 
117 // G4double z = theTrack->GetPosition().z();
118 
119  F04UserTrackInformation* trackInformation =
121 
122  if (trackInformation->GetTrackStatusFlag() != reverse) {
123  if (thePreLV != fTargetVolume ) {
124  if ( theTrack-> GetMomentumDirection().z()>0.0 &&
125  theTrack->GetVertexMomentumDirection().z()<0.0 )
126  {
127  trackInformation->SetTrackStatusFlag(reverse);
128  }
129  }
130  }
131 
132  // check if it is alive
133  if (theTrack->GetTrackStatus() == fAlive) { return; }
134 
135  if (thePostPoint->GetProcessDefinedStep() != 0) {
136  if (thePostPoint->GetProcessDefinedStep()->GetProcessName() != "Decay")
137  return;
138  }
139 
140 }
void SetTrackStatus(const G4TrackStatus aTrackStatus)
G4int GetParentID() const
Definition of the F04SteppingAction class.
CLHEP::Hep3Vector G4ThreeVector
virtual void UserSteppingAction(const G4Step *)
Definition of the F04UserTrackInformation class.
G4TrackStatus GetTrackStatus() const
G4LogicalVolume * fTestPlaneVolume
G4LogicalVolume * GetVolume(const G4String &name, G4bool verbose=true) const
G4VUserTrackInformation * GetUserInformation() const
G4StepPoint * GetPreStepPoint() const
Definition of the F04SteppingActionMessenger class.
G4VPhysicalVolume * GetPhysicalVolume() const
G4LogicalVolume * fTargetVolume
static G4LogicalVolumeStore * GetInstance()
Definition: G4Step.hh:76
const G4String & GetProcessName() const
Definition: G4VProcess.hh:408
const G4VProcess * GetProcessDefinedStep() const
const G4ThreeVector & GetMomentumDirection() const
G4LogicalVolume * GetLogicalVolume() const
void SetTrackStatusFlag(TrackStatus s)
G4StepPoint * GetPostStepPoint() const
F04SteppingActionMessenger * fSteppingMessenger
TrackStatus GetTrackStatusFlag() const
G4Track * GetTrack() const
const G4ThreeVector & GetVertexMomentumDirection() const
virtual ~F04SteppingAction()