Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2016-2020 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/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 <algorithm>
0018 #include <utility>
0019 #include <vector>
0020 
0021 Acts::StrawSurface::StrawSurface(const Transform3& transform, double radius,
0022                                  double halez)
0023     : GeometryObject(), LineSurface(transform, radius, halez) {}
0024 
0025 Acts::StrawSurface::StrawSurface(const Transform3& transform,
0026                                  std::shared_ptr<const LineBounds> lbounds)
0027     : GeometryObject(), LineSurface(transform, std::move(lbounds)) {}
0028 
0029 Acts::StrawSurface::StrawSurface(
0030     const std::shared_ptr<const LineBounds>& lbounds,
0031     const DetectorElementBase& detelement)
0032     : GeometryObject(), LineSurface(lbounds, detelement) {}
0033 
0034 Acts::StrawSurface::StrawSurface(const Acts::StrawSurface& other)
0035     : GeometryObject(), LineSurface(other) {}
0036 
0037 Acts::StrawSurface::StrawSurface(const GeometryContext& gctx,
0038                                  const StrawSurface& other,
0039                                  const Transform3& shift)
0040     : GeometryObject(), LineSurface(gctx, other, shift) {}
0041 
0042 Acts::StrawSurface& Acts::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 Acts::Polyhedron Acts::StrawSurface::polyhedronRepresentation(
0051     const GeometryContext& gctx, std::size_t lseg) 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 (lseg > 1) {
0060     double r = m_bounds->get(LineBounds::eR);
0061     auto phiSegs = detail::VerticesHelper::phiSegments();
0062     // Write the two bows/circles on either side
0063     std::vector<int> sides = {-1, 1};
0064     for (auto& side : sides) {
0065       for (std::size_t iseg = 0; iseg < phiSegs.size() - 1; ++iseg) {
0066         int addon = (iseg == phiSegs.size() - 2) ? 1 : 0;
0067         /// Helper method to create the segment
0068         detail::VerticesHelper::createSegment(
0069             vertices, {r, r}, phiSegs[iseg], phiSegs[iseg + 1], lseg, addon,
0070             Vector3(0., 0., side * m_bounds->get(LineBounds::eHalfLengthZ)),
0071             ctransform);
0072       }
0073     }
0074     auto facesMesh = detail::FacesHelper::cylindricalFaceMesh(vertices);
0075     faces = facesMesh.first;
0076     triangularMesh = facesMesh.second;
0077   }
0078 
0079   std::size_t bvertices = vertices.size();
0080   Vector3 left(0, 0, -m_bounds->get(LineBounds::eHalfLengthZ));
0081   Vector3 right(0, 0, m_bounds->get(LineBounds::eHalfLengthZ));
0082   // The central wire/straw
0083   vertices.push_back(ctransform * left);
0084   vertices.push_back(ctransform * right);
0085   faces.push_back({bvertices, bvertices + 1});
0086   vertices.push_back(ctransform * Vector3(0., 0., 0.));
0087   triangularMesh.push_back({bvertices, bvertices + 2, bvertices + 1});
0088 
0089   return Polyhedron(vertices, faces, triangularMesh, false);
0090 }