Warning, file /geant4/examples/advanced/hadrontherapy/src/HadrontherapySteppingAction.cc was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
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 "G4SteppingManager.hh"
0030 #include "G4TrackVector.hh"
0031 #include "HadrontherapySteppingAction.hh"
0032 #include "G4ios.hh"
0033 #include "G4SteppingManager.hh"
0034 #include "G4Track.hh"
0035 #include "G4Step.hh"
0036 #include "G4StepPoint.hh"
0037 #include "G4TrackStatus.hh"
0038 #include "G4TrackVector.hh"
0039 #include "G4ParticleDefinition.hh"
0040 #include "G4ParticleTypes.hh"
0041 #include "G4UserEventAction.hh"
0042 #include "G4TransportationManager.hh"
0043 #include "G4VSensitiveDetector.hh"
0044 #include "HadrontherapyRunAction.hh"
0045 #include "HadrontherapyMatrix.hh"
0046 #include "G4SystemOfUnits.hh"
0047
0048
0049 HadrontherapySteppingAction::HadrontherapySteppingAction( HadrontherapyRunAction *run)
0050 {
0051 runAction = run;
0052 }
0053
0054
0055 HadrontherapySteppingAction::~HadrontherapySteppingAction()
0056 {
0057 }
0058
0059
0060 void HadrontherapySteppingAction::UserSteppingAction(const G4Step* aStep)
0061 {
0062
0063
0064
0065
0066
0067
0068 G4StepPoint* PreStep = aStep->GetPreStepPoint();
0069 G4StepPoint* PostStep = aStep->GetPostStepPoint();
0070
0071 G4TouchableHandle touchPreStep = PreStep->GetTouchableHandle();
0072 G4TouchableHandle touchPostStep = PostStep->GetTouchableHandle();
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083 G4VPhysicalVolume* volumePre = touchPreStep->GetVolume();
0084
0085
0086
0087 G4String namePre = volumePre->GetName();
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099 G4double eKin = aStep -> GetPreStepPoint() -> GetKineticEnergy();
0100
0101 G4double PosX = aStep->GetTrack()->GetPosition().x();
0102 G4double PosY = aStep->GetTrack()->GetPosition().y();
0103 G4double PosZ = aStep->GetTrack()->GetPosition().z();
0104
0105 G4String volume= aStep->GetTrack()->GetVolume()->GetName();
0106 G4Track* theTrack = aStep->GetTrack();
0107
0108
0109
0110
0111
0112
0113 G4String particleName = aStep->GetTrack()->GetDefinition()->GetParticleName();
0114
0115 G4double momentumX = aStep->GetTrack()->GetMomentumDirection().x();
0116 G4double momentumY = aStep->GetTrack()->GetMomentumDirection().y();
0117 G4double momentumZ = aStep->GetTrack()->GetMomentumDirection().z();
0118
0119
0120 G4ParticleDefinition *particleDef = theTrack -> GetDefinition();
0121 G4int pdg = particleDef ->GetPDGEncoding();
0122
0123 if(namePre == "VirtualLayer")
0124 {
0125 std::ofstream WriteDataIn("Virtual_Layer.txt", std::ios::app);
0126 WriteDataIn
0127
0128 << eKin <<" "
0129 << PosX <<" "
0130 << PosY <<" "
0131 << PosZ <<" "
0132 << momentumX <<" "
0133 << momentumY <<" "
0134 << momentumZ <<" "
0135 << pdg
0136
0137
0138 << G4endl;
0139
0140 theTrack -> SetTrackStatus(fKillTrackAndSecondaries);
0141
0142
0143 }
0144
0145
0146
0147
0148 }
0149
0150
0151