14 #ifndef DD4HEP_DDG4_GEANT4KERNEL_H
15 #define DD4HEP_DDG4_GEANT4KERNEL_H
32 namespace Simulation {
35 class Geant4ActionPhase;
46 typedef std::map<unsigned long, Geant4Kernel*>
Workers;
47 typedef std::map<std::string, Geant4ActionPhase*>
Phases;
196 Geant4Action*
globalAction(
const std::string& action_name,
bool throw_if_not_present =
true);
204 Geant4Action*
globalFilter(
const std::string& filter_name,
bool throw_if_not_present =
true);
207 Geant4ActionPhase*
getPhase(
const std::string& name);
210 virtual Geant4ActionPhase*
addSimplePhase(
const std::string& name,
bool throw_on_exist);
213 virtual Geant4ActionPhase*
addPhase(
const std::string& name,
const std::type_info& arg1,
const std::type_info& arg2,
214 const std::type_info& arg3,
bool throw_on_exist);
217 return addPhase(name,
typeid(A0),
typeid(
void),
typeid(
void), throw_on_exist);
220 template <
typename A0,
typename A1>
222 return addPhase(name,
typeid(A0),
typeid(A1),
typeid(
void), throw_on_exist);
225 template <
typename A0,
typename A1,
typename A2>
227 return addPhase(name,
typeid(A0),
typeid(A1),
typeid(A2), throw_on_exist);
235 virtual bool executePhase(
const std::string& name,
const void** args)
const;
238 virtual void loadGeometry(
const std::string& compact_file);
240 virtual void loadXML(
const char* fname);
288 #endif // DD4HEP_DDG4_GEANT4KERNEL_H
void add(const std::string &name, const Property &property)
Add a new property.
virtual Geant4ActionPhase * addPhase(const std::string &name, const std::type_info &arg1, const std::type_info &arg2, const std::type_info &arg3, bool throw_on_exist)
Add a new phase to the phase.
void setTrackMgr(G4TrackingManager *mgr)
Access the tracking manager.
The property class to assign options to actions.
PropertyManager & properties()
Access to the properties of the object.
ClientOutputLevels m_clientLevels
Property: Client output levels.
Geant4Kernel & worker(unsigned long thread_identifier, bool create_if=false)
Access worker instance by it's identifier.
static unsigned long int thread_self()
Access thread identifier.
Geant4Kernel & declareProperty(const std::string &nam, T &val)
Declare property.
int numWorkers() const
Access number of workers.
GlobalActions m_globalFilters
Globally registered filters of sensitive detectors.
std::map< std::string, int > ClientOutputLevels
virtual Geant4ActionPhase * addSimplePhase(const std::string &name, bool throw_on_exist)
Add a new phase to the phase.
Geant4Kernel * m_kernel
Reference to embedding object.
int m_outputLevel
Property: Output level.
virtual int runEvents(int num_events)
Run the simulation: Simulate the number of events "num_events" and modify the property "NumEvents"...
Geant4ActionPhase & operator[](const std::string &name) const
Phase access to the map.
G4RunManager * m_runManager
Reference to the run manager.
Geant4ActionPhase * addPhase(const std::string &name, bool throw_on_exist=true)
Add a new phase to the phase.
GlobalActions m_globalActions
Globally registered actions.
static int terminate(Geant4Kernel &kernel)
Terminate the application.
LCDD & lcdd() const
Access to detector description.
const std::string & directoryName() const
Access the command directory.
virtual int initialize()
Run the simulation: Initialize Geant4.
std::map< unsigned long, Geant4Kernel * > Workers
Property & property(const std::string &name)
Access single property.
std::string m_uiName
Property: Name of the UI action. Must be member of the global actions.
Main executor steering the Geant4 execution.
PhaseSelector(Geant4Kernel *kernel)
Standard constructor.
virtual int run()
Run the simulation: Simulate the number of events given by the property "NumEvents".
virtual Geant4Kernel & createWorker()
Create identified worker instance.
Geant4ActionPhase * getPhase(const std::string &name)
Access phase by name.
static int initialize(Geant4Kernel &kernel)
Initialize the application.
Geant4Kernel(Geant4Kernel *m, unsigned long identifier)
Standard constructor for workers.
Class, which allows all Geant4Action derivatives to access the DDG4 kernel structures.
Geant4Kernel * m_master
Parent reference.
virtual ~Geant4Kernel()
Default destructor.
Class, which allows all Geant4Action to be stored.
PropertyManager m_properties
Property pool.
bool isMultiThreaded() const
Geant4Context * m_threadContext
Geant4Kernel & registerGlobalAction(Geant4Action *action)
Register action by name to be retrieved when setting up and connecting action objects.
Geant4Kernel & master() const
Thread's master context.
Embedded helper class to facilitate map access to the phases.
Workers m_workers
Worker threads.
PrintLevel setOutputLevel(PrintLevel new_level)
Set the global output level of the kernel object; returns previous value.
virtual void loadXML(const char *fname)
Load XML file.
bool hasProperty(const std::string &name) const
Check property for existence.
Geant4ActionPhase * addPhase(const std::string &name, bool throw_on_exist=true)
Add a new phase to the phase.
PrintLevel outputLevel() const
Access the output level.
virtual int terminate()
Run the simulation: Terminate Geant4.
int m_numThreads
Property: Running in multi threaded context.
virtual void destroyPhases()
Destroy all phases. To be called only at shutdown.
G4TrackingManager * m_trackMgr
Reference to Geant4 track manager.
DD4hep::Geometry::LCDD LCDD
std::string m_controlName
Property: Name of the G4UI command tree.
LCDD * m_lcdd
Detector description object.
Phases m_phases
Action phases.
virtual bool executePhase(const std::string &name, const void **args) const
Execute phase action if it exists.
PhaseSelector & operator=(const PhaseSelector &c)
Assignment operator.
G4RunManager & runManager()
Access to the Geant4 run manager.
virtual void loadGeometry(const std::string &compact_file)
Construct detector geometry using lcdd plugin.
static int configure(Geant4Kernel &kernel)
Configure the application.
Geant4Action * globalFilter(const std::string &filter_name, bool throw_if_not_present=true)
Retrieve filter from repository.
class DD4hep::Simulation::Geant4Kernel::PhaseSelector phase
Generic context to extend user, run and event information.
Action phase definition. Client callback at various stage of the simulation processing.
G4TrackingManager * trackMgr() const
Access the tracking manager.
long m_numEvent
Property: Number of events to be executed in batch mode.
The main interface to the DD4hep detector description package.
Geant4Kernel & shared() const
Shared action context.
unsigned long m_id
Flag: Master instance (id<0) or worker (id >= 0)
unsigned long id() const
Access worker identifier.
const Phases & phases() const
Access phase phases.
std::map< std::string, Geant4ActionPhase * > Phases
virtual int configure()
Run the simulation: Configure Geant4.
static int run(Geant4Kernel &kernel)
Run the application and simulate events.
virtual bool removePhase(const std::string &name)
Remove an existing phase from the phase. If not existing returns false.
std::map< std::string, Geant4Action * > GlobalActions
Geant4Action * globalAction(const std::string &action_name, bool throw_if_not_present=true)
Retrieve action from repository.
static Geant4Kernel & instance(LCDD &lcdd)
Instance accessor.
G4UIdirectory * m_control
Top level control directory.
Manager to ease the handling of groups of properties.
void printProperties() const
Print the property values.
Geant4Kernel & registerGlobalFilter(Geant4Action *filter)
Register filter by name to be retrieved when setting up and connecting filter objects.
Geant4ActionPhase * addPhase(const std::string &name, bool throw_on_exist=true)
Add a new phase to the phase.
PrintLevel getOutputLevel(const std::string object) const
Retrieve the global output level of a named object.