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
Geant4RunAction.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_GEANT4RUNACTION_H
15 #define DD4HEP_DDG4_GEANT4RUNACTION_H
16 
17 // Framework include files
18 #include "DDG4/Geant4Action.h"
19 
20 // Forward declaration
21 class G4Run;
22 
24 namespace DD4hep {
25 
27  namespace Simulation {
28 
29  // Forward declarations
30  class Geant4RunAction;
31  class Geant4SharedRunAction;
32  class Geant4RunActionSequence;
33 
35 
45  class Geant4RunAction: public Geant4Action {
46  public:
48 
49  protected:
51  Geant4RunAction() = default;
53  Geant4RunAction(const Geant4RunAction& copy) = delete;
56 
57  public:
59  Geant4RunAction(Geant4Context* context, const std::string& nam);
61  virtual ~Geant4RunAction();
63  virtual void begin(const G4Run* run);
65  virtual void end(const G4Run* run);
66  };
67 
69 
82  protected:
85 
86  protected:
88  Geant4SharedRunAction() = default;
93 
94  public:
97  Geant4SharedRunAction(Geant4Context* context, const std::string& nam);
99  virtual ~Geant4SharedRunAction();
101  virtual void configureFiber(Geant4Context* thread_context);
103  virtual void use(Geant4RunAction* action);
105  virtual void begin(const G4Run* run);
107  virtual void end(const G4Run* run);
108  };
109 
111 
126 
127  protected:
133  Actors<Geant4RunAction> m_actors;
134 
135  protected:
137  Geant4RunActionSequence() = default;
142 
143  public:
145  Geant4RunActionSequence(Geant4Context* context, const std::string& nam);
147  virtual ~Geant4RunActionSequence();
149  virtual void updateContext(Geant4Context* ctxt);
151  virtual void configureFiber(Geant4Context* thread_context);
153  Geant4RunAction* get(const std::string& name) const;
155  template <typename Q, typename T>
156  void callAtBegin(Q* p, void (T::*f)(const G4Run*)) {
157  m_begin.add(p, f);
158  }
160  template <typename Q, typename T>
161  void callAtEnd(Q* p, void (T::*f)(const G4Run*)) {
162  m_end.add(p, f);
163  }
165  void adopt(Geant4RunAction* action);
167  virtual void begin(const G4Run* run);
169  virtual void end(const G4Run* run);
170  };
171 
172  } // End namespace Simulation
173 } // End namespace DD4hep
174 
175 #endif // DD4HEP_DDG4_GEANT4RUNACTION_H
virtual ~Geant4SharedRunAction()
Default destructor.
Geant4RunAction & operator=(const Geant4RunAction &copy)=delete
Inhibit assignment operator.
Geant4SharedRunAction()=default
Inhibit default constructor.
virtual void end(const G4Run *run)
End-of-run callback.
virtual void configureFiber(Geant4Context *thread_context)
Set or update client for the use in a new thread fiber.
void callAtEnd(Q *p, void(T::*f)(const G4Run *))
Register end-of-run callback. Types Q and T must be polymorph!
void add(const Callback &cb, Location where)
Generically Add a new callback to the sequence depending on the location arguments.
Definition: Callback.h:362
Concrete basic implementation of the Geant4 run action base class.
void copy(Alignment from, Alignment to)
Copy alignment object from source object.
Definition of an actor on sequences of callbacks.
Definition: Callback.h:334
Geant4Context * context() const
Access the context.
Definition: Geant4Action.h:261
virtual void begin(const G4Run *run)
Begin-of-run callback.
const std::string & name() const
Access name of the action.
Definition: Geant4Action.h:271
virtual void updateContext(Geant4Context *ctxt)
Set or update client context.
virtual void configureFiber(Geant4Context *thread_context)
Set or update client for the use in a new thread fiber.
Geant4RunAction()=default
Inhibit default constructor.
CallbackSequence m_begin
Callback sequence for begin-run action.
virtual ~Geant4RunAction()
Default destructor.
void callAtBegin(Q *p, void(T::*f)(const G4Run *))
Register begin-of-run callback. Types Q and T must be polymorph!
virtual void use(Geant4RunAction *action)
Underlying object to be used during the execution of this thread.
Implementation of the Geant4 shared run action.
virtual ~Geant4RunActionSequence()
Default destructor.
Actors< Geant4RunAction > m_actors
The list of action objects to be called.
Concrete basic implementation of the Geant4 run action sequencer.
virtual void end(const G4Run *run)
End-of-run callback.
CallbackSequence m_end
Callback sequence for end-run action.
Geant4RunAction * m_action
Reference to the shared action.
Geant4SharedRunAction & operator=(const Geant4SharedRunAction &copy)=delete
Inhibit assignment operator.
virtual void end(const G4Run *run)
End-of-run callback.
Generic context to extend user, run and event information.
void adopt(Geant4RunAction *action)
Add an actor responding to all callbacks. Sequence takes ownership.
Geant4RunActionSequence & operator=(const Geant4RunActionSequence &copy)=delete
Inhibit assignment operator.
Geant4RunActionSequence()=default
Inhibit default constructor.
Default base class for all Geant 4 actions and derivates thereof.
Definition: Geant4Action.h:91
virtual void begin(const G4Run *run)
Begin-of-run callback.
virtual void begin(const G4Run *run)
Begin-of-run callback.