ECCE @ EIC 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 
11 #include <cmath>
12 #include <iomanip>
13 #include <iostream>
14 
16  double halfXmaxR, double minR,
17  double maxR, double avgPhi,
18  double stereo) noexcept(false)
19  : m_values({halfXminR, halfXmaxR, minR, maxR, avgPhi, stereo}) {
20  checkConsistency();
21 }
22 
25 }
26 
28  const Acts::Vector2D& lposition) const {
29  return {lposition[eLOC_R] * std::sin(lposition[eLOC_PHI] - get(eAveragePhi)),
30  lposition[eLOC_R] * std::cos(lposition[eLOC_PHI] - get(eAveragePhi))};
31 }
32 
34  const Acts::Vector2D& lposition) const {
35  ActsMatrixD<2, 2> jacobian;
36  jacobian(0, eLOC_R) = std::sin(lposition[eLOC_PHI] - get(eAveragePhi));
37  jacobian(1, eLOC_R) = std::cos(lposition[eLOC_PHI] - get(eAveragePhi));
38  jacobian(0, eLOC_PHI) = lposition[eLOC_R] * std::cos(lposition[eLOC_PHI]);
39  jacobian(1, eLOC_PHI) = lposition[eLOC_R] * -std::sin(lposition[eLOC_PHI]);
40  return jacobian;
41 }
42 
44  const Acts::Vector2D& lposition, const Acts::BoundaryCheck& bcheck) const {
45  Vector2D vertices[] = {{get(eHalfLengthXminR), get(eMinR)},
46  {get(eHalfLengthXmaxR), get(eMaxR)},
47  {-get(eHalfLengthXmaxR), get(eMaxR)},
48  {-get(eHalfLengthXminR), get(eMinR)}};
49  auto jacobian = jacobianToLocalCartesian(lposition);
50  return bcheck.transformed(jacobian).isInside(toLocalCartesian(lposition),
51  vertices);
52 }
53 
55  const Acts::Vector2D& lposition) const {
56  Vector2D vertices[] = {{get(eHalfLengthXminR), get(eMinR)},
57  {get(eHalfLengthXmaxR), get(eMaxR)},
58  {-get(eHalfLengthXmaxR), get(eMaxR)},
59  {-get(eHalfLengthXminR), get(eMinR)}};
60  return BoundaryCheck(true).distance(toLocalCartesian(lposition), vertices);
61 }
62 
63 std::vector<Acts::Vector2D> Acts::DiscTrapezoidBounds::vertices(
64  unsigned int /*lseg*/) const {
65  Vector2D cAxis(std::cos(get(eAveragePhi)), std::sin(get(eAveragePhi)));
66  Vector2D nAxis(cAxis.y(), -cAxis.x());
67  return {get(eMinR) * cAxis - get(eHalfLengthXminR) * nAxis,
68  get(eMinR) * cAxis + get(eHalfLengthXminR) * nAxis,
69  get(eMaxR) * cAxis + get(eHalfLengthXmaxR) * nAxis,
70  get(eMaxR) * cAxis - get(eHalfLengthXmaxR) * nAxis};
71 }
72 
73 // ostream operator overload
74 std::ostream& Acts::DiscTrapezoidBounds::toStream(std::ostream& sl) const {
75  sl << std::setiosflags(std::ios::fixed);
76  sl << std::setprecision(7);
77  sl << "Acts::DiscTrapezoidBounds: (innerRadius, outerRadius, "
78  "halfLengthXminR, "
79  "halfLengthXmaxR, halfLengthY, halfPhiSector, averagePhi, rCenter, "
80  "stereo) = ";
81  sl << "(" << get(eMinR) << ", " << get(eMaxR) << ", " << get(eHalfLengthXminR)
82  << ", " << get(eHalfLengthXmaxR) << ", " << halfLengthY() << ", "
83  << halfPhiSector() << ", " << get(eAveragePhi) << ", " << rCenter() << ", "
84  << stereo() << ")";
85  sl << std::setprecision(-1);
86  return sl;
87 }