Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4ExceptionHandler.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 //
27 // $Id: G4ExceptionHandler.cc 109231 2018-04-05 06:57:57Z gcosmo $
28 //
29 //
30 // ------------------------------------------------------------
31 // GEANT 4 class implementation file
32 //
33 // ---------------- G4ExceptionHandler ----------------
34 // by Makoto Asai (August 2002)
35 // ------------------------------------------------------------
36 
37 #include "G4ExceptionHandler.hh"
38 #include "G4StateManager.hh"
39 #include "G4RunManager.hh"
40 #include "G4ios.hh"
41 #include <stdlib.h>
42 #include "G4String.hh"
43 
45 {
46 }
47 
49 {
50 }
51 
54 {
55 }
56 
58 {
59  return *this;
60 }
61 
63 {
64  return (this == &right);
65 }
66 
68 {
69  return (this != &right);
70 }
71 
72 G4bool G4ExceptionHandler::Notify(const char* originOfException,
73  const char* exceptionCode,
74  G4ExceptionSeverity severity,
75  const char* description)
76 {
77  static const G4String es_banner
78  = "\n-------- EEEE ------- G4Exception-START -------- EEEE -------\n";
79  static const G4String ee_banner
80  = "\n-------- EEEE -------- G4Exception-END --------- EEEE -------\n";
81  static const G4String ws_banner
82  = "\n-------- WWWW ------- G4Exception-START -------- WWWW -------\n";
83  static const G4String we_banner
84  = "\n-------- WWWW -------- G4Exception-END --------- WWWW -------\n";
85  std::ostringstream message;
86  message << "*** G4Exception : " << exceptionCode << G4endl
87  << " issued by : " << originOfException << G4endl
88  << description << G4endl;
89  G4bool abortionForCoreDump = false;
91  switch(severity)
92  {
93  case FatalException:
94  G4cerr << es_banner << message.str() << "*** Fatal Exception *** core dump ***" << G4endl;
95  DumpTrackInfo();
96  G4cerr << ee_banner << G4endl;
97  abortionForCoreDump = true;
98  break;
100  G4cerr << es_banner << message.str() << "*** Fatal Error In Argument *** core dump ***" << G4endl;
101  DumpTrackInfo();
102  G4cerr << ee_banner << G4endl;
103  abortionForCoreDump = true;
104  break;
105  case RunMustBeAborted:
106  if(aps==G4State_GeomClosed || aps==G4State_EventProc)
107  {
108  G4cerr << es_banner << message.str() << "*** Run Must Be Aborted ***" << G4endl;
109  DumpTrackInfo();
110  G4cerr << ee_banner << G4endl;
112  }
113  abortionForCoreDump = false;
114  break;
115  case EventMustBeAborted:
116  if(aps==G4State_EventProc)
117  {
118  G4cerr << es_banner << message.str() << "*** Event Must Be Aborted ***" << G4endl;
119  DumpTrackInfo();
120  G4cerr << ee_banner << G4endl;
122  }
123  abortionForCoreDump = false;
124  break;
125  default:
126  G4cout << ws_banner << message.str() << "*** This is just a warning message. ***"
127  << we_banner << G4endl;
128  abortionForCoreDump = false;
129  break;
130  }
131  return abortionForCoreDump;
132 }
133 
134 #include "G4RunManagerKernel.hh"
135 #include "G4EventManager.hh"
136 #include "G4TrackingManager.hh"
137 #include "G4SteppingManager.hh"
138 #include "G4Track.hh"
139 #include "G4Step.hh"
140 #include "G4StepPoint.hh"
141 #include "G4ParticleDefinition.hh"
142 #include "G4VProcess.hh"
143 #include "G4VPhysicalVolume.hh"
144 #include "G4Material.hh"
145 #include "G4UnitsTable.hh"
146 
148 {
152  const G4Track* theTrack = steppingMgr->GetfTrack();
153  const G4Step* theStep = steppingMgr->GetfStep();
154 
155  if(aps!=G4State_EventProc || !theTrack)
156  {
157  G4cerr << " **** Track information is not available at this moment" << G4endl;
158  }
159  else
160  {
161  G4cerr << "G4Track (" << theTrack << ") - track ID = " << theTrack->GetTrackID()
162  << ", parent ID = " << theTrack->GetParentID() << G4endl;
163  G4cerr << " Particle type : " << theTrack->GetParticleDefinition()->GetParticleName();
164  if(theTrack->GetCreatorProcess())
165  { G4cerr
166  << " - creator process : " << theTrack->GetCreatorProcess()->GetProcessName()
167  << ", creator model : " << theTrack->GetCreatorModelName() << G4endl;
168  }
169  else
170  { G4cerr << " - creator process : not available" << G4endl; }
171  G4cerr << " Kinetic energy : " << G4BestUnit(theTrack->GetKineticEnergy(),"Energy")
172  << " - Momentum direction : " << theTrack->GetMomentumDirection() << G4endl;
173  }
174 
175  if(aps!=G4State_EventProc || !theStep)
176  {
177  G4cerr << " **** Step information is not available at this moment" << G4endl;
178  }
179  else
180  {
181  G4cerr << " Step length : " << G4BestUnit(theStep->GetStepLength(),"Length")
182  << " - total energy deposit : " << G4BestUnit(theStep->GetTotalEnergyDeposit(),"Energy")
183  << G4endl;
184  G4cerr << " Pre-step point : " << theStep->GetPreStepPoint()->GetPosition();
185  G4cerr << " - Physical volume : ";
186  if(theStep->GetPreStepPoint()->GetPhysicalVolume())
187  {
188  G4cerr << theStep->GetPreStepPoint()->GetPhysicalVolume()->GetName();
189  if(theStep->GetPreStepPoint()->GetMaterial())
190  { G4cerr << " (" << theStep->GetPreStepPoint()->GetMaterial()->GetName() << ")"; }
191  else
192  { G4cerr << " (material not available)"; }
193  }
194  else
195  { G4cerr << "not available"; }
196  G4cerr << G4endl;
197  if(theStep->GetPreStepPoint()->GetProcessDefinedStep())
198  {
199  G4cerr << " - defined by : "
201  << " - step status : " << theStep->GetPreStepPoint()->GetStepStatus() << G4endl;
202  }
203  else
204  {
205  G4cerr << " - defined by : not available" << G4endl;
206  }
207  G4cerr << " Post-step point : " << theStep->GetPostStepPoint()->GetPosition();
208  G4cerr << " - Physical volume : ";
209  if(theStep->GetPostStepPoint()->GetPhysicalVolume())
210  {
211  G4cerr << theStep->GetPostStepPoint()->GetPhysicalVolume()->GetName();
212  if(theStep->GetPostStepPoint()->GetMaterial())
213  { G4cerr << " (" << theStep->GetPostStepPoint()->GetMaterial()->GetName() << ")"; }
214  else
215  { G4cerr << " (material not available)"; }
216  }
217  else
218  { G4cerr << "not available"; }
219  G4cerr << G4endl;
220  if(theStep->GetPostStepPoint()->GetProcessDefinedStep())
221  {
222  G4cerr << " - defined by : "
224  << " - step status : " << theStep->GetPostStepPoint()->GetStepStatus() << G4endl;
225  }
226  else
227  {
228  G4cerr << " - defined by : not available" << G4endl;
229  }
230  G4cerr << " *** Note: Step information might not be properly updated." << G4endl;
231  }
232 }
233 
virtual void AbortRun(G4bool softAbort=false)
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:80
G4double GetKineticEnergy() const
G4StepPoint * GetPreStepPoint() const
#define G4endl
Definition: G4ios.hh:61
void message(RunManager *runmanager)
Definition: ts_scorers.cc:72
const G4String & GetParticleName() const
G4int GetTrackID() const
G4VPhysicalVolume * GetPhysicalVolume() const
const G4ParticleDefinition * GetParticleDefinition() const
G4TrackingManager * GetTrackingManager() const
const G4String & GetName() const
Definition: G4Material.hh:179
static G4RunManagerKernel * GetRunManagerKernel()
G4ExceptionHandler & operator=(const G4ExceptionHandler &right)
bool G4bool
Definition: G4Types.hh:79
G4StepStatus GetStepStatus() const
const G4String & GetCreatorModelName() const
G4Material * GetMaterial() const
G4double GetStepLength() const
const G4ThreeVector & GetPosition() const
const G4String & GetProcessName() const
Definition: G4VProcess.hh:411
G4double GetTotalEnergyDeposit() const
Definition: G4Step.hh:76
G4StepPoint * GetPostStepPoint() const
G4GLOB_DLL std::ostream G4cerr
G4ExceptionSeverity
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
int G4int
Definition: G4Types.hh:78
G4int operator!=(const G4ExceptionHandler &right) const
G4ApplicationState GetCurrentState() const
const G4VProcess * GetCreatorProcess() const
G4GLOB_DLL std::ostream G4cout
G4ApplicationState
virtual void AbortEvent()
const G4VProcess * GetProcessDefinedStep() const
G4int operator==(const G4ExceptionHandler &right) const
const G4ThreeVector & GetMomentumDirection() const
G4SteppingManager * GetSteppingManager() const
virtual G4bool Notify(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
const G4String & GetName() const
static G4StateManager * GetStateManager()
G4int GetParentID() const