Back to home page

sPhenix code displayed by LXR

 
 

    


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

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