Analysis Software
Documentation for sPHENIX simulation 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 
15 
16 #include <cstdint>
17 
18 namespace ActsFatras {
19 
27 class Hit {
28  public:
32 
34  Hit() = default;
48  const Vector4& pos4, const Vector4& before4, const Vector4& after4,
49  int32_t index_ = -1)
50  : m_geometryId(geometryId),
51  m_particleId(particleId),
52  m_index(index_),
53  m_pos4(pos4),
54  m_before4(before4),
55  m_after4(after4) {}
56  Hit(const Hit&) = default;
57  Hit(Hit&&) = default;
58  Hit& operator=(const Hit&) = default;
59  Hit& operator=(Hit&&) = default;
60 
62  constexpr Acts::GeometryIdentifier geometryId() const { return m_geometryId; }
64  constexpr Barcode particleId() const { return m_particleId; }
68  constexpr int32_t index() const { return m_index; }
69 
71  const Vector4& fourPosition() const { return m_pos4; }
73  auto position() const { return m_pos4.segment<3>(Acts::ePos0); }
75  Scalar time() const { return m_pos4[Acts::eTime]; }
76 
78  const Vector4& momentum4Before() const { return m_before4; }
80  const Vector4& momentum4After() const { return m_after4; }
83  return m_before4.segment<3>(Acts::eMom0).normalized();
84  }
87  return m_after4.segment<3>(Acts::eMom0).normalized();
88  }
90  Vector3 direction() const {
91  auto dir0 = m_before4.segment<3>(Acts::eMom0).normalized();
92  auto dir1 = m_after4.segment<3>(Acts::eMom0).normalized();
93  return ((dir0 + dir1) / 2.).segment<3>(Acts::eMom0).normalized();
94  }
101  }
102 
103  private:
109  int32_t m_index = -1;
111  Vector4 m_pos4 = Vector4::Zero();
113  Vector4 m_before4 = Vector4::Zero();
115  Vector4 m_after4 = Vector4::Zero();
116 };
117 
118 } // namespace ActsFatras