ECCE @ 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 #include <iomanip>
11 #include <iostream>
12 #include <utility>
16 
18 
19 Acts::StrawSurface::StrawSurface(std::shared_ptr<const Transform3D> htrans,
20  double radius, double halez)
21  : GeometryObject(), LineSurface(std::move(htrans), radius, halez) {}
22 
23 Acts::StrawSurface::StrawSurface(std::shared_ptr<const Transform3D> htrans,
24  std::shared_ptr<const LineBounds> lbounds)
25  : GeometryObject(), LineSurface(std::move(htrans), std::move(lbounds)) {}
26 
28  const std::shared_ptr<const LineBounds>& lbounds,
29  const DetectorElementBase& detelement)
30  : GeometryObject(), LineSurface(lbounds, detelement) {}
31 
33  : GeometryObject(), LineSurface(other) {}
34 
36  const StrawSurface& other,
37  const Transform3D& transf)
38  : GeometryObject(), LineSurface(gctx, other, transf) {}
39 
41  if (this != &other) {
43  m_bounds = other.m_bounds;
44  }
45  return *this;
46 }
47 
49  const GeometryContext& gctx, size_t lseg) const {
50  // Prepare vertices and faces
51  std::vector<Vector3D> vertices;
52  std::vector<Polyhedron::FaceType> faces;
53  std::vector<Polyhedron::FaceType> triangularMesh;
54 
55  const Transform3D& ctransform = transform(gctx);
56  // Draw the bounds if more than one segment are chosen
57  if (lseg > 1) {
58  double r = m_bounds->get(LineBounds::eR);
59  auto phiSegs = detail::VerticesHelper::phiSegments();
60  // Write the two bows/circles on either side
61  std::vector<int> sides = {-1, 1};
62  for (auto& side : sides) {
63  for (size_t iseg = 0; iseg < phiSegs.size() - 1; ++iseg) {
64  int addon = (iseg == phiSegs.size() - 2) ? 1 : 0;
67  vertices, {r, r}, phiSegs[iseg], phiSegs[iseg + 1], lseg, addon,
68  Vector3D(0., 0., side * m_bounds->get(LineBounds::eHalfLengthZ)),
69  ctransform);
70  }
71  }
72  auto facesMesh = detail::FacesHelper::cylindricalFaceMesh(vertices);
73  faces = facesMesh.first;
74  triangularMesh = facesMesh.second;
75  }
76 
77  size_t bvertices = vertices.size();
78  Vector3D left(0, 0, -m_bounds->get(LineBounds::eHalfLengthZ));
79  Vector3D right(0, 0, m_bounds->get(LineBounds::eHalfLengthZ));
80  // The central wire/straw
81  vertices.push_back(ctransform * left);
82  vertices.push_back(ctransform * right);
83  faces.push_back({bvertices, bvertices + 1});
84  vertices.push_back(ctransform * Vector3D(0., 0., 0.));
85  triangularMesh.push_back({bvertices, bvertices + 2, bvertices + 1});
86 
87  return Polyhedron(vertices, faces, triangularMesh);
88 }