|
|
|||
File indexing completed on 2026-05-03 07:44:48
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 /// \file PrimaryKiller.cc 0027 /// \brief Implementation of the PrimaryKiller class 0028 0029 // This example is provided by the Geant4-DNA collaboration 0030 // Any report or published results obtained using the Geant4-DNA software 0031 // shall cite the following Geant4-DNA collaboration publication: 0032 // Med. Phys. 37 (2010) 4692-4708 0033 // J. Comput. Phys. 274 (2014) 841-882 0034 // Phys. Med. Biol. 63(10) (2018) 105014-12pp 0035 // The Geant4-DNA web site is available at http://geant4-dna.org 0036 // 0037 // 0038 #include "PrimaryKiller.hh" 0039 0040 #include <G4Event.hh> 0041 #include <G4EventManager.hh> 0042 #include <G4RunManager.hh> 0043 #include <G4UIcmdWithADoubleAndUnit.hh> 0044 #include <G4UnitsTable.hh> 0045 #include <globals.hh> 0046 0047 /** \class PrimaryKiller 0048 0049 Kill the primary particle: 0050 - either after a given energy loss 0051 - or after the primary particle has reached a given energy 0052 */ 0053 0054 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0055 0056 PrimaryKiller::PrimaryKiller(G4String name, G4int depth) 0057 : G4VPrimitiveScorer(name, depth), G4UImessenger() 0058 { 0059 fpELossUI = new G4UIcmdWithADoubleAndUnit("/primaryKiller/eLossMin", this); 0060 fpAbortEventIfELossUpperThan = new G4UIcmdWithADoubleAndUnit("/primaryKiller/eLossMax", this); 0061 } 0062 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0063 0064 void PrimaryKiller::SetNewValue(G4UIcommand* command, G4String newValue) 0065 { 0066 if (command == fpELossUI) { 0067 fELossRange_Min = fpELossUI->GetNewDoubleValue(newValue); 0068 } 0069 else if (command == fpAbortEventIfELossUpperThan) { 0070 fELossRange_Max = fpAbortEventIfELossUpperThan->GetNewDoubleValue(newValue); 0071 } 0072 } 0073 0074 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0075 0076 G4bool PrimaryKiller::ProcessHits(G4Step* aStep, G4TouchableHistory*) 0077 { 0078 const G4Track* track = aStep->GetTrack(); 0079 0080 if (track->GetTrackID() != 1) return FALSE; 0081 0082 //------------------- 0083 0084 auto kineticE = aStep->GetPostStepPoint()->GetKineticEnergy(); 0085 0086 auto eLoss = aStep->GetPreStepPoint()->GetKineticEnergy() - kineticE; 0087 0088 if (eLoss == 0.) return FALSE; 0089 0090 //------------------- 0091 fELoss += eLoss; 0092 0093 if (fELoss > fELossRange_Max) { 0094 G4RunManager::GetRunManager()->AbortEvent(); 0095 int eventID = G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetEventID(); 0096 G4cout << "Aborts event " << eventID 0097 << ", energy loss " 0098 "is too large. \n" 0099 << " * Energy loss by primary is: " << G4BestUnit(fELoss, "Energy") 0100 << ". Event is aborted if the Eloss is > " << G4BestUnit(fELossRange_Max, "Energy") 0101 << G4endl; 0102 } 0103 0104 if (fELoss >= fELossRange_Min) { //|| kineticE <= fKineticE_Min){ 0105 ((G4Track*)track)->SetTrackStatus(fStopAndKill); 0106 G4cout << "Kill track at : " << G4BestUnit(kineticE, "Energy") 0107 << ", Energy loss by primary is: " << G4BestUnit(fELoss, "Energy") 0108 << ", primary is terminated as Eloss is >: " << G4BestUnit(fELossRange_Min, "Energy") 0109 << G4endl; //", EThreshold is: " 0110 } 0111 0112 return true; 0113 } 0114 0115 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0116 0117 void PrimaryKiller::Initialize(G4HCofThisEvent* /*HCE*/) 0118 { 0119 Clear(); 0120 } 0121 0122 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|