Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-13 07:57:43

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/CylinderLayer.hpp"
0010 
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Geometry/BoundarySurfaceFace.hpp"
0013 #include "Acts/Geometry/CylinderVolumeBounds.hpp"
0014 #include "Acts/Geometry/GenericApproachDescriptor.hpp"
0015 #include "Acts/Geometry/Volume.hpp"
0016 #include "Acts/Geometry/VolumeBounds.hpp"
0017 #include "Acts/Surfaces/Surface.hpp"
0018 #include "Acts/Surfaces/SurfaceArray.hpp"
0019 
0020 #include <cstddef>
0021 #include <vector>
0022 
0023 namespace Acts {
0024 
0025 using VectorHelpers::phi;
0026 
0027 std::shared_ptr<CylinderLayer> CylinderLayer::create(
0028     const Transform3& transform,
0029     const std::shared_ptr<const CylinderBounds>& cbounds,
0030     std::unique_ptr<SurfaceArray> surfaceArray, double thickness,
0031     std::unique_ptr<ApproachDescriptor> ad, LayerType laytyp) {
0032   return std::shared_ptr<CylinderLayer>(
0033       new CylinderLayer(transform, cbounds, std::move(surfaceArray), thickness,
0034                         std::move(ad), laytyp));
0035 }
0036 
0037 CylinderLayer::CylinderLayer(
0038     const Transform3& transform,
0039     const std::shared_ptr<const CylinderBounds>& cBounds,
0040     std::unique_ptr<SurfaceArray> surfaceArray, double thickness,
0041     std::unique_ptr<ApproachDescriptor> ades, LayerType laytyp)
0042     : CylinderSurface(transform, cBounds),
0043       Layer(std::move(surfaceArray), thickness, std::move(ades), laytyp) {
0044   // create the representing volume
0045   auto cVolumeBounds = std::make_shared<CylinderVolumeBounds>(
0046       *CylinderSurface::m_bounds, thickness);
0047   // @todo rotate around x for the avePhi if you have a sector
0048   m_representingVolume = std::make_unique<Volume>(*m_transform, cVolumeBounds);
0049 
0050   // associate the layer to the surface
0051   CylinderSurface::associateLayer(*this);
0052   // an approach descriptor is automatically created if there's a surface array
0053   if (!m_approachDescriptor && m_surfaceArray) {
0054     buildApproachDescriptor();
0055   }
0056   // register the layer to the approach descriptor surfaces
0057   if (m_approachDescriptor) {
0058     approachDescriptor()->registerLayer(*this);
0059   }
0060 }
0061 
0062 const CylinderSurface& CylinderLayer::surfaceRepresentation() const {
0063   return (*this);
0064 }
0065 
0066 CylinderSurface& CylinderLayer::surfaceRepresentation() {
0067   return (*this);
0068 }
0069 
0070 void CylinderLayer::buildApproachDescriptor() {
0071   // delete and reset as you build a new one
0072   m_approachDescriptor.reset(nullptr);
0073 
0074   // take the boundary surfaces of the representving volume if they exist
0075   if (m_representingVolume != nullptr) {
0076     // The representing volume is built by the cylinder layer itself.
0077     /// @todo Think whether the geometry context needs to be wired
0078     const auto gctx = GeometryContext::dangerouslyDefaultConstruct();
0079     // get the boundary surfaces
0080     std::vector<OrientedSurface> bSurfaces =
0081         m_representingVolume->volumeBounds().orientedSurfaces(
0082             m_representingVolume->localToGlobalTransform(gctx));
0083 
0084     // fill in the surfaces into the vector
0085     std::vector<std::shared_ptr<const Surface>> aSurfaces;
0086     if (bSurfaces.size() > static_cast<std::size_t>(tubeInnerCover)) {
0087       aSurfaces.push_back(bSurfaces.at(tubeInnerCover).surface);
0088     }
0089     aSurfaces.push_back(bSurfaces.at(tubeOuterCover).surface);
0090     // create an ApproachDescriptor with Boundary surfaces
0091     m_approachDescriptor =
0092         std::make_unique<const GenericApproachDescriptor>(std::move(aSurfaces));
0093   }
0094 
0095   for (auto& sfPtr : (m_approachDescriptor->containedSurfaces())) {
0096     if (sfPtr != nullptr) {
0097       auto& mutableSf = *(const_cast<Surface*>(sfPtr));
0098       mutableSf.associateLayer(*this);
0099     }
0100   }
0101 }
0102 
0103 }  // namespace Acts