Skip to content

Commit

Permalink
Add replay_event_with_new_origin
Browse files Browse the repository at this point in the history
  • Loading branch information
sfegan committed Jul 9, 2024
1 parent ed35824 commit cce3259
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/simulation/misc_trackers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ class RecordingTrackVisitor: public calin::simulation::tracker::TrackVisitor
calin::simulation::tracker::Event event() const { return event_; }
const std::vector<calin::simulation::tracker::Track>& 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_;
Expand Down
22 changes: 22 additions & 0 deletions src/simulation/misc_trackers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

// =============================================================================
// =============================================================================
//
Expand Down

0 comments on commit cce3259

Please sign in to comment.