DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
Geant4EventAction.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 
14 #ifndef DDG4_GEANT4EVENTACTION_H
15 #define DDG4_GEANT4EVENTACTION_H
16 
17 // Framework include files
18 #include <DDG4/Geant4Action.h>
19 
20 // Forward declarations
21 class G4Event;
22 
24 namespace dd4hep {
25 
27  namespace sim {
28 
29  // Forward declarations
30  class Geant4EventAction;
31  class Geant4SharedEventAction;
32  class Geant4EventActionSequence;
33 
35 
54  public:
56 
57  protected:
60 
61  public:
63  Geant4EventAction(Geant4Context* context, const std::string& nam);
65  virtual ~Geant4EventAction();
67  virtual void begin(const G4Event* event);
69  virtual void end(const G4Event* event);
70  };
71 
73 
86  protected:
89 
90  protected:
93 
94  public:
96  Geant4SharedEventAction(Geant4Context* context, const std::string& nam);
98  virtual ~Geant4SharedEventAction();
100  virtual void configureFiber(Geant4Context* thread_context) override;
102  virtual void use(Geant4EventAction* action);
104  virtual void begin(const G4Event* event) override;
106  virtual void end(const G4Event* event) override;
107  };
108 
110 
125  protected:
134 
135  protected:
138 
139  public:
141  Geant4EventActionSequence(Geant4Context* context, const std::string& nam);
143  virtual ~Geant4EventActionSequence();
145  virtual void updateContext(Geant4Context* ctxt) override;
147  virtual void configureFiber(Geant4Context* thread_context) override;
149  Geant4EventAction* get(const std::string& name) const;
151  template <typename Q, typename T>
152  void callAtBegin(Q* p, void (T::*f)(const G4Event*)) {
153  m_begin.add(p, f);
154  }
156  template <typename Q, typename T>
157  void callAtEnd(Q* p, void (T::*f)(const G4Event*)) {
158  m_end.add(p, f);
159  }
161  template <typename Q, typename T>
162  void callAtFinal(Q* p, void (T::*f)(const G4Event*)) {
163  m_final.add(p, f);
164  }
166  void adopt(Geant4EventAction* action);
168  virtual void begin(const G4Event* event);
170  virtual void end(const G4Event* event);
171  };
172 
173  } // End namespace sim
174 } // End namespace dd4hep
175 #endif // DDG4_GEANT4EVENTACTION_H
dd4hep::sim::Geant4EventActionSequence::begin
virtual void begin(const G4Event *event)
Begin-of-event callback.
Definition: Geant4EventAction.cpp:142
dd4hep::sim::Geant4EventAction::DDG4_DEFINE_ACTION_CONSTRUCTORS
DDG4_DEFINE_ACTION_CONSTRUCTORS(Geant4EventAction)
Define standard assignments and constructors.
dd4hep::sim::Geant4SharedEventAction::configureFiber
virtual void configureFiber(Geant4Context *thread_context) override
Set or update client for the use in a new thread fiber.
Definition: Geant4EventAction.cpp:62
dd4hep::sim::Geant4EventActionSequence::Geant4EventActionSequence
Geant4EventActionSequence(Geant4Context *context, const std::string &nam)
Standard constructor.
Definition: Geant4EventAction.cpp:98
dd4hep::sim::Geant4EventActionSequence::updateContext
virtual void updateContext(Geant4Context *ctxt) override
Set or update client context.
Definition: Geant4EventAction.cpp:115
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::Geant4SharedEventAction::m_action
Geant4EventAction * m_action
Reference to the shared action.
Definition: Geant4EventAction.h:88
dd4hep::sim::Geant4SharedEventAction::DDG4_DEFINE_ACTION_CONSTRUCTORS
DDG4_DEFINE_ACTION_CONSTRUCTORS(Geant4SharedEventAction)
Define standard assignments and constructors.
dd4hep::sim::Geant4EventActionSequence::callAtEnd
void callAtEnd(Q *p, void(T::*f)(const G4Event *))
Register end-of-event callback.
Definition: Geant4EventAction.h:157
dd4hep::sim::Geant4EventActionSequence::m_actors
Actors< Geant4EventAction > m_actors
The list of action objects to be called.
Definition: Geant4EventAction.h:133
dd4hep::sim::Geant4SharedEventAction
Implementation of the Geant4 shared event action.
Definition: Geant4EventAction.h:85
dd4hep::sim::Geant4EventAction
Concrete basic implementation of the Geant4 event action.
Definition: Geant4EventAction.h:53
dd4hep::CallbackSequence
Definition of an actor on sequences of callbacks.
Definition: Callback.h:339
dd4hep::sim::Geant4EventAction::Geant4EventAction
Geant4EventAction(Geant4Context *context, const std::string &nam)
Standard constructor.
Definition: Geant4EventAction.cpp:29
dd4hep::sim::Geant4EventActionSequence::callAtBegin
void callAtBegin(Q *p, void(T::*f)(const G4Event *))
Register begin-of-event callback.
Definition: Geant4EventAction.h:152
dd4hep::sim::Geant4SharedEventAction::use
virtual void use(Geant4EventAction *action)
Underlying object to be used during the execution of this thread.
Definition: Geant4EventAction.cpp:67
dd4hep::sim::Geant4EventActionSequence::m_begin
CallbackSequence m_begin
Callback sequence for event initialization action.
Definition: Geant4EventAction.h:127
dd4hep::sim::Geant4EventAction::begin
virtual void begin(const G4Event *event)
Begin-of-event callback.
Definition: Geant4EventAction.cpp:41
dd4hep::sim::Geant4EventActionSequence::callAtFinal
void callAtFinal(Q *p, void(T::*f)(const G4Event *))
Register event-cleanup callback (after end-of-event callback – unordered)
Definition: Geant4EventAction.h:162
dd4hep::sim::Geant4EventActionSequence::DDG4_DEFINE_ACTION_CONSTRUCTORS
DDG4_DEFINE_ACTION_CONSTRUCTORS(Geant4EventActionSequence)
Define standard assignments and constructors.
dd4hep::sim::Geant4EventAction::shared_type
Geant4SharedEventAction shared_type
Definition: Geant4EventAction.h:55
dd4hep::sim::Geant4EventActionSequence::m_end
CallbackSequence m_end
Callback sequence for event finalization action.
Definition: Geant4EventAction.h:129
dd4hep::sim::Geant4Action
Default base class for all Geant 4 actions and derivates thereof.
Definition: Geant4Action.h:113
dd4hep::sim::Geant4Action::name
const std::string & name() const
Access name of the action.
Definition: Geant4Action.h:280
dd4hep::sim::Geant4EventAction::~Geant4EventAction
virtual ~Geant4EventAction()
Default destructor.
Definition: Geant4EventAction.cpp:36
dd4hep::sim::Geant4SharedEventAction::~Geant4SharedEventAction
virtual ~Geant4SharedEventAction()
Default destructor.
Definition: Geant4EventAction.cpp:56
dd4hep::sim::Geant4EventActionSequence::end
virtual void end(const G4Event *event)
End-of-event callback.
Definition: Geant4EventAction.cpp:148
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::sim::Geant4SharedEventAction::begin
virtual void begin(const G4Event *event) override
Begin-of-event callback.
Definition: Geant4EventAction.cpp:78
dd4hep::sim::Geant4EventActionSequence::get
Geant4EventAction * get(const std::string &name) const
Get an action by name.
Definition: Geant4EventAction.cpp:126
dd4hep::sim::Geant4EventActionSequence::configureFiber
virtual void configureFiber(Geant4Context *thread_context) override
Set or update client for the use in a new thread fiber.
Definition: Geant4EventAction.cpp:121
dd4hep::sim::Geant4EventActionSequence::m_final
CallbackSequence m_final
Callback sequence for event finalization action.
Definition: Geant4EventAction.h:131
dd4hep::sim::Geant4Action::Actors
Actor class to manipulate action groups.
Definition: Geant4Action.h:168
dd4hep::sim::Geant4EventAction::end
virtual void end(const G4Event *event)
End-of-event callback.
Definition: Geant4EventAction.cpp:45
dd4hep::sim::Geant4EventActionSequence
Concrete implementation of the Geant4 event action sequence.
Definition: Geant4EventAction.h:124
dd4hep::sim::Geant4SharedEventAction::Geant4SharedEventAction
Geant4SharedEventAction(Geant4Context *context, const std::string &nam)
Standard constructor.
Definition: Geant4EventAction.cpp:49
dd4hep::sim::Geant4EventActionSequence::~Geant4EventActionSequence
virtual ~Geant4EventActionSequence()
Default destructor.
Definition: Geant4EventAction.cpp:105
dd4hep::sim::Geant4SharedEventAction::end
virtual void end(const G4Event *event) override
End-of-event callback.
Definition: Geant4EventAction.cpp:88
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
dd4hep::sim::Geant4EventActionSequence::adopt
void adopt(Geant4EventAction *action)
Add an actor responding to all callbacks. Sequence takes ownership.
Definition: Geant4EventAction.cpp:131