Analysis Software
Documentation for sPHENIX simulation 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 
12 
13 #include <cmath>
14 #include <iomanip>
15 #include <iostream>
16 #include <limits>
17 
18 Acts::ConeBounds::ConeBounds(double alpha, bool symm, double halfphi,
19  double avphi) noexcept(false)
20  : m_values({alpha, symm ? -std::numeric_limits<double>::infinity() : 0,
21  std::numeric_limits<double>::infinity(), halfphi, avphi}),
22  m_tanAlpha(std::tan(alpha)) {
23  checkConsistency();
24 }
25 
26 Acts::ConeBounds::ConeBounds(double alpha, double minz, double maxz,
27  double halfphi, double avphi) noexcept(false)
28  : m_values({alpha, minz, maxz, halfphi, avphi}),
29  m_tanAlpha(std::tan(alpha)) {
30  checkConsistency();
31 }
32 
33 Acts::ConeBounds::ConeBounds(const std::array<double, eSize>& values) noexcept(
34  false)
35  : m_values(values), m_tanAlpha(std::tan(values[eAlpha])) {
36  checkConsistency();
37 }
38 
40  return SurfaceBounds::eCone;
41 }
42 
46 
47  auto x = r(lposition[eBoundLoc1]); // cone radius at the local position
48  Vector2 shifted;
49  shifted[eBoundLoc1] = lposition[eBoundLoc1];
50  shifted[eBoundLoc0] =
51  std::isnormal(x)
52  ? (x * radian_sym((lposition[eBoundLoc0] / x) - get(eAveragePhi)))
53  : lposition[eBoundLoc0];
54  return shifted;
55 }
56 
58  const Acts::BoundaryCheck& bcheck) const {
59  auto rphiHalf = r(lposition[eBoundLoc1]) * get(eHalfPhiSector);
60  return bcheck.isInside(shifted(lposition), Vector2(-rphiHalf, get(eMinZ)),
61  Vector2(rphiHalf, get(eMaxZ)));
62 }
63 
64 std::ostream& Acts::ConeBounds::toStream(std::ostream& sl) const {
65  sl << std::setiosflags(std::ios::fixed);
66  sl << std::setprecision(7);
67  sl << "Acts::ConeBounds: (tanAlpha, minZ, maxZ, halfPhiSector, averagePhi) "
68  "= ";
69  sl << "(" << m_tanAlpha << ", " << get(eMinZ) << ", " << get(eMaxZ) << ", "
70  << get(eHalfPhiSector) << ", " << get(eAveragePhi) << ")";
71  sl << std::setprecision(-1);
72  return sl;
73 }