EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
StrawSurface.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file StrawSurface.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2016-2020 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
10 
15 
16 #include <iomanip>
17 #include <iostream>
18 #include <utility>
19 
21  double halez)
22  : GeometryObject(), LineSurface(transform, radius, halez) {}
23 
25  std::shared_ptr<const LineBounds> lbounds)
26  : GeometryObject(), LineSurface(transform, std::move(lbounds)) {}
27 
29  const std::shared_ptr<const LineBounds>& lbounds,
30  const DetectorElementBase& detelement)
31  : GeometryObject(), LineSurface(lbounds, detelement) {}
32 
34  : GeometryObject(), LineSurface(other) {}
35 
37  const StrawSurface& other,
38  const Transform3D& shift)
39  : GeometryObject(), LineSurface(gctx, other, shift) {}
40 
42  if (this != &other) {
44  m_bounds = other.m_bounds;
45  }
46  return *this;
47 }
48 
50  const GeometryContext& gctx, size_t lseg) const {
51  // Prepare vertices and faces
52  std::vector<Vector3D> vertices;
53  std::vector<Polyhedron::FaceType> faces;
54  std::vector<Polyhedron::FaceType> triangularMesh;
55 
56  const Transform3D& ctransform = transform(gctx);
57  // Draw the bounds if more than one segment are chosen
58  if (lseg > 1) {
59  double r = m_bounds->get(LineBounds::eR);
60  auto phiSegs = detail::VerticesHelper::phiSegments();
61  // Write the two bows/circles on either side
62  std::vector<int> sides = {-1, 1};
63  for (auto& side : sides) {
64  for (size_t iseg = 0; iseg < phiSegs.size() - 1; ++iseg) {
65  int addon = (iseg == phiSegs.size() - 2) ? 1 : 0;
68  vertices, {r, r}, phiSegs[iseg], phiSegs[iseg + 1], lseg, addon,
69  Vector3D(0., 0., side * m_bounds->get(LineBounds::eHalfLengthZ)),
70  ctransform);
71  }
72  }
73  auto facesMesh = detail::FacesHelper::cylindricalFaceMesh(vertices);
74  faces = facesMesh.first;
75  triangularMesh = facesMesh.second;
76  }
77 
78  size_t bvertices = vertices.size();
79  Vector3D left(0, 0, -m_bounds->get(LineBounds::eHalfLengthZ));
80  Vector3D right(0, 0, m_bounds->get(LineBounds::eHalfLengthZ));
81  // The central wire/straw
82  vertices.push_back(ctransform * left);
83  vertices.push_back(ctransform * right);
84  faces.push_back({bvertices, bvertices + 1});
85  vertices.push_back(ctransform * Vector3D(0., 0., 0.));
86  triangularMesh.push_back({bvertices, bvertices + 2, bvertices + 1});
87 
88  return Polyhedron(vertices, faces, triangularMesh, false);
89 }