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
Geant4StackingAction.h
Go to the documentation of this file.
1 // $Id: $
2 //==========================================================================
3 // AIDA Detector description implementation for LCD
4 //--------------------------------------------------------------------------
5 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
6 // All rights reserved.
7 //
8 // For the licensing terms see $DD4hepINSTALL/LICENSE.
9 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
10 //
11 // Author : M.Frank
12 //
13 //==========================================================================
14 #ifndef DD4HEP_DDG4_GEANT4STACKINGACTION_H
15 #define DD4HEP_DDG4_GEANT4STACKINGACTION_H
16 
17 // Framework include files
18 #include "DDG4/Geant4Action.h"
19 
21 namespace DD4hep {
22 
24  namespace Simulation {
25 
26  // Forward declarations
27  class Geant4StackingAction;
28  class Geant4SharedStackingAction;
29  class Geant4StackingActionSequence;
30 
32 
38  public:
40  public:
42  Geant4StackingAction(Geant4Context* ctxt, const std::string& name);
44  virtual ~Geant4StackingAction();
46  virtual void newStage() {
47  }
49  virtual void prepare() {
50  }
51  };
52 
54 
67  protected:
70  public:
72  Geant4SharedStackingAction(Geant4Context* context, const std::string& nam);
76  virtual void configureFiber(Geant4Context* thread_context);
78  virtual void use(Geant4StackingAction* action);
80  virtual void newStage();
82  virtual void prepare();
83  };
84 
86 
101  protected:
104  // Callback sequence for the prepare call
107  Actors<Geant4StackingAction> m_actors;
108  public:
110  Geant4StackingActionSequence(Geant4Context* ctxt, const std::string& name);
114  virtual void updateContext(Geant4Context* ctxt);
116  virtual void configureFiber(Geant4Context* thread_context);
118  Geant4StackingAction* get(const std::string& name) const;
120  template <typename T> void callAtNewStage(T* p, void (T::*f)()) {
121  m_newStage.add(p, f);
122  }
124  template <typename T> void callAtPrepare(T* p, void (T::*f)()) {
125  m_prepare.add(p, f);
126  }
128  void adopt(Geant4StackingAction* action);
130  virtual void newStage();
132  virtual void prepare();
133  };
134 
135  } // End namespace Simulation
136 } // End namespace DD4hep
137 
138 #endif // DD4HEP_DDG4_GEANT4STACKINGACTION_H
virtual void prepare()
Preparation callback.
virtual void prepare()
Preparation callback.
virtual void configureFiber(Geant4Context *thread_context)
Set or update client for the use in a new thread fiber.
virtual void configureFiber(Geant4Context *thread_context)
Set or update client for the use in a new thread fiber.
CallbackSequence m_newStage
Callback sequence for the newStage call.
void callAtNewStage(T *p, void(T::*f)())
Register begin-of-event 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
Definition of an actor on sequences of callbacks.
Definition: Callback.h:334
Concrete implementation of the Geant4 stacking action base class.
Geant4SharedStackingAction(Geant4Context *context, const std::string &nam)
Standard constructor.
virtual void use(Geant4StackingAction *action)
Underlying object to be used during the execution of this thread.
Geant4Context * context() const
Access the context.
Definition: Geant4Action.h:261
const std::string & name() const
Access name of the action.
Definition: Geant4Action.h:271
Concrete implementation of the Geant4 stacking action sequence.
Geant4StackingActionSequence(Geant4Context *ctxt, const std::string &name)
Standard constructor.
Actors< Geant4StackingAction > m_actors
The list of action objects to be called.
Geant4StackingAction * m_action
Reference to the shared action.
Implementation of the Geant4 shared stacking action.
Geant4StackingAction(Geant4Context *ctxt, const std::string &name)
Standard constructor.
Generic context to extend user, run and event information.
virtual ~Geant4StackingActionSequence()
Default destructor.
void callAtPrepare(T *p, void(T::*f)())
Register end-of-event callback. Types Q and T must be polymorph!
virtual void updateContext(Geant4Context *ctxt)
Set or update client context.
virtual ~Geant4SharedStackingAction()
Default destructor.
virtual void newStage()
New-stage callback.
void adopt(Geant4StackingAction *action)
Add an actor responding to all callbacks. Sequence takes ownership.
Default base class for all Geant 4 actions and derivates thereof.
Definition: Geant4Action.h:91
virtual ~Geant4StackingAction()
Default destructor.