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 
10 
12 
13 #include <cmath>
14 #include <iomanip>
15 #include <iostream>
16 
19 
22 }
23 
25  const Acts::Vector2D& lposition) const {
26  return {Acts::detail::radian_sym((lposition[Acts::eBoundLoc0] / get(eR)) -
27  get(eAveragePhi)),
28  lposition[Acts::eBoundLoc1]};
29 }
30 
33  j(0, eBoundLoc0) = 1 / get(eR);
34  j(0, eBoundLoc1) = 0;
35  j(1, eBoundLoc0) = 0;
36  j(1, eBoundLoc1) = 1;
37  return j;
38 }
39 
40 bool Acts::CylinderBounds::inside(const Vector2D& lposition,
41  const BoundaryCheck& bcheck) const {
42  return bcheck.transformed(jacobian())
43  .isInside(shifted(lposition),
44  Vector2D(-get(eHalfPhiSector), -get(eHalfLengthZ)),
45  Vector2D(get(eHalfPhiSector), get(eHalfLengthZ)));
46 }
47 
49  const BoundaryCheck& bcheck) const {
50  // additional tolerance from the boundary check if configred
51  bool checkAbsolute = bcheck.m_type == BoundaryCheck::Type::eAbsolute;
52 
53  // this fast check only applies to closed cylindrical bounds
54  double addToleranceR =
55  (checkAbsolute && m_closed) ? bcheck.m_tolerance[0] : 0.;
56  double addToleranceZ = checkAbsolute ? bcheck.m_tolerance[1] : 0.;
57  // check if the position compatible with the radius
58  if ((s_onSurfaceTolerance + addToleranceR) <=
59  std::abs(perp(position) - get(eR))) {
60  return false;
61  } else if (checkAbsolute && m_closed) {
62  return ((s_onSurfaceTolerance + addToleranceZ + get(eHalfLengthZ)) >=
63  std::abs(position.z()));
64  }
65  // detailed, but slower check
66  Vector2D lpos(detail::radian_sym(phi(position) - get(eAveragePhi)),
67  position.z());
68  return bcheck.transformed(jacobian())
69  .isInside(lpos, Vector2D(-get(eHalfPhiSector), -get(eHalfLengthZ)),
70  Vector2D(get(eHalfPhiSector), get(eHalfLengthZ)));
71 }
72 
73 std::ostream& Acts::CylinderBounds::toStream(std::ostream& sl) const {
74  sl << std::setiosflags(std::ios::fixed);
75  sl << std::setprecision(7);
76  sl << "Acts::CylinderBounds: (radius, halfLengthZ, halfPhiSector, "
77  "averagePhi) = ";
78  sl << "(" << get(eR) << ", " << get(eHalfLengthZ) << ", ";
79  sl << get(eHalfPhiSector) << ", " << get(eAveragePhi) << ")";
80  sl << std::setprecision(-1);
81  return sl;
82 }