Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PrimaryKiller.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // This example is provided by the Geant4-DNA collaboration
27 // Any report or published results obtained using the Geant4-DNA software
28 // shall cite the following Geant4-DNA collaboration publication:
29 // Med. Phys. 37 (2010) 4692-4708
30 // J. Comput. Phys. 274 (2014) 841-882
31 // The Geant4-DNA web site is available at http://geant4-dna.org
32 //
33 // $Id$
34 //
35 #include "PrimaryKiller.hh"
36 
37 #include <G4UnitsTable.hh>
38 #include <G4Event.hh>
39 #include <G4SystemOfUnits.hh>
40 #include <globals.hh>
42 #include <G4RunManager.hh>
43 #include <G4EventManager.hh>
44 
45 
54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
55 
57 : G4VPrimitiveScorer(name,depth),
59 {
60  fELoss = 0.; // cumulated energy for current event
61 
62  fELossRange_Min = DBL_MAX; // fELoss from which the primary is killed
63  fELossRange_Max = DBL_MAX; // fELoss from which the event is aborted
64  fKineticE_Min = 0; // kinetic energy below which the primary is killed
65 
66  fpELossUI = new G4UIcmdWithADoubleAndUnit("/primaryKiller/eLossMin",this);
67  fpAbortEventIfELossUpperThan =
68  new G4UIcmdWithADoubleAndUnit("/primaryKiller/eLossMax", this);
69  fpMinKineticE =
70  new G4UIcmdWithADoubleAndUnit("/primaryKiller/minKineticE", this);
71 }
72 
73 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
74 
76 {;}
77 
78 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
79 
81  G4String newValue)
82 {
83  if(command == fpELossUI){
84  fELossRange_Min = fpELossUI->GetNewDoubleValue(newValue);
85  }
86  else if(command == fpAbortEventIfELossUpperThan){
87  fELossRange_Max =
88  fpAbortEventIfELossUpperThan->GetNewDoubleValue(newValue);
89  }
90 }
91 
92 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
93 
95 {
96  const G4Track* track = aStep->GetTrack();
97 
98  if(track->GetTrackID() != 1) return FALSE;
99 
100  //-------------------
101 
102  double kineticE = aStep->GetPostStepPoint()->GetKineticEnergy();
103 
104  G4double eLoss = aStep->GetPreStepPoint()->GetKineticEnergy()
105  - kineticE;
106 
107  if ( eLoss == 0. ) return FALSE;
108 
109  //-------------------
110 
111  fELoss+=eLoss;
112 
113  if(fELoss > fELossRange_Max){
115  int eventID =
117  G4cout << " * PrimaryKiller: aborts event " << eventID <<", energy loss "
118  "is too large. \n"
119  << " * Energy loss by primary is: "
120  << G4BestUnit(fELoss, "Energy")
121  << ". Event is aborted if the Eloss is > "
122  << G4BestUnit(fELossRange_Max, "Energy")
123  << G4endl;
124 
125  }
126 
127  if(fELoss >= fELossRange_Min || kineticE <= fKineticE_Min){
128  ((G4Track*)track)->SetTrackStatus(fStopAndKill);
129 // G4cout << "kill track at : "
130 // << G4BestUnit(kineticE, "Energy")
131 // << ", E loss is: "
132 // << G4BestUnit(fELoss, "Energy")
133 // << " /fELossMax: "
134 // << G4BestUnit(fELossMax, "Energy")
135 // << ", EThreshold is: "
136 // << G4BestUnit(fEThreshold, "Energy")
137 // << G4endl;
138  }
139 
140  return TRUE;
141 }
142 
143 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
144 
146 {
147  clear();
148 }
149 
150 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
151 
153 {
154 }
155 
156 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
157 
159 {
160  fELoss = 0.;
161 }
162 
163 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
164 
166 {;}
167 
168 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
169 
171 {}
172 
173 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
const XML_Char * name
Definition: expat.h:151
PrimaryKiller(G4String name, G4int depth=0)
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
static G4double GetNewDoubleValue(const char *paramString)
int G4int
Definition: G4Types.hh:78
virtual void PrintAll()
G4int GetEventID() const
Definition: G4Event.hh:151
G4StepPoint * GetPreStepPoint() const
virtual void clear()
G4GLOB_DLL std::ostream G4cout
bool G4bool
Definition: G4Types.hh:79
#define FALSE
Definition: globals.hh:52
#define TRUE
Definition: globals.hh:55
Definition: G4Step.hh:76
G4int GetTrackID() const
virtual void EndOfEvent(G4HCofThisEvent *)
virtual ~PrimaryKiller()
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
virtual G4bool ProcessHits(G4Step *, G4TouchableHistory *)
G4StepPoint * GetPostStepPoint() const
static G4EventManager * GetEventManager()
#define G4endl
Definition: G4ios.hh:61
virtual void DrawAll()
virtual void AbortEvent()
G4double GetKineticEnergy() const
double G4double
Definition: G4Types.hh:76
const G4Event * GetConstCurrentEvent()
G4Track * GetTrack() const
#define DBL_MAX
Definition: templates.hh:83
virtual void Initialize(G4HCofThisEvent *)
virtual void SetNewValue(G4UIcommand *command, G4String newValue)