From 5b907d5c1aa76c1a0fd2a0b4b70da59d6a6aa947 Mon Sep 17 00:00:00 2001
From: christos <christos@cern.ch>
Date: Sat, 11 May 2019 15:33:10 +0100
Subject: [PATCH] Trk::Track clarify changes due to const correctness in
 documentation. Get rid of a couple of const_cast in TrkTrackSummaryTool

---
 Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h   | 52 ++++++++++++++-----
 .../src/TrackSummaryTool.cxx                  |  4 +-
 2 files changed, 42 insertions(+), 14 deletions(-)

diff --git a/Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h b/Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h
index f165e7e9cf2..db364f40d5f 100755
--- a/Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h
+++ b/Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h
@@ -36,28 +36,50 @@ namespace Trk
      * allowing a Track to be incomplete (and in general a Track WILL be
      * incomplete).
      *
-     * A Track can contain:
+     * A Track typically is constructed via
      *
      * - Trk::FitQuality          - the fit quality of a track
-     * - Trk::TrackStateOnSurface - this is a sub-container, which holds
-     *                              various properties defining a Track,
-     *                              on a particular surface. It can contain:
+     * - A DataVector of Trk::TrackStateOnSurface
+     *
+     * A TrackStateOnSurface is sub-container, which holds
+     * various properties defining a Track, on a particular surface.
+     * It can contain:
      * - Trk::FitQualityOnSurface
      * - Trk::TrackParameters 
      * - Trk::MeasurementBase
      * - Trk::MaterialEffectsOnTrack
      * - Trk::ScatteringAngleOnTrack
+     * 
+     * This class provides convenient helpers to retrieve and cache
+     * DataVectors (VIEW ELEMENTs) to 
+     * - TrackParameters
+     * - Measurements
+     * - Outliers
+     * from the TrackStateOnSurface DataVector
+     *
+     * It also allows for retrieving/caching 
+     * the Track Parameter at perigee
+     *
+     *
+     *  Furthermore a Track can contain 
      * - Trk::TrackInfo
+     * - Trk::TrackSummary - used to cache the TrackSummary. Might be 0! 
      * 
-     * - Trk::TrackSummary - used to cash TrackSummary. Might be 0!
-     *                       One still needs to use the TrackSummaryTool to create it.
-     *                       SummaryTool will return the cashed pointer if it exists.
+     * They can be modified for a non-const Track 
+     * But not for a const one
+     *  
+     * For the TrackSummary one still needs 
+     * to use the TrackSummaryTool to create it.
+     *The SummaryTool will return the cashed pointer if it exists.
+     *  
      *
      * Please look at the mainpage of this package (see the link at the top
      * of the page) for more information.
      *
      * @author edward.moyse@cern.ch
      * @author Kirill.Prokofiev@cern.ch
+     *
+     * MT modification Christos
      */
     
     class Track
@@ -159,25 +181,31 @@ namespace Trk
          return m_trackStateVector;
        }
        /**									            
-        * returns the const info of the track for const tracks.           
+        * returns a const info for const tracks.           
         */									            
        const TrackInfo& info() const{
          return m_trackInfo;
        }
 
        /**									            
-        * returns the info of the track for non-const tracks.           
+        * returns the info (non-const) for non-const tracks.           
         */									            
        TrackInfo& info() {
          return m_trackInfo;
        }
         											            
        /**									            
-        * Returns  A pointer to the Trk::TrackSummary owned by this track (could be 0)     
+        * Returns  a const pointer to the Trk::TrackSummary owned by this const track (could be 0)     
         */									            
        const Trk::TrackSummary* trackSummary() const{
          return m_trackSummary;
        }
+       /**									            
+        * Returns a  pointer to the Trk::TrackSummary owned by this  track (could be 0)     
+        */									            
+       Trk::TrackSummary* trackSummary() {
+         return m_trackSummary;
+       }
         	
        /**
         * reset all caches
@@ -261,7 +289,7 @@ namespace Trk
        /**									   
         * Datamember to cache the TrackSummary  				   
         */									   
-       const Trk::TrackSummary* m_trackSummary; 
+       Trk::TrackSummary* m_trackSummary; 
        
        /**									   
         * This is aclass which stores the identity of where the track 	   
@@ -275,7 +303,7 @@ namespace Trk
        private:
        /**
         * find PerigeeImpl. 
-        * Assumes that Perigee parameters are currently inValid
+        * Assumes that Perigee parameters are currently inValid.
         */
        void findPerigeeImpl() const;						   
              
diff --git a/Tracking/TrkTools/TrkTrackSummaryTool/src/TrackSummaryTool.cxx b/Tracking/TrkTools/TrkTrackSummaryTool/src/TrackSummaryTool.cxx
index 0ad0df6dc3a..9ef687a6fc2 100755
--- a/Tracking/TrkTools/TrkTrackSummaryTool/src/TrackSummaryTool.cxx
+++ b/Tracking/TrkTools/TrkTrackSummaryTool/src/TrackSummaryTool.cxx
@@ -369,7 +369,7 @@ void Trk::TrackSummaryTool::updateSharedHitCount(Track& track) const
       createSummary( track, true );
       return;
   } 
-  Trk::TrackSummary* tSummary = const_cast<Trk::TrackSummary*>(track.m_trackSummary);
+  Trk::TrackSummary* tSummary = track.m_trackSummary;
   m_idTool->updateSharedHitCount(track, *tSummary);
   return;
 }
@@ -381,7 +381,7 @@ void Trk::TrackSummaryTool::updateAdditionalInfo(Track& track) const
       createSummary( track, true );
       return;
   } 
-  Trk::TrackSummary* tSummary = const_cast<Trk::TrackSummary*>(track.m_trackSummary);
+  Trk::TrackSummary* tSummary = track.m_trackSummary;
   
   unsigned int numberOfeProbabilityTypes = Trk::numberOfeProbabilityTypes+1;
   std::vector<float> eProbability(numberOfeProbabilityTypes,0.5); 
-- 
GitLab