diff --git a/MuonSpectrometer/MuonDetDescr/MuonTrackingGeometry/src/MuonTrackingGeometryBuilder.cxx b/MuonSpectrometer/MuonDetDescr/MuonTrackingGeometry/src/MuonTrackingGeometryBuilder.cxx index cf061c8abc1b817544e0469dc1d2d20b308c4838..3093ed3109768ed52e3ca97faae38d7fd2711b3b 100644 --- a/MuonSpectrometer/MuonDetDescr/MuonTrackingGeometry/src/MuonTrackingGeometryBuilder.cxx +++ b/MuonSpectrometer/MuonDetDescr/MuonTrackingGeometry/src/MuonTrackingGeometryBuilder.cxx @@ -1215,7 +1215,7 @@ Trk::TrackingVolume* Muon::MuonTrackingGeometryBuilder::processVolume(const Trk: tVol = new Trk::TrackingVolume(*vol, aLVC.m_muonMaterial, nullptr, subVols, volumeName); // register glue volumes - const Trk::GlueVolumesDescriptor& volGlueVolumes = tVol->glueVolumesDescriptor(); + Trk::GlueVolumesDescriptor& volGlueVolumes = tVol->glueVolumesDescriptor(); volGlueVolumes.registerGlueVolumes(Trk::tubeInnerCover, sVols); volGlueVolumes.registerGlueVolumes(Trk::tubeOuterCover, sVols); volGlueVolumes.registerGlueVolumes(Trk::negativeFaceXY, sVolsNeg); @@ -1599,7 +1599,7 @@ Muon::MuonTrackingGeometryBuilder::processVolume( tVol = new Trk::TrackingVolume( *vol, aLVC.m_muonMaterial, nullptr, subVols, volumeName); // register glue volumes - const Trk::GlueVolumesDescriptor& volGlueVolumes = + Trk::GlueVolumesDescriptor& volGlueVolumes = tVol->glueVolumesDescriptor(); volGlueVolumes.registerGlueVolumes(Trk::tubeInnerCover, sVolsInn); volGlueVolumes.registerGlueVolumes(Trk::tubeOuterCover, sVolsOut); @@ -1760,7 +1760,7 @@ Muon::MuonTrackingGeometryBuilder::processVolume( tVol = new Trk::TrackingVolume( *vol, aLVC.m_muonMaterial, nullptr, subVols, volumeName); // register glue volumes - const Trk::GlueVolumesDescriptor& volGlueVolumes = + Trk::GlueVolumesDescriptor& volGlueVolumes = tVol->glueVolumesDescriptor(); volGlueVolumes.registerGlueVolumes(Trk::tubeInnerCover, sVols); volGlueVolumes.registerGlueVolumes(Trk::tubeOuterCover, sVols); @@ -1800,7 +1800,7 @@ const Trk::TrackingVolume* Muon::MuonTrackingGeometryBuilder::processShield(cons LocalVariablesContainer& aLVC) const { ATH_MSG_VERBOSE(name() << "processing shield volume " << volumeName << " in mode:" << type); - const Trk::TrackingVolume* tVol = nullptr; + Trk::TrackingVolume* tVol = nullptr; unsigned int colorCode = m_colorCode; @@ -1957,7 +1957,7 @@ const Trk::TrackingVolume* Muon::MuonTrackingGeometryBuilder::processShield(cons tVol = new Trk::TrackingVolume(*vol, aLVC.m_muonMaterial, nullptr, subVols, volumeName); // register glue volumes - const Trk::GlueVolumesDescriptor& volGlueVolumes = tVol->glueVolumesDescriptor(); + Trk::GlueVolumesDescriptor& volGlueVolumes = tVol->glueVolumesDescriptor(); volGlueVolumes.registerGlueVolumes(Trk::tubeInnerCover, sVolsInn); volGlueVolumes.registerGlueVolumes(Trk::tubeOuterCover, sVolsOut); volGlueVolumes.registerGlueVolumes(Trk::negativeFaceXY, sVolsNeg); diff --git a/MuonSpectrometer/MuonDetDescr/MuonTrackingGeometry/src/MuonTrackingGeometryBuilderCond.cxx b/MuonSpectrometer/MuonDetDescr/MuonTrackingGeometry/src/MuonTrackingGeometryBuilderCond.cxx index a6c1f9b063ea1fedae2e6f08cfb5f73e139128d0..585a2a53f9d549e5fd51645c0e963a4a953b1f59 100644 --- a/MuonSpectrometer/MuonDetDescr/MuonTrackingGeometry/src/MuonTrackingGeometryBuilderCond.cxx +++ b/MuonSpectrometer/MuonDetDescr/MuonTrackingGeometry/src/MuonTrackingGeometryBuilderCond.cxx @@ -1226,7 +1226,7 @@ Trk::TrackingVolume* Muon::MuonTrackingGeometryBuilderCond::processVolume(const tVol = new Trk::TrackingVolume(*vol, aLVC.m_muonMaterial, nullptr, subVols, volumeName); // register glue volumes - const Trk::GlueVolumesDescriptor& volGlueVolumes = tVol->glueVolumesDescriptor(); + Trk::GlueVolumesDescriptor& volGlueVolumes = tVol->glueVolumesDescriptor(); volGlueVolumes.registerGlueVolumes(Trk::tubeInnerCover, sVols); volGlueVolumes.registerGlueVolumes(Trk::tubeOuterCover, sVols); volGlueVolumes.registerGlueVolumes(Trk::negativeFaceXY, sVolsNeg); @@ -1537,7 +1537,7 @@ Trk::TrackingVolume* Muon::MuonTrackingGeometryBuilderCond::processVolume(const tVol = new Trk::TrackingVolume(*vol, aLVC.m_muonMaterial, nullptr, subVols, volumeName); // register glue volumes - const Trk::GlueVolumesDescriptor& volGlueVolumes = tVol->glueVolumesDescriptor(); + Trk::GlueVolumesDescriptor& volGlueVolumes = tVol->glueVolumesDescriptor(); volGlueVolumes.registerGlueVolumes(Trk::tubeInnerCover, sVolsInn); volGlueVolumes.registerGlueVolumes(Trk::tubeOuterCover, sVolsOut); volGlueVolumes.registerGlueVolumes(Trk::negativeFaceXY, sVolsNeg); @@ -1662,7 +1662,7 @@ Trk::TrackingVolume* Muon::MuonTrackingGeometryBuilderCond::processVolume(const tVol = new Trk::TrackingVolume(*vol, aLVC.m_muonMaterial, nullptr, subVols, volumeName); // register glue volumes - const Trk::GlueVolumesDescriptor& volGlueVolumes = tVol->glueVolumesDescriptor(); + Trk::GlueVolumesDescriptor& volGlueVolumes = tVol->glueVolumesDescriptor(); volGlueVolumes.registerGlueVolumes(Trk::tubeInnerCover, sVols); volGlueVolumes.registerGlueVolumes(Trk::tubeOuterCover, sVols); volGlueVolumes.registerGlueVolumes(Trk::negativeFaceXY, sVolsNeg); @@ -1697,7 +1697,7 @@ const Trk::TrackingVolume* Muon::MuonTrackingGeometryBuilderCond::processShield( LocalVariablesContainer& aLVC, bool hasStations) const { ATH_MSG_VERBOSE(name() << "processing shield volume " << volumeName << " in mode:" << type); - const Trk::TrackingVolume* tVol = nullptr; + Trk::TrackingVolume* tVol = nullptr; unsigned int colorCode = m_colorCode; @@ -1854,7 +1854,7 @@ const Trk::TrackingVolume* Muon::MuonTrackingGeometryBuilderCond::processShield( tVol = new Trk::TrackingVolume(*vol, aLVC.m_muonMaterial, nullptr, subVols, volumeName); // register glue volumes - const Trk::GlueVolumesDescriptor& volGlueVolumes = tVol->glueVolumesDescriptor(); + Trk::GlueVolumesDescriptor& volGlueVolumes = tVol->glueVolumesDescriptor(); volGlueVolumes.registerGlueVolumes(Trk::tubeInnerCover, sVolsInn); volGlueVolumes.registerGlueVolumes(Trk::tubeOuterCover, sVolsOut); volGlueVolumes.registerGlueVolumes(Trk::negativeFaceXY, sVolsNeg); diff --git a/Tracking/TrkDetDescr/TrkDetDescrTools/src/CylinderVolumeCreator.cxx b/Tracking/TrkDetDescr/TrkDetDescrTools/src/CylinderVolumeCreator.cxx index 53a81762736aaffa477fe352aa2dafedad290c87..5b90387f95ca7612b32151cc4f5f036179f7dda5 100644 --- a/Tracking/TrkDetDescr/TrkDetDescrTools/src/CylinderVolumeCreator.cxx +++ b/Tracking/TrkDetDescr/TrkDetDescrTools/src/CylinderVolumeCreator.cxx @@ -628,7 +628,7 @@ StatusCode Trk::CylinderVolumeCreator::interGlueTrackingVolume(Trk::TrackingVolu ATH_MSG_VERBOSE( "Glue contained TrackingVolumes of container '" << tVolume.volumeName() << "'." ); // get the glueVolumes descriptor of the top volume to register the outside volumes - const Trk::GlueVolumesDescriptor& glueDescr = tVolume.glueVolumesDescriptor(); + Trk::GlueVolumesDescriptor& glueDescr = tVolume.glueVolumesDescriptor(); // so far we know that we can do that (private method) const std::vector<const Trk::TrackingVolume*>& volumes = tVolume.confinedVolumes()->arrayObjects(); diff --git a/Tracking/TrkDetDescr/TrkDetDescrTools/src/TrackingVolumeHelper.cxx b/Tracking/TrkDetDescr/TrkDetDescrTools/src/TrackingVolumeHelper.cxx index f3dc46be25c1eeb05af95c0a440b3fa08792629c..2776b33d4713559026700bb3afb03683860d954a 100755 --- a/Tracking/TrkDetDescr/TrkDetDescrTools/src/TrackingVolumeHelper.cxx +++ b/Tracking/TrkDetDescr/TrkDetDescrTools/src/TrackingVolumeHelper.cxx @@ -556,7 +556,7 @@ Trk::TrackingVolume* Trk::TrackingVolumeHelper::glueTrackingVolumeArrays( // ENVELOPE GLUE DESCRIPTION ----------------------------------------------------------------- // glue descriptors ---- they jump to the first one - const Trk::GlueVolumesDescriptor& glueDescr = enclosingVolume->glueVolumesDescriptor(); + Trk::GlueVolumesDescriptor& glueDescr = enclosingVolume->glueVolumesDescriptor(); // for the outside volumes, could be done in a loop as well, but will only save 4 lines std::vector<const Trk::TrackingVolume*> glueNegXY; diff --git a/Tracking/TrkDetDescr/TrkGeometry/TrkGeometry/GlueVolumesDescriptor.h b/Tracking/TrkDetDescr/TrkGeometry/TrkGeometry/GlueVolumesDescriptor.h index 8615f43917760137c870cc61ddca3f0ea88ee8a1..0942ea07b108d5377692a0c42df5cd69886eeadd 100644 --- a/Tracking/TrkDetDescr/TrkGeometry/TrkGeometry/GlueVolumesDescriptor.h +++ b/Tracking/TrkDetDescr/TrkGeometry/TrkGeometry/GlueVolumesDescriptor.h @@ -17,7 +17,6 @@ #include <map> #include <vector> -#include "CxxUtils/checker_macros.h" namespace Trk { @@ -54,8 +53,6 @@ class GlueVolumesDescriptor { /** register the volumes */ void registerGlueVolumes(BoundarySurfaceFace, std::vector<const TrackingVolume*>&); - void registerGlueVolumes ATLAS_NOT_THREAD_SAFE( - BoundarySurfaceFace, std::vector<const TrackingVolume*>&) const; /** retrieve them again */ const std::vector<const TrackingVolume*>& glueVolumes( @@ -71,11 +68,6 @@ class GlueVolumesDescriptor { static const std::vector<const TrackingVolume*> s_emptyVector; }; -inline void GlueVolumesDescriptor::registerGlueVolumes ATLAS_NOT_THREAD_SAFE( - BoundarySurfaceFace bSurf, std::vector<const TrackingVolume*>& vols) const { - const_cast<GlueVolumesDescriptor*>(this)->registerGlueVolumes(bSurf, vols); -} - inline const std::vector<BoundarySurfaceFace>& GlueVolumesDescriptor::glueFaces() const { return m_glueFaces; diff --git a/Tracking/TrkDetDescr/TrkGeometry/TrkGeometry/TrackingVolume.h b/Tracking/TrkDetDescr/TrkGeometry/TrkGeometry/TrackingVolume.h index 67320d140df71d9c991b14c1a69d74bde5a1ad90..f1084031fd93f64cc1937c5d2f84de49b291ab36 100644 --- a/Tracking/TrkDetDescr/TrkGeometry/TrkGeometry/TrackingVolume.h +++ b/Tracking/TrkDetDescr/TrkGeometry/TrkGeometry/TrackingVolume.h @@ -23,6 +23,7 @@ #include "TrkGeometry/DetachedTrackingVolume.h" #include "TrkGeometry/Material.h" #include "TrkGeometry/LayerAttemptsCalculator.h" +#include "TrkGeometry/GlueVolumesDescriptor.h" #include "TrkDetDescrUtils/BinnedArray.h" #include "TrkDetDescrUtils/SharedObject.h" #include "TrkDetDescrUtils/ObjectAccessor.h" @@ -35,6 +36,7 @@ #include "AthenaBaseComps/AthMsgStreamMacros.h" #include "CxxUtils/checker_macros.h" +#include "CxxUtils/CachedUniquePtr.h" #ifndef TRKGEOMETRY_MAXLAYERATTEMPTS #define TRKGEOMETRY_MAXLAYERATTEMPTS 100 #endif @@ -48,7 +50,6 @@ namespace Trk { class PlaneLayer; class TrackingVolume; class DetachedTrackingVolume; - class GlueVolumesDescriptor; class VolumeBounds; typedef BinnedArray< Layer > LayerArray; @@ -303,8 +304,8 @@ namespace Trk { void registerOutsideGlueVolumes (GlueVolumesDescriptor* gvd); - const GlueVolumesDescriptor& glueVolumesDescriptor(); - const GlueVolumesDescriptor& glueVolumesDescriptor ATLAS_NOT_THREAD_SAFE() const; + GlueVolumesDescriptor& glueVolumesDescriptor(); + const GlueVolumesDescriptor& glueVolumesDescriptor () const; /** the sensitive area */ void registerSensitiveVolume(const AbstractVolume* svol); @@ -415,8 +416,9 @@ namespace Trk { const std::vector<const TrackingVolume*>* m_confinedDenseVolumes; //!< Unordered subvolumes //(b) const std::vector<const Layer*>* m_confinedArbitraryLayers; //!< Unordered Layers inside the Volume - - GlueVolumesDescriptor* m_outsideGlueVolumes; //!< Volumes to glue Volumes from the outside + + ////!< Volumes to glue Volumes from the outside + CxxUtils:: CachedUniquePtrT<GlueVolumesDescriptor> m_outsideGlueVolumes; const AbstractVolume* m_sensitiveVolume; //!< Sensitive volume diff --git a/Tracking/TrkDetDescr/TrkGeometry/src/TrackingVolume.cxx b/Tracking/TrkDetDescr/TrkGeometry/src/TrackingVolume.cxx index d9ac42dec5ea89a9cacec9d1eba1eb1da7ed36ab..3a8fe964efd510aefbb974b7d9cf3826743f4e75 100755 --- a/Tracking/TrkDetDescr/TrkGeometry/src/TrackingVolume.cxx +++ b/Tracking/TrkDetDescr/TrkGeometry/src/TrackingVolume.cxx @@ -12,7 +12,6 @@ #include "TrkGeometry/CylinderLayer.h" #include "TrkGeometry/CylinderLayerAttemptsCalculator.h" #include "TrkGeometry/DiscLayerAttemptsCalculator.h" -#include "TrkGeometry/GlueVolumesDescriptor.h" #include "TrkGeometry/Layer.h" #include "TrkGeometry/NavigationLayer.h" #include "TrkGeometry/PlaneLayer.h" @@ -527,7 +526,6 @@ Trk::TrackingVolume::~TrackingVolume() { delete (*m_confinedArbitraryLayers)[i]; delete m_confinedArbitraryLayers; } - delete m_outsideGlueVolumes; delete m_sensitiveVolume; delete m_layerAttemptsCalculator; } @@ -1103,21 +1101,28 @@ const Trk::LayerArray* Trk::TrackingVolume::checkoutConfinedLayers() const { return checkoutLayers; } -void Trk::TrackingVolume::registerOutsideGlueVolumes( - Trk::GlueVolumesDescriptor* gvd) { - delete m_outsideGlueVolumes; - m_outsideGlueVolumes = gvd; +void +Trk::TrackingVolume::registerOutsideGlueVolumes(Trk::GlueVolumesDescriptor* gvd) +{ + m_outsideGlueVolumes.store(std::unique_ptr<Trk::GlueVolumesDescriptor>(gvd)); } -const Trk::GlueVolumesDescriptor& Trk::TrackingVolume::glueVolumesDescriptor() { - if (!m_outsideGlueVolumes) - m_outsideGlueVolumes = new Trk::GlueVolumesDescriptor; +Trk::GlueVolumesDescriptor& +Trk::TrackingVolume::glueVolumesDescriptor() +{ + if (!m_outsideGlueVolumes) { + m_outsideGlueVolumes.store(std::make_unique<Trk::GlueVolumesDescriptor>()); + } return (*m_outsideGlueVolumes); } -const Trk::GlueVolumesDescriptor& Trk::TrackingVolume::glueVolumesDescriptor -ATLAS_NOT_THREAD_SAFE() const { - return (const_cast<Trk::TrackingVolume*>(this))->glueVolumesDescriptor(); +const Trk::GlueVolumesDescriptor& +Trk::TrackingVolume::glueVolumesDescriptor() const +{ + if (!m_outsideGlueVolumes) { + m_outsideGlueVolumes.set(std::make_unique<Trk::GlueVolumesDescriptor>()); + } + return (*m_outsideGlueVolumes); } void