diff --git a/include/simulation/misc_trackers.hpp b/include/simulation/misc_trackers.hpp index 155c6c46..401ceb98 100644 --- a/include/simulation/misc_trackers.hpp +++ b/include/simulation/misc_trackers.hpp @@ -130,6 +130,8 @@ class RecordingTrackVisitor: public calin::simulation::tracker::TrackVisitor calin::simulation::tracker::Event event() const { return event_; } const std::vector& tracks() const { return tracks_; } void replay_event(calin::simulation::tracker::TrackVisitor* visitor) const; + void replay_event_with_new_origin(calin::simulation::tracker::TrackVisitor* visitor, + double x0, double y0) const; void clear_tracks() { tracks_.clear(); } private: calin::simulation::tracker::Event event_; diff --git a/src/simulation/misc_trackers.cpp b/src/simulation/misc_trackers.cpp index cf689f71..ce5c08ac 100644 --- a/src/simulation/misc_trackers.cpp +++ b/src/simulation/misc_trackers.cpp @@ -346,6 +346,28 @@ replay_event(calin::simulation::tracker::TrackVisitor* visitor) const visitor->leave_event(); } +void RecordingTrackVisitor:: +replay_event_with_new_origin(calin::simulation::tracker::TrackVisitor* visitor, double x0, double y0) const +{ + bool kill_event = false; + Event shifted_event = event_; + shifted_event.x0.x() -= x0; + shifted_event.x0.y() -= y0; + visitor->visit_event(shifted_event, kill_event); + if(!kill_event) { + for(const auto& track : tracks_) { + Track shifted_track = track; + shifted_track.x0.x() -= x0; + shifted_track.x0.y() -= y0; + shifted_track.x1.x() -= x0; + shifted_track.x1.y() -= y0; + bool kill_track = false; + visitor->visit_track(shifted_track, kill_track); + } + } + visitor->leave_event(); +} + // ============================================================================= // ============================================================================= //