ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ConeBounds.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ConeBounds.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 #include <limits>
15 
16 Acts::ConeBounds::ConeBounds(double alpha, bool symm, double halfphi,
17  double avphi) noexcept(false)
18  : m_values({alpha, symm ? -std::numeric_limits<double>::infinity() : 0,
19  std::numeric_limits<double>::infinity(), halfphi, avphi}),
20  m_tanAlpha(std::tan(alpha)) {
21  checkConsistency();
22 }
23 
25  double halfphi, double avphi) noexcept(false)
26  : m_values({alpha, minz, maxz, halfphi, avphi}),
27  m_tanAlpha(std::tan(alpha)) {
28  checkConsistency();
29 }
30 
31 Acts::ConeBounds::ConeBounds(const std::array<double, eSize>& values) noexcept(
32  false)
33  : m_values(values), m_tanAlpha(std::tan(values[eAlpha])) {
34  checkConsistency();
35 }
36 
38  return SurfaceBounds::eCone;
39 }
40 
43  const Acts::Vector2D& lposition) const {
45 
46  auto x = r(lposition[eLOC_Z]); // cone radius at the local position
47  Vector2D shifted;
48  shifted[eLOC_Z] = lposition[eLOC_Z];
49  shifted[eLOC_RPHI] =
50  std::isnormal(x)
51  ? (x * radian_sym((lposition[eLOC_RPHI] / x) - get(eAveragePhi)))
52  : lposition[eLOC_RPHI];
53  return shifted;
54 }
55 
57  const Acts::BoundaryCheck& bcheck) const {
58  auto rphiHalf = r(lposition[eLOC_Z]) * get(eHalfPhiSector);
59  return bcheck.isInside(shifted(lposition), Vector2D(-rphiHalf, get(eMinZ)),
60  Vector2D(rphiHalf, get(eMaxZ)));
61 }
62 
64  const Acts::Vector2D& lposition) const {
65  auto rphiHalf = r(lposition[eLOC_Z]) * get(eHalfPhiSector);
66  return BoundaryCheck(true).distance(shifted(lposition),
67  Vector2D(-rphiHalf, get(eMinZ)),
68  Vector2D(rphiHalf, get(eMaxZ)));
69 }
70 
71 std::ostream& Acts::ConeBounds::toStream(std::ostream& sl) const {
72  sl << std::setiosflags(std::ios::fixed);
73  sl << std::setprecision(7);
74  sl << "Acts::ConeBounds: (tanAlpha, minZ, maxZ, halfPhiSector, averagePhi) "
75  "= ";
76  sl << "(" << m_tanAlpha << ", " << get(eMinZ) << ", " << get(eMaxZ) << ", "
77  << get(eHalfPhiSector) << ", " << get(eAveragePhi) << ")";
78  sl << std::setprecision(-1);
79  return sl;
80 }