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