Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DiscTrapezoidBounds.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file DiscTrapezoidBounds.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 
12 
13 #include <cmath>
14 #include <iomanip>
15 #include <iostream>
16 #include <utility>
17 
19  double halfXmaxR, double minR,
20  double maxR, double avgPhi,
21  double stereo) noexcept(false)
22  : m_values({halfXminR, halfXmaxR, minR, maxR, avgPhi, stereo}) {
23  checkConsistency();
24  m_ymax = std::sqrt(get(eMaxR) * get(eMaxR) -
25  get(eHalfLengthXmaxR) * get(eHalfLengthXmaxR));
26 }
27 
30 }
31 
33  const Acts::Vector2& lposition) const {
34  return {lposition[eBoundLoc0] *
35  std::sin(lposition[eBoundLoc1] - get(eAveragePhi)),
36  lposition[eBoundLoc0] *
37  std::cos(lposition[eBoundLoc1] - get(eAveragePhi))};
38 }
39 
41  const Acts::Vector2& lposition) const {
42  ActsMatrix<2, 2> jacobian;
43  jacobian(0, eBoundLoc0) = std::sin(lposition[eBoundLoc1] - get(eAveragePhi));
44  jacobian(1, eBoundLoc0) = std::cos(lposition[eBoundLoc1] - get(eAveragePhi));
45  jacobian(0, eBoundLoc1) =
46  lposition[eBoundLoc0] * std::cos(lposition[eBoundLoc1]);
47  jacobian(1, eBoundLoc1) =
48  lposition[eBoundLoc0] * -std::sin(lposition[eBoundLoc1]);
49  return jacobian;
50 }
51 
53  const Acts::Vector2& lposition, const Acts::BoundaryCheck& bcheck) const {
54  Vector2 vertices[] = {{get(eHalfLengthXminR), get(eMinR)},
55  {get(eHalfLengthXmaxR), m_ymax},
56  {-get(eHalfLengthXmaxR), m_ymax},
57  {-get(eHalfLengthXminR), get(eMinR)}};
58  auto jacobian = jacobianToLocalCartesian(lposition);
59  return bcheck.transformed(jacobian).isInside(toLocalCartesian(lposition),
60  vertices);
61 }
62 
63 std::vector<Acts::Vector2> Acts::DiscTrapezoidBounds::vertices(
64  unsigned int /*lseg*/) const {
65  Vector2 cAxis(std::cos(get(eAveragePhi)), std::sin(get(eAveragePhi)));
66  Vector2 nAxis(cAxis.y(), -cAxis.x());
67  auto ymin = std::sqrt(get(eMinR) * get(eMinR) -
68  get(eHalfLengthXminR) * get(eHalfLengthXminR));
69  auto halfY = (m_ymax - ymin) / 2;
70  return {-halfY * cAxis - get(eHalfLengthXminR) * nAxis,
71  -halfY * cAxis + get(eHalfLengthXminR) * nAxis,
72  halfY * cAxis + get(eHalfLengthXmaxR) * nAxis,
73  halfY * cAxis - get(eHalfLengthXmaxR) * nAxis};
74 }
75 
76 // ostream operator overload
77 std::ostream& Acts::DiscTrapezoidBounds::toStream(std::ostream& sl) const {
78  sl << std::setiosflags(std::ios::fixed);
79  sl << std::setprecision(7);
80  sl << "Acts::DiscTrapezoidBounds: (innerRadius, outerRadius, "
81  "halfLengthXminR, "
82  "halfLengthXmaxR, halfLengthY, halfPhiSector, averagePhi, rCenter, "
83  "stereo) = ";
84  sl << "(" << get(eMinR) << ", " << get(eMaxR) << ", " << get(eHalfLengthXminR)
85  << ", " << get(eHalfLengthXmaxR) << ", " << halfLengthY() << ", "
86  << halfPhiSector() << ", " << get(eAveragePhi) << ", " << rCenter() << ", "
87  << stereo() << ")";
88  sl << std::setprecision(-1);
89  return sl;
90 }