ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PrimaryKiller.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PrimaryKiller.cc
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 //
34 #include "PrimaryKiller.hh"
35 
36 #include <G4UnitsTable.hh>
37 #include <G4Event.hh>
38 #include <G4SystemOfUnits.hh>
39 #include <globals.hh>
41 #include <G4RunManager.hh>
42 #include <G4EventManager.hh>
43 
44 
53 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
54 
56 : G4VPrimitiveScorer(name,depth),
58 {
59  fELoss = 0.; // cumulated energy for current event
60 
61  fELossRange_Min = DBL_MAX; // fELoss from which the primary is killed
62  fELossRange_Max = DBL_MAX; // fELoss from which the event is aborted
63  fKineticE_Min = 0; // kinetic energy below which the primary is killed
64 
65  fpELossUI = new G4UIcmdWithADoubleAndUnit("/primaryKiller/eLossMin",this);
67  new G4UIcmdWithADoubleAndUnit("/primaryKiller/eLossMax", this);
69  new G4UIcmdWithADoubleAndUnit("/primaryKiller/minKineticE", this);
70 }
71 
72 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
73 
75 {;}
76 
77 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
78 
80  G4String newValue)
81 {
82  if(command == fpELossUI){
84  }
85  else if(command == fpAbortEventIfELossUpperThan){
88  }
89 }
90 
91 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
92 
94 {
95  const G4Track* track = aStep->GetTrack();
96 
97  if(track->GetTrackID() != 1) return FALSE;
98 
99  //-------------------
100 
101  double kineticE = aStep->GetPostStepPoint()->GetKineticEnergy();
102 
103  G4double eLoss = aStep->GetPreStepPoint()->GetKineticEnergy()
104  - kineticE;
105 
106  if ( eLoss == 0. ) return FALSE;
107 
108  //-------------------
109 
110  fELoss+=eLoss;
111 
112  if(fELoss > fELossRange_Max){
114  int eventID =
116  G4cout << " * PrimaryKiller: aborts event " << eventID <<", energy loss "
117  "is too large. \n"
118  << " * Energy loss by primary is: "
119  << G4BestUnit(fELoss, "Energy")
120  << ". Event is aborted if the Eloss is > "
121  << G4BestUnit(fELossRange_Max, "Energy")
122  << G4endl;
123 
124  }
125 
126  if(fELoss >= fELossRange_Min || kineticE <= fKineticE_Min){
127  ((G4Track*)track)->SetTrackStatus(fStopAndKill);
128 // G4cout << "kill track at : "
129 // << G4BestUnit(kineticE, "Energy")
130 // << ", E loss is: "
131 // << G4BestUnit(fELoss, "Energy")
132 // << " /fELossMax: "
133 // << G4BestUnit(fELossMax, "Energy")
134 // << ", EThreshold is: "
135 // << G4BestUnit(fEThreshold, "Energy")
136 // << G4endl;
137  }
138 
139  return TRUE;
140 }
141 
142 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
143 
145 {
146  clear();
147 }
148 
149 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
150 
152 {
153 }
154 
155 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
156 
158 {
159  fELoss = 0.;
160 }
161 
162 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
163 
165 {;}
166 
167 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
168 
170 {}
171 
172 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......