Skip to content

Commit

Permalink
add tracking action callback to output schemes
Browse files Browse the repository at this point in the history
  • Loading branch information
ManuelHu committed Aug 17, 2024
1 parent d5689ba commit eab669f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
6 changes: 3 additions & 3 deletions include/RMGTrackingAction.hh
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@

#include "G4UserTrackingAction.hh"

class RMGEventAction;
class RMGRunAction;
class RMGTrackingAction : public G4UserTrackingAction {

public:

RMGTrackingAction(RMGEventAction*);
RMGTrackingAction(RMGRunAction*);
~RMGTrackingAction() = default;

RMGTrackingAction(RMGTrackingAction const&) = delete;
Expand All @@ -39,7 +39,7 @@ class RMGTrackingAction : public G4UserTrackingAction {

private:

RMGEventAction* fEventAction = nullptr;
RMGRunAction* fRunAction = nullptr;
};

#endif
Expand Down
3 changes: 3 additions & 0 deletions include/RMGVOutputScheme.hh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ class RMGVOutputScheme {
}
virtual inline std::optional<bool> StackingActionNewStage(const int) { return std::nullopt; }

// hook into G4TrackingAction
virtual inline void TrackingActionPre(const G4Track* aTrack) {};

inline void SetNtuplePerDetector(bool ntuple_per_det) { fNtuplePerDetector = ntuple_per_det; }

protected:
Expand Down
9 changes: 6 additions & 3 deletions src/RMGTrackingAction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@

#include "G4Track.hh"

#include "RMGEventAction.hh"
#include "RMGRunAction.hh"

RMGTrackingAction::RMGTrackingAction(RMGEventAction* eventaction) : fEventAction(eventaction) {}
RMGTrackingAction::RMGTrackingAction(RMGRunAction* run_action) : fRunAction(run_action) {}

void RMGTrackingAction::PreUserTrackingAction(const G4Track* /*aTrack*/) {}
void RMGTrackingAction::PreUserTrackingAction(const G4Track* aTrack) {

for (auto& el : fRunAction->GetAllOutputDataFields()) { el->TrackingActionPre(aTrack); }
}

void RMGTrackingAction::PostUserTrackingAction(const G4Track* /*aTrack*/) {}

Expand Down
2 changes: 1 addition & 1 deletion src/RMGUserAction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void RMGUserAction::Build() const {

// Add the remage-internal tracking action and optional user-specified custom stepping actions.
const auto user_tracking_actions = RMGManager::Instance()->GetUserInit()->GetTrackingActions();
G4UserTrackingAction* tracking_action = new RMGTrackingAction(event_action);
G4UserTrackingAction* tracking_action = new RMGTrackingAction(run_action);
if (!user_tracking_actions.empty()) {
auto multi_tracking_action = new G4MultiTrackingAction();
multi_tracking_action->push_back(std::unique_ptr<G4UserTrackingAction>(tracking_action));
Expand Down

0 comments on commit eab669f

Please sign in to comment.