DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
Geant4FastPhysics.cpp
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 // Author : M.Frank
11 //
12 //==========================================================================
13 #ifndef DDG4_GEANT4FASTPHYSICS_H
14 #define DDG4_GEANT4FASTPHYSICS_H
15 
16 // Framework include files
17 #include <DDG4/Geant4Action.h>
18 #include <DDG4/Geant4PhysicsList.h>
19 
20 // Geant4 include files
21 #include <G4VModularPhysicsList.hh>
22 class G4FastSimulationPhysics;
23 
24 // C/C++ include files
25 #include <vector>
26 
28 namespace dd4hep {
29 
31  namespace sim {
32 
34 
45  protected:
48 
50  std::vector<std::string> m_enabledParticles;
52  bool m_verbose { false };
53 
55  G4FastSimulationPhysics* m_fastPhysics { nullptr };
56 
57  public:
59  Geant4FastPhysics(Geant4Context* context, const std::string& nam);
60 
62  virtual ~Geant4FastPhysics() = default;
63 
65  virtual void constructPhysics(G4VModularPhysicsList* physics) override;
66  };
67  } /* End namespace sim */
68 } /* End namespace dd4hep */
69 #endif // DDG4_GEANT4FASTPHYSICS_H
70 
71 //==========================================================================
72 // AIDA Detector description implementation
73 //--------------------------------------------------------------------------
74 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
75 // All rights reserved.
76 //
77 // For the licensing terms see $DD4hepINSTALL/LICENSE.
78 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
79 //
80 // Author : M.Frank
81 //
82 //==========================================================================
83 
85 // #include <DDG4/Geant4FastPhysics.h>
86 
87 // Geant4 include files
88 #include <G4FastSimulationPhysics.hh>
89 
90 using namespace dd4hep::sim;
91 
94 : Geant4PhysicsList(ctxt, nam)
95 {
96  declareProperty("EnabledParticles", m_enabledParticles);
97  declareProperty("BeVerbose", m_verbose);
98 }
99 
101 void Geant4FastPhysics::constructPhysics(G4VModularPhysicsList* physics) {
103  m_fastPhysics = new G4FastSimulationPhysics(this->name());
104  if ( this->m_verbose ) m_fastPhysics->BeVerbose();
105 
107  for( const auto& part_name : m_enabledParticles ) {
108  this->info("Enable fast simulation for particle type: %s", part_name.c_str());
109  m_fastPhysics->ActivateFastSimulation(part_name);
110  }
116  physics->RegisterPhysics(m_fastPhysics);
117  this->info("Constructed and initialized Geant4 Fast Physics [G4FastSimulationPhysics].");
118 }
119 
120 #include <DDG4/Factories.h>
dd4hep::sim::Geant4FastPhysics::constructPhysics
virtual void constructPhysics(G4VModularPhysicsList *physics) override
constructPhysics callback
Definition: Geant4FastPhysics.cpp:101
dd4hep::sim::Geant4FastPhysics::DDG4_DEFINE_ACTION_CONSTRUCTORS
DDG4_DEFINE_ACTION_CONSTRUCTORS(Geant4FastPhysics)
Define standard assignments and constructors.
Geant4PhysicsList.h
DECLARE_GEANT4ACTION
#define DECLARE_GEANT4ACTION(name)
Plugin defintion to create Geant4Action objects.
Definition: Factories.h:210
dd4hep::sim::Geant4FastPhysics::Geant4FastPhysics
Geant4FastPhysics(Geant4Context *context, const std::string &nam)
Standard constructor.
Definition: Geant4FastPhysics.cpp:93
dd4hep::sim::Geant4Action::info
void info(const char *fmt,...) const
Support of info messages.
Definition: Geant4Action.cpp:215
dd4hep::sim::Geant4PhysicsList::physics
PhysicsConstructors & physics()
Access all physics constructors.
Definition: Geant4PhysicsList.h:171
dd4hep::sim::Geant4FastPhysics::m_enabledParticles
std::vector< std::string > m_enabledParticles
Vector of particle names for which fast simulation is enabled.
Definition: Geant4FastPhysics.cpp:50
dd4hep::sim::Geant4Action::declareProperty
Geant4Action & declareProperty(const std::string &nam, T &val)
Declare property.
Definition: Geant4Action.h:366
dd4hep::sim::Geant4Action::name
const std::string & name() const
Access name of the action.
Definition: Geant4Action.h:280
dd4hep::sim::Geant4FastPhysics
Wrapper for G4FastSimulationPhysics with properties.
Definition: Geant4FastPhysics.cpp:44
dd4hep::sim::Geant4PhysicsList
Concrete basic implementation of a Geant4 physics list action.
Definition: Geant4PhysicsList.h:41
Factories.h
dd4hep::sim
Namespace for the Geant4 based simulation part of the AIDA detector description toolkit.
Definition: Geant4Output2EDM4hep.cpp:49
dd4hep::sim::Geant4FastPhysics::m_verbose
bool m_verbose
Property to set verbosity flag on G4FastSimulationPhysics.
Definition: Geant4FastPhysics.cpp:52
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::sim::Geant4FastPhysics::~Geant4FastPhysics
virtual ~Geant4FastPhysics()=default
Default destructor.
dd4hep::sim::Geant4FastPhysics::m_fastPhysics
G4FastSimulationPhysics * m_fastPhysics
Reference to fast physics object.
Definition: Geant4FastPhysics.cpp:55
Geant4Action.h
dd4hep::sim::Geant4Context
Generic context to extend user, run and event information.
Definition: Geant4Context.h:201
dd4hep::sim::Geant4Action::context
Geant4Context * context() const
Access the context.
Definition: Geant4Action.h:270