DD4hep - The AIDA detector description toolkit for high energy physics experiments
DD4hep  Rev:Unversioneddirectory
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Geant4EventAction.h
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation for LCD
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 DD4HEP_DDG4_GEANT4EVENTACTION_H
15 #define DD4HEP_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 Simulation {
28 
29  // Forward declarations
30  class Geant4EventAction;
31  class Geant4SharedEventAction;
32  class Geant4EventActionSequence;
33 
35 
54  public:
56  protected:
58  Geant4EventAction() = default;
60  Geant4EventAction(const Geant4EventAction& copy) = delete;
63 
64  public:
66  Geant4EventAction(Geant4Context* context, const std::string& nam);
68  virtual ~Geant4EventAction();
70  virtual void begin(const G4Event* event);
72  virtual void end(const G4Event* event);
73  };
74 
76 
89  protected:
92 
93  protected:
95  Geant4SharedEventAction() = default;
100 
101  public:
103  Geant4SharedEventAction(Geant4Context* context, const std::string& nam);
105  virtual ~Geant4SharedEventAction();
107  virtual void configureFiber(Geant4Context* thread_context);
109  virtual void use(Geant4EventAction* action);
111  virtual void begin(const G4Event* event);
113  virtual void end(const G4Event* event);
114  };
115 
117 
132  protected:
141 
142  protected:
144  Geant4EventActionSequence() = default;
149 
150  public:
152  Geant4EventActionSequence(Geant4Context* context, const std::string& nam);
154  virtual ~Geant4EventActionSequence();
156  virtual void updateContext(Geant4Context* ctxt);
158  virtual void configureFiber(Geant4Context* thread_context);
160  Geant4EventAction* get(const std::string& name) const;
162  template <typename Q, typename T>
163  void callAtBegin(Q* p, void (T::*f)(const G4Event*)) {
164  m_begin.add(p, f);
165  }
167  template <typename Q, typename T>
168  void callAtEnd(Q* p, void (T::*f)(const G4Event*)) {
169  m_end.add(p, f);
170  }
172  template <typename Q, typename T>
173  void callAtFinal(Q* p, void (T::*f)(const G4Event*)) {
174  m_final.add(p, f);
175  }
177  void adopt(Geant4EventAction* action);
179  virtual void begin(const G4Event* event);
181  virtual void end(const G4Event* event);
182  };
183 
184  } // End namespace Simulation
185 } // End namespace DD4hep
186 
187 #endif // DD4HEP_DDG4_GEANT4EVENTACTION_H
virtual void configureFiber(Geant4Context *thread_context)
Set or update client for the use in a new thread fiber.
Geant4SharedEventAction()=default
Inhibit copy constructor.
Geant4EventAction & operator=(const Geant4EventAction &copy)=delete
Inhibit assignment operator.
virtual ~Geant4EventActionSequence()
Default destructor.
virtual void end(const G4Event *event)
End-of-event callback.
Geant4EventActionSequence()=default
Inhibit copy constructor.
virtual void end(const G4Event *event)
End-of-event callback.
void callAtEnd(Q *p, void(T::*f)(const G4Event *))
Register end-of-event callback.
virtual ~Geant4SharedEventAction()
Default destructor.
void add(const Callback &cb, Location where)
Generically Add a new callback to the sequence depending on the location arguments.
Definition: Callback.h:362
void copy(Alignment from, Alignment to)
Copy alignment object from source object.
void callAtFinal(Q *p, void(T::*f)(const G4Event *))
Register event-cleanup callback (after end-of-event callback – unordered)
virtual void updateContext(Geant4Context *ctxt)
Set or update client context.
Definition of an actor on sequences of callbacks.
Definition: Callback.h:334
Concrete implementation of the Geant4 event action sequence.
Concrete basic implementation of the Geant4 event action.
Geant4Context * context() const
Access the context.
Definition: Geant4Action.h:261
const std::string & name() const
Access name of the action.
Definition: Geant4Action.h:271
void callAtBegin(Q *p, void(T::*f)(const G4Event *))
Register begin-of-event callback.
CallbackSequence m_end
Callback sequence for event finalization action.
void adopt(Geant4EventAction *action)
Add an actor responding to all callbacks. Sequence takes ownership.
Implementation of the Geant4 shared event action.
Geant4EventAction * m_action
Reference to the shared action.
CallbackSequence m_begin
Callback sequence for event initialization action.
virtual void end(const G4Event *event)
End-of-event callback.
virtual void begin(const G4Event *event)
Begin-of-event callback.
virtual void configureFiber(Geant4Context *thread_context)
Set or update client for the use in a new thread fiber.
virtual ~Geant4EventAction()
Default destructor.
Geant4EventAction()=default
Inhibit copy constructor.
Geant4EventActionSequence & operator=(const Geant4EventActionSequence &copy)=delete
Inhibit assignment operator.
Generic context to extend user, run and event information.
Geant4SharedEventAction & operator=(const Geant4SharedEventAction &copy)=delete
Inhibit assignment operator.
virtual void use(Geant4EventAction *action)
Underlying object to be used during the execution of this thread.
Default base class for all Geant 4 actions and derivates thereof.
Definition: Geant4Action.h:91
CallbackSequence m_final
Callback sequence for event finalization action.
virtual void begin(const G4Event *event)
Begin-of-event callback.
virtual void begin(const G4Event *event)
Begin-of-event callback.
Actors< Geant4EventAction > m_actors
The list of action objects to be called.
Actor class to manipulate action groups.
Definition: Geant4Action.h:146