DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
Geant4RunAction.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_GEANT4RUNACTION_H
15 #define 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 sim {
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:
52 
53  public:
55  Geant4RunAction(Geant4Context* context, const std::string& nam);
57  virtual ~Geant4RunAction();
59  virtual void begin(const G4Run* run);
61  virtual void end(const G4Run* run);
62  };
63 
65 
78  protected:
81 
82  protected:
85 
86  public:
89  Geant4SharedRunAction(Geant4Context* context, const std::string& nam);
91  virtual ~Geant4SharedRunAction();
93  virtual void configureFiber(Geant4Context* thread_context) override;
95  virtual void use(Geant4RunAction* action);
97  virtual void begin(const G4Run* run) override;
99  virtual void end(const G4Run* run) override;
100  };
101 
103 
118 
119  protected:
126 
127  protected:
130 
131  public:
133  Geant4RunActionSequence(Geant4Context* context, const std::string& nam);
135  virtual ~Geant4RunActionSequence();
137  virtual void updateContext(Geant4Context* ctxt) override;
139  virtual void configureFiber(Geant4Context* thread_context) override;
141  Geant4RunAction* get(const std::string& name) const;
143  template <typename Q, typename T>
144  void callAtBegin(Q* p, void (T::*f)(const G4Run*)) {
145  m_begin.add(p, f);
146  }
148  template <typename Q, typename T>
149  void callAtEnd(Q* p, void (T::*f)(const G4Run*)) {
150  m_end.add(p, f);
151  }
153  void adopt(Geant4RunAction* action);
155  virtual void begin(const G4Run* run);
157  virtual void end(const G4Run* run);
158  };
159 
160  } // End namespace sim
161 } // End namespace dd4hep
162 
163 #endif // DDG4_GEANT4RUNACTION_H
dd4hep::sim::Geant4RunActionSequence::adopt
void adopt(Geant4RunAction *action)
Add an actor responding to all callbacks. Sequence takes ownership.
Definition: Geant4RunAction.cpp:130
dd4hep::sim::Geant4RunActionSequence::updateContext
virtual void updateContext(Geant4Context *ctxt) override
Set or update client context.
Definition: Geant4RunAction.cpp:114
dd4hep::sim::Geant4SharedRunAction::~Geant4SharedRunAction
virtual ~Geant4SharedRunAction()
Default destructor.
Definition: Geant4RunAction.cpp:56
dd4hep::sim::Geant4RunAction::DDG4_DEFINE_ACTION_CONSTRUCTORS
DDG4_DEFINE_ACTION_CONSTRUCTORS(Geant4RunAction)
Define standard assignments and constructors.
dd4hep::sim::Geant4RunActionSequence::m_actors
Actors< Geant4RunAction > m_actors
The list of action objects to be called.
Definition: Geant4RunAction.h:125
dd4hep::sim::Geant4RunActionSequence::end
virtual void end(const G4Run *run)
End-of-run callback.
Definition: Geant4RunAction.cpp:148
dd4hep::sim::Geant4RunActionSequence::Geant4RunActionSequence
Geant4RunActionSequence(Geant4Context *context, const std::string &nam)
Standard constructor.
Definition: Geant4RunAction.cpp:98
dd4hep::sim::Geant4SharedRunAction::end
virtual void end(const G4Run *run) override
End-of-run callback.
Definition: Geant4RunAction.cpp:88
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::Geant4RunActionSequence::callAtBegin
void callAtBegin(Q *p, void(T::*f)(const G4Run *))
Register begin-of-run callback. Types Q and T must be polymorph!
Definition: Geant4RunAction.h:144
dd4hep::sim::Geant4RunAction::begin
virtual void begin(const G4Run *run)
Begin-of-run callback.
Definition: Geant4RunAction.cpp:41
dd4hep::sim::Geant4SharedRunAction
Implementation of the Geant4 shared run action.
Definition: Geant4RunAction.h:77
dd4hep::sim::Geant4RunActionSequence::callAtEnd
void callAtEnd(Q *p, void(T::*f)(const G4Run *))
Register end-of-run callback. Types Q and T must be polymorph!
Definition: Geant4RunAction.h:149
dd4hep::CallbackSequence
Definition of an actor on sequences of callbacks.
Definition: Callback.h:339
dd4hep::sim::Geant4SharedRunAction::DDG4_DEFINE_ACTION_CONSTRUCTORS
DDG4_DEFINE_ACTION_CONSTRUCTORS(Geant4SharedRunAction)
Define standard assignments and constructors.
dd4hep::sim::Geant4RunActionSequence::~Geant4RunActionSequence
virtual ~Geant4RunActionSequence()
Default destructor.
Definition: Geant4RunAction.cpp:105
dd4hep::sim::Geant4SharedRunAction::begin
virtual void begin(const G4Run *run) override
Begin-of-run callback.
Definition: Geant4RunAction.cpp:78
dd4hep::sim::Geant4RunAction::end
virtual void end(const G4Run *run)
End-of-run callback.
Definition: Geant4RunAction.cpp:45
dd4hep::sim::Geant4SharedRunAction::Geant4SharedRunAction
Geant4SharedRunAction(Geant4Context *context, const std::string &nam)
Standard constructor.
Definition: Geant4RunAction.cpp:49
dd4hep::sim::Geant4RunActionSequence
Concrete basic implementation of the Geant4 run action sequencer.
Definition: Geant4RunAction.h:117
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::Geant4SharedRunAction::configureFiber
virtual void configureFiber(Geant4Context *thread_context) override
Set or update client for the use in a new thread fiber.
Definition: Geant4RunAction.cpp:62
dd4hep::sim::Geant4RunActionSequence::begin
virtual void begin(const G4Run *run)
Begin-of-run callback.
Definition: Geant4RunAction.cpp:141
dd4hep::sim::Geant4SharedRunAction::m_action
Geant4RunAction * m_action
Reference to the shared action.
Definition: Geant4RunAction.h:80
dd4hep::sim::Geant4SharedRunAction::use
virtual void use(Geant4RunAction *action)
Underlying object to be used during the execution of this thread.
Definition: Geant4RunAction.cpp:67
dd4hep::sim::Geant4RunActionSequence::m_begin
CallbackSequence m_begin
Callback sequence for begin-run action.
Definition: Geant4RunAction.h:121
dd4hep::sim::Geant4RunAction::shared_type
Geant4SharedRunAction shared_type
Definition: Geant4RunAction.h:47
dd4hep::sim::Geant4RunActionSequence::get
Geant4RunAction * get(const std::string &name) const
Get an action by name.
Definition: Geant4RunAction.cpp:125
dd4hep::sim::Geant4RunAction
Concrete basic implementation of the Geant4 run action base class.
Definition: Geant4RunAction.h:45
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::sim::Geant4RunAction::~Geant4RunAction
virtual ~Geant4RunAction()
Default destructor.
Definition: Geant4RunAction.cpp:36
dd4hep::sim::Geant4RunActionSequence::DDG4_DEFINE_ACTION_CONSTRUCTORS
DDG4_DEFINE_ACTION_CONSTRUCTORS(Geant4RunActionSequence)
Define standard assignments and constructors.
dd4hep::sim::Geant4Action::Actors
Actor class to manipulate action groups.
Definition: Geant4Action.h:168
dd4hep::sim::Geant4RunActionSequence::m_end
CallbackSequence m_end
Callback sequence for end-run action.
Definition: Geant4RunAction.h:123
dd4hep::sim::Geant4RunActionSequence::configureFiber
virtual void configureFiber(Geant4Context *thread_context) override
Set or update client for the use in a new thread fiber.
Definition: Geant4RunAction.cpp:120
dd4hep::sim::Geant4RunAction::Geant4RunAction
Geant4RunAction(Geant4Context *context, const std::string &nam)
Standard constructor.
Definition: Geant4RunAction.cpp:30
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