ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CylinderBounds.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CylinderBounds.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 
11 
12 #include <cmath>
13 #include <iomanip>
14 #include <iostream>
15 
18 
21 }
22 
24  const Acts::Vector2D& lposition) const {
25  return {Acts::detail::radian_sym((lposition[Acts::eLOC_RPHI] / get(eR)) -
26  get(eAveragePhi)),
27  lposition[Acts::eLOC_Z]};
28 }
29 
32  j(0, eLOC_RPHI) = 1 / get(eR);
33  j(0, eLOC_Z) = 0;
34  j(1, eLOC_RPHI) = 0;
35  j(1, eLOC_Z) = 1;
36  return j;
37 }
38 
39 bool Acts::CylinderBounds::inside(const Vector2D& lposition,
40  const BoundaryCheck& bcheck) const {
41  return bcheck.transformed(jacobian())
42  .isInside(shifted(lposition),
43  Vector2D(-get(eHalfPhiSector), -get(eHalfLengthZ)),
44  Vector2D(get(eHalfPhiSector), get(eHalfLengthZ)));
45 }
46 
48  const BoundaryCheck& bcheck) const {
49  // additional tolerance from the boundary check if configred
50  bool checkAbsolute = bcheck.m_type == BoundaryCheck::Type::eAbsolute;
51 
52  // this fast check only applies to closed cylindrical bounds
53  double addToleranceR =
54  (checkAbsolute && m_closed) ? bcheck.m_tolerance[0] : 0.;
55  double addToleranceZ = checkAbsolute ? bcheck.m_tolerance[1] : 0.;
56  // check if the position compatible with the radius
57  if ((s_onSurfaceTolerance + addToleranceR) <=
58  std::abs(perp(position) - get(eR))) {
59  return false;
60  } else if (checkAbsolute && m_closed) {
61  return ((s_onSurfaceTolerance + addToleranceZ + get(eHalfLengthZ)) >=
62  std::abs(position.z()));
63  }
64  // detailed, but slower check
65  Vector2D lpos(detail::radian_sym(phi(position) - get(eAveragePhi)),
66  position.z());
67  return bcheck.transformed(jacobian())
68  .isInside(lpos, Vector2D(-get(eHalfPhiSector), -get(eHalfLengthZ)),
69  Vector2D(get(eHalfPhiSector), get(eHalfLengthZ)));
70 }
71 
73  const Acts::Vector2D& lposition) const {
74  return BoundaryCheck(true).distance(
75  shifted(lposition), Vector2D(-get(eHalfPhiSector), -get(eHalfLengthZ)),
76  Vector2D(get(eHalfPhiSector), get(eHalfLengthZ)));
77 }
78 
79 std::ostream& Acts::CylinderBounds::toStream(std::ostream& sl) const {
80  sl << std::setiosflags(std::ios::fixed);
81  sl << std::setprecision(7);
82  sl << "Acts::CylinderBounds: (radius, halfLengthZ, halfPhiSector, "
83  "averagePhi) = ";
84  sl << "(" << get(eR) << ", " << get(eHalfLengthZ) << ", ";
85  sl << get(eHalfPhiSector) << ", " << get(eAveragePhi) << ")";
86  sl << std::setprecision(-1);
87  return sl;
88 }