Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:23:10

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 #include "Acts/Geometry/PlaneLayer.hpp"
0010 
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Geometry/GenericApproachDescriptor.hpp"
0013 #include "Acts/Geometry/GeometryContext.hpp"
0014 #include "Acts/Surfaces/Surface.hpp"
0015 #include "Acts/Surfaces/SurfaceArray.hpp"
0016 
0017 #include <vector>
0018 
0019 namespace Acts {
0020 
0021 std::shared_ptr<PlaneLayer> PlaneLayer::create(
0022     const Transform3& transform, std::shared_ptr<const PlanarBounds> pbounds,
0023     std::unique_ptr<SurfaceArray> surfaceArray, double thickness,
0024     std::unique_ptr<ApproachDescriptor> ad, LayerType laytyp) {
0025   return std::shared_ptr<PlaneLayer>(
0026       new PlaneLayer(transform, pbounds, std::move(surfaceArray), thickness,
0027                      std::move(ad), laytyp));
0028 }
0029 
0030 PlaneLayer::PlaneLayer(const Transform3& transform,
0031                        std::shared_ptr<const PlanarBounds>& pbounds,
0032                        std::unique_ptr<SurfaceArray> surfaceArray,
0033                        double thickness,
0034                        std::unique_ptr<ApproachDescriptor> ades,
0035                        LayerType laytyp)
0036     : PlaneSurface(transform, pbounds),
0037       Layer(std::move(surfaceArray), thickness, std::move(ades), laytyp) {
0038   // @todo create representing volume
0039   // register the layer to the surface
0040   PlaneSurface::associateLayer(*this);
0041   // deal with the approach descriptor
0042   if (!m_approachDescriptor && m_surfaceArray) {
0043     buildApproachDescriptor();
0044   }
0045   // register the layer to the approach descriptor
0046   if (m_approachDescriptor) {
0047     approachDescriptor()->registerLayer(*this);
0048   }
0049 }
0050 
0051 const PlaneSurface& PlaneLayer::surfaceRepresentation() const {
0052   return (*this);
0053 }
0054 
0055 PlaneSurface& PlaneLayer::surfaceRepresentation() {
0056   return (*this);
0057 }
0058 
0059 void PlaneLayer::buildApproachDescriptor() {
0060   // delete it
0061   m_approachDescriptor.reset(nullptr);
0062   // delete the surfaces
0063   std::vector<std::shared_ptr<const Surface>> aSurfaces;
0064   // get the appropriate transform, the center and the normal vector
0065 
0066   //@todo fix with representing volume
0067   const Transform3& lTransform = transform(GeometryContext());
0068   RotationMatrix3 lRotation = lTransform.rotation();
0069   const Vector3& lCenter = center(GeometryContext());
0070   const Vector3& lVector = normal(GeometryContext(), lCenter);
0071   // create new surfaces
0072   const Transform3 apnTransform = Transform3(
0073       Translation3(lCenter - 0.5 * Layer::m_layerThickness * lVector) *
0074       lRotation);
0075   const Transform3 appTransform = Transform3(
0076       Translation3(lCenter + 0.5 * Layer::m_layerThickness * lVector) *
0077       lRotation);
0078   // create the new surfaces
0079   aSurfaces.push_back(
0080       Surface::makeShared<PlaneSurface>(apnTransform, PlaneSurface::m_bounds));
0081   aSurfaces.push_back(
0082       Surface::makeShared<PlaneSurface>(appTransform, PlaneSurface::m_bounds));
0083   // set the layer and make TrackingGeometry
0084   for (auto& sfPtr : aSurfaces) {
0085     auto mutableSf = const_cast<Surface*>(sfPtr.get());
0086     mutableSf->associateLayer(*this);
0087   }
0088   // @todo check if we can provide the layer at surface creation
0089   m_approachDescriptor =
0090       std::make_unique<const GenericApproachDescriptor>(std::move(aSurfaces));
0091 }
0092 
0093 }  // namespace Acts