EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Hit.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Hit.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 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 
9 #pragma once
10 
14 
15 #include <cstdint>
16 
17 namespace ActsFatras {
18 
26 class Hit {
27  public:
28  using Scalar = double;
31 
33  Hit() = default;
47  const Vector4& pos4, const Vector4& before4, const Vector4& after4,
48  int32_t index_ = -1)
49  : m_geometryId(geometryId),
50  m_particleId(particleId),
51  m_index(index_),
52  m_pos4(pos4),
53  m_before4(before4),
54  m_after4(after4) {}
55  Hit(const Hit&) = default;
56  Hit(Hit&&) = default;
57  Hit& operator=(const Hit&) = default;
58  Hit& operator=(Hit&&) = default;
59 
61  constexpr Acts::GeometryIdentifier geometryId() const { return m_geometryId; }
63  constexpr Barcode particleId() const { return m_particleId; }
67  constexpr int32_t index() const { return m_index; }
68 
70  const Vector4& position4() const { return m_pos4; }
72  auto position() const { return m_pos4.segment<3>(Acts::ePos0); }
74  Scalar time() const { return m_pos4[Acts::eTime]; }
75 
77  const Vector4& momentum4Before() const { return m_before4; }
79  const Vector4& momentum4After() const { return m_after4; }
82  return m_before4.segment<3>(Acts::eMom0).normalized();
83  }
86  return m_after4.segment<3>(Acts::eMom0).normalized();
87  }
90  auto dir0 = m_before4 / (2 * m_before4.segment<3>(Acts::eMom0).norm());
91  auto dir1 = m_after4 / (2 * m_after4.segment<3>(Acts::eMom0).norm());
92  return (dir0 + dir1).segment<3>(Acts::eMom0).normalized();
93  }
100  }
101 
102  private:
108  int32_t m_index = -1;
110  Vector4 m_pos4 = Vector4::Zero();
112  Vector4 m_before4 = Vector4::Zero();
114  Vector4 m_after4 = Vector4::Zero();
115 };
116 
117 } // namespace ActsFatras