DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
Geant4GeneratorAction.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_GEANT4GENERATORACTION_H
14 #define DDG4_GEANT4GENERATORACTION_H
15 
16 // Framework include files
17 #include <DDG4/Geant4Action.h>
18 
19 // Forward declaration
20 class G4Event;
21 
23 namespace dd4hep {
24 
26  namespace sim {
27 
28  // Forward declarations
29  class Geant4GeneratorAction;
30  class Geant4SharedGeneratorAction;
31  class Geant4GeneratorActionSequence;
32 
34 
48  public:
50  protected:
52 
55  public:
57  Geant4GeneratorAction(Geant4Context* context, const std::string& name);
59  virtual ~Geant4GeneratorAction();
61  virtual void operator()(G4Event*) {
62  }
63  };
64 
66 
79  protected:
82 
85  public:
87  Geant4SharedGeneratorAction(Geant4Context* context, const std::string& nam);
91  virtual void configureFiber(Geant4Context* thread_context) override;
93  virtual void use(Geant4GeneratorAction* action);
95  virtual void operator()(G4Event* event) override;
96  };
97 
99 
116  protected:
120  Actors<Geant4GeneratorAction> m_actors;
121 
124  public:
130  virtual void updateContext(Geant4Context* ctxt) override;
132  virtual void configureFiber(Geant4Context* thread_context) override;
134  Geant4GeneratorAction* get(const std::string& name) const;
136  template <typename Q, typename T>
137  void call(Q* p, void (T::*f)(G4Event*)) {
138  m_calls.add(p, f);
139  }
141  void adopt(Geant4GeneratorAction* action);
143  virtual void operator()(G4Event* event);
144  };
145 
146  } // End namespace sim
147 } // End namespace dd4hep
148 
149 #endif // DDG4_GEANT4GENERATORACTION_H
dd4hep::sim::Geant4GeneratorActionSequence::m_calls
CallbackSequence m_calls
Callback sequence to generate primary particles.
Definition: Geant4GeneratorAction.h:118
dd4hep::sim::Geant4GeneratorActionSequence::m_actors
Actors< Geant4GeneratorAction > m_actors
The list of action objects to be called.
Definition: Geant4GeneratorAction.h:120
dd4hep::sim::Geant4GeneratorAction::operator()
virtual void operator()(G4Event *)
Callback to generate primary particles.
Definition: Geant4GeneratorAction.h:61
dd4hep::sim::Geant4GeneratorActionSequence::~Geant4GeneratorActionSequence
virtual ~Geant4GeneratorActionSequence()
Default destructor.
Definition: Geant4GeneratorAction.cpp:86
dd4hep::sim::Geant4GeneratorAction::Geant4GeneratorAction
Geant4GeneratorAction(Geant4Context *context, const std::string &name)
Standard constructor.
Definition: Geant4GeneratorAction.cpp:30
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::Geant4SharedGeneratorAction::configureFiber
virtual void configureFiber(Geant4Context *thread_context) override
Set or update client for the use in a new thread fiber.
Definition: Geant4GeneratorAction.cpp:54
dd4hep::sim::Geant4GeneratorActionSequence::Geant4GeneratorActionSequence
Geant4GeneratorActionSequence(Geant4Context *context, const std::string &name)
Standard constructor.
Definition: Geant4GeneratorAction.cpp:79
dd4hep::CallbackSequence
Definition of an actor on sequences of callbacks.
Definition: Callback.h:339
dd4hep::sim::Geant4GeneratorActionSequence
Concrete implementation of the Geant4 generator action sequence.
Definition: Geant4GeneratorAction.h:115
dd4hep::sim::Geant4GeneratorActionSequence::call
void call(Q *p, void(T::*f)(G4Event *))
Register primary particle generation callback. Types Q and T must be polymorph!
Definition: Geant4GeneratorAction.h:137
dd4hep::Callback
Definition of the generic callback structure for member functions.
Definition: Callback.h:38
dd4hep::sim::Geant4GeneratorAction::DDG4_DEFINE_ACTION_CONSTRUCTORS
DDG4_DEFINE_ACTION_CONSTRUCTORS(Geant4GeneratorAction)
Define standard assignments and constructors.
dd4hep::sim::Geant4GeneratorAction
Concrete implementation of the Geant4 generator action base class.
Definition: Geant4GeneratorAction.h:47
dd4hep::sim::Geant4GeneratorActionSequence::get
Geant4GeneratorAction * get(const std::string &name) const
Get an action by name.
Definition: Geant4GeneratorAction.cpp:105
dd4hep::sim::Geant4Action
Default base class for all Geant 4 actions and derivates thereof.
Definition: Geant4Action.h:113
dd4hep::sim::Geant4GeneratorActionSequence::operator()
virtual void operator()(G4Event *event)
Callback to generate primary particles.
Definition: Geant4GeneratorAction.cpp:121
dd4hep::sim::Geant4Action::name
const std::string & name() const
Access name of the action.
Definition: Geant4Action.h:280
dd4hep::sim::Geant4GeneratorAction::m_calls
Callback m_calls
Definition: Geant4GeneratorAction.h:51
dd4hep::sim::Geant4SharedGeneratorAction::m_action
Geant4GeneratorAction * m_action
Reference to the shared action.
Definition: Geant4GeneratorAction.h:81
dd4hep::sim::Geant4GeneratorActionSequence::configureFiber
virtual void configureFiber(Geant4Context *thread_context) override
Set or update client for the use in a new thread fiber.
Definition: Geant4GeneratorAction.cpp:100
dd4hep::sim::Geant4GeneratorActionSequence::DDG4_DEFINE_ACTION_CONSTRUCTORS
DDG4_DEFINE_ACTION_CONSTRUCTORS(Geant4GeneratorActionSequence)
Define standard assignments and constructors.
dd4hep::sim::Geant4GeneratorAction::~Geant4GeneratorAction
virtual ~Geant4GeneratorAction()
Default destructor.
Definition: Geant4GeneratorAction.cpp:36
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::sim::Geant4SharedGeneratorAction::~Geant4SharedGeneratorAction
virtual ~Geant4SharedGeneratorAction()
Default destructor.
Definition: Geant4GeneratorAction.cpp:48
dd4hep::sim::Geant4SharedGeneratorAction::use
virtual void use(Geant4GeneratorAction *action)
Underlying object to be used during the execution of this thread.
Definition: Geant4GeneratorAction.cpp:59
dd4hep::sim::Geant4SharedGeneratorAction::Geant4SharedGeneratorAction
Geant4SharedGeneratorAction(Geant4Context *context, const std::string &nam)
Standard constructor.
Definition: Geant4GeneratorAction.cpp:41
dd4hep::sim::Geant4GeneratorActionSequence::updateContext
virtual void updateContext(Geant4Context *ctxt) override
Set or update client context.
Definition: Geant4GeneratorAction.cpp:94
dd4hep::sim::Geant4SharedGeneratorAction
Implementation of the Geant4 shared generator action.
Definition: Geant4GeneratorAction.h:78
dd4hep::sim::Geant4GeneratorAction::shared_type
Geant4SharedGeneratorAction shared_type
Definition: Geant4GeneratorAction.h:49
dd4hep::sim::Geant4SharedGeneratorAction::operator()
virtual void operator()(G4Event *event) override
User generator callback.
Definition: Geant4GeneratorAction.cpp:69
Geant4Action.h
dd4hep::sim::Geant4Context
Generic context to extend user, run and event information.
Definition: Geant4Context.h:201
dd4hep::sim::Geant4GeneratorActionSequence::adopt
void adopt(Geant4GeneratorAction *action)
Add an actor responding to all callbacks. Sequence takes ownership.
Definition: Geant4GeneratorAction.cpp:110
dd4hep::sim::Geant4Action::context
Geant4Context * context() const
Access the context.
Definition: Geant4Action.h:270
dd4hep::sim::Geant4SharedGeneratorAction::DDG4_DEFINE_ACTION_CONSTRUCTORS
DDG4_DEFINE_ACTION_CONSTRUCTORS(Geant4SharedGeneratorAction)
Define standard assignments and constructors.