ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4ExceptionHandler.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file 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 //
28 //
29 // ------------------------------------------------------------
30 // GEANT 4 class implementation file
31 //
32 // ---------------- G4ExceptionHandler ----------------
33 // by Makoto Asai (August 2002)
34 // ------------------------------------------------------------
35 
36 #include "G4ExceptionHandler.hh"
37 #include "G4StateManager.hh"
38 #include "G4RunManager.hh"
39 #include "G4ios.hh"
40 #include <stdlib.h>
41 #include "G4String.hh"
42 
44 {
45 }
46 
48 {
49 }
50 
53 {
54 }
55 
57 {
58  return *this;
59 }
60 
62 {
63  return (this == &right);
64 }
65 
67 {
68  return (this != &right);
69 }
70 
71 G4bool G4ExceptionHandler::Notify(const char* originOfException,
72  const char* exceptionCode,
73  G4ExceptionSeverity severity,
74  const char* description)
75 {
76  static const G4String es_banner
77  = "\n-------- EEEE ------- G4Exception-START -------- EEEE -------\n";
78  static const G4String ee_banner
79  = "\n-------- EEEE -------- G4Exception-END --------- EEEE -------\n";
80  static const G4String ws_banner
81  = "\n-------- WWWW ------- G4Exception-START -------- WWWW -------\n";
82  static const G4String we_banner
83  = "\n-------- WWWW -------- G4Exception-END --------- WWWW -------\n";
84  std::ostringstream message;
85  message << "*** G4Exception : " << exceptionCode << G4endl
86  << " issued by : " << originOfException << G4endl
87  << description << G4endl;
88  G4bool abortionForCoreDump = false;
90  switch(severity)
91  {
92  case FatalException:
93  G4cerr << es_banner << message.str() << "*** Fatal Exception *** core dump ***" << G4endl;
94  DumpTrackInfo();
95  G4cerr << ee_banner << G4endl;
96  abortionForCoreDump = true;
97  break;
99  G4cerr << es_banner << message.str() << "*** Fatal Error In Argument *** core dump ***" << G4endl;
100  DumpTrackInfo();
101  G4cerr << ee_banner << G4endl;
102  abortionForCoreDump = true;
103  break;
104  case RunMustBeAborted:
105  if(aps==G4State_GeomClosed || aps==G4State_EventProc)
106  {
107  G4cerr << es_banner << message.str() << "*** Run Must Be Aborted ***" << G4endl;
108  DumpTrackInfo();
109  G4cerr << ee_banner << G4endl;
111  }
112  abortionForCoreDump = false;
113  break;
114  case EventMustBeAborted:
115  if(aps==G4State_EventProc)
116  {
117  G4cerr << es_banner << message.str() << "*** Event Must Be Aborted ***" << G4endl;
118  DumpTrackInfo();
119  G4cerr << ee_banner << G4endl;
121  }
122  abortionForCoreDump = false;
123  break;
124  default:
125  G4cout << ws_banner << message.str() << "*** This is just a warning message. ***"
126  << we_banner << G4endl;
127  abortionForCoreDump = false;
128  break;
129  }
130  return abortionForCoreDump;
131 }
132 
133 #include "G4RunManagerKernel.hh"
134 #include "G4EventManager.hh"
135 #include "G4TrackingManager.hh"
136 #include "G4SteppingManager.hh"
137 #include "G4Track.hh"
138 #include "G4Step.hh"
139 #include "G4StepPoint.hh"
140 #include "G4ParticleDefinition.hh"
141 #include "G4VProcess.hh"
142 #include "G4VPhysicalVolume.hh"
143 #include "G4Material.hh"
144 #include "G4UnitsTable.hh"
145 
147 {
151  const G4Track* theTrack = steppingMgr->GetfTrack();
152  const G4Step* theStep = steppingMgr->GetfStep();
153 
154  if(aps!=G4State_EventProc || !theTrack)
155  {
156  G4cerr << " **** Track information is not available at this moment" << G4endl;
157  }
158  else
159  {
160  G4cerr << "G4Track (" << theTrack << ") - track ID = " << theTrack->GetTrackID()
161  << ", parent ID = " << theTrack->GetParentID() << G4endl;
162  G4cerr << " Particle type : " << theTrack->GetParticleDefinition()->GetParticleName();
163  if(theTrack->GetCreatorProcess())
164  { G4cerr
165  << " - creator process : " << theTrack->GetCreatorProcess()->GetProcessName()
166  << ", creator model : " << theTrack->GetCreatorModelName() << G4endl;
167  }
168  else
169  { G4cerr << " - creator process : not available" << G4endl; }
170  G4cerr << " Kinetic energy : " << G4BestUnit(theTrack->GetKineticEnergy(),"Energy")
171  << " - Momentum direction : " << theTrack->GetMomentumDirection() << G4endl;
172  }
173 
174  if(aps!=G4State_EventProc || !theStep)
175  {
176  G4cerr << " **** Step information is not available at this moment" << G4endl;
177  }
178  else
179  {
180  G4cerr << " Step length : " << G4BestUnit(theStep->GetStepLength(),"Length")
181  << " - total energy deposit : " << G4BestUnit(theStep->GetTotalEnergyDeposit(),"Energy")
182  << G4endl;
183  G4cerr << " Pre-step point : " << theStep->GetPreStepPoint()->GetPosition();
184  G4cerr << " - Physical volume : ";
185  if(theStep->GetPreStepPoint()->GetPhysicalVolume())
186  {
187  G4cerr << theStep->GetPreStepPoint()->GetPhysicalVolume()->GetName();
188  if(theStep->GetPreStepPoint()->GetMaterial())
189  { G4cerr << " (" << theStep->GetPreStepPoint()->GetMaterial()->GetName() << ")"; }
190  else
191  { G4cerr << " (material not available)"; }
192  }
193  else
194  { G4cerr << "not available"; }
195  G4cerr << G4endl;
196  if(theStep->GetPreStepPoint()->GetProcessDefinedStep())
197  {
198  G4cerr << " - defined by : "
200  << " - step status : " << theStep->GetPreStepPoint()->GetStepStatus() << G4endl;
201  }
202  else
203  {
204  G4cerr << " - defined by : not available" << G4endl;
205  }
206  G4cerr << " Post-step point : " << theStep->GetPostStepPoint()->GetPosition();
207  G4cerr << " - Physical volume : ";
208  if(theStep->GetPostStepPoint()->GetPhysicalVolume())
209  {
210  G4cerr << theStep->GetPostStepPoint()->GetPhysicalVolume()->GetName();
211  if(theStep->GetPostStepPoint()->GetMaterial())
212  { G4cerr << " (" << theStep->GetPostStepPoint()->GetMaterial()->GetName() << ")"; }
213  else
214  { G4cerr << " (material not available)"; }
215  }
216  else
217  { G4cerr << "not available"; }
218  G4cerr << G4endl;
219  if(theStep->GetPostStepPoint()->GetProcessDefinedStep())
220  {
221  G4cerr << " - defined by : "
223  << " - step status : " << theStep->GetPostStepPoint()->GetStepStatus() << G4endl;
224  }
225  else
226  {
227  G4cerr << " - defined by : not available" << G4endl;
228  }
229  G4cerr << " *** Note: Step information might not be properly updated." << G4endl;
230  }
231 }
232