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_GEANT4STACKINGACTION_H
0014 #define DDG4_GEANT4STACKINGACTION_H
0015
0016
0017 #include <DDG4/Geant4Action.h>
0018
0019
0020 #include <G4ClassificationOfNewTrack.hh>
0021
0022
0023 class G4StackManager;
0024
0025
0026 namespace dd4hep {
0027
0028
0029 namespace sim {
0030
0031
0032 class Geant4StackingAction;
0033 class Geant4SharedStackingAction;
0034 class Geant4StackingActionSequence;
0035
0036 enum Geant4StackingActionTrackClassification {
0037 NoTrackClassification = 0xFEED
0038 };
0039 union TrackClassification {
0040 G4ClassificationOfNewTrack value;
0041 int type;
0042 TrackClassification() { type = NoTrackClassification; }
0043 TrackClassification(G4ClassificationOfNewTrack val) { value = val; }
0044 };
0045
0046
0047
0048
0049
0050
0051
0052 class Geant4StackingAction: public Geant4Action {
0053 public:
0054 friend class Geant4StackingActionSequence;
0055 typedef Geant4SharedStackingAction shared_type;
0056 public:
0057
0058 DDG4_DEFINE_ACTION_CONSTRUCTORS(Geant4StackingAction);
0059
0060 public:
0061
0062 Geant4StackingAction(Geant4Context* ctxt, const std::string& name);
0063
0064 virtual ~Geant4StackingAction();
0065
0066 virtual void newStage(G4StackManager* ) {
0067 }
0068
0069 virtual void prepare(G4StackManager* ) {
0070 }
0071
0072 virtual TrackClassification
0073 classifyNewTrack(G4StackManager* , const G4Track* track);
0074 };
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089 class Geant4SharedStackingAction : public Geant4StackingAction {
0090 protected:
0091
0092 Geant4StackingAction* m_action;
0093
0094 DDG4_DEFINE_ACTION_CONSTRUCTORS(Geant4SharedStackingAction);
0095 public:
0096
0097 Geant4SharedStackingAction(Geant4Context* context, const std::string& nam);
0098
0099 virtual ~Geant4SharedStackingAction();
0100
0101 virtual void configureFiber(Geant4Context* thread_context) override;
0102
0103 virtual void use(Geant4StackingAction* action);
0104
0105 virtual void newStage(G4StackManager* stackManager) override;
0106
0107 virtual void prepare(G4StackManager* stackManager) override;
0108
0109 virtual TrackClassification
0110 classifyNewTrack(G4StackManager* stackManager, const G4Track* track) override;
0111 };
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128 class Geant4StackingActionSequence: public Geant4Action {
0129 protected:
0130
0131 CallbackSequence m_newStage;
0132
0133 CallbackSequence m_prepare;
0134
0135 Actors<Geant4StackingAction> m_actors;
0136
0137
0138 DDG4_DEFINE_ACTION_CONSTRUCTORS(Geant4StackingActionSequence);
0139 public:
0140
0141 Geant4StackingActionSequence(Geant4Context* ctxt, const std::string& name);
0142
0143 virtual ~Geant4StackingActionSequence();
0144
0145 virtual void updateContext(Geant4Context* ctxt) override;
0146
0147 virtual void configureFiber(Geant4Context* thread_context) override;
0148
0149 Geant4StackingAction* get(const std::string& name) const;
0150
0151 template <typename T> void callAtNewStage(T* p, void (T::*f)(G4StackManager*)) {
0152 m_newStage.add(p, f);
0153 }
0154
0155 template <typename T> void callAtPrepare(T* p, void (T::*f)(G4StackManager*)) {
0156 m_prepare.add(p, f);
0157 }
0158
0159 void adopt(Geant4StackingAction* action);
0160
0161 virtual void newStage(G4StackManager* stackManager);
0162
0163 virtual void prepare(G4StackManager* stackManager);
0164
0165 virtual TrackClassification
0166 classifyNewTrack(G4StackManager* stackManager, const G4Track* track);
0167 };
0168
0169 }
0170 }
0171 #endif