DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
Geant4UserInitialization.h
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_GEANT4USERINITIALIZATION_H
14 #define DDG4_GEANT4USERINITIALIZATION_H
15 
16 // Framework include files
17 #include <DDG4/Geant4Action.h>
18 
19 // Forward declarations
20 
22 namespace dd4hep {
23 
25  namespace sim {
26 
28 
34  protected:
35  public:
37  Geant4UserInitialization(Geant4Context* c, const std::string& nam);
39  virtual ~Geant4UserInitialization();
41  virtual void build() const;
43  virtual void buildMaster() const;
44  };
45 
47 
53  protected:
59  Actors<Geant4UserInitialization> m_actors;
60 
61  public:
63  Geant4UserInitializationSequence(Geant4Context* c, const std::string& nam);
67  template <typename Q, typename T> void build(Q* p, void (T::*f)()) {
68  m_workerCalls.add(p, f);
69  }
71  template <typename Q, typename T> void buildMaster(Q* p, void (T::*f)()) {
72  m_masterCalls.add(p, f);
73  }
75  void adopt(Geant4UserInitialization* action);
76 
78  virtual void updateContext(Geant4Context* ctxt) override;
80  virtual void build() const override;
82  virtual void buildMaster() const override;
83  };
84 
85  } // End namespace sim
86 } // End namespace dd4hep
87 #endif // DDG4_GEANT4USERINITIALIZATION_H
dd4hep::sim::Geant4UserInitializationSequence::adopt
void adopt(Geant4UserInitialization *action)
Add an actor responding to all callbacks. Sequence takes ownership.
Definition: Geant4UserInitialization.cpp:57
dd4hep::sim::Geant4UserInitializationSequence
Class to orchestrate a modular initializion of a multi- or single threaded Geant4 application.
Definition: Geant4UserInitialization.h:52
dd4hep::sim::Geant4UserInitialization::~Geant4UserInitialization
virtual ~Geant4UserInitialization()
Default destructor.
Definition: Geant4UserInitialization.cpp:28
dd4hep::CallbackSequence::add
void add(const Callback &cb, Location where)
Generically Add a new callback to the sequence depending on the location arguments.
Definition: Callback.h:367
dd4hep::sim::Geant4UserInitialization::build
virtual void build() const
Callback function to build setup for the MT worker thread.
Definition: Geant4UserInitialization.cpp:33
dd4hep::sim::Geant4UserInitializationSequence::m_actors
Actors< Geant4UserInitialization > m_actors
The list of action objects to be called.
Definition: Geant4UserInitialization.h:59
dd4hep::sim::Geant4UserInitialization::Geant4UserInitialization
Geant4UserInitialization(Geant4Context *c, const std::string &nam)
Standard constructor.
Definition: Geant4UserInitialization.cpp:21
dd4hep::sim::Geant4UserInitializationSequence::build
void build(Q *p, void(T::*f)())
Register callback to setup worker. Types Q and T must be polymorph!
Definition: Geant4UserInitialization.h:67
dd4hep::CallbackSequence
Definition of an actor on sequences of callbacks.
Definition: Callback.h:339
dd4hep::sim::Geant4UserInitialization
Base class to initialize a multi-threaded or single threaded Geant4 application.
Definition: Geant4UserInitialization.h:33
dd4hep::sim::Geant4UserInitializationSequence::buildMaster
void buildMaster(Q *p, void(T::*f)())
Register callback to setup master. Types Q and T must be polymorph!
Definition: Geant4UserInitialization.h:71
dd4hep::sim::Geant4Action
Default base class for all Geant 4 actions and derivates thereof.
Definition: Geant4Action.h:113
dd4hep::sim::Geant4UserInitializationSequence::m_masterCalls
CallbackSequence m_masterCalls
Callback sequence to initialize the thread master.
Definition: Geant4UserInitialization.h:55
dd4hep::sim::Geant4UserInitializationSequence::m_workerCalls
CallbackSequence m_workerCalls
Callback sequence to initialize worker elements.
Definition: Geant4UserInitialization.h:57
dd4hep::sim::Geant4UserInitializationSequence::~Geant4UserInitializationSequence
virtual ~Geant4UserInitializationSequence()
Default destructor.
Definition: Geant4UserInitialization.cpp:48
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::sim::Geant4UserInitializationSequence::updateContext
virtual void updateContext(Geant4Context *ctxt) override
Set client context.
Definition: Geant4UserInitialization.cpp:79
dd4hep::sim::Geant4UserInitialization::buildMaster
virtual void buildMaster() const
Callback function to build setup for the MT master thread.
Definition: Geant4UserInitialization.cpp:37
dd4hep::sim::Geant4UserInitializationSequence::build
virtual void build() const override
Callback function to build setup for the MT worker thread.
Definition: Geant4UserInitialization.cpp:67
dd4hep::sim::Geant4UserInitializationSequence::Geant4UserInitializationSequence
Geant4UserInitializationSequence(Geant4Context *c, const std::string &nam)
Standard constructor.
Definition: Geant4UserInitialization.cpp:41
dd4hep::sim::Geant4UserInitializationSequence::buildMaster
virtual void buildMaster() const override
Callback function to build setup for the MT master thread.
Definition: Geant4UserInitialization.cpp:73
Geant4Action.h
dd4hep::sim::Geant4Context
Generic context to extend user, run and event information.
Definition: Geant4Context.h:201