diff --git a/Tracking/TrkDetDescr/TrkDetDescrTools/src/TrackingVolumeHelper.cxx b/Tracking/TrkDetDescr/TrkDetDescrTools/src/TrackingVolumeHelper.cxx index ff27aa5a271d7dda68d110f597f62a046402d01a..b0d428e6b499e10011fa36acfec6e578dbb7542c 100755 --- a/Tracking/TrkDetDescr/TrkDetDescrTools/src/TrackingVolumeHelper.cxx +++ b/Tracking/TrkDetDescr/TrkDetDescrTools/src/TrackingVolumeHelper.cxx @@ -109,9 +109,9 @@ void Trk::TrackingVolumeHelper::glueTrackingVolumes(const Trk::TrackingVolume& f if (lmps){ const Trk::Layer* mLayer = new Trk::MaterialLayer(firstFaceSurface, *lmps); ATH_MSG_VERBOSE( "Set MaterialLayer to the BoundarySurface of first volume." ); - firstFaceSurface.setMaterialLayer(*mLayer); - ATH_MSG_VERBOSE( "Set MaterialLayer to the BoundarySurface of second volume." ); - secondFaceSurface.setMaterialLayer(*mLayer); + (const_cast<Trk::Surface&>(firstFaceSurface)).setMaterialLayer(*mLayer); + ATH_MSG_VERBOSE("Set MaterialLayer to the BoundarySurface of second volume."); + (const_cast<Trk::Surface&>(secondFaceSurface)).setMaterialLayer(*mLayer); } } } @@ -143,7 +143,7 @@ void Trk::TrackingVolumeHelper::glueTrackingVolumes(const Trk::TrackingVolume& f // the material layer is ready - it can be assigned mLayer = new Trk::MaterialLayer(firstFaceSurface, *lmps); ATH_MSG_VERBOSE( "Set MaterialLayer to the BoundarySurface of first volume (may be shared with second volume)." ); - firstFaceSurface.setMaterialLayer(*mLayer); + (const_cast<Trk::Surface&>(firstFaceSurface)).setMaterialLayer(*mLayer); } // if only one volume was given in the vector call the standard one-to-one glueing // 1-to-1 case @@ -195,7 +195,7 @@ void Trk::TrackingVolumeHelper::glueTrackingVolumes(const Trk::TrackingVolume& f // if existing, set the material Layer // get the second face surface and set the new MaterialLayer const Trk::Surface& secondFaceSurface = volIter->boundarySurfaces()[secondFace]->surfaceRepresentation(); - secondFaceSurface.setMaterialLayer(mLayer); + (const_cast<Trk::Surface&>(secondFaceSurface)).setMaterialLayer(mLayer); } } } // 1-to-n case @@ -279,7 +279,8 @@ void Trk::TrackingVolumeHelper::glueTrackingVolumes(const std::vector<const Trk: // attach the material layer to the shared boundary if existing if (mLayer) { ATH_MSG_VERBOSE( "Set MaterialLayer to the BoundarySurface of volume from second array." ); - boundarySurface->surfaceRepresentation().setMaterialLayer(*(mLayer.release())); + (const_cast<Trk::Surface&>(boundarySurface->surfaceRepresentation())) + .setMaterialLayer(*(mLayer.release())); } // set the boundary surface to the volumes of both sides for (const auto & volIter : firstVolumes){ @@ -362,9 +363,10 @@ void Trk::TrackingVolumeHelper::glueTrackingVolumes(const std::vector<const Trk: Trk::SharedObject<const Trk::BoundarySurface<Trk::TrackingVolume> > sharedBoundarySurface(boundarySurface); // attach the material layer to the shared boundary if existing if (mLayer) { - ATH_MSG_VERBOSE( "Set MaterialLayer to the BoundarySurface of volume from second array." ); - // assume that now the mlayer onwership goes over to the TrackingVolume - boundarySurface->surfaceRepresentation().setMaterialLayer(*(mLayer.release())); + ATH_MSG_VERBOSE("Set MaterialLayer to the BoundarySurface of volume from second array."); + // assume that now the mlayer onwership goes over to the TrackingVolume + (const_cast<Trk::Surface&>(boundarySurface->surfaceRepresentation())) + .setMaterialLayer(*(mLayer.release())); } // set the boundary surface to the volumes of both sides for (const auto & volIter : firstVolumes){ @@ -407,7 +409,7 @@ void Trk::TrackingVolumeHelper::glueTrackingVolumes(const std::vector<const Trk: const Trk::Surface& firstFaceSurface = tVolIter->boundarySurfaces()[firstFace]->surfaceRepresentation(); // assume that now the mlayer onwership goes over to the TrackingVolume mLayer.release(); - firstFaceSurface.setMaterialLayer(*mLayer_ptr); + (const_cast<Trk::Surface&>(firstFaceSurface)).setMaterialLayer(*mLayer_ptr); } } @@ -426,7 +428,7 @@ void Trk::TrackingVolumeHelper::glueTrackingVolumes(const std::vector<const Trk: const Trk::Surface& secondFaceSurface = tVolIter->boundarySurfaces()[secondFace]->surfaceRepresentation(); // assume that now the mlayer onwership goes over to the TrackingVolume mLayer.release(); - secondFaceSurface.setMaterialLayer(*mLayer_ptr); + (const_cast<Trk::Surface&>(secondFaceSurface)).setMaterialLayer(*mLayer_ptr); } } // coverity will report a bug here for mLayer running out of scope, but the memory management is done later in the TrackingVolume diff --git a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h index 84a0774f51bee723eb5c9c3116c58a293160a1c7..f92abd1694ffb39e56c7b4e233e478b5887c1489 100644 --- a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h +++ b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h @@ -420,10 +420,6 @@ public: void setMaterialLayer(const Layer* mlay); - /** set material layer const */ - void setMaterialLayer ATLAS_NOT_CONST_THREAD_SAFE(const Layer& mlay) const; - void setMaterialLayer ATLAS_NOT_CONST_THREAD_SAFE(const Layer* mlay) const; - /** Output Method for MsgStream, to be overloaded by child classes */ virtual MsgStream& dump(MsgStream& sl) const; diff --git a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.icc b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.icc index a51b0ef3af8480528e27c3046227ae09a35728db..82d3c7383d740dc2d25395fc15ee903049bd6447 100644 --- a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.icc +++ b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.icc @@ -262,18 +262,6 @@ Surface::setMaterialLayer(const Layer* mlay) m_materialLayer = mlay; } -inline void Surface::setMaterialLayer -ATLAS_NOT_CONST_THREAD_SAFE(const Layer& mlay) const -{ - const_cast<Surface*>(this)->m_materialLayer = (&mlay); -} - -inline void Surface::setMaterialLayer -ATLAS_NOT_CONST_THREAD_SAFE(const Layer* mlay) const -{ - const_cast<Surface*>(this)->m_materialLayer = mlay; -} - inline void Surface::associateLayer(const Layer& lay) {