|
||||
File indexing completed on 2025-01-31 09:22:18
0001 // 0002 // ******************************************************************** 0003 // * License and Disclaimer * 0004 // * * 0005 // * The Geant4 software is copyright of the Copyright Holders of * 0006 // * the Geant4 Collaboration. It is provided under the terms and * 0007 // * conditions of the Geant4 Software License, included in the file * 0008 // * LICENSE and available at http://cern.ch/geant4/license . These * 0009 // * include a list of copyright holders. * 0010 // * * 0011 // * Neither the authors of this software system, nor their employing * 0012 // * institutes,nor the agencies providing financial support for this * 0013 // * work make any representation or warranty, express or implied, * 0014 // * regarding this software system or assume any liability for its * 0015 // * use. Please see the license in the file LICENSE and URL above * 0016 // * for the full disclaimer and the limitation of liability. * 0017 // * * 0018 // * This code implementation is the result of the scientific and * 0019 // * technical work of the GEANT4 collaboration. * 0020 // * By using, copying, modifying or distributing the software (or * 0021 // * any work based on the software) you agree to acknowledge its * 0022 // * use in resulting scientific publications, and indicate your * 0023 // * acceptance of all terms of the Geant4 Software license. * 0024 // ******************************************************************** 0025 // 0026 // Hadrontherapy advanced example for Geant4 0027 // See more at: https://twiki.cern.ch/twiki/bin/view/Geant4/AdvancedExamplesHadrontherapy 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 // The followings are calls to usefuls information retrieved at the step level 0064 // Please, comment out them if want to use 0065 0066 // G4Track* theTrack = aStep->GetTrack(); 0067 0068 G4StepPoint* PreStep = aStep->GetPreStepPoint(); 0069 G4StepPoint* PostStep = aStep->GetPostStepPoint(); 0070 0071 G4TouchableHandle touchPreStep = PreStep->GetTouchableHandle(); 0072 G4TouchableHandle touchPostStep = PostStep->GetTouchableHandle(); 0073 0074 //G4double PreStepX =PreStep->GetPosition().x(); 0075 //G4double PreStepY =PreStep->GetPosition().y(); 0076 //G4double PreStepZ =PreStep->GetPosition().z(); 0077 0078 //G4double PostStepX =PostStep->GetPosition().x(); 0079 //G4double PostStepY =PostStep->GetPosition().y(); 0080 //G4double PostStepZ =PostStep->GetPosition().z(); 0081 0082 //To get the current volume: 0083 G4VPhysicalVolume* volumePre = touchPreStep->GetVolume(); 0084 //G4VPhysicalVolume* volumePost =touchPostStep->GetVolume(); 0085 0086 //To get its name: 0087 G4String namePre = volumePre->GetName(); 0088 0089 0090 // positions in the global coordinate system: 0091 //G4ThreeVector posPreStep = PreStep->GetPosition(); 0092 //G4ThreeVector posPostStep = PostStep->GetPosition(); 0093 0094 //G4int eventNum = G4RunManager::GetRunManager() -> GetCurrentEvent() -> GetEventID(); 0095 0096 //G4double parentID =aStep->GetTrack()->GetParentID(); 0097 //G4double trackID =aStep->GetTrack()->GetTrackID(); 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 //G4String material= aStep -> GetTrack() -> GetMaterial() -> GetName(); 0109 //G4cout << "material " << material << G4endl; 0110 //G4String volume= aStep->GetTrack()->GetVolume()->GetName(); 0111 //G4String pvname= pv-> GetName(); 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 <<" " // 1 0129 << PosX <<" " // 2 0130 << PosY <<" " // 3 0131 << PosZ <<" " // 4 0132 << momentumX <<" " // 5 0133 << momentumY <<" " // 6 0134 << momentumZ <<" " // 7 0135 << pdg 0136 //<< theTrack << '\t' << " " 0137 0138 << G4endl; 0139 0140 theTrack -> SetTrackStatus(fKillTrackAndSecondaries); 0141 0142 0143 } 0144 0145 0146 0147 0148 } 0149 0150 0151
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |