Go to the documentation of this file.00001 #include "SimG4Core/Application/interface/ExceptionHandler.h"
00002 #include "SimG4Core/Application/interface/RunManager.h"
00003
00004 #include "SimG4Core/Notification/interface/SimG4Exception.h"
00005
00006 #include "G4EventManager.hh"
00007 #include "G4StateManager.hh"
00008 #include "G4ios.hh"
00009
00010 using std::cout;
00011 using std::endl;
00012 using std::string;
00013
00014 ExceptionHandler::ExceptionHandler(RunManager* rm)
00015 : fRunManager(rm)
00016 {
00017
00018
00019 }
00020
00021 ExceptionHandler::~ExceptionHandler() {}
00022
00023 bool ExceptionHandler::Notify(const char* exceptionOrigin,const char* exceptionCode,
00024 G4ExceptionSeverity severity,const char* description)
00025 {
00026 cout << endl;
00027 cout << "*** G4Exception : " << exceptionCode << " issued by " << exceptionOrigin << endl;
00028 cout << " " << description << endl;
00029 bool abortionForCoreDump = false;
00030 G4ApplicationState aps = G4StateManager::GetStateManager()->GetCurrentState();
00031 switch(severity)
00032 {
00033 case FatalException:
00034 if ( aps==G4State_EventProc && exceptionOrigin==string("G4HadronicProcess") )
00035 {
00036 cout << "*** Fatal exception *** " << endl;
00037 throw SimG4Exception( "SimG4CoreApplication: Bug in G4HadronicProcess" ) ;
00038 }
00039 else
00040 {
00041 cout << "*** Fatal exception *** core dump ***" << endl;
00042 abortionForCoreDump = true;
00043 }
00044
00045
00046
00047
00048 break;
00049 case FatalErrorInArgument:
00050 cout << "*** Fatal error in argument *** core dump ***" << endl;
00051 abortionForCoreDump = true;
00052 break;
00053 case RunMustBeAborted:
00054 if(aps==G4State_GeomClosed || aps==G4State_EventProc)
00055 {
00056 cout << "*** Run must be aborted " << endl;
00057 fRunManager->abortRun(false);
00058
00059 }
00060 abortionForCoreDump = false;
00061 break;
00062 case EventMustBeAborted:
00063 if(aps==G4State_EventProc)
00064 {
00065 cout << "*** Event must be aborted " << endl;
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093 throw SimG4Exception( "SimG4CoreApplication: G4Navigator:StuckTrack detected" ) ;
00094 }
00095 abortionForCoreDump = false;
00096 break;
00097 default:
00098 cout << "*** This is just a warning message " << endl;
00099 abortionForCoreDump = false;
00100 break;
00101 }
00102 cout << endl;
00103 return abortionForCoreDump;
00104 }
00105