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 
16 #include "Definitions.hpp"
17 
18 namespace Acts {
19 
23 template <unsigned int DIM>
24 struct Intersection {
26  enum class Status : int {
27  missed = 0,
28  unreachable = 0,
29  reachable = 1,
30  onSurface = 2
31  };
32 
36  double pathLength{std::numeric_limits<double>::infinity()};
38  Status status{Status::unreachable};
39 
45  Intersection(const ActsVector<double, DIM>& sinter, double slength,
46  Status sstatus)
47  : position(sinter), pathLength(slength), status(sstatus) {}
48 
50  Intersection() = default;
51 
53  explicit operator bool() const { return (status != Status::missed); }
54 
58  bool operator<(const Intersection<DIM>& si) const {
59  if (status == Status::unreachable) {
60  return false;
61  }
62  // Now check the pathLength
63  if (si.status != Status::unreachable) {
64  return (pathLength < si.pathLength);
65  }
66  // The current one wins, no re-ordering
67  return true;
68  }
69 
73  bool operator>(const Intersection<DIM>& si) const {
74  if (status == Status::unreachable) {
75  return false;
76  }
77  // Now check the pathLength
78  if (si.status != Status::unreachable) {
79  return (pathLength > si.pathLength);
80  }
81  // The current one wins, no re-ordering
82  return true;
83  }
84 };
85 
87 
89 
91 template <typename object_t, typename representation_t = object_t>
93  public:
97  const object_t* object{nullptr};
99  const representation_t* representation{nullptr};
100 
103 
105  ObjectIntersection() = default;
106 
112  template <typename T = representation_t,
114  ObjectIntersection(const Intersection3D& sInter, const object_t* sObject)
115  : intersection(sInter), object(sObject), representation(sObject) {}
116 
122  ObjectIntersection(const Intersection3D& sInter, const object_t* sObject,
123  const representation_t* sRepresentation)
124  : intersection(sInter),
125  object(sObject),
126  representation(sRepresentation) {}
127 
129  explicit operator bool() const { return bool(intersection); }
130 
137  bool operator<(
139  return (intersection < oi.intersection);
140  }
141 
148  bool operator>(
150  return (intersection > oi.intersection);
151  }
152 };
153 
162  template <typename intersection_t>
163  bool operator()(const intersection_t& i1, const intersection_t& i2) const {
164  return (i1.object == i2.object);
165  }
166 };
167 
168 } // namespace Acts