Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-18 08:12:14

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/DiscLayer.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/Layer.hpp"
0016 #include "Acts/Geometry/Volume.hpp"
0017 #include "Acts/Surfaces/RadialBounds.hpp"
0018 #include "Acts/Surfaces/Surface.hpp"
0019 #include "Acts/Surfaces/SurfaceArray.hpp"
0020 
0021 #include <vector>
0022 
0023 namespace Acts {
0024 
0025 using VectorHelpers::perp;
0026 using VectorHelpers::phi;
0027 
0028 std::shared_ptr<DiscLayer> DiscLayer::create(
0029     const Transform3& transform,
0030     const std::shared_ptr<const DiscBounds>& dbounds,
0031     std::unique_ptr<SurfaceArray> surfaceArray, double thickness,
0032     std::unique_ptr<ApproachDescriptor> ad, LayerType laytyp) {
0033   return std::shared_ptr<DiscLayer>(
0034       new DiscLayer(transform, dbounds, std::move(surfaceArray), thickness,
0035                     std::move(ad), laytyp));
0036 }
0037 
0038 DiscLayer::DiscLayer(const Transform3& transform,
0039                      const std::shared_ptr<const DiscBounds>& dbounds,
0040                      std::unique_ptr<SurfaceArray> surfaceArray,
0041                      double thickness, std::unique_ptr<ApproachDescriptor> ades,
0042                      LayerType laytyp)
0043     : DiscSurface(transform, dbounds),
0044       Layer(std::move(surfaceArray), thickness, std::move(ades), laytyp) {
0045   // In case we have Radial bounds
0046   const RadialBounds* rBounds =
0047       dynamic_cast<const RadialBounds*>(DiscSurface::m_bounds.get());
0048   if (rBounds != nullptr) {
0049     // The volume bounds
0050     auto rVolumeBounds =
0051         std::make_shared<CylinderVolumeBounds>(*rBounds, thickness);
0052     // @todo rotate around x for the avePhi if you have a sector
0053     m_representingVolume =
0054         std::make_unique<Volume>(*m_transform, rVolumeBounds);
0055   }
0056   // associate the layer to the layer surface itself
0057   DiscSurface::associateLayer(*this);
0058   // build an approach descriptor if none provided
0059   if (!m_approachDescriptor && m_surfaceArray) {
0060     buildApproachDescriptor();
0061   }
0062   // register the layer to the approach descriptor
0063   if (m_approachDescriptor) {
0064     approachDescriptor()->registerLayer(*this);
0065   }
0066 }
0067 
0068 const DiscSurface& DiscLayer::surfaceRepresentation() const {
0069   return (*this);
0070 }
0071 
0072 DiscSurface& DiscLayer::surfaceRepresentation() {
0073   return (*this);
0074 }
0075 
0076 void DiscLayer::buildApproachDescriptor() {
0077   // delete it
0078   m_approachDescriptor.reset(nullptr);
0079   // take the boundary surfaces of the representving volume if they exist
0080   if (m_representingVolume != nullptr) {
0081     // get the boundary surfaces
0082     std::vector<OrientedSurface> bSurfaces =
0083         m_representingVolume->volumeBounds().orientedSurfaces(
0084             m_representingVolume->transform());
0085     // fill in the surfaces into the vector
0086     std::vector<std::shared_ptr<const Surface>> aSurfaces;
0087     aSurfaces.push_back(bSurfaces.at(negativeFaceXY).surface);
0088     aSurfaces.push_back(bSurfaces.at(positiveFaceXY).surface);
0089     aSurfaces.push_back(bSurfaces.at(tubeInnerCover).surface);
0090     aSurfaces.push_back(bSurfaces.at(tubeOuterCover).surface);
0091     // create an ApproachDescriptor with Boundary surfaces
0092     m_approachDescriptor =
0093         std::make_unique<const GenericApproachDescriptor>(std::move(aSurfaces));
0094   }
0095 
0096   // @todo check if we can give the layer at curface creation
0097   for (auto& sfPtr : (m_approachDescriptor->containedSurfaces())) {
0098     if (sfPtr != nullptr) {
0099       auto& mutableSf = *(const_cast<Surface*>(sfPtr));
0100       mutableSf.associateLayer(*this);
0101     }
0102   }
0103 }
0104 
0105 }  // namespace Acts