diff --git a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/SiDetectorElement.h b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/SiDetectorElement.h index 2c052109eb443981bc68791a4eae2ec005257a03..3d080a519b120768c7c84eebf4149823075b52f7 100644 --- a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/SiDetectorElement.h +++ b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/InDetReadoutGeometry/SiDetectorElement.h @@ -734,18 +734,21 @@ namespace InDetDD { inline double SiDetectorElement::hitDepthDirection() const { + std::lock_guard<std::recursive_mutex> lock(m_mutex); if (!m_cacheValid) updateCache(); return (m_depthDirection) ? 1. : -1.; } inline double SiDetectorElement::hitPhiDirection() const { + std::lock_guard<std::recursive_mutex> lock(m_mutex); if (!m_cacheValid) updateCache(); return (m_phiDirection) ? 1. : -1.; } inline double SiDetectorElement::hitEtaDirection() const { + std::lock_guard<std::recursive_mutex> lock(m_mutex); if (!m_cacheValid) updateCache(); return (m_etaDirection) ? 1. : -1.; } @@ -767,6 +770,7 @@ namespace InDetDD { inline void SiDetectorElement::updateAllCaches() const { + std::lock_guard<std::recursive_mutex> lock(m_mutex); if (!m_cacheValid) updateCache(); if (not m_surface) surface(); } @@ -774,36 +778,42 @@ namespace InDetDD { inline double SiDetectorElement::rMin() const { + std::lock_guard<std::recursive_mutex> lock(m_mutex); if (!m_cacheValid) updateCache(); return m_minR; } inline double SiDetectorElement::rMax() const { + std::lock_guard<std::recursive_mutex> lock(m_mutex); if (!m_cacheValid) updateCache(); return m_maxR; } inline double SiDetectorElement::zMin() const { + std::lock_guard<std::recursive_mutex> lock(m_mutex); if (!m_cacheValid) updateCache(); return m_minZ; } inline double SiDetectorElement::zMax() const { + std::lock_guard<std::recursive_mutex> lock(m_mutex); if (!m_cacheValid) updateCache(); return m_maxZ; } inline double SiDetectorElement::phiMin() const { + std::lock_guard<std::recursive_mutex> lock(m_mutex); if (!m_cacheValid) updateCache(); return m_minPhi; } inline double SiDetectorElement::phiMax() const { + std::lock_guard<std::recursive_mutex> lock(m_mutex); if (!m_cacheValid) updateCache(); return m_maxPhi; } @@ -905,6 +915,7 @@ namespace InDetDD { inline bool SiDetectorElement::swapPhiReadoutDirection() const { + std::lock_guard<std::recursive_mutex> lock(m_mutex); if (m_firstTime) updateCache(); // In order to set m_phiDirection // equivalent to (m_design->swapHitPhiReadoutDirection() xor !m_phiDirection) return ((!m_design->swapHitPhiReadoutDirection() && !m_phiDirection) @@ -913,6 +924,7 @@ namespace InDetDD { inline bool SiDetectorElement::swapEtaReadoutDirection() const { + std::lock_guard<std::recursive_mutex> lock(m_mutex); if (m_firstTime) updateCache(); // In order to set m_etaDirection // equivalent to (m_design->swapHitEtaReadoutDirection() xor !m_etaDirection) return ((!m_design->swapHitEtaReadoutDirection() && !m_etaDirection) diff --git a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/src/SiDetectorElement.cxx b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/src/SiDetectorElement.cxx index bf87647bbb2ee913a1491ad6d30020bdc8b326ab..bb597d1be11827dd18a6baa137ab4568ff81c42b 100644 --- a/InnerDetector/InDetDetDescr/InDetReadoutGeometry/src/SiDetectorElement.cxx +++ b/InnerDetector/InDetDetDescr/InDetReadoutGeometry/src/SiDetectorElement.cxx @@ -148,10 +148,9 @@ SiDetectorElement::updateCache() const { std::lock_guard<std::recursive_mutex> lock(m_mutex); - m_cacheValid = true; - bool firstTimeTmp = m_firstTime; m_firstTime = false; + m_cacheValid = true; const GeoTrf::Transform3D & geoTransform = transformHit(); @@ -289,7 +288,7 @@ SiDetectorElement::updateCache() const m_etaDirection = true; // Don't swap } - } // end if (m_firstTime) + } // end if (firstTimeTmp) @@ -361,7 +360,6 @@ SiDetectorElement::updateCache() const m_isStereo = false; } } - } @@ -415,6 +413,7 @@ SiDetectorElement::recoToHitTransform() const // Determine the reconstruction local (LocalPosition) to global transform. + std::lock_guard<std::recursive_mutex> lock(m_mutex); if (m_firstTime) updateCache(); // global = transform * recoLocal @@ -550,6 +549,7 @@ SiDetectorElement::phiAxis() const Amg::Vector2D SiDetectorElement::hitLocalToLocal(double xEta, double xPhi) const // Will change order to phi,eta { + std::lock_guard<std::recursive_mutex> lock(m_mutex); if (!m_cacheValid) updateCache(); if (!m_etaDirection) xEta = -xEta; if (!m_phiDirection) xPhi = -xPhi; @@ -560,6 +560,7 @@ HepGeom::Point3D<double> SiDetectorElement::hitLocalToLocal3D(const HepGeom::Point3D<double> & hitPosition) const { // Equiv to transform().inverse * transformHit() * hitPosition + std::lock_guard<std::recursive_mutex> lock(m_mutex); if (!m_cacheValid) updateCache(); double xDepth = hitPosition[m_hitDepth]; double xPhi = hitPosition[m_hitPhi]; @@ -644,6 +645,7 @@ double SiDetectorElement::sinTilt() const double SiDetectorElement::sinTilt(const Amg::Vector2D &localPos) const { + std::lock_guard<std::recursive_mutex> lock(m_mutex); if (!m_cacheValid) updateCache(); // tilt angle is not defined for the endcap @@ -708,6 +710,7 @@ double SiDetectorElement::sinStereo() const double SiDetectorElement::sinStereo(const Amg::Vector2D &localPos) const { + std::lock_guard<std::recursive_mutex> lock(m_mutex); if (!m_cacheValid) updateCache(); HepGeom::Point3D<double> point=globalPositionCLHEP(localPos); @@ -752,6 +755,7 @@ double SiDetectorElement::sinStereo(const HepGeom::Point3D<double> &globalPos) c bool SiDetectorElement::isStereo() const { + std::lock_guard<std::recursive_mutex> lock(m_mutex); if (m_firstTime) updateCache(); return m_isStereo; } @@ -895,6 +899,7 @@ void SiDetectorElement::getExtent(double &rMin, double &rMax, void SiDetectorElement::getEtaPhiRegion(double deltaZ, double &etaMin, double &etaMax, double &phiMin, double &phiMax, double &rz) const { + std::lock_guard<std::recursive_mutex> lock(m_mutex); if (!m_cacheValid) updateCache(); HepGeom::Point3D<double> corners[4]; @@ -980,6 +985,7 @@ void SiDetectorElement::getEtaPhiPoint(const HepGeom::Point3D<double> & point, d void SiDetectorElement::getCorners(HepGeom::Point3D<double> *corners) const { + std::lock_guard<std::recursive_mutex> lock(m_mutex); if (!m_cacheValid) updateCache(); // This makes the assumption that the forward SCT detectors are orientated such that