diff --git a/Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h b/Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h index 1bf3a71984b8bca62caf57a4fe09c4e619fb915e..2a8dc08725fd0a9297161dd59a0b25b40f86fe7d 100755 --- a/Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h +++ b/Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h @@ -93,8 +93,6 @@ namespace Trk class Track { public: - - friend class TrackSummaryTool; friend class TrackSlimmingTool; Track (); //!<needed by POOL. DO NOT USE YOURSELF! @@ -233,7 +231,7 @@ namespace Trk /** * Set the track summary pointer. The Trk::Track takes ownership */ - void setTrackSummary(Trk::TrackSummary* input); + void setTrackSummary(std::unique_ptr<Trk::TrackSummary> input); /** * reset all caches @@ -323,7 +321,7 @@ namespace Trk /** * Datamember to cache the TrackSummary */ - Trk::TrackSummary* m_trackSummary; + std::unique_ptr<Trk::TrackSummary> m_trackSummary; /** * This is aclass which stores the identity of where the track diff --git a/Tracking/TrkEvent/TrkTrack/TrkTrack/Track.icc b/Tracking/TrkEvent/TrkTrack/TrkTrack/Track.icc index f68aded1c6e755c82702942a5d99645b2c469d71..251dca1c813187b2251289377544673e58259091 100644 --- a/Tracking/TrkEvent/TrkTrack/TrkTrack/Track.icc +++ b/Tracking/TrkEvent/TrkTrack/TrkTrack/Track.icc @@ -32,13 +32,13 @@ Track::info() inline const Trk::TrackSummary* Track::trackSummary() const { - return m_trackSummary; + return m_trackSummary.get(); } inline Trk::TrackSummary* Track::trackSummary() { - return m_trackSummary; + return m_trackSummary.get(); } } diff --git a/Tracking/TrkEvent/TrkTrack/src/Track.cxx b/Tracking/TrkEvent/TrkTrack/src/Track.cxx index c05c963bf384df946221cdfa8087264e2d60e014..438fee95ae373bc392b4a7f6254734756eae4e6f 100755 --- a/Tracking/TrkEvent/TrkTrack/src/Track.cxx +++ b/Tracking/TrkEvent/TrkTrack/src/Track.cxx @@ -28,7 +28,6 @@ Trk::Track::Track() , m_cachedOutlierVector{} , m_perigeeParameters{} , m_fitQuality(nullptr) - , m_trackSummary(nullptr) { #ifndef NDEBUG s_numberOfInstantiations++; // new Track, so increment total count @@ -45,7 +44,6 @@ Trk::Track::Track( , m_cachedOutlierVector{} , m_perigeeParameters{} , m_fitQuality(fitQuality) - , m_trackSummary(nullptr) , m_trackInfo(info) { // find the Perigee params they will become valid given the outcome @@ -62,7 +60,6 @@ Trk::Track::Track(const Trk::Track& rhs) , m_cachedOutlierVector{} , m_perigeeParameters{} , m_fitQuality(nullptr) - , m_trackSummary(nullptr) { //Do the actual payload copy copyHelper(rhs); @@ -79,8 +76,7 @@ Trk::Track::operator=(const Trk::Track& rhs) // First clear this object delete m_fitQuality; m_fitQuality = nullptr; - delete m_trackSummary; - m_trackSummary = nullptr; + m_trackSummary.reset(nullptr); // Invalidate the caches m_cachedParameterVector.reset(); m_cachedMeasurementVector.reset(); @@ -110,7 +106,7 @@ Trk::Track::copyHelper(const Trk::Track& rhs) } // create & copy other variables if (rhs.trackSummary() != nullptr) { - m_trackSummary = new Trk::TrackSummary(*(rhs.m_trackSummary)); + m_trackSummary = std::make_unique<Trk::TrackSummary>(*(rhs.m_trackSummary)); } // Create the TrackStateVector and the perigeeParameters if (rhs.m_trackStateVector != nullptr) { @@ -154,7 +150,6 @@ Trk::Track::Track(Trk::Track&& rhs) noexcept // but undefined state make the ptr null. rhs.m_trackStateVector = nullptr; rhs.m_fitQuality = nullptr; - rhs.m_trackSummary = nullptr; #ifndef NDEBUG s_numberOfInstantiations++; // new Track, so increment total count @@ -168,7 +163,6 @@ Trk::Track::operator=(Trk::Track&& rhs) noexcept // First clear this object // same as dtor of the object delete m_fitQuality; - delete m_trackSummary; delete m_trackStateVector; // move from rhs to this m_trackStateVector = std::move(rhs.m_trackStateVector); @@ -182,7 +176,6 @@ Trk::Track::operator=(Trk::Track&& rhs) noexcept // but undefined state make the ptr null. rhs.m_trackStateVector = nullptr; rhs.m_fitQuality = nullptr; - rhs.m_trackSummary = nullptr; } return *this; } @@ -190,7 +183,6 @@ Trk::Track::operator=(Trk::Track&& rhs) noexcept Trk::Track::~Track() { delete m_fitQuality; - delete m_trackSummary; // the following is DataVectors // and so delete the contained objects automatically. delete m_trackStateVector; @@ -339,10 +331,9 @@ void Trk::Track::setInfo(const TrackInfo& input) m_trackInfo = input; } -void Trk::Track::setTrackSummary(Trk::TrackSummary* input) +void Trk::Track::setTrackSummary(std::unique_ptr<Trk::TrackSummary> input) { - delete m_trackSummary; // delete existing - m_trackSummary = input; // add new + m_trackSummary = std::move(input); } void Trk::Track::reset() diff --git a/Tracking/TrkTools/TrkTrackSummaryTool/TrkTrackSummaryTool/TrackSummaryTool.h b/Tracking/TrkTools/TrkTrackSummaryTool/TrkTrackSummaryTool/TrackSummaryTool.h index 13ae226c33b7e95185648a7258621bc50c45529f..ca02495f95a222ff09d6fde28964e16663ccc5ce 100755 --- a/Tracking/TrkTools/TrkTrackSummaryTool/TrkTrackSummaryTool/TrackSummaryTool.h +++ b/Tracking/TrkTools/TrkTrackSummaryTool/TrkTrackSummaryTool/TrackSummaryTool.h @@ -101,7 +101,7 @@ public: if (!track.trackSummary()) { computeAndReplaceTrackSummary(track, prd_to_track_map, false /*DO NOT suppress hole search*/); } else { - updateSharedHitCount(track, prd_to_track_map, *track.m_trackSummary); + updateSharedHitCount(track, prd_to_track_map, *track.trackSummary()); } } @@ -148,7 +148,7 @@ public: if (!track.trackSummary()) { computeAndReplaceTrackSummary(track, nullptr, false /*DO NOT suppress hole search*/); } else { - updateSharedHitCount(track, nullptr, *track.m_trackSummary); + updateSharedHitCount(track, nullptr, *track.trackSummary()); } } @@ -191,11 +191,9 @@ private: bool doHolesInDet, bool doHolesMuon) const { - Trk::TrackSummary* ts = createSummary(track, prd_to_track_map, doHolesInDet, doHolesMuon).release(); Trk::Track& nonConstTrack = const_cast<Trk::Track&>(track); - delete nonConstTrack.m_trackSummary; - nonConstTrack.m_trackSummary = ts; - return onlyUpdateTrack ? nullptr : new Trk::TrackSummary(*ts); + nonConstTrack.setTrackSummary(createSummary(track, prd_to_track_map, doHolesInDet, doHolesMuon)); + return onlyUpdateTrack ? nullptr : new Trk::TrackSummary(*nonConstTrack.trackSummary()); } /** use this method to update a track. this means a tracksummary is created for this track but not returned. the summary can then be obtained from the track. diff --git a/Tracking/TrkTools/TrkTrackSummaryTool/src/TrackSummaryTool.cxx b/Tracking/TrkTools/TrkTrackSummaryTool/src/TrackSummaryTool.cxx index bcb0783196329b40c6dd85996be83eb786cefa34..f1c6b44cb460c0ed64df874c644a788a277462ee 100755 --- a/Tracking/TrkTools/TrkTrackSummaryTool/src/TrackSummaryTool.cxx +++ b/Tracking/TrkTools/TrkTrackSummaryTool/src/TrackSummaryTool.cxx @@ -136,12 +136,14 @@ const Trk::TrackSummary* Trk::TrackSummaryTool::createSummary( const Track& trac void Trk::TrackSummaryTool::computeAndReplaceTrackSummary(Trk::Track &track, const Trk::PRDtoTrackMap *prd_to_track_map, bool suppress_hole_search) const { - delete track.m_trackSummary; - track.m_trackSummary = nullptr; - track.m_trackSummary = createSummary(track, - prd_to_track_map, - m_doHolesInDet & !suppress_hole_search, - m_doHolesMuon & !suppress_hole_search).release(); + track.setTrackSummary( + createSummary( + track, + prd_to_track_map, + m_doHolesInDet & !suppress_hole_search, + m_doHolesMuon & !suppress_hole_search + ) + ); } std::unique_ptr<Trk::TrackSummary> Trk::TrackSummaryTool::summary( const Track& track) const @@ -338,7 +340,7 @@ Trk::TrackSummaryTool::updateTrackNoHoleSearch(Track& track, { // first check if track has summary already. computeAndReplaceTrackSummary(track, prd_to_track_map, true /*suppress hole search*/); - m_idTool->updateExpectedHitInfo(track, *track.m_trackSummary); /*Needed for expected B-Layer*/ + m_idTool->updateExpectedHitInfo(track, *track.trackSummary()); /*Needed for expected B-Layer*/ } void Trk::TrackSummaryTool::updateSharedHitCount(const Track& track, const Trk::PRDtoTrackMap *prd_to_track_map,TrackSummary &summary) const