diff --git a/core/include/Track.h b/core/include/Track.h index aedf49686a896b14ae206b961bfdcf94a6cdab8e..089d6c628c99b62bc9d218a584aa7b620bdd28d9 100644 --- a/core/include/Track.h +++ b/core/include/Track.h @@ -259,6 +259,15 @@ class Track : public TObject { //! get time of flight in ns between to trackPoints (if nullptr, for cardinal rep) double getTOF(AbsTrackRep* rep = nullptr, int startId = 0, int endId = -1) const; + /** + * Delete the fit status and all the FitStates of the TrackPoints + * for the given hypothesis. + * This is equal to resetting the track for the rep, so another fit + * can start from scratch. + * Useful if you have changed some seeds. + */ + void deleteFittedState(const genfit::AbsTrackRep* rep); + //! Construct a new TrackCand containing the hit IDs of the measurements /** * The idea is hat you can get a TrackCand for storing the hit IDs after a track has been fitted. diff --git a/core/src/Track.cc b/core/src/Track.cc index 190bcba569ffe7e662e36f47aea2f96bbce6db1c..82829c9f5a69e5bd64b69956ef314da069115034 100644 --- a/core/src/Track.cc +++ b/core/src/Track.cc @@ -505,6 +505,20 @@ void Track::deletePoint(int id) { void Track::insertMeasurement(AbsMeasurement* measurement, int id) { insertPoint(new TrackPoint(measurement, this), id); } + +void Track::deleteFittedState(const genfit::AbsTrackRep* rep) { + if(hasFitStatus(rep)) { + delete fitStatuses_.at(rep); + fitStatuses_.erase(rep); + } + + // delete FitterInfos related to the deleted TrackRep + for (const auto& trackPoint : trackPoints_) { + if(trackPoint->hasFitterInfo(rep)) { + trackPoint->deleteFitterInfo(rep); + } + } +} void Track::mergeTrack(const Track* other, int id) {