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/GeometryContext.hpp"
0013 #include "ActsExamples/DetectorCommons/AlignmentContext.hpp"
0014 
0015 #include <any>
0016 
0017 namespace ActsExamples {
0018 
0019 /// A detector element that is aligned with the ACTS framework
0020 /// This class is a wrapper around the DetectorElement class
0021 /// for different detectors and can be used with the same alignment
0022 /// showcase infrastructure.
0023 template <typename DetectorElement>
0024 class Aligned : public DetectorElement {
0025  public:
0026   /// Using the constructor from the base class
0027   using DetectorElement::DetectorElement;
0028   /// An alignment aware transform call
0029   /// @param gctx the geometry context which is - if possible - unpacked to an AlignementContext
0030   /// @return The alignment-corrected transform if available, otherwise the nominal transform.
0031   const Acts::Transform3& transform(
0032       const Acts::GeometryContext& gctx) const final {
0033     if (gctx.hasValue()) {
0034       const auto* alignmentContext = gctx.maybeGet<AlignmentContext>();
0035       if (alignmentContext != nullptr && alignmentContext->store != nullptr) {
0036         const auto* transform =
0037             alignmentContext->store->contextualTransform(this->surface());
0038         // The store may only have a subset of surfaces registered
0039         if (transform != nullptr) {
0040           return *transform;
0041         }
0042       }
0043     }
0044     // If no alignment context is available, return the nominal transform
0045     return DetectorElement::nominalTransform();
0046   }
0047 };
0048 
0049 }  // namespace ActsExamples