diff --git a/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoVFullPhysVol.h b/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoVFullPhysVol.h index 21a399c37ec34a999a37a85155a554e188f51c15..795ac30700019a3038eac1e42bf4ea3ed0c4af3f 100644 --- a/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoVFullPhysVol.h +++ b/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoVFullPhysVol.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #ifndef GEOMODELKERNEL_GEOVFULLPHYSVOL_H @@ -19,8 +19,22 @@ class GeoVFullPhysVol : public GeoVPhysVol GeoVFullPhysVol(const GeoVFullPhysVol &right) = delete; GeoVFullPhysVol & operator=(const GeoVFullPhysVol &right) = delete; - /// Returns the absolute transform of the volume. + /// Returns the (default) absolute transform of the volume. + /// 1. When store=nullptr. This is considered a "serial case" when + /// the cached (default) absolute transform is kept as a data member of the + /// GeoVFullPhysVol class. If the local cache is empty, then it gets computed and stored. + /// + /// 2. When store!=nullptr. This is considered a "multithreaded case" when + /// the cached (default) absolute trnasforms of Full Physical Volumes are kept in + /// an external object pointed by store. If the cache for given full physical + /// volume is missing, it gets computed and saved in the store. const GeoTrf::Transform3D& getAbsoluteTransform(GeoVAlignmentStore* store=nullptr) const; + const GeoTrf::Transform3D& getDefAbsoluteTransform(GeoVAlignmentStore* store=nullptr) const; + + /// Returns the previously computed and cached (default) absolute transform of the volume. + /// If the cache has not yet been computed, and exception gets thrown + const GeoTrf::Transform3D& getCachedAbsoluteTransform(const GeoVAlignmentStore* store=nullptr) const; + const GeoTrf::Transform3D& getCachedDefAbsoluteTransform(const GeoVAlignmentStore* store=nullptr) const; /// Clears the position information. This can be used if /// the cache is determined to be invalid. The usual client @@ -28,9 +42,6 @@ class GeoVFullPhysVol : public GeoVPhysVol /// There is little need for casual users to call this. void clearPositionInfo() const; - /// Returns the default absolute transform of the volume. - const GeoTrf::Transform3D& getDefAbsoluteTransform(GeoVAlignmentStore* store=nullptr) const; - /// Returns the absolute name of this node. const std::string& getAbsoluteName(); diff --git a/GeoModelCore/GeoModelKernel/src/GeoVFullPhysVol.cxx b/GeoModelCore/GeoModelKernel/src/GeoVFullPhysVol.cxx index 1ba9337dc088a7ec4c693a696d7915a825aaba8b..6555d46344900f5b0f492c587e0746342648ff53 100755 --- a/GeoModelCore/GeoModelKernel/src/GeoVFullPhysVol.cxx +++ b/GeoModelCore/GeoModelKernel/src/GeoVFullPhysVol.cxx @@ -75,6 +75,19 @@ const GeoTrf::Transform3D & GeoVFullPhysVol::getAbsoluteTransform(GeoVAlignmentS } } +const GeoTrf::Transform3D& GeoVFullPhysVol::getCachedAbsoluteTransform(const GeoVAlignmentStore* store) const +{ + if(store==nullptr) { + if(m_absPosInfo->getAbsTransform()) return *m_absPosInfo->getAbsTransform(); + } + else { + const GeoTrf::Transform3D* storedPos = store->getAbsPosition(this); + if(storedPos) return *storedPos; + } + throw std::runtime_error("Failed to find the cached absolute transform for " + getLogVol()->getName()); +} + + void GeoVFullPhysVol::clearPositionInfo() const { delete m_absPosInfo; @@ -137,6 +150,18 @@ const GeoTrf::Transform3D& GeoVFullPhysVol::getDefAbsoluteTransform(GeoVAlignmen } } +const GeoTrf::Transform3D& GeoVFullPhysVol::getCachedDefAbsoluteTransform(const GeoVAlignmentStore* store) const +{ + if(store==nullptr) { + if(m_absPosInfo->getDefAbsTransform()) return *m_absPosInfo->getDefAbsTransform(); + } + else { + const GeoTrf::Transform3D* storedPos = store->getDefAbsPosition(this); + if(storedPos) return *storedPos; + } + throw std::runtime_error("Failed to find the cached default absolute transform for " + getLogVol()->getName()); +} + const std::string & GeoVFullPhysVol::getAbsoluteName () { //------------------------------------------------------------------------------------------------//