File indexing completed on 2026-05-29 07:35:41
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 #ifndef DDG4_Geant4SetKETolerance_h
0025 #define DDG4_Geant4SetKETolerance_h 1
0026
0027
0028 #include <DDG4/Geant4PhysicsList.h>
0029
0030
0031 #include <G4Version.hh>
0032 #if G4VERSION_NUMBER >= 1130
0033 #include "G4ExceptionSeverity.hh"
0034 #include "G4PrimaryTransformer.hh"
0035 #endif
0036
0037 #include <CLHEP/Units/SystemOfUnits.h>
0038
0039
0040 namespace dd4hep {
0041
0042
0043 namespace sim {
0044
0045
0046
0047
0048
0049
0050
0051 class Geant4SetKETolerance : public Geant4PhysicsList {
0052 public:
0053 Geant4SetKETolerance(Geant4Context* ctxt, const std::string& nam)
0054 : Geant4PhysicsList(ctxt, nam), m_kETolerance(1.0*CLHEP::MeV)
0055 #if G4VERSION_NUMBER >= 1130
0056 , m_kESeverity(G4ExceptionSeverity::JustWarning)
0057 #endif
0058 {
0059 declareProperty("Tolerance", m_kETolerance);
0060 #if G4VERSION_NUMBER >= 1130
0061 declareProperty("Severity", m_kESeverity);
0062 #endif
0063 }
0064 virtual ~Geant4SetKETolerance() {
0065 }
0066
0067 virtual void constructProcesses(G4VUserPhysicsList*) {
0068 #if G4VERSION_NUMBER >= 1130
0069 G4PrimaryTransformer::SetKETolerance(m_kETolerance, G4ExceptionSeverity(m_kESeverity));
0070 printout(INFO, name(), "setting tolerance to %f MeV", m_kETolerance / CLHEP::MeV);
0071 printout(INFO, name(), "setting severity to %s", m_sevMap[m_kESeverity].c_str());
0072 #else
0073 printout(DEBUG, name(), "SetKETolerance not implemented for this version of Geant4");
0074 #endif
0075 }
0076
0077 private:
0078 double m_kETolerance;
0079 #if G4VERSION_NUMBER >= 1130
0080 int m_kESeverity;
0081 std::map<int, std::string> m_sevMap = {
0082 {0, "FatalException"},
0083 {1, "FatalErrorInArgument"},
0084 {2, "RunMustBeAborted"},
0085 {3, "EventMustBeAborted"},
0086 {4, "JustWarning"},
0087 {5, "IgnoreTheIssue"}};
0088 #endif
0089 };
0090 }
0091 }
0092 #endif
0093
0094 #include <DDG4/Factories.h>
0095 using namespace dd4hep::sim;
0096 DECLARE_GEANT4ACTION(Geant4SetKETolerance)