DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
Geant4TrackingAction.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_GEANT4TRACKINGACTION_H
14 #define DDG4_GEANT4TRACKINGACTION_H
15 
16 // Framework include files
17 #include <DDG4/Geant4Action.h>
18 #include <G4VUserTrackInformation.hh>
19 
20 class G4TrackingManager;
21 class G4Track;
22 
24 namespace dd4hep {
25 
27  namespace sim {
28 
29  // Forward declarations
30  class Geant4TrackInformation;
31  class Geant4TrackingAction;
32  class Geant4SharedTrackingAction;
33  class Geant4TrackingActionSequence;
34 
36 
42  public:
44 
47  public:
49  Geant4TrackingAction(Geant4Context* context, const std::string& name = "");
51  virtual ~Geant4TrackingAction();
53  G4TrackingManager* trackMgr() const {
54  return m_context ? m_context->trackMgr() : 0;
55  }
57  void mark(const G4Track* track) const;
59  virtual void begin(const G4Track* track);
61  virtual void end(const G4Track* track);
62  };
63 
65 
78  protected:
81 
84  public:
86  Geant4SharedTrackingAction(Geant4Context* context, const std::string& nam);
90  virtual void configureFiber(Geant4Context* thread_context) override;
92  virtual void use(Geant4TrackingAction* action);
94  virtual void begin(const G4Track* track) override;
96  virtual void end(const G4Track* track) override;
97  };
98 
100 
115  protected:
126 
127 
130 
131  public:
137  virtual void updateContext(Geant4Context* ctxt) override;
139  virtual void configureFiber(Geant4Context* thread_context) override;
141  Geant4TrackingAction* get(const std::string& name) const;
143  template <typename Q, typename T>
144  void callUpFront(Q* p, void (T::*f)(const G4Track*),
146  m_front.add(p, f, where);
147  }
149  template <typename Q, typename T>
150  void callAtBegin(Q* p, void (T::*f)(const G4Track*),
152  m_begin.add(p, f, where);
153  }
155  template <typename Q, typename T>
156  void callAtEnd(Q* p, void (T::*f)(const G4Track*),
158  m_end.add(p, f, where);
159  }
161  template <typename Q, typename T>
162  void callAtFinal(Q* p, void (T::*f)(const G4Track*),
164  m_final.add(p, f, where);
165  }
167  void adopt(Geant4TrackingAction* action);
169  virtual void begin(const G4Track* track);
171  virtual void end(const G4Track* track);
172  };
173 
174  } // End namespace sim
175 } // End namespace dd4hep
176 #endif // DDG4_GEANT4TRACKINGACTION_H
dd4hep::sim::Geant4SharedTrackingAction::m_action
Geant4TrackingAction * m_action
Reference to the shared action.
Definition: Geant4TrackingAction.h:80
dd4hep::sim::Geant4SharedTrackingAction
Implementation of the Geant4 shared track action.
Definition: Geant4TrackingAction.h:77
dd4hep::sim::Geant4TrackingActionSequence::end
virtual void end(const G4Track *track)
Post-tracking action callback.
Definition: Geant4TrackingAction.cpp:88
dd4hep::sim::Geant4TrackingActionSequence::adopt
void adopt(Geant4TrackingAction *action)
Add an actor responding to all callbacks. Sequence takes ownership.
Definition: Geant4TrackingAction.cpp:70
dd4hep::sim::Geant4TrackingAction::begin
virtual void begin(const G4Track *track)
Pre-track action callback.
Definition: Geant4TrackingAction.cpp:106
dd4hep::sim::Geant4TrackingActionSequence::DDG4_DEFINE_ACTION_CONSTRUCTORS
DDG4_DEFINE_ACTION_CONSTRUCTORS(Geant4TrackingActionSequence)
Define standard assignments and constructors.
dd4hep::sim::Geant4Action::m_context
Geant4Context * m_context
Reference to the Geant4 context.
Definition: Geant4Action.h:116
dd4hep::CallbackSequence::Location
Location
Definition: Callback.h:341
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::Geant4TrackingActionSequence::callAtBegin
void callAtBegin(Q *p, void(T::*f)(const G4Track *), CallbackSequence::Location where=CallbackSequence::END)
Register Pre-track action callback.
Definition: Geant4TrackingAction.h:150
dd4hep::sim::Geant4TrackingActionSequence::begin
virtual void begin(const G4Track *track)
Pre-tracking action callback.
Definition: Geant4TrackingAction.cpp:81
dd4hep::sim::Geant4TrackingActionSequence::callAtFinal
void callAtFinal(Q *p, void(T::*f)(const G4Track *), CallbackSequence::Location where=CallbackSequence::END)
Register Post-track action callback.
Definition: Geant4TrackingAction.h:162
dd4hep::sim::Geant4TrackingActionSequence
Concrete implementation of the Geant4 tracking action sequence.
Definition: Geant4TrackingAction.h:114
dd4hep::sim::Geant4TrackingActionSequence::get
Geant4TrackingAction * get(const std::string &name) const
Get an action by name.
Definition: Geant4TrackingAction.cpp:65
dd4hep::sim::Geant4TrackingAction::end
virtual void end(const G4Track *track)
Post-track action callback.
Definition: Geant4TrackingAction.cpp:110
dd4hep::CallbackSequence::END
@ END
Definition: Callback.h:341
dd4hep::sim::Geant4SharedTrackingAction::configureFiber
virtual void configureFiber(Geant4Context *thread_context) override
Set or update client for the use in a new thread fiber.
Definition: Geant4TrackingAction.cpp:133
dd4hep::CallbackSequence
Definition of an actor on sequences of callbacks.
Definition: Callback.h:339
dd4hep::sim::Geant4SharedTrackingAction::DDG4_DEFINE_ACTION_CONSTRUCTORS
DDG4_DEFINE_ACTION_CONSTRUCTORS(Geant4SharedTrackingAction)
Define standard assignments and constructors.
dd4hep::sim::Geant4SharedTrackingAction::end
virtual void end(const G4Track *track) override
End-of-track callback.
Definition: Geant4TrackingAction.cpp:159
dd4hep::sim::Geant4TrackingAction::Geant4TrackingAction
Geant4TrackingAction(Geant4Context *context, const std::string &name="")
Standard constructor.
Definition: Geant4TrackingAction.cpp:95
dd4hep::sim::Geant4SharedTrackingAction::~Geant4SharedTrackingAction
virtual ~Geant4SharedTrackingAction()
Default destructor.
Definition: Geant4TrackingAction.cpp:127
dd4hep::sim::Geant4SharedTrackingAction::Geant4SharedTrackingAction
Geant4SharedTrackingAction(Geant4Context *context, const std::string &nam)
Standard constructor.
Definition: Geant4TrackingAction.cpp:120
dd4hep::sim::Geant4SharedTrackingAction::use
virtual void use(Geant4TrackingAction *action)
Underlying object to be used during the execution of this thread.
Definition: Geant4TrackingAction.cpp:138
dd4hep::sim::Geant4TrackingActionSequence::callUpFront
void callUpFront(Q *p, void(T::*f)(const G4Track *), CallbackSequence::Location where=CallbackSequence::END)
Register Pre-track action callback before anything else.
Definition: Geant4TrackingAction.h:144
dd4hep::sim::Geant4Action
Default base class for all Geant 4 actions and derivates thereof.
Definition: Geant4Action.h:113
dd4hep::sim::Geant4TrackingAction::~Geant4TrackingAction
virtual ~Geant4TrackingAction()
Default destructor.
Definition: Geant4TrackingAction.cpp:101
dd4hep::sim::Geant4Action::name
const std::string & name() const
Access name of the action.
Definition: Geant4Action.h:280
dd4hep::sim::Geant4TrackingAction::trackMgr
G4TrackingManager * trackMgr() const
Access the Geant4 tracking manager. Only use between tracking pre- and post action.
Definition: Geant4TrackingAction.h:53
dd4hep::sim::Geant4TrackingActionSequence::configureFiber
virtual void configureFiber(Geant4Context *thread_context) override
Set or update client for the use in a new thread fiber.
Definition: Geant4TrackingAction.cpp:60
dd4hep::sim::Geant4TrackingActionSequence::~Geant4TrackingActionSequence
virtual ~Geant4TrackingActionSequence()
Default destructor.
Definition: Geant4TrackingAction.cpp:43
dd4hep::sim::Geant4SharedTrackingAction::begin
virtual void begin(const G4Track *track) override
Begin-of-track callback.
Definition: Geant4TrackingAction.cpp:149
dd4hep::sim::Geant4TrackingAction
Default base class for all geant 4 tracking actions used in DDG4.
Definition: Geant4TrackingAction.h:41
dd4hep::sim::Geant4TrackingActionSequence::m_begin
CallbackSequence m_begin
Callback sequence for pre tracking action.
Definition: Geant4TrackingAction.h:119
dd4hep::sim::Geant4TrackingActionSequence::m_front
CallbackSequence m_front
Callback sequence for pre tracking action.
Definition: Geant4TrackingAction.h:117
dd4hep::sim::Geant4TrackingActionSequence::m_end
CallbackSequence m_end
Callback sequence for post tracking action.
Definition: Geant4TrackingAction.h:121
dd4hep::sim::Geant4TrackingActionSequence::m_actors
Actors< Geant4TrackingAction > m_actors
The list of action objects to be called.
Definition: Geant4TrackingAction.h:125
dd4hep::sim::Geant4TrackingAction::DDG4_DEFINE_ACTION_CONSTRUCTORS
DDG4_DEFINE_ACTION_CONSTRUCTORS(Geant4TrackingAction)
Define standard assignments and constructors.
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::sim::Geant4TrackingActionSequence::m_final
CallbackSequence m_final
Callback sequence for pre tracking action.
Definition: Geant4TrackingAction.h:123
dd4hep::sim::Geant4TrackingActionSequence::Geant4TrackingActionSequence
Geant4TrackingActionSequence(Geant4Context *context, const std::string &name)
Standard constructor.
Definition: Geant4TrackingAction.cpp:36
dd4hep::sim::Geant4Action::Actors
Actor class to manipulate action groups.
Definition: Geant4Action.h:168
dd4hep::sim::Geant4Context::trackMgr
G4TrackingManager * trackMgr() const
Access the tracking manager.
Definition: Geant4Context.cpp:108
dd4hep::sim::Geant4TrackingActionSequence::updateContext
virtual void updateContext(Geant4Context *ctxt) override
Set or update client context.
Definition: Geant4TrackingAction.cpp:54
dd4hep::sim::Geant4TrackingAction::shared_type
Geant4SharedTrackingAction shared_type
Definition: Geant4TrackingAction.h:43
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
dd4hep::sim::Geant4TrackingAction::mark
void mark(const G4Track *track) const
Mark the track to be kept for MC truth propagation.
Definition: Geant4TrackingAction.cpp:114
dd4hep::sim::Geant4TrackingActionSequence::callAtEnd
void callAtEnd(Q *p, void(T::*f)(const G4Track *), CallbackSequence::Location where=CallbackSequence::END)
Register Post-track action callback.
Definition: Geant4TrackingAction.h:156