ECCE @ 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 
11 #include <cstdint>
12 
16 
17 namespace ActsFatras {
18 
26 class Hit {
27  public:
28  using Scalar = double;
31 
33  Hit() = default;
47  template <typename Position4, typename Momentum40, typename Momentum41>
49  const Eigen::MatrixBase<Position4>& pos4,
50  const Eigen::MatrixBase<Momentum40>& before4,
51  const Eigen::MatrixBase<Momentum41>& after4, int32_t index_ = -1)
52  : m_geometryId(geometryId),
53  m_particleId(particleId),
54  m_index(index_),
55  m_pos4(pos4),
56  m_before4(before4),
57  m_after4(after4) {}
58  Hit(const Hit&) = default;
59  Hit(Hit&&) = default;
60  Hit& operator=(const Hit&) = default;
61  Hit& operator=(Hit&&) = default;
62 
64  constexpr Acts::GeometryID geometryId() const { return m_geometryId; }
66  constexpr Barcode particleId() const { return m_particleId; }
70  constexpr int32_t index() const { return m_index; }
71 
75  const Vector4& position4() const { return m_pos4; }
77  auto position() const { return m_pos4.head<3>(); }
79  Scalar time() const { return m_pos4[3]; }
80 
84  const Vector4& momentum4Before() const { return m_before4; }
88  const Vector4& momentum4After() const { return m_after4; }
91  return m_before4.head<3>().normalized();
92  }
94  Vector3 unitDirectionAfter() const { return m_after4.head<3>().normalized(); }
97  auto dir0 = m_before4 / (2 * m_before4.head<3>().norm());
98  auto dir1 = m_after4 / (2 * m_after4.head<3>().norm());
99  return (dir0 + dir1).head<3>().normalized();
100  }
105  Scalar depositedEnergy() const { return m_before4[3] - m_after4[3]; }
106 
107  private:
113  int32_t m_index = -1;
115  Vector4 m_pos4 = Vector4::Zero();
117  Vector4 m_before4 = Vector4::Zero();
119  Vector4 m_after4 = Vector4::Zero();
120 };
121 
122 } // namespace ActsFatras