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