File indexing completed on 2025-01-31 09:22:04
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 #include "FlashSteppingAction.hh"
0031 #include "FlashDetectorConstruction.hh"
0032 #include "FlashEventAction.hh"
0033 #include "FlashRunAction.hh"
0034 #include "G4Electron.hh"
0035 #include "G4Event.hh"
0036 #include "G4Gamma.hh"
0037 #include "G4LogicalVolume.hh"
0038 #include "G4RunManager.hh"
0039 #include "G4Step.hh"
0040 #include "G4Threading.hh"
0041 #include "G4Track.hh"
0042 #include <sstream>
0043 #include <string>
0044
0045 FlashSteppingAction::FlashSteppingAction(FlashEventAction *)
0046 : G4UserSteppingAction()
0047
0048 {
0049
0050
0051 }
0052
0053 FlashSteppingAction::~FlashSteppingAction() {
0054 }
0055
0056 void FlashSteppingAction::UserSteppingAction(const G4Step *aStep)
0057 {
0058
0059 G4int eventid =
0060 G4RunManager::GetRunManager()->GetCurrentEvent()->GetEventID();
0061 G4StepPoint *postStep = aStep->GetPostStepPoint();
0062 G4StepPoint *preStep = aStep->GetPreStepPoint();
0063
0064
0065
0066
0067
0068
0069
0070 if (postStep->GetStepStatus() == fGeomBoundary)
0071 {
0072
0073 G4String volumeName =
0074 postStep->GetPhysicalVolume()->GetLogicalVolume()->GetName();
0075 G4String prevolumeName =
0076 preStep->GetPhysicalVolume()->GetLogicalVolume()->GetName();
0077
0078 G4int parentid = aStep->GetTrack()->GetParentID();
0079
0080 G4double kineticEnergy = aStep->GetTrack()->GetKineticEnergy();
0081 G4double pos_x = aStep->GetTrack()->GetPosition().x();
0082 G4double pos_y = aStep->GetTrack()->GetPosition().y();
0083 G4double pos_z = aStep->GetTrack()->GetPosition().z();
0084 G4double cos_x = aStep->GetTrack()->GetMomentum().x();
0085 G4double cos_y = aStep->GetTrack()->GetMomentum().y();
0086 G4double cos_z = aStep->GetTrack()->GetMomentum().z();
0087
0088 G4double momentum = std::sqrt(cos_x*cos_x+cos_y*cos_y+cos_z*cos_z);
0089
0090
0091
0092 if (aStep->GetTrack()->GetDefinition()==G4Electron::ElectronDefinition() && prevolumeName == "logicTreatmentRoom" && volumeName == "phantomLog")
0093
0094 {
0095
0096 std::ofstream WriteDataIn("PhantomEntrance.txt", std::ios::app);
0097 WriteDataIn
0098
0099 << parentid << "\t"<< eventid << "\t" << kineticEnergy << "\t" <<pos_x<<"\t"<<pos_y<<"\t"<<pos_z<<"\t"<<momentum<<"\t"<<cos_x<<"\t"<<cos_y<<"\t"<<cos_z<<"\t"<<G4endl;
0100
0101
0102 }
0103
0104 }
0105 }