DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
Geant4StackingAction.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 #ifndef DDG4_GEANT4STACKINGACTION_H
14 #define DDG4_GEANT4STACKINGACTION_H
15 
17 #include <DDG4/Geant4Action.h>
18 
20 #include <G4ClassificationOfNewTrack.hh>
21 
23 class G4StackManager;
24 
26 namespace dd4hep {
27 
29  namespace sim {
30 
31  // Forward declarations
32  class Geant4StackingAction;
33  class Geant4SharedStackingAction;
34  class Geant4StackingActionSequence;
35 
37  NoTrackClassification = 0xFEED
38  };
40  G4ClassificationOfNewTrack value;
41  int type;
43  TrackClassification(G4ClassificationOfNewTrack val) { value = val; }
44  };
45 
47 
53  public:
56  public:
59 
60  public:
62  Geant4StackingAction(Geant4Context* ctxt, const std::string& name);
64  virtual ~Geant4StackingAction();
66  virtual void newStage(G4StackManager* /* stackManager */) {
67  }
69  virtual void prepare(G4StackManager* /* stackManager */) {
70  }
72  virtual TrackClassification
73  classifyNewTrack(G4StackManager* /* stackManager */, const G4Track* track);
74  };
75 
77 
90  protected:
95  public:
97  Geant4SharedStackingAction(Geant4Context* context, const std::string& nam);
101  virtual void configureFiber(Geant4Context* thread_context) override;
103  virtual void use(Geant4StackingAction* action);
105  virtual void newStage(G4StackManager* stackManager) override;
107  virtual void prepare(G4StackManager* stackManager) override;
109  virtual TrackClassification
110  classifyNewTrack(G4StackManager* stackManager, const G4Track* track) override;
111  };
112 
114 
129  protected:
132  // Callback sequence for the prepare call
135  Actors<Geant4StackingAction> m_actors;
136 
139  public:
141  Geant4StackingActionSequence(Geant4Context* ctxt, const std::string& name);
145  virtual void updateContext(Geant4Context* ctxt) override;
147  virtual void configureFiber(Geant4Context* thread_context) override;
149  Geant4StackingAction* get(const std::string& name) const;
151  template <typename T> void callAtNewStage(T* p, void (T::*f)(G4StackManager*)) {
152  m_newStage.add(p, f);
153  }
155  template <typename T> void callAtPrepare(T* p, void (T::*f)(G4StackManager*)) {
156  m_prepare.add(p, f);
157  }
159  void adopt(Geant4StackingAction* action);
161  virtual void newStage(G4StackManager* stackManager);
163  virtual void prepare(G4StackManager* stackManager);
165  virtual TrackClassification
166  classifyNewTrack(G4StackManager* stackManager, const G4Track* track);
167  };
168 
169  } // End namespace sim
170 } // End namespace dd4hep
171 #endif // DDG4_GEANT4STACKINGACTION_H
dd4hep::sim::Geant4StackingActionSequence::updateContext
virtual void updateContext(Geant4Context *ctxt) override
Set or update client context.
Definition: Geant4StackingAction.cpp:133
dd4hep::sim::TrackClassification::TrackClassification
TrackClassification(G4ClassificationOfNewTrack val)
Definition: Geant4StackingAction.h:43
dd4hep::sim::TrackClassification::value
G4ClassificationOfNewTrack value
Definition: Geant4StackingAction.h:40
dd4hep::sim::Geant4SharedStackingAction::m_action
Geant4StackingAction * m_action
Reference to the shared action.
Definition: Geant4StackingAction.h:92
dd4hep::sim::TrackClassification::type
int type
Definition: Geant4StackingAction.h:41
dd4hep::sim::Geant4StackingActionSequence::m_newStage
CallbackSequence m_newStage
Callback sequence for the newStage call.
Definition: Geant4StackingAction.h:131
dd4hep::sim::Geant4StackingActionSequence::DDG4_DEFINE_ACTION_CONSTRUCTORS
DDG4_DEFINE_ACTION_CONSTRUCTORS(Geant4StackingActionSequence)
Define standard assignments and constructors.
dd4hep::sim::Geant4StackingActionSequence
Concrete implementation of the Geant4 stacking action sequence.
Definition: Geant4StackingAction.h:128
dd4hep::sim::Geant4SharedStackingAction::DDG4_DEFINE_ACTION_CONSTRUCTORS
DDG4_DEFINE_ACTION_CONSTRUCTORS(Geant4SharedStackingAction)
Define standard assignments and constructors.
dd4hep::sim::Geant4StackingActionTrackClassification
Geant4StackingActionTrackClassification
Definition: Geant4StackingAction.h:36
dd4hep::sim::Geant4StackingAction::newStage
virtual void newStage(G4StackManager *)
New-stage callback.
Definition: Geant4StackingAction.h:66
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::Geant4StackingActionSequence::m_actors
Actors< Geant4StackingAction > m_actors
The list of action objects to be called.
Definition: Geant4StackingAction.h:135
dd4hep::sim::Geant4StackingAction::shared_type
Geant4SharedStackingAction shared_type
Definition: Geant4StackingAction.h:55
dd4hep::sim::Geant4SharedStackingAction::classifyNewTrack
virtual TrackClassification classifyNewTrack(G4StackManager *stackManager, const G4Track *track) override
Return TrackClassification with enum G4ClassificationOfNewTrack or NoTrackClassification.
Definition: Geant4StackingAction.cpp:95
dd4hep::sim::Geant4StackingActionSequence::get
Geant4StackingAction * get(const std::string &name) const
Get an action by name.
Definition: Geant4StackingAction.cpp:144
dd4hep::CallbackSequence
Definition of an actor on sequences of callbacks.
Definition: Callback.h:339
dd4hep::sim::Geant4StackingAction::Geant4StackingAction
Geant4StackingAction(Geant4Context *ctxt, const std::string &name)
Standard constructor.
Definition: Geant4StackingAction.cpp:28
dd4hep::sim::Geant4StackingAction::~Geant4StackingAction
virtual ~Geant4StackingAction()
Default destructor.
Definition: Geant4StackingAction.cpp:34
dd4hep::sim::Geant4SharedStackingAction::~Geant4SharedStackingAction
virtual ~Geant4SharedStackingAction()
Default destructor.
Definition: Geant4StackingAction.cpp:52
dd4hep::sim::Geant4StackingActionSequence::prepare
virtual void prepare(G4StackManager *stackManager)
Preparation callback.
Definition: Geant4StackingAction.cpp:155
dd4hep::sim::Geant4StackingActionSequence::m_prepare
CallbackSequence m_prepare
Definition: Geant4StackingAction.h:133
dd4hep::sim::Geant4Action
Default base class for all Geant 4 actions and derivates thereof.
Definition: Geant4Action.h:113
dd4hep::sim::Geant4StackingAction::DDG4_DEFINE_ACTION_CONSTRUCTORS
DDG4_DEFINE_ACTION_CONSTRUCTORS(Geant4StackingAction)
Define standard assignments and constructors.
dd4hep::sim::Geant4Action::name
const std::string & name() const
Access name of the action.
Definition: Geant4Action.h:280
dd4hep::sim::Geant4StackingAction::classifyNewTrack
virtual TrackClassification classifyNewTrack(G4StackManager *, const G4Track *track)
Return TrackClassification with enum G4ClassificationOfNewTrack or NoTrackClassification.
Definition: Geant4StackingAction.cpp:40
dd4hep::sim::Geant4SharedStackingAction::prepare
virtual void prepare(G4StackManager *stackManager) override
Preparation callback.
Definition: Geant4StackingAction.cpp:84
dd4hep::sim::Geant4StackingAction::prepare
virtual void prepare(G4StackManager *)
Preparation callback.
Definition: Geant4StackingAction.h:69
dd4hep::sim::Geant4SharedStackingAction::configureFiber
virtual void configureFiber(Geant4Context *thread_context) override
Set or update client for the use in a new thread fiber.
Definition: Geant4StackingAction.cpp:58
dd4hep::sim::Geant4SharedStackingAction::Geant4SharedStackingAction
Geant4SharedStackingAction(Geant4Context *context, const std::string &nam)
Standard constructor.
Definition: Geant4StackingAction.cpp:45
dd4hep::sim::TrackClassification
Definition: Geant4StackingAction.h:39
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::sim::Geant4SharedStackingAction::use
virtual void use(Geant4StackingAction *action)
Underlying object to be used during the execution of this thread.
Definition: Geant4StackingAction.cpp:63
dd4hep::sim::TrackClassification::TrackClassification
TrackClassification()
Definition: Geant4StackingAction.h:42
dd4hep::sim::Geant4StackingAction
Concrete implementation of the Geant4 stacking action base class.
Definition: Geant4StackingAction.h:52
dd4hep::sim::Geant4StackingActionSequence::callAtPrepare
void callAtPrepare(T *p, void(T::*f)(G4StackManager *))
Register end-of-event callback. Types Q and T must be polymorph!
Definition: Geant4StackingAction.h:155
dd4hep::sim::Geant4StackingActionSequence::newStage
virtual void newStage(G4StackManager *stackManager)
New-stage callback.
Definition: Geant4StackingAction.cpp:149
dd4hep::sim::Geant4StackingActionSequence::~Geant4StackingActionSequence
virtual ~Geant4StackingActionSequence()
Default destructor.
Definition: Geant4StackingAction.cpp:114
dd4hep::sim::Geant4StackingActionSequence::adopt
void adopt(Geant4StackingAction *action)
Add an actor responding to all callbacks. Sequence takes ownership.
Definition: Geant4StackingAction.cpp:123
dd4hep::sim::Geant4SharedStackingAction::newStage
virtual void newStage(G4StackManager *stackManager) override
New-stage callback.
Definition: Geant4StackingAction.cpp:74
dd4hep::sim::Geant4StackingActionSequence::Geant4StackingActionSequence
Geant4StackingActionSequence(Geant4Context *ctxt, const std::string &name)
Standard constructor.
Definition: Geant4StackingAction.cpp:107
dd4hep::sim::NoTrackClassification
@ NoTrackClassification
Definition: Geant4StackingAction.h:37
dd4hep::sim::Geant4SharedStackingAction
Implementation of the Geant4 shared stacking action.
Definition: Geant4StackingAction.h:89
dd4hep::sim::Geant4StackingActionSequence::classifyNewTrack
virtual TrackClassification classifyNewTrack(G4StackManager *stackManager, const G4Track *track)
Classify new track: The first call in the sequence returning non-null pointer wins!
Definition: Geant4StackingAction.cpp:162
Geant4Action.h
dd4hep::sim::Geant4StackingActionSequence::callAtNewStage
void callAtNewStage(T *p, void(T::*f)(G4StackManager *))
Register begin-of-event callback. Types Q and T must be polymorph!
Definition: Geant4StackingAction.h:151
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::Geant4StackingActionSequence::configureFiber
virtual void configureFiber(Geant4Context *thread_context) override
Set or update client for the use in a new thread fiber.
Definition: Geant4StackingAction.cpp:139