Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:09:37

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