Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-29 07:35:41

0001 //==========================================================================
0002 //  AIDA Detector description implementation
0003 //--------------------------------------------------------------------------
0004 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 // All rights reserved.
0006 //
0007 // For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0009 //
0010 // Author     : A. Sailer
0011 //
0012 //==========================================================================
0013 
0014 /** \addtogroup Geant4PhysicsConstructor
0015  *
0016  * @{
0017  * \package Geant4SetKETolerance
0018  *
0019  * \brief PhysicsConstructor to change the KETolerance and its warning severity for dynamic particles
0020  *
0021  * @}
0022  */
0023 
0024 #ifndef DDG4_Geant4SetKETolerance_h
0025 #define DDG4_Geant4SetKETolerance_h 1
0026 
0027 // Framework include files
0028 #include <DDG4/Geant4PhysicsList.h>
0029 
0030 // geant4
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 /// Namespace for the AIDA detector description toolkit
0040 namespace dd4hep {
0041 
0042   /// Namespace for the Geant4 based simulation part of the AIDA detector description toolkit
0043   namespace sim {
0044 
0045     /// Geant4 physics list action to set KETolerance
0046     /**
0047      *  \author  A.Sailer
0048      *  \version 1.0
0049      *  \ingroup DD4HEP_SIMULATION
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       /// Callback to call the KETolerance setter
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   // DDG4_Geant4SetKETolerance_h
0093 
0094 #include <DDG4/Factories.h>
0095 using namespace dd4hep::sim;
0096 DECLARE_GEANT4ACTION(Geant4SetKETolerance)