6 #include "G4EventManager.hh"
7 #include "G4TrackingManager.hh"
17 const char* exceptionCode,
20 static const G4String es_banner =
"\n-------- EEEE ------- G4Exception-START -------- EEEE -------\n";
21 static const G4String ee_banner =
"\n-------- EEEE -------- G4Exception-END --------- EEEE -------\n";
22 static const G4String ws_banner =
"\n-------- WWWW ------- G4Exception-START -------- WWWW -------\n";
23 static const G4String we_banner =
"\n-------- WWWW -------- G4Exception-END --------- WWWW -------\n";
25 const G4Track*
track = G4EventManager::GetEventManager()->GetTrackingManager()->GetTrack();
28 std::stringstream message;
29 message <<
"*** G4Exception : " << exceptionCode <<
"\n"
30 <<
" issued by : " << exceptionOrigin <<
"\n"
34 if (
nullptr !=
track) {
35 ekin =
track->GetKineticEnergy();
37 <<
"TrackID=" <<
track->GetTrackID() <<
" ParentID=" <<
track->GetParentID() <<
" "
38 <<
track->GetParticleDefinition()->GetParticleName() <<
"; Ekin(MeV)=" << ekin /
CLHEP::MeV
39 <<
"; time(ns)=" <<
track->GetGlobalTime() / CLHEP::ns <<
"; status=" <<
track->GetTrackStatus()
40 <<
"\n position(mm): " <<
track->GetPosition() <<
"; direction: " <<
track->GetMomentumDirection();
41 const G4VPhysicalVolume* vol =
track->GetVolume();
43 message <<
"\n PhysicalVolume: " << vol->GetName() <<
"; material: " <<
track->GetMaterial()->GetName();
45 message <<
"\n stepNumber=" <<
track->GetCurrentStepNumber()
46 <<
"; stepLength(mm)=" <<
track->GetStepLength() / CLHEP::mm <<
"; weight=" <<
track->GetWeight();
47 const G4VProcess*
proc =
track->GetCreatorProcess();
48 if (
nullptr !=
proc) {
49 message <<
"; creatorProcess: " <<
proc->GetProcessName() <<
"; modelID=" <<
track->GetCreatorModelID();
54 G4ExceptionSeverity localSeverity =
severity;
55 G4String code = G4String(*exceptionCode);
56 if (ekin <
m_eth && code ==
"GeomNav0003") {
57 localSeverity = JustWarning;
61 switch (localSeverity) {
63 case FatalErrorInArgument:
64 case RunMustBeAborted:
65 case EventMustBeAborted:
66 ss << es_banner << message.str() << ee_banner;
72 << ws_banner << message.str() <<
"*** This is just a warning message. ***" << we_banner;