11#include " SimG4Core/Application/interface/ExceptionHandler.h"
2+ #include " SimG4Core/Application/interface/CMSG4TrackInterface.h"
23
34#include " FWCore/MessageLogger/interface/MessageLogger.h"
45#include " FWCore/Utilities/interface/Exception.h"
1112
1213ExceptionHandler::ExceptionHandler (double th, bool tr) : m_eth(th), m_trace(tr) {}
1314
14- ExceptionHandler::~ExceptionHandler () {}
15-
1615bool ExceptionHandler::Notify (const char * exceptionOrigin,
1716 const char * exceptionCode,
1817 G4ExceptionSeverity severity,
@@ -22,12 +21,14 @@ bool ExceptionHandler::Notify(const char* exceptionOrigin,
2221 static const G4String ws_banner = " \n -------- WWWW ------- G4Exception-START -------- WWWW -------\n " ;
2322 static const G4String we_banner = " \n -------- WWWW -------- G4Exception-END --------- WWWW -------\n " ;
2423
25- G4Track* track = G4EventManager::GetEventManager ()->GetTrackingManager ()->GetTrack ();
24+ auto ig4 = CMSG4TrackInterface::instance ();
25+ const G4Track* track = ig4->getCurrentTrack ();
26+ int id = ig4->getThreadID ();
2627 double ekin = m_eth;
2728
2829 std::stringstream message;
2930 message << " *** G4Exception : " << exceptionCode << " \n "
30- << " issued by : " << exceptionOrigin << " \n "
31+ << " issued by : " << exceptionOrigin << " in threadID= " << id << " \n "
3132 << description;
3233
3334 // part of exception happens outside tracking loop
@@ -61,10 +62,10 @@ bool ExceptionHandler::Notify(const char* exceptionOrigin,
6162 G4String code;
6263 mescode >> code;
6364
64- // track is killed
65+ // track should be killed, const_cast is allowed in this place
6566 if (ekin < m_eth && (code == " GeomNav0003" || code == " GeomField0003" )) {
6667 localSeverity = JustWarning;
67- track->SetTrackStatus (fStopAndKill );
68+ const_cast <G4Track*>( track) ->SetTrackStatus (fStopAndKill );
6869 ++m_number;
6970 }
7071
0 commit comments