ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Intersection.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Intersection.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2016-2018 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 // Intersection.hpp, Acts project
12 
13 #pragma once
14 #include <limits>
15 #include "Definitions.hpp"
16 
17 namespace Acts {
18 
22 struct Intersection {
24  enum class Status : int {
25  missed = 0,
26  unreachable = 0,
27  reachable = 1,
28  onSurface = 2
29  };
30 
32  Vector3D position{0., 0., 0.};
34  double pathLength{std::numeric_limits<double>::infinity()};
36  Status status{Status::unreachable};
37 
43  Intersection(const Vector3D& sinter, double slength, Status sstatus)
44  : position(sinter), pathLength(slength), status(sstatus) {}
45 
47  Intersection() = default;
48 
50  explicit operator bool() const { return (status != Status::missed); }
51 
55  bool operator<(const Intersection& si) const {
56  if (status == Status::unreachable) {
57  return false;
58  }
59  // Now check the pathLength
60  if (si.status != Status::unreachable) {
61  return (pathLength < si.pathLength);
62  }
63  // The current one wins, no re-ordering
64  return true;
65  }
66 
70  bool operator>(const Intersection& si) const {
71  if (status == Status::unreachable) {
72  return false;
73  }
74  // Now check the pathLength
75  if (si.status != Status::unreachable) {
76  return (pathLength > si.pathLength);
77  }
78  // The current one wins, no re-ordering
79  return true;
80  }
81 };
82 
84 template <typename object_t, typename representation_t = object_t>
86  public:
90  const object_t* object{nullptr};
92  const representation_t* representation{nullptr};
93 
96 
98  ObjectIntersection() = default;
99 
105  template <typename T = representation_t,
107  ObjectIntersection(const Intersection& sInter, const object_t* sObject)
108  : intersection(sInter), object(sObject), representation(sObject) {}
109 
115  ObjectIntersection(const Intersection& sInter, const object_t* sObject,
116  const representation_t* sRepresentation)
117  : intersection(sInter),
118  object(sObject),
119  representation(sRepresentation) {}
120 
122  explicit operator bool() const { return bool(intersection); }
123 
130  bool operator<(
132  return (intersection < oi.intersection);
133  }
134 
141  bool operator>(
143  return (intersection > oi.intersection);
144  }
145 };
146 
155  template <typename intersection_t>
156  bool operator()(const intersection_t& i1, const intersection_t& i2) const {
157  return (i1.object == i2.object);
158  }
159 };
160 
161 } // namespace Acts