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
Geant4TrackingAction.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_GEANT4TRACKINGACTION_H
15 #define DD4HEP_DDG4_GEANT4TRACKINGACTION_H
16 
17 // Framework include files
18 #include "DDG4/Geant4Action.h"
19 #include "G4VUserTrackInformation.hh"
20 
21 class G4TrackingManager;
22 class G4Track;
23 
25 namespace DD4hep {
26 
28  namespace Simulation {
29 
30  // Forward declarations
31  class Geant4TrackInformation;
32  class Geant4TrackingAction;
33  class Geant4SharedTrackingAction;
34  class Geant4TrackingActionSequence;
35 
37 
43  public:
45  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  public:
85  Geant4SharedTrackingAction(Geant4Context* context, const std::string& nam);
89  virtual void configureFiber(Geant4Context* thread_context);
91  virtual void use(Geant4TrackingAction* action);
93  virtual void begin(const G4Track* track);
95  virtual void end(const G4Track* track);
96  };
97 
99 
114  protected:
125  public:
133  virtual void updateContext(Geant4Context* ctxt);
135  virtual void configureFiber(Geant4Context* thread_context);
137  Geant4TrackingAction* get(const std::string& name) const;
139  template <typename Q, typename T>
140  void callUpFront(Q* p, void (T::*f)(const G4Track*),
142  m_front.add(p, f, where);
143  }
145  template <typename Q, typename T>
146  void callAtBegin(Q* p, void (T::*f)(const G4Track*),
148  m_begin.add(p, f, where);
149  }
151  template <typename Q, typename T>
152  void callAtEnd(Q* p, void (T::*f)(const G4Track*),
154  m_end.add(p, f, where);
155  }
157  template <typename Q, typename T>
158  void callAtFinal(Q* p, void (T::*f)(const G4Track*),
160  m_final.add(p, f, where);
161  }
163  void adopt(Geant4TrackingAction* action);
165  virtual void begin(const G4Track* track);
167  virtual void end(const G4Track* track);
168  };
169 
170  } // End namespace Simulation
171 } // End namespace DD4hep
172 #endif // DD4HEP_DDG4_GEANT4TRACKINGACTION_H
CallbackSequence m_front
Callback sequence for pre tracking action.
virtual void use(Geant4TrackingAction *action)
Underlying object to be used during the execution of this thread.
void callAtEnd(Q *p, void(T::*f)(const G4Track *), CallbackSequence::Location where=CallbackSequence::END)
Register Post-track action callback.
G4TrackingManager * trackMgr() const
Access the Geant4 tracking manager. Only use between tracking pre- and post action.
G4TrackingManager * trackMgr() const
Access the tracking manager.
Geant4TrackingAction * m_action
Reference to the shared action.
void adopt(Geant4TrackingAction *action)
Add an actor responding to all callbacks. Sequence takes ownership.
virtual void configureFiber(Geant4Context *thread_context)
Set or update client for the use in a new thread fiber.
void callAtBegin(Q *p, void(T::*f)(const G4Track *), CallbackSequence::Location where=CallbackSequence::END)
Register Pre-track action callback.
Default base class for all geant 4 tracking actions used in DDG4.
virtual void configureFiber(Geant4Context *thread_context)
Set or update client for the use in a new thread fiber.
virtual void end(const G4Track *track)
Post-tracking action callback.
void add(const Callback &cb, Location where)
Generically Add a new callback to the sequence depending on the location arguments.
Definition: Callback.h:362
void copy(Alignment from, Alignment to)
Copy alignment object from source object.
void mark(const G4Track *track) const
Mark the track to be kept for MC truth propagation.
Actors< Geant4TrackingAction > m_actors
The list of action objects to be called.
Definition of an actor on sequences of callbacks.
Definition: Callback.h:334
Geant4Context * context() const
Access the context.
Definition: Geant4Action.h:261
CallbackSequence m_final
Callback sequence for pre tracking action.
Concrete implementation of the Geant4 tracking action sequence.
const std::string & name() const
Access name of the action.
Definition: Geant4Action.h:271
virtual void begin(const G4Track *track)
Pre-track action callback.
Geant4Context * m_context
Reference to the Geant4 context.
Definition: Geant4Action.h:94
virtual void end(const G4Track *track)
End-of-track callback.
virtual ~Geant4TrackingActionSequence()
Default destructor.
CallbackSequence m_end
Callback sequence for post tracking action.
CallbackSequence m_begin
Callback sequence for pre tracking action.
void callUpFront(Q *p, void(T::*f)(const G4Track *), CallbackSequence::Location where=CallbackSequence::END)
Register Pre-track action callback before anything else.
void callAtFinal(Q *p, void(T::*f)(const G4Track *), CallbackSequence::Location where=CallbackSequence::END)
Register Post-track action callback.
Geant4TrackingActionSequence(const Geant4TrackingAction &copy)=delete
Inhibit copy constructor.
Geant4SharedTrackingAction(const Geant4TrackingAction &copy)=delete
Inhibit copy constructor.
virtual void updateContext(Geant4Context *ctxt)
Set or update client context.
Generic context to extend user, run and event information.
Implementation of the Geant4 shared track action.
virtual void begin(const G4Track *track)
Begin-of-track callback.
virtual void end(const G4Track *track)
Post-track action callback.
virtual ~Geant4TrackingAction()
Default destructor.
Geant4TrackingAction(const Geant4TrackingAction &copy)=delete
Inhibit copy constructor.
virtual ~Geant4SharedTrackingAction()
Default destructor.
Default base class for all Geant 4 actions and derivates thereof.
Definition: Geant4Action.h:91
virtual void begin(const G4Track *track)
Pre-tracking action callback.
Actor class to manipulate action groups.
Definition: Geant4Action.h:146