CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

ExceptionHandler Class Reference

#include <ExceptionHandler.h>

List of all members.

Public Member Functions

 ExceptionHandler (RunManager *rm)
 ExceptionHandler ()
virtual bool Notify (const char *exceptionOrigin, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
int operator!= (const ExceptionHandler &right) const
int operator== (const ExceptionHandler &right) const
virtual ~ExceptionHandler ()

Private Member Functions

 ExceptionHandler (const ExceptionHandler &)
ExceptionHandleroperator= (const ExceptionHandler &right)

Private Attributes

RunManagerfRunManager

Detailed Description

Definition at line 9 of file ExceptionHandler.h.


Constructor & Destructor Documentation

ExceptionHandler::ExceptionHandler ( RunManager rm)

Definition at line 14 of file ExceptionHandler.cc.

   : fRunManager(rm)
{ 
//    override = false; 
//    verbose = 0; 
}
ExceptionHandler::ExceptionHandler ( ) [inline]

Definition at line 13 of file ExceptionHandler.h.

{} ;
ExceptionHandler::~ExceptionHandler ( ) [virtual]

Definition at line 21 of file ExceptionHandler.cc.

{}
ExceptionHandler::ExceptionHandler ( const ExceptionHandler ) [inline, private]

Definition at line 20 of file ExceptionHandler.h.

: G4VExceptionHandler() {}

Member Function Documentation

bool ExceptionHandler::Notify ( const char *  exceptionOrigin,
const char *  exceptionCode,
G4ExceptionSeverity  severity,
const char *  description 
) [virtual]

Definition at line 23 of file ExceptionHandler.cc.

References RunManager::abortRun(), gather_cfg::cout, and fRunManager.

{
    cout << endl;
    cout << "*** G4Exception : " << exceptionCode << " issued by " << exceptionOrigin << endl;
    cout << "    " << description << endl;
    bool abortionForCoreDump = false;
    G4ApplicationState aps = G4StateManager::GetStateManager()->GetCurrentState();
    switch(severity)
    {
    case FatalException:
        if ( aps==G4State_EventProc && exceptionOrigin==string("G4HadronicProcess") )
        {
        cout << "*** Fatal exception *** " << endl;
        throw SimG4Exception( "SimG4CoreApplication: Bug in G4HadronicProcess" ) ;
        }
        else
        {
        cout << "*** Fatal exception *** core dump ***" << endl;
        abortionForCoreDump = true;
        }
/*
        cout << "*** Fatal exception *** core dump ***" << endl;
        abortionForCoreDump = true;
*/
        break;
    case FatalErrorInArgument:
        cout << "*** Fatal error in argument *** core dump ***" << endl;
        abortionForCoreDump = true;
        break;
    case RunMustBeAborted:
        if(aps==G4State_GeomClosed || aps==G4State_EventProc)
        {
            cout << "*** Run must be aborted " << endl;
            fRunManager->abortRun(false);
            //RunManager::instance()->abortRun(false) ;
        }
        abortionForCoreDump = false;
        break;
    case EventMustBeAborted:
        if(aps==G4State_EventProc)
        {
            cout << "*** Event must be aborted " << endl;
            // if (override && exceptionCode == string("StuckTrack"))
/*
            if (exceptionCode == string("StuckTrack"))
            {
                //if (verbose > 1) cout << "*** overriden by user " << endl;
                G4Track * t = G4EventManager::GetEventManager()->GetTrackingManager()->GetTrack();
                //if (verbose > 1) 
                    cout << " ERROR - G4Navigator::ComputeStep() " << endl 
                         << " Track " << t->GetTrackID() << " stuck " 
                         << " in volume " << t->GetVolume()->GetName()
                         << " at point " << t->GetPosition()/mm << " mm "<< endl
                         << " with direction: " << t->GetMomentumDirection()
                         << " and distance to out " 
                         << (t->GetVolume()->GetLogicalVolume()->GetSolid())
                        ->DistanceToOut(t->GetPosition())/mm << " mm " << endl;
                //if (verbose > 1) 
                    cout << " Particle " << t->GetDynamicParticle()->GetDefinition()->GetParticleName()
                         << " from parent ID " << t->GetParentID() << endl
                         << " with " << t->GetKineticEnergy()/MeV << " MeV kinetic energy " 
                         << " created in " << t->GetLogicalVolumeAtVertex()->GetName() << endl;
                cout << " *** StuckTrack: track status set to fStopButAlive " << endl;
                t->SetTrackStatus(fStopButAlive);
            }
            else
*/
                //fRunManager->abortEvent();
                //RunManager::instance()->abortEvent() ;
                throw SimG4Exception( "SimG4CoreApplication: G4Navigator:StuckTrack detected" ) ;
        }
        abortionForCoreDump = false;
        break;
    default:
        cout << "*** This is just a warning message " << endl;
        abortionForCoreDump = false;
        break;
    }
    cout << endl;
    return abortionForCoreDump;
}
int ExceptionHandler::operator!= ( const ExceptionHandler right) const [inline]

Definition at line 16 of file ExceptionHandler.h.

{ return (this != &right); }
ExceptionHandler& ExceptionHandler::operator= ( const ExceptionHandler right) [inline, private]

Definition at line 21 of file ExceptionHandler.h.

{ return *this; }
int ExceptionHandler::operator== ( const ExceptionHandler right) const [inline]

Definition at line 15 of file ExceptionHandler.h.

{ return (this == &right); }

Member Data Documentation

Definition at line 22 of file ExceptionHandler.h.

Referenced by Notify().