|
|
|||
File indexing completed on 2026-07-16 08:08:07
0001 // This file is part of the ACTS project. 0002 // 0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project 0004 // 0005 // This Source Code Form is subject to the terms of the Mozilla Public 0006 // License, v. 2.0. If a copy of the MPL was not distributed with this 0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/. 0008 0009 #pragma once 0010 0011 #include "Acts/Definitions/Algebra.hpp" 0012 #include "Acts/Geometry/GeometryIdentifier.hpp" 0013 #include "Acts/Surfaces/Surface.hpp" 0014 0015 #include <unordered_map> 0016 0017 namespace ActsExamples { 0018 0019 /// @brief Base class for alignment stores which can retrieve contextual 0020 /// transforms from specific surfaces. 0021 /// 0022 /// Possible implementations may take the geometry identifier, access the 0023 /// detector element or use other means to identify which transform is being 0024 /// queried. 0025 class IAlignmentStore { 0026 public: 0027 /// @brief Virtual destructor 0028 virtual ~IAlignmentStore() = default; 0029 0030 /// Clone the alignment store 0031 /// 0032 /// @return a unique pointer to the cloned store 0033 virtual std::shared_ptr<IAlignmentStore> clone() const = 0; 0034 0035 /// Retrieve the contextual transform for a given surface 0036 /// 0037 /// @param surface the surface for which the contextual transform is requested 0038 /// @return a pointer to the transform if found, otherwise nullptr 0039 virtual const Acts::Transform3* contextualTransform( 0040 const Acts::Surface& surface) const = 0; 0041 0042 /// Visitor pattern to eventually generate an misalignment for demonstration 0043 /// purposes. 0044 /// @param visitor the visitor to be called with the store 0045 virtual void visitStore( 0046 const std::function<void(Acts::Transform3*)>& visitor) = 0; 0047 }; 0048 0049 /// A simple struct holding a store raw pointer, ownership should not be in the 0050 /// Context as the store may expand lifetime beyond a context scope 0051 struct AlignmentContext { 0052 /// The store pointer 0053 const IAlignmentStore* store{nullptr}; 0054 }; 0055 0056 /// One possible implementation with a simple unordered map that relates a 0057 /// surface via its geometry identifier to a transform within the store 0058 /// 0059 /// To use this store, the GeometryContext of the corresponding geometry must 0060 /// be decorated with such a store and equipped to use it. 0061 class GeoIdAlignmentStore : public IAlignmentStore { 0062 public: 0063 /// Constructor from an unordered map of geometry ids and transforms 0064 /// @param transformMap the map of geometry ids and transforms 0065 explicit GeoIdAlignmentStore( 0066 std::unordered_map<Acts::GeometryIdentifier, Acts::Transform3> 0067 transformMap) 0068 : m_transformMap(std::move(transformMap)) {} 0069 0070 /// @copydoc IAlignmentStore::clone 0071 std::shared_ptr<IAlignmentStore> clone() const override { 0072 return std::make_shared<GeoIdAlignmentStore>(m_transformMap); 0073 } 0074 0075 /// @copydoc ITransformStore::contextualTransform 0076 const Acts::Transform3* contextualTransform( 0077 const Acts::Surface& surface) const override { 0078 auto it = m_transformMap.find(surface.geometryId()); 0079 if (it != m_transformMap.end()) { 0080 return &(it->second); 0081 } 0082 return nullptr; 0083 } 0084 0085 /// @copydoc ITransformStore::visitStore 0086 void visitStore( 0087 const std::function<void(Acts::Transform3*)>& visitor) override { 0088 for (auto& [id, trf] : m_transformMap) { 0089 visitor(&trf); 0090 } 0091 } 0092 0093 private: 0094 /// The geometry id map 0095 std::unordered_map<Acts::GeometryIdentifier, Acts::Transform3> m_transformMap; 0096 }; 0097 0098 } // namespace ActsExamples
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|