Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TrapezoidBounds.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TrapezoidBounds.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 <iomanip>
14 #include <iostream>
15 
17 
20 }
21 
23  const Acts::BoundaryCheck& bcheck) const {
24  const double x = lposition[0];
25  const double y = lposition[1];
26 
27  const double hlY = get(TrapezoidBounds::eHalfLengthY);
28  const double hlXnY = get(TrapezoidBounds::eHalfLengthXnegY);
29  const double hlXpY = get(TrapezoidBounds::eHalfLengthXposY);
30 
31  if (bcheck.type() == BoundaryCheck::Type::eAbsolute) {
32  double tolX = bcheck.tolerance()[eBoundLoc0];
33  double tolY = bcheck.tolerance()[eBoundLoc1];
34 
35  if (std::abs(y) - hlY > tolY) {
36  // outside y range
37  return false;
38  }
39 
40  if (std::abs(x) - std::max(hlXnY, hlXpY) > tolX) {
41  // outside x range
42  return false;
43  }
44 
45  if (std::abs(x) - std::min(hlXnY, hlXpY) <= tolX) {
46  // inside x range
47  return true;
48  }
49  }
50 
51  // at this stage, the point can only be in the triangles
52  // run slow-ish polygon check
53  std::array<Vector2, 4> v{
54  Vector2{-hlXnY, -hlY}, {hlXnY, -hlY}, {hlXpY, hlY}, {-hlXpY, hlY}};
55  return bcheck.isInside(lposition, v);
56 }
57 
58 std::vector<Acts::Vector2> Acts::TrapezoidBounds::vertices(
59  unsigned int /*lseg*/) const {
60  double minhx = get(TrapezoidBounds::eHalfLengthXnegY);
61  double maxhx = get(TrapezoidBounds::eHalfLengthXposY);
62  double hy = get(TrapezoidBounds::eHalfLengthY);
63  return {{-minhx, -hy}, {minhx, -hy}, {maxhx, hy}, {-maxhx, hy}};
64 }
65 
67  return m_boundingBox;
68 }
69 
70 std::ostream& Acts::TrapezoidBounds::toStream(std::ostream& sl) const {
71  sl << std::setiosflags(std::ios::fixed);
72  sl << std::setprecision(7);
73  sl << "Acts::TrapezoidBounds: (halfXnegY, halfXposY, halfY) = "
74  << "(" << get(eHalfLengthXnegY) << ", " << get(eHalfLengthXposY) << ", "
75  << get(eHalfLengthY) << ")";
76  sl << std::setprecision(-1);
77  return sl;
78 }