File indexing completed on 2025-01-18 09:55:24
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef DDG4_GEANT4TRACKINGACTION_H
0014 #define DDG4_GEANT4TRACKINGACTION_H
0015
0016
0017 #include <DDG4/Geant4Action.h>
0018 #include <G4VUserTrackInformation.hh>
0019
0020 class G4TrackingManager;
0021 class G4Track;
0022
0023
0024 namespace dd4hep {
0025
0026
0027 namespace sim {
0028
0029
0030 class Geant4TrackInformation;
0031 class Geant4TrackingAction;
0032 class Geant4SharedTrackingAction;
0033 class Geant4TrackingActionSequence;
0034
0035
0036
0037
0038
0039
0040
0041 class Geant4TrackingAction: public Geant4Action {
0042 public:
0043 typedef Geant4SharedTrackingAction shared_type;
0044
0045
0046 DDG4_DEFINE_ACTION_CONSTRUCTORS(Geant4TrackingAction);
0047 public:
0048
0049 Geant4TrackingAction(Geant4Context* context, const std::string& name = "");
0050
0051 virtual ~Geant4TrackingAction();
0052
0053 G4TrackingManager* trackMgr() const {
0054 return m_context ? m_context->trackMgr() : 0;
0055 }
0056
0057 void mark(const G4Track* track) const;
0058
0059 virtual void begin(const G4Track* track);
0060
0061 virtual void end(const G4Track* track);
0062 };
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077 class Geant4SharedTrackingAction : public Geant4TrackingAction {
0078 protected:
0079
0080 Geant4TrackingAction* m_action = 0;
0081
0082
0083 DDG4_DEFINE_ACTION_CONSTRUCTORS(Geant4SharedTrackingAction);
0084 public:
0085
0086 Geant4SharedTrackingAction(Geant4Context* context, const std::string& nam);
0087
0088 virtual ~Geant4SharedTrackingAction();
0089
0090 virtual void configureFiber(Geant4Context* thread_context) override;
0091
0092 virtual void use(Geant4TrackingAction* action);
0093
0094 virtual void begin(const G4Track* track) override;
0095
0096 virtual void end(const G4Track* track) override;
0097 };
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114 class Geant4TrackingActionSequence: public Geant4Action {
0115 protected:
0116
0117 CallbackSequence m_front;
0118
0119 CallbackSequence m_begin;
0120
0121 CallbackSequence m_end;
0122
0123 CallbackSequence m_final;
0124
0125 Actors<Geant4TrackingAction> m_actors;
0126
0127
0128
0129 DDG4_DEFINE_ACTION_CONSTRUCTORS(Geant4TrackingActionSequence);
0130
0131 public:
0132
0133 Geant4TrackingActionSequence(Geant4Context* context, const std::string& name);
0134
0135 virtual ~Geant4TrackingActionSequence();
0136
0137 virtual void updateContext(Geant4Context* ctxt) override;
0138
0139 virtual void configureFiber(Geant4Context* thread_context) override;
0140
0141 Geant4TrackingAction* get(const std::string& name) const;
0142
0143 template <typename Q, typename T>
0144 void callUpFront(Q* p, void (T::*f)(const G4Track*),
0145 CallbackSequence::Location where=CallbackSequence::END) {
0146 m_front.add(p, f, where);
0147 }
0148
0149 template <typename Q, typename T>
0150 void callAtBegin(Q* p, void (T::*f)(const G4Track*),
0151 CallbackSequence::Location where=CallbackSequence::END) {
0152 m_begin.add(p, f, where);
0153 }
0154
0155 template <typename Q, typename T>
0156 void callAtEnd(Q* p, void (T::*f)(const G4Track*),
0157 CallbackSequence::Location where=CallbackSequence::END) {
0158 m_end.add(p, f, where);
0159 }
0160
0161 template <typename Q, typename T>
0162 void callAtFinal(Q* p, void (T::*f)(const G4Track*),
0163 CallbackSequence::Location where=CallbackSequence::END) {
0164 m_final.add(p, f, where);
0165 }
0166
0167 void adopt(Geant4TrackingAction* action);
0168
0169 virtual void begin(const G4Track* track);
0170
0171 virtual void end(const G4Track* track);
0172 };
0173
0174 }
0175 }
0176 #endif