|
|
|||
File indexing completed on 2026-06-02 08:06:34
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 // The Geant4-DNA web site is available at http://geant4-dna.org 0035 // 0036 // 0037 #include "PrimaryKiller.hh" 0038 0039 #include <G4Event.hh> 0040 #include <G4EventManager.hh> 0041 #include <G4RunManager.hh> 0042 #include <G4SystemOfUnits.hh> 0043 #include <G4UIcmdWithADoubleAndUnit.hh> 0044 #include <G4UnitsTable.hh> 0045 #include <globals.hh> 0046 0047 /** \file PrimaryKiller.cc 0048 \class PrimaryKiller 0049 0050 Kill the primary particle: 0051 - either after a given energy loss 0052 - or after the primary particle has reached a given energy 0053 */ 0054 0055 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0056 0057 PrimaryKiller::PrimaryKiller(G4String name, G4int depth) 0058 : G4VPrimitiveScorer(name, depth), G4UImessenger() 0059 { 0060 fELoss = 0.; // cumulated energy for current event 0061 0062 fELossRange_Min = DBL_MAX; // fELoss from which the primary is killed 0063 fELossRange_Max = DBL_MAX; // fELoss from which the event is aborted 0064 fKineticE_Min = 0; // kinetic energy below which the primary is killed 0065 0066 fpELossUI = new G4UIcmdWithADoubleAndUnit("/primaryKiller/eLossMin", this); 0067 fpAbortEventIfELossUpperThan = new G4UIcmdWithADoubleAndUnit("/primaryKiller/eLossMax", this); 0068 fpMinKineticE = new G4UIcmdWithADoubleAndUnit("/primaryKiller/minKineticE", this); 0069 } 0070 0071 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0072 0073 PrimaryKiller::~PrimaryKiller() 0074 { 0075 ; 0076 } 0077 0078 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0079 0080 void PrimaryKiller::SetNewValue(G4UIcommand* command, G4String newValue) 0081 { 0082 if (command == fpELossUI) { 0083 fELossRange_Min = fpELossUI->GetNewDoubleValue(newValue); 0084 } 0085 else if (command == fpAbortEventIfELossUpperThan) { 0086 fELossRange_Max = fpAbortEventIfELossUpperThan->GetNewDoubleValue(newValue); 0087 } 0088 } 0089 0090 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0091 0092 G4bool PrimaryKiller::ProcessHits(G4Step* aStep, G4TouchableHistory*) 0093 { 0094 const G4Track* track = aStep->GetTrack(); 0095 0096 if (track->GetTrackID() != 1) return FALSE; 0097 0098 //------------------- 0099 0100 double kineticE = aStep->GetPostStepPoint()->GetKineticEnergy(); 0101 0102 G4double eLoss = aStep->GetPreStepPoint()->GetKineticEnergy() - kineticE; 0103 0104 if (eLoss == 0.) return FALSE; 0105 0106 //------------------- 0107 0108 fELoss += eLoss; 0109 0110 if (fELoss > fELossRange_Max) { 0111 G4RunManager::GetRunManager()->AbortEvent(); 0112 int eventID = G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetEventID(); 0113 G4cout << " * PrimaryKiller: aborts event " << eventID 0114 << ", energy loss " 0115 "is too large. \n" 0116 << " * Energy loss by primary is: " << G4BestUnit(fELoss, "Energy") 0117 << ". Event is aborted if the Eloss is > " << G4BestUnit(fELossRange_Max, "Energy") 0118 << G4endl; 0119 } 0120 0121 if (fELoss >= fELossRange_Min || kineticE <= fKineticE_Min) { 0122 ((G4Track*)track)->SetTrackStatus(fStopAndKill); 0123 // G4cout << "kill track at : " 0124 // << G4BestUnit(kineticE, "Energy") 0125 // << ", E loss is: " 0126 // << G4BestUnit(fELoss, "Energy") 0127 // << " /fELossMax: " 0128 // << G4BestUnit(fELossMax, "Energy") 0129 // << ", EThreshold is: " 0130 // << G4BestUnit(fEThreshold, "Energy") 0131 // << G4endl; 0132 } 0133 0134 return TRUE; 0135 } 0136 0137 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0138 0139 void PrimaryKiller::Initialize(G4HCofThisEvent* /*HCE*/) 0140 { 0141 Clear(); 0142 } 0143 0144 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0145 0146 void PrimaryKiller::EndOfEvent(G4HCofThisEvent*) {} 0147 0148 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0149 0150 void PrimaryKiller::Clear() 0151 { 0152 fELoss = 0.; 0153 } 0154 0155 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0156 0157 void PrimaryKiller::DrawAll() 0158 { 0159 ; 0160 } 0161 0162 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0163 0164 void PrimaryKiller::PrintAll() {} 0165 0166 //....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 |
|