| 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 | //
|
|---|
| 27 | //
|
|---|
| 28 |
|
|---|
| 29 | #include "G4Track.hh"
|
|---|
| 30 |
|
|---|
| 31 | #include "F04SteppingAction.hh"
|
|---|
| 32 | #include "G4SteppingManager.hh"
|
|---|
| 33 | #include "F04SteppingActionMessenger.hh"
|
|---|
| 34 |
|
|---|
| 35 | #include "G4ParticleTypes.hh"
|
|---|
| 36 |
|
|---|
| 37 | #include "F04UserTrackInformation.hh"
|
|---|
| 38 |
|
|---|
| 39 | F04SteppingAction::F04SteppingAction()
|
|---|
| 40 | {
|
|---|
| 41 | steppingMessenger = new F04SteppingActionMessenger(this);
|
|---|
| 42 | }
|
|---|
| 43 |
|
|---|
| 44 | F04SteppingAction::~F04SteppingAction()
|
|---|
| 45 | {
|
|---|
| 46 | delete steppingMessenger ;
|
|---|
| 47 | }
|
|---|
| 48 |
|
|---|
| 49 | void F04SteppingAction::UserSteppingAction(const G4Step* theStep)
|
|---|
| 50 | {
|
|---|
| 51 | G4Track* theTrack = theStep->GetTrack();
|
|---|
| 52 |
|
|---|
| 53 | if (theTrack->GetParentID()==0) {
|
|---|
| 54 | //This is a primary track
|
|---|
| 55 | G4String theVolumeName = theStep->GetPreStepPoint()->
|
|---|
| 56 | GetPhysicalVolume()->GetName();
|
|---|
| 57 | if (theVolumeName != "Target") {
|
|---|
| 58 | theTrack->SetTrackStatus(fStopAndKill);
|
|---|
| 59 | return;
|
|---|
| 60 | }
|
|---|
| 61 | }
|
|---|
| 62 |
|
|---|
| 63 | // G4ParticleDefinition* particleType = theTrack->GetDefinition();
|
|---|
| 64 |
|
|---|
| 65 | // check if it is entering the test volume
|
|---|
| 66 | G4StepPoint* thePrePoint = theStep->GetPreStepPoint();
|
|---|
| 67 | G4VPhysicalVolume* thePrePV = thePrePoint->GetPhysicalVolume();
|
|---|
| 68 | G4String thePrePVname = thePrePV->GetName();
|
|---|
| 69 |
|
|---|
| 70 | G4String thePostPVname = " ";
|
|---|
| 71 | G4StepPoint* thePostPoint = theStep->GetPostStepPoint();
|
|---|
| 72 |
|
|---|
| 73 | if (thePostPoint) {
|
|---|
| 74 | G4VPhysicalVolume* thePostPV = thePostPoint->GetPhysicalVolume();
|
|---|
| 75 | if (thePostPV) thePostPVname = thePostPV->GetName();
|
|---|
| 76 | }
|
|---|
| 77 |
|
|---|
| 78 | if (thePrePVname != "TestPlane" &&
|
|---|
| 79 | thePostPVname == "TestPlane") {
|
|---|
| 80 |
|
|---|
| 81 | // G4double x = theTrack->GetPosition().x();
|
|---|
| 82 | // G4double y = theTrack->GetPosition().y();
|
|---|
| 83 |
|
|---|
| 84 | G4ThreeVector theMomentumDirection = theTrack->
|
|---|
| 85 | GetDynamicParticle()->GetMomentumDirection();
|
|---|
| 86 | // G4double theTotalMomentum = theTrack->GetDynamicParticle()->
|
|---|
| 87 | // GetTotalMomentum();
|
|---|
| 88 |
|
|---|
| 89 | // then kill the track
|
|---|
| 90 | theTrack->SetTrackStatus(fStopAndKill);
|
|---|
| 91 | return;
|
|---|
| 92 |
|
|---|
| 93 | }
|
|---|
| 94 |
|
|---|
| 95 | // G4double z = theTrack->GetPosition().z();
|
|---|
| 96 |
|
|---|
| 97 | F04UserTrackInformation* trackInformation =
|
|---|
| 98 | (F04UserTrackInformation*)theTrack->GetUserInformation();
|
|---|
| 99 |
|
|---|
| 100 | if (trackInformation->GetTrackStatusFlag() != reverse) {
|
|---|
| 101 | if (thePrePVname != "Target" ) {
|
|---|
| 102 | if ( theTrack-> GetMomentumDirection().z()>0.0 &&
|
|---|
| 103 | theTrack->GetVertexMomentumDirection().z()<0.0 )
|
|---|
| 104 | {
|
|---|
| 105 | trackInformation->SetTrackStatusFlag(reverse);
|
|---|
| 106 | }
|
|---|
| 107 | }
|
|---|
| 108 | }
|
|---|
| 109 |
|
|---|
| 110 | // check if it is alive
|
|---|
| 111 | if (theTrack->GetTrackStatus() == fAlive) { return; }
|
|---|
| 112 |
|
|---|
| 113 | if (thePostPoint->GetProcessDefinedStep() != 0) {
|
|---|
| 114 | if (thePostPoint->GetProcessDefinedStep()->GetProcessName() != "Decay") return;
|
|---|
| 115 | }
|
|---|
| 116 |
|
|---|
| 117 | }
|
|---|