ATLAS Offline Software
TransformCache.icc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 #ifndef ActsGeoUtils_TransformCache_ICC
5 #define ActsGeoUtils_TransformCache_ICC
6 
7 #include <CxxUtils/inline_hints.h>
8 
9 namespace ActsTrk {
10  ATH_FLATTEN
11  inline const Amg::Transform3D& TransformCache::getTransform(const ActsTrk::DetectorAlignStore* alignStore) const {
12  /// Valid alignment store is given -> Take the transformation from the cache there
13  if (alignStore) {
14  const Amg::Transform3D* cache = alignStore->trackingAlignment->getTransform(m_clientNo);
15  if (cache) return *cache;
16  const Amg::Transform3D& trf{alignStore->trackingAlignment->setTransform(m_clientNo, fetchTransform(alignStore))};
17  /// If an external alignment store is presented release the nominal transformation
18  releaseNominalCache();
19  return trf;
20  }
21  /// Fall back solution to go onto the nominal cache
22  if (!m_nomCache) {
23  std::unique_lock guard{m_mutex};
24  m_nomCache.set(std::make_unique<Amg::Transform3D>(fetchTransform(alignStore)));
25  return (*m_nomCache);
26  }
27  std::shared_lock guard{m_mutex};
28  return (*m_nomCache);
29  }
30  inline IdentifierHash TransformCache::hash() const { return m_hash; }
31 #ifndef SIMULATIONBASE
32  ATH_FLATTEN
33  inline const Amg::Transform3D& TransformCache::transform(const Acts::GeometryContext& anygctx) const {
34  const ActsGeometryContext* gctx = anygctx.get<const ActsGeometryContext*>();
35  // unpack the alignment store from the context
36  return getTransform(gctx->getStore(m_type).get());
37 
38  }
39 #endif
40 
41 
42 template<typename CachingDetectorEle>
43  TransformCacheDetEle<CachingDetectorEle>::TransformCacheDetEle(const IdentifierHash& hash,
44  const CachingDetectorEle* parentEle):
45  TransformCache(hash, parentEle->detectorType()),
46  m_parent{parentEle} {}
47 template<typename CachingDetectorEle>
48  const IDetectorElement* TransformCacheDetEle<CachingDetectorEle>::parent() const {
49  return m_parent;
50  }
51 }
52 #endif