Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // This example is provided by the Geant4-DNA 26 // This example is provided by the Geant4-DNA collaboration 27 // Any report or published results obtained us 27 // Any report or published results obtained using the Geant4-DNA software 28 // shall cite the following Geant4-DNA collabo 28 // shall cite the following Geant4-DNA collaboration publication: 29 // Med. Phys. 37 (2010) 4692-4708 29 // Med. Phys. 37 (2010) 4692-4708 30 // and papers 30 // and papers 31 // M. Batmunkh et al. J Radiat Res Appl Sci 8 31 // M. Batmunkh et al. J Radiat Res Appl Sci 8 (2015) 498-507 32 // O. Belov et al. Physica Medica 32 (2016) 15 32 // O. Belov et al. Physica Medica 32 (2016) 1510-1520 33 // The Geant4-DNA web site is available at htt 33 // The Geant4-DNA web site is available at http://geant4-dna.org 34 // << 34 // 35 // ------------------------------------------- 35 // ------------------------------------------------------------------- 36 // November 2016 36 // November 2016 37 // ------------------------------------------- 37 // ------------------------------------------------------------------- 38 // 38 // 39 /// \file TrackingAction.cc << 39 /// \file TrackingAction.cc 40 /// \brief Implementation of the TrackingActio 40 /// \brief Implementation of the TrackingAction class 41 41 42 #include "TrackingAction.hh" 42 #include "TrackingAction.hh" 43 << 43 #include "G4Track.hh" >> 44 #include "G4VSolid.hh" >> 45 #include "G4Region.hh" 44 #include "G4Electron.hh" 46 #include "G4Electron.hh" 45 #include "G4Gamma.hh" 47 #include "G4Gamma.hh" 46 #include "G4Region.hh" << 47 #include "G4RegionStore.hh" 48 #include "G4RegionStore.hh" 48 #include "G4Track.hh" << 49 #include "G4VSolid.hh" << 50 // 49 // >> 50 #include "G4UnitsTable.hh" >> 51 #include "G4SystemOfUnits.hh" >> 52 #include "G4ios.hh" 51 #include "G4LogicalVolume.hh" 53 #include "G4LogicalVolume.hh" 52 #include "G4LogicalVolumeStore.hh" 54 #include "G4LogicalVolumeStore.hh" 53 #include "G4PhysicalVolumeStore.hh" << 54 #include "G4SystemOfUnits.hh" << 55 #include "G4UnitsTable.hh" << 56 #include "G4VPhysicalVolume.hh" 55 #include "G4VPhysicalVolume.hh" 57 #include "G4ios.hh" << 56 #include "G4PhysicalVolumeStore.hh" 58 // 57 // 59 // Bosons 58 // Bosons 60 #include "G4ChargedGeantino.hh" 59 #include "G4ChargedGeantino.hh" 61 #include "G4Gamma.hh" << 62 #include "G4Geantino.hh" 60 #include "G4Geantino.hh" >> 61 #include "G4Gamma.hh" 63 // leptons 62 // leptons 64 #include "G4AntiNeutrinoE.hh" << 65 #include "G4AntiNeutrinoMu.hh" << 66 #include "G4Electron.hh" 63 #include "G4Electron.hh" 67 #include "G4MuonMinus.hh" << 64 #include "G4Positron.hh" 68 #include "G4MuonPlus.hh" 65 #include "G4MuonPlus.hh" 69 #include "G4NeutrinoE.hh" << 66 #include "G4MuonMinus.hh" 70 #include "G4NeutrinoMu.hh" 67 #include "G4NeutrinoMu.hh" 71 #include "G4Positron.hh" << 68 #include "G4AntiNeutrinoMu.hh" >> 69 #include "G4NeutrinoE.hh" >> 70 #include "G4AntiNeutrinoE.hh" 72 // Mesons 71 // Mesons 73 #include "G4AntiKaonZero.hh" << 72 #include "G4PionPlus.hh" >> 73 #include "G4PionMinus.hh" >> 74 #include "G4PionZero.hh" 74 #include "G4Eta.hh" 75 #include "G4Eta.hh" 75 #include "G4EtaPrime.hh" 76 #include "G4EtaPrime.hh" 76 #include "G4KaonMinus.hh" << 77 77 #include "G4KaonPlus.hh" 78 #include "G4KaonPlus.hh" >> 79 #include "G4KaonMinus.hh" 78 #include "G4KaonZero.hh" 80 #include "G4KaonZero.hh" >> 81 #include "G4AntiKaonZero.hh" 79 #include "G4KaonZeroLong.hh" 82 #include "G4KaonZeroLong.hh" 80 #include "G4KaonZeroShort.hh" 83 #include "G4KaonZeroShort.hh" 81 #include "G4PionMinus.hh" << 82 #include "G4PionPlus.hh" << 83 #include "G4PionZero.hh" << 84 // Baryons 84 // Baryons 85 #include "G4AntiNeutron.hh" << 85 #include "G4Proton.hh" 86 #include "G4AntiProton.hh" 86 #include "G4AntiProton.hh" 87 #include "G4Neutron.hh" 87 #include "G4Neutron.hh" 88 #include "G4Proton.hh" << 88 #include "G4AntiNeutron.hh" 89 // Nuclei 89 // Nuclei 90 #include "Run.hh" << 91 << 92 #include "G4Alpha.hh" 90 #include "G4Alpha.hh" 93 #include "G4Deuteron.hh" 91 #include "G4Deuteron.hh" 94 #include "G4GenericIon.hh" << 92 #include "G4Triton.hh" 95 #include "G4He3.hh" 93 #include "G4He3.hh" 96 #include "G4RunManager.hh" << 94 #include "G4GenericIon.hh" 97 #include "G4Step.hh" 95 #include "G4Step.hh" 98 #include "G4StepStatus.hh" 96 #include "G4StepStatus.hh" 99 #include "G4Triton.hh" << 97 #include "Run.hh" >> 98 #include "G4RunManager.hh" 100 99 101 //....oooOO0OOooo........oooOO0OOooo........oo 100 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 102 101 103 TrackingAction::TrackingAction() : G4UserTrack << 102 TrackingAction::TrackingAction() : >> 103 G4UserTrackingAction(), >> 104 RunInitObserver(), fpTargetRegion(0) >> 105 {} 104 106 105 //....oooOO0OOooo........oooOO0OOooo........oo 107 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 106 108 107 TrackingAction::~TrackingAction() 109 TrackingAction::~TrackingAction() 108 { 110 { 109 fpTargetRegion = 0; << 111 fpTargetRegion = 0; 110 } 112 } 111 113 112 //....oooOO0OOooo........oooOO0OOooo........oo 114 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 113 115 114 void TrackingAction::PreUserTrackingAction(con 116 void TrackingAction::PreUserTrackingAction(const G4Track* track) 115 { 117 { 116 // Target volumes << 118 >> 119 // Target volumes 117 G4VPhysicalVolume* volumeStep = track->GetTo 120 G4VPhysicalVolume* volumeStep = track->GetTouchableHandle()->GetVolume(); 118 G4VPhysicalVolume* volumeMedium = G4Physical << 121 G4VPhysicalVolume* volumeMedium = 119 G4VPhysicalVolume* volumeSlice = G4PhysicalV << 122 G4PhysicalVolumeStore::GetInstance()->GetVolume("Medium"); 120 Run* run = static_cast<Run*>(G4RunManager::G << 123 G4VPhysicalVolume* volumeSlice = 121 << 124 G4PhysicalVolumeStore::GetInstance()->GetVolume("BoundingSlice"); 122 // count secondary particles << 125 Run* run = static_cast<Run*>( 123 if (track->GetTrackID() == 1) return; << 126 G4RunManager::GetRunManager()->GetNonConstCurrentRun()); 124 G4String name = track->GetDefinition()->GetP << 127 125 G4double energy = track->GetKineticEnergy(); << 128 //count secondary particles 126 << 129 if (track->GetTrackID() == 1) return; >> 130 G4String name = track->GetDefinition()->GetParticleName(); >> 131 G4double energy = track->GetKineticEnergy(); >> 132 127 // outside bounding slice 133 // outside bounding slice 128 // if (volumeStep == volumeMedium) run->Part << 134 //if (volumeStep == volumeMedium) run->ParticleCount(name,energy); 129 // inside bounding slice << 135 // inside bounding slice 130 // if (volumeStep != volumeMedium) run->Part << 136 //if (volumeStep != volumeMedium) run->ParticleCountNeuron(name,energy); 131 << 137 132 // particles outside neuron structure << 138 // particles outside neuron structure 133 if (volumeStep == volumeMedium || volumeStep << 139 if (volumeStep == volumeMedium || volumeStep == volumeSlice) 134 run->ParticleCount(name, energy); << 140 { 135 } << 141 run->ParticleCount(name,energy); 136 // count secondary particles in neuron << 142 } 137 else // if (volumeStep != volumeMedium && v << 143 // count secondary particles in neuron 138 { << 144 else //if (volumeStep != volumeMedium && volumeStep != volumeSlice) 139 run->ParticleCountNeuron(name, energy); << 145 { 140 } << 146 run->ParticleCountNeuron(name,energy); >> 147 } >> 148 141 } 149 } 142 //....oooOO0OOooo........oooOO0OOooo........oo 150 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 143 151 144 void TrackingAction::PostUserTrackingAction(co 152 void TrackingAction::PostUserTrackingAction(const G4Track* track) 145 { 153 { 146 if (track->GetTrackID() == 1) { << 147 G4cout << "End of tracking primary particl << 148 << G4BestUnit(track->GetKineticEner << 149 } << 150 154 151 Run* run = static_cast<Run*>(G4RunManager::G << 155 if(track->GetTrackID() == 1) >> 156 { >> 157 G4cout<<"End of tracking primary particle, its final energy is :" >> 158 << G4BestUnit(track->GetKineticEnergy(), "Energy")<< G4endl; >> 159 } >> 160 >> 161 Run* run = static_cast<Run*>( >> 162 G4RunManager::GetRunManager()->GetNonConstCurrentRun()); 152 G4double tracklen = track->GetTrackLength(); 163 G4double tracklen = track->GetTrackLength(); 153 if (track->GetTrackID() == 1) run->SetTrackL << 164 if (track->GetTrackID() == 1) run->SetTrackLength(tracklen); 154 // G4cout<< " track length = " << tracklen / << 165 //G4cout<< " track length = " << tracklen / um << G4endl; 155 } 166 } 156 167 157 //....oooOO0OOooo........oooOO0OOooo........oo 168 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 158 void TrackingAction::Initialize() << 169 void >> 170 TrackingAction::Initialize() 159 { 171 { 160 // fpTargetRegion = G4RegionStore::GetInstan << 172 //fpTargetRegion = G4RegionStore::GetInstance()->GetRegion("BoundingSlice"); 161 } 173 } 162 174