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 << 27 // Any report or published results obtained us << 28 // shall cite the following Geant4-DNA collabo << 29 // Med. Phys. 45 (2018) e722-e739 << 30 // Phys. Med. 31 (2015) 861-874 << 31 // Med. Phys. 37 (2010) 4692-4708 << 32 // Int. J. Model. Simul. Sci. Comput. 1 (2010) << 33 // << 34 // The Geant4-DNA web site is available at htt << 35 // << 36 /// \file SteppingAction.cc 26 /// \file SteppingAction.cc 37 /// \brief Implementation of the SteppingActio 27 /// \brief Implementation of the SteppingAction class 38 28 39 #include "SteppingAction.hh" 29 #include "SteppingAction.hh" 40 << 41 #include "HistoManager.hh" << 42 #include "Run.hh" 30 #include "Run.hh" >> 31 #include "HistoManager.hh" 43 32 >> 33 #include "G4SystemOfUnits.hh" 44 #include "G4RunManager.hh" 34 #include "G4RunManager.hh" >> 35 #include "G4Electron.hh" >> 36 #include "G4Gamma.hh" >> 37 #include "G4Proton.hh" >> 38 #include "G4DNAGenericIonsManager.hh" 45 39 46 //....oooOO0OOooo........oooOO0OOooo........oo 40 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 47 41 48 SteppingAction::SteppingAction() : G4UserStepp << 42 SteppingAction::SteppingAction() >> 43 :G4UserSteppingAction() >> 44 {} 49 45 50 //....oooOO0OOooo........oooOO0OOooo........oo 46 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 51 47 52 SteppingAction::~SteppingAction() {} << 48 SteppingAction::~SteppingAction() >> 49 {} 53 50 54 //....oooOO0OOooo........oooOO0OOooo........oo 51 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 55 52 56 void SteppingAction::UserSteppingAction(const 53 void SteppingAction::UserSteppingAction(const G4Step* aStep) 57 { 54 { 58 const G4StepPoint* endPoint = aStep->GetPost 55 const G4StepPoint* endPoint = aStep->GetPostStepPoint(); 59 G4String procName = endPoint->GetProcessDefi 56 G4String procName = endPoint->GetProcessDefinedStep()->GetProcessName(); 60 << 57 61 Run* run = static_cast<Run*>(G4RunManager::G << 58 Run* run = static_cast<Run*>( 62 << 59 G4RunManager::GetRunManager()->GetNonConstCurrentRun()); 63 G4bool transmit = (endPoint->GetStepStatus() << 60 64 if (transmit) { << 61 G4bool transmit = (endPoint->GetStepStatus() <= fGeomBoundary); 65 run->CountProcesses(procName); << 62 if (transmit) { run->CountProcesses(procName); } 66 } << 63 else { 67 else { << 64 // count real processes and sum track length 68 // Count processes and sum track length << 69 G4double stepLength = aStep->GetStepLength 65 G4double stepLength = aStep->GetStepLength(); 70 run->CountProcesses(procName); << 66 run->CountProcesses(procName); 71 run->SumTrack(stepLength); 67 run->SumTrack(stepLength); 72 } 68 } 73 << 69 74 // Call analysis manager << 70 // plot final state 75 G4AnalysisManager* analysisManager = G4Analy 71 G4AnalysisManager* analysisManager = G4AnalysisManager::Instance(); 76 << 72 77 // Scattered primary particle << 73 // scattered primary particle 78 G4int id = 1; 74 G4int id = 1; 79 if (aStep->GetTrack()->GetTrackStatus() == f 75 if (aStep->GetTrack()->GetTrackStatus() == fAlive) { 80 G4double energy = endPoint->GetKineticEner << 76 G4double energy = endPoint->GetKineticEnergy(); 81 analysisManager->FillH1(id, energy); << 77 analysisManager->FillH1(id,energy); 82 id = 2; 78 id = 2; 83 G4ThreeVector direction = endPoint->GetMom 79 G4ThreeVector direction = endPoint->GetMomentumDirection(); 84 // Assuming incident particle shot along x << 80 // assuming incident particle shot along x 85 G4double costeta = direction.x(); << 81 G4double costeta = direction.x(); 86 analysisManager->FillH1(id, costeta); << 82 analysisManager->FillH1(id,costeta); 87 } << 83 } 88 << 84 89 // Secondaries << 85 //secondaries 90 const std::vector<const G4Track*>* secondary << 86 const std::vector<const G4Track*>* secondary 91 for (size_t lp = 0; lp < (*secondary).size() << 87 = aStep->GetSecondaryInCurrentStep(); >> 88 for (size_t lp=0; lp<(*secondary).size(); lp++) { 92 G4double charge = (*secondary)[lp]->GetDef 89 G4double charge = (*secondary)[lp]->GetDefinition()->GetPDGCharge(); 93 if (charge != 0.) { << 90 if (charge != 0.) { id = 3; } else { id = 5; } 94 id = 3; << 95 } << 96 else { << 97 id = 5; << 98 } << 99 G4double energy = (*secondary)[lp]->GetKin 91 G4double energy = (*secondary)[lp]->GetKineticEnergy(); 100 analysisManager->FillH1(id, energy); << 92 analysisManager->FillH1(id,energy); 101 93 102 ++id; 94 ++id; 103 G4ThreeVector direction = (*secondary)[lp] << 95 G4ThreeVector direction = (*secondary)[lp]->GetMomentumDirection(); 104 G4double costeta = direction.x(); 96 G4double costeta = direction.x(); 105 analysisManager->FillH1(id, costeta); << 97 analysisManager->FillH1(id,costeta); 106 << 98 107 // Energy tranferred to charged secondarie << 99 // energy tranferred to charged secondaries 108 if (charge != 0.) { << 100 if (charge != 0.) { run->SumeTransf(energy); } 109 run->SumeTransf(energy); << 110 } << 111 } 101 } 112 << 102 113 // Kill event after first interaction << 103 // kill event after first interaction 114 G4RunManager::GetRunManager()->AbortEvent(); << 104 G4RunManager::GetRunManager()->AbortEvent(); 115 } 105 } 116 106