Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-12 07:52:16

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   /// Retrieve the contextual transform for a given surface
0031   ///
0032   /// @param surface the  surface for which the contextual transform is requested
0033   /// @return a pointer to the transform if found, otherwise nullptr
0034   virtual const Acts::Transform3* contextualTransform(
0035       const Acts::Surface& surface) const = 0;
0036 };
0037 
0038 /// A simple struct holding a store raw pointer, ownership should not be in the
0039 /// Context as the store may expand lifetime beyond a context scope
0040 struct AlignmentContext {
0041   /// The store pointer
0042   const IAlignmentStore* store{nullptr};
0043 };
0044 
0045 /// One possible implementation with a simple unordered map that relates a
0046 /// surface via its geometry identifier to a transform within the store
0047 ///
0048 /// To use this store, the GeometryContext of the corresponding geometry must
0049 /// be decorated with such a store and equipped to use it.
0050 class GeoIdAlignmentStore : public IAlignmentStore {
0051  public:
0052   /// Constructor from an unordered map of geometry ids and transforms
0053   /// @param transformMap the map of geometry ids and transforms
0054   explicit GeoIdAlignmentStore(
0055       std::unordered_map<Acts::GeometryIdentifier, Acts::Transform3>
0056           transformMap)
0057       : m_transformMap(std::move(transformMap)) {}
0058 
0059   /// @copydoc IAlignmentStore::contextualTransform
0060   const Acts::Transform3* contextualTransform(
0061       const Acts::Surface& surface) const override {
0062     auto it = m_transformMap.find(surface.geometryId());
0063     if (it != m_transformMap.end()) {
0064       return &(it->second);
0065     }
0066     return nullptr;
0067   }
0068 
0069  private:
0070   /// The geometry id map
0071   std::unordered_map<Acts::GeometryIdentifier, Acts::Transform3> m_transformMap;
0072 };
0073 
0074 }  // namespace ActsExamples