From 62100899b0c9f30a380ca6dd537a5b271c8dc518 Mon Sep 17 00:00:00 2001 From: christos <christos@cern.ch> Date: Fri, 10 May 2019 14:29:42 +0100 Subject: [PATCH] Move the const_cast from the EDM to the problematic tool --- .../TrkTrack/TrkTrack/TrackStateOnSurface.h | 4 ++-- .../TrkTrack/src/TrackStateOnSurface.cxx | 12 ++++-------- .../src/TrackSlimmingTool.cxx | 17 +++++++++-------- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/Tracking/TrkEvent/TrkTrack/TrkTrack/TrackStateOnSurface.h b/Tracking/TrkEvent/TrkTrack/TrkTrack/TrackStateOnSurface.h index b5c1f8c7bee..2df1ac8e6c4 100755 --- a/Tracking/TrkEvent/TrkTrack/TrkTrack/TrackStateOnSurface.h +++ b/Tracking/TrkEvent/TrkTrack/TrkTrack/TrackStateOnSurface.h @@ -269,13 +269,13 @@ namespace Trk * Use this method to set persistification hints. * @throw logic_error if the type is not a persistification flag. */ - void setHint ATLAS_NOT_THREAD_SAFE ( const TrackStateOnSurfaceType& type ) const; + void setHint ( const TrackStateOnSurfaceType& type ) ; /** * Use this method to clear persistification hint flag. * @throw logic_error if the type is not a persistification flag. */ - void resetHint ATLAS_NOT_THREAD_SAFE ( const TrackStateOnSurfaceType& type ) const; + void resetHint ( const TrackStateOnSurfaceType& type ) ; /** returns a string with the expanded type of the object (i.e. if it has several type bits set, they all will be returned)*/ diff --git a/Tracking/TrkEvent/TrkTrack/src/TrackStateOnSurface.cxx b/Tracking/TrkEvent/TrkTrack/src/TrackStateOnSurface.cxx index d712a1aac31..0af3fbecff3 100755 --- a/Tracking/TrkEvent/TrkTrack/src/TrackStateOnSurface.cxx +++ b/Tracking/TrkEvent/TrkTrack/src/TrackStateOnSurface.cxx @@ -235,24 +235,20 @@ TrackStateOnSurface::isSane() const { } - void TrackStateOnSurface::setHint ATLAS_NOT_THREAD_SAFE ( const TrackStateOnSurfaceType& type ) const { + void TrackStateOnSurface::setHint ( const TrackStateOnSurfaceType& type ) { if (type>=PartialPersistification && type<=PersistifySlimCaloDeposit) { // allowed to modify persistification flags although this is const - - /* Fixing this needs revisiting the slimming code*/ - (const_cast< std::bitset<TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes>&> (this->m_typeFlags)).reset(type); + m_typeFlags.reset(type); } else { throw std::logic_error("Can only use TrackStateOnSurface::mark to set persistification flags"); } } - void TrackStateOnSurface::resetHint ATLAS_NOT_THREAD_SAFE ( const TrackStateOnSurfaceType& type ) const { + void TrackStateOnSurface::resetHint ( const TrackStateOnSurfaceType& type ) { if (type>=PartialPersistification && type<=PersistifySlimCaloDeposit) { // allowed to modify persistification flags although this is const - - /* Fixing this needs revisiting the slimming code*/ - (const_cast< std::bitset<TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes>&> (this->m_typeFlags)).reset(type); + m_typeFlags.reset(type); } else { throw std::logic_error("Can only use TrackStateOnSurface::mark to set persistification flags"); diff --git a/Tracking/TrkTools/TrkTrackSlimmingTool/src/TrackSlimmingTool.cxx b/Tracking/TrkTools/TrkTrackSlimmingTool/src/TrackSlimmingTool.cxx index c6e5649105c..d2d8c35eb1b 100755 --- a/Tracking/TrkTools/TrkTrackSlimmingTool/src/TrackSlimmingTool.cxx +++ b/Tracking/TrkTools/TrkTrackSlimmingTool/src/TrackSlimmingTool.cxx @@ -100,7 +100,8 @@ Trk::Track* Trk::TrackSlimmingTool::slim(const Trk::Track& track) const // search last valid TSOS first (as won't be found in later loop) for ( DataVector<const TrackStateOnSurface>::const_reverse_iterator rItTSoS = oldTrackStates->rbegin(); rItTSoS != oldTrackStates->rend(); ++rItTSoS) { - if ( (*rItTSoS)->type(TrackStateOnSurface::Measurement) && (*rItTSoS)->trackParameters()!=0 && (*rItTSoS)->measurementOnTrack()!=0 && !dynamic_cast<const Trk::PseudoMeasurementOnTrack*>((*rItTSoS)->measurementOnTrack())) + if ( (*rItTSoS)->type(TrackStateOnSurface::Measurement) && (*rItTSoS)->trackParameters()!=0 && (*rItTSoS)->measurementOnTrack()!=0 + && !dynamic_cast<const Trk::PseudoMeasurementOnTrack*>((*rItTSoS)->measurementOnTrack())) { if (m_detID->is_indet((*rItTSoS)->trackParameters()->associatedSurface().associatedDetectorElementIdentifier() ) ) { lastValidIDTSOS = (*rItTSoS); @@ -130,7 +131,7 @@ Trk::Track* Trk::TrackSlimmingTool::slim(const Trk::Track& track) const for ( ; itTSoS!=oldTrackStates->end(); ++itTSoS) { if (m_setPersistificationHints) { - (**itTSoS).setHint(Trk::TrackStateOnSurface::PartialPersistification); + const_cast<TrackStateOnSurface&>((**itTSoS)).setHint(Trk::TrackStateOnSurface::PartialPersistification); } parameters=0; rot=0; @@ -145,7 +146,7 @@ Trk::Track* Trk::TrackSlimmingTool::slim(const Trk::Track& track) const if ((**itTSoS).type(TrackStateOnSurface::Scatterer)) { if (m_setPersistificationHints) { - (**itTSoS).resetHint(Trk::TrackStateOnSurface::PartialPersistification); + const_cast<TrackStateOnSurface&> ((**itTSoS)).resetHint(Trk::TrackStateOnSurface::PartialPersistification); } else { trackStates->push_back((**itTSoS).clone()); @@ -163,8 +164,8 @@ Trk::Track* Trk::TrackSlimmingTool::slim(const Trk::Track& track) const { if (m_setPersistificationHints) { // (**itTSoS).resetHint(Trk::TrackStateOnSurface::PartialPersistification); - (**itTSoS).setHint(Trk::TrackStateOnSurface::PersistifySlimCaloDeposit); - (**itTSoS).setHint(Trk::TrackStateOnSurface::PersistifyTrackParameters); + const_cast<TrackStateOnSurface&> ((**itTSoS)).setHint(Trk::TrackStateOnSurface::PersistifySlimCaloDeposit); + const_cast<TrackStateOnSurface&> ((**itTSoS)).setHint(Trk::TrackStateOnSurface::PersistifyTrackParameters); } else { trackStates->push_back( @@ -184,7 +185,7 @@ Trk::Track* Trk::TrackSlimmingTool::slim(const Trk::Track& track) const if (itTSoS != oldTrackStates->end() && (**itTSoS).type(TrackStateOnSurface::Scatterer)) { if (m_setPersistificationHints) { - (**itTSoS).resetHint(Trk::TrackStateOnSurface::PartialPersistification); + const_cast<TrackStateOnSurface&> ((**itTSoS)).resetHint(Trk::TrackStateOnSurface::PartialPersistification); } else { trackStates->push_back((**itTSoS).clone()); @@ -277,10 +278,10 @@ Trk::Track* Trk::TrackSlimmingTool::slim(const Trk::Track& track) const if (rot!=0 || parameters!=0) { if (m_setPersistificationHints) { if (rot) { - (**itTSoS).setHint(Trk::TrackStateOnSurface::PersistifyMeasurement); + const_cast<TrackStateOnSurface&> ((**itTSoS)).setHint(Trk::TrackStateOnSurface::PersistifyMeasurement); } if (parameters) { - (**itTSoS).setHint(Trk::TrackStateOnSurface::PersistifyTrackParameters); + const_cast<TrackStateOnSurface&> ((**itTSoS)).setHint(Trk::TrackStateOnSurface::PersistifyTrackParameters); } } else { -- GitLab