Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:11:30

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/Surfaces/StrawSurface.hpp"
0010 
0011 #include "Acts/Geometry/GeometryObject.hpp"
0012 #include "Acts/Geometry/Polyhedron.hpp"
0013 #include "Acts/Surfaces/LineBounds.hpp"
0014 #include "Acts/Surfaces/detail/FacesHelper.hpp"
0015 #include "Acts/Surfaces/detail/VerticesHelper.hpp"
0016 
0017 #include <numbers>
0018 #include <utility>
0019 #include <vector>
0020 
0021 namespace Acts {
0022 
0023 StrawSurface::StrawSurface(const Transform3& transform, double radius,
0024                            double halez)
0025     : GeometryObject(), LineSurface(transform, radius, halez) {}
0026 
0027 StrawSurface::StrawSurface(const Transform3& transform,
0028                            std::shared_ptr<const LineBounds> lbounds)
0029     : GeometryObject(), LineSurface(transform, std::move(lbounds)) {}
0030 
0031 StrawSurface::StrawSurface(const std::shared_ptr<const LineBounds>& lbounds,
0032                            const DetectorElementBase& detelement)
0033     : GeometryObject(), LineSurface(lbounds, detelement) {}
0034 
0035 StrawSurface::StrawSurface(const StrawSurface& other)
0036     : GeometryObject(), LineSurface(other) {}
0037 
0038 StrawSurface::StrawSurface(const GeometryContext& gctx,
0039                            const StrawSurface& other, const Transform3& shift)
0040     : GeometryObject(), LineSurface(gctx, other, shift) {}
0041 
0042 StrawSurface& StrawSurface::operator=(const StrawSurface& other) {
0043   if (this != &other) {
0044     LineSurface::operator=(other);
0045     m_bounds = other.m_bounds;
0046   }
0047   return *this;
0048 }
0049 
0050 Polyhedron StrawSurface::polyhedronRepresentation(
0051     const GeometryContext& gctx, unsigned int quarterSegments) const {
0052   // Prepare vertices and faces
0053   std::vector<Vector3> vertices;
0054   std::vector<Polyhedron::FaceType> faces;
0055   std::vector<Polyhedron::FaceType> triangularMesh;
0056 
0057   const Transform3& ctransform = transform(gctx);
0058   // Draw the bounds if more than one segment are chosen
0059   if (quarterSegments > 0u) {
0060     double r = m_bounds->get(LineBounds::eR);
0061     // Write the two bows/circles on either side
0062     std::vector<int> sides = {-1, 1};
0063     for (auto& side : sides) {
0064       // Helper method to create the segment
0065       auto svertices = detail::VerticesHelper::segmentVertices(
0066           {r, r}, -std::numbers::pi, std::numbers::pi, {}, quarterSegments,
0067           Vector3(0., 0., side * m_bounds->get(LineBounds::eHalfLengthZ)),
0068           ctransform);
0069       vertices.insert(vertices.end(), svertices.begin(), svertices.end());
0070     }
0071     auto facesMesh = detail::FacesHelper::cylindricalFaceMesh(vertices);
0072     faces = facesMesh.first;
0073     triangularMesh = facesMesh.second;
0074   }
0075 
0076   std::size_t bvertices = vertices.size();
0077   Vector3 left(0, 0, -m_bounds->get(LineBounds::eHalfLengthZ));
0078   Vector3 right(0, 0, m_bounds->get(LineBounds::eHalfLengthZ));
0079   // The central wire/straw
0080   vertices.push_back(ctransform * left);
0081   vertices.push_back(ctransform * right);
0082   faces.push_back({bvertices, bvertices + 1});
0083   vertices.push_back(ctransform * Vector3(0., 0., 0.));
0084   triangularMesh.push_back({bvertices, bvertices + 2, bvertices + 1});
0085 
0086   return Polyhedron(vertices, faces, triangularMesh, false);
0087 }
0088 
0089 }  // namespace Acts