Belle II Software development
Geant4MaterialInterfaceExceptioHandler Class Reference

This class implements a custom exception handler for Geant4 which is used to record whether a critical exception occurred when calling the G4Navigator. More...

Inheritance diagram for Geant4MaterialInterfaceExceptioHandler:

Public Member Functions

virtual ~Geant4MaterialInterfaceExceptioHandler ()=default
 virtual destructor for proper resource de-allocation
 
virtual bool Notify (const char *origin, const char *code, G4ExceptionSeverity serv, const char *description)
 G4VExceptionHandler method called when an exception is raised.
 
bool isInFailureState () const
 Returns true if a problematic exception was encountered.
 
void resetFailureState ()
 Reset the recorded failure state to be ready for the next calls to Geant4.
 

Private Attributes

bool m_inFailureState = false
 Stores whether a problematic exception occurred.
 

Detailed Description

This class implements a custom exception handler for Geant4 which is used to record whether a critical exception occurred when calling the G4Navigator.

This class is mainly used to handle stuck tracks.

Definition at line 43 of file Geant4MaterialInterface.cc.

Member Function Documentation

◆ isInFailureState()

bool isInFailureState ( ) const
inline

Returns true if a problematic exception was encountered.

Definition at line 78 of file Geant4MaterialInterface.cc.

79 {
80 return m_inFailureState;
81 }
bool m_inFailureState
Stores whether a problematic exception occurred.

◆ Notify()

virtual bool Notify ( const char *  origin,
const char *  code,
G4ExceptionSeverity  serv,
const char *  description 
)
inlinevirtual

G4VExceptionHandler method called when an exception is raised.

Definition at line 53 of file Geant4MaterialInterface.cc.

54 {
55 B2WARNING("Geant4 exception during material lookup -- origin: "
56 << origin << "\n code:"
57 << code << "\n description:"
58 << description);
59
60 if (serv == EventMustBeAborted || serv == RunMustBeAborted) {
61 m_inFailureState = true;
62 }
63
64 if (serv == FatalException || serv == FatalErrorInArgument) {
65 // on fatal exceptions, instruct Geant4 to create core dump
66 // and crash
67 return true;
68 }
69
70 // returning false will continue the program execution
71 // G4ExceptionSeverity = JustWarning will be covered by this, too
72 return false;
73 }

◆ resetFailureState()

void resetFailureState ( )
inline

Reset the recorded failure state to be ready for the next calls to Geant4.

Definition at line 87 of file Geant4MaterialInterface.cc.

88 {
89 m_inFailureState = false;
90 }

Member Data Documentation

◆ m_inFailureState

bool m_inFailureState = false
private

Stores whether a problematic exception occurred.

Definition at line 96 of file Geant4MaterialInterface.cc.


The documentation for this class was generated from the following file: