File indexing completed on 2026-04-12 07:34:57
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "ActsExamples/EventData/SimParticle.hpp"
0013 #include "ActsFatras/EventData/GenerationProcess.hpp"
0014
0015 #include <boost/container/flat_set.hpp>
0016
0017 namespace ActsExamples {
0018
0019 class SimVertexBarcode {
0020 public:
0021 using PrimaryVertexId = SimBarcode::PrimaryVertexId;
0022 using SecondaryVertexId = SimBarcode::SecondaryVertexId;
0023 using ParticleId = SimBarcode::ParticleId;
0024 using GenerationId = SimBarcode::GenerationId;
0025 using SubParticleId = SimBarcode::SubParticleId;
0026
0027 explicit constexpr SimVertexBarcode(SimBarcode barcode)
0028 : m_id(barcode.vertexId()) {}
0029
0030 constexpr SimVertexBarcode() = default;
0031
0032
0033 constexpr SimBarcode barcode() const { return m_id; }
0034
0035
0036 constexpr PrimaryVertexId vertexPrimary() const {
0037 return m_id.vertexPrimary();
0038 }
0039
0040 constexpr SecondaryVertexId vertexSecondary() const {
0041 return m_id.vertexSecondary();
0042 }
0043
0044 constexpr GenerationId generation() const { return m_id.generation(); }
0045
0046
0047 [[nodiscard]]
0048 constexpr SimVertexBarcode withVertexPrimary(PrimaryVertexId id) const {
0049 return SimVertexBarcode(m_id.withVertexPrimary(id));
0050 }
0051
0052 [[nodiscard]]
0053 constexpr SimVertexBarcode withVertexSecondary(SecondaryVertexId id) const {
0054 return SimVertexBarcode(m_id.withVertexSecondary(id));
0055 }
0056
0057 [[nodiscard]]
0058 constexpr SimVertexBarcode withGeneration(GenerationId id) const {
0059 return SimVertexBarcode(m_id.withGeneration(id));
0060 }
0061
0062 std::size_t hash() const { return m_id.hash(); }
0063
0064 private:
0065
0066
0067 SimBarcode m_id;
0068
0069 friend constexpr bool operator<(SimVertexBarcode lhs, SimVertexBarcode rhs) {
0070 return lhs.m_id < rhs.m_id;
0071 }
0072
0073 friend constexpr bool operator==(SimVertexBarcode lhs, SimVertexBarcode rhs) {
0074 return lhs.m_id == rhs.m_id;
0075 }
0076
0077 friend inline std::ostream& operator<<(std::ostream& os,
0078 SimVertexBarcode idx) {
0079 return os << idx.m_id;
0080 }
0081 };
0082
0083
0084 struct SimVertex {
0085
0086 SimVertexBarcode id = SimVertexBarcode(SimBarcode::Invalid());
0087
0088 Acts::Vector4 position4 = Acts::Vector4::Zero();
0089
0090 ActsFatras::GenerationProcess process =
0091 ActsFatras::GenerationProcess::eUndefined;
0092
0093 SimBarcodeContainer incoming;
0094
0095 SimBarcodeContainer outgoing;
0096
0097
0098
0099
0100
0101
0102
0103
0104 SimVertex(SimVertexBarcode id_, const Acts::Vector4& position4_,
0105 ActsFatras::GenerationProcess process_ =
0106 ActsFatras::GenerationProcess::eUndefined)
0107 : id(id_), position4(position4_), process(process_) {}
0108
0109 SimVertex() = default;
0110 SimVertex(const SimVertex&) = default;
0111 SimVertex(SimVertex&&) = default;
0112 SimVertex& operator=(const SimVertex&) = default;
0113 SimVertex& operator=(SimVertex&&) = default;
0114
0115 constexpr SimVertexBarcode vertexId() const { return id; }
0116
0117 auto position() const { return position4.head<3>(); }
0118
0119 double time() const { return position4[3]; }
0120 };
0121
0122 namespace detail {
0123 struct CompareVertexId {
0124 using is_transparent = void;
0125 constexpr bool operator()(const SimVertex& lhs, const SimVertex& rhs) const {
0126 return lhs.vertexId() < rhs.vertexId();
0127 }
0128 constexpr bool operator()(SimVertexBarcode lhs, const SimVertex& rhs) const {
0129 return lhs < rhs.vertexId();
0130 }
0131 constexpr bool operator()(const SimVertex& lhs, SimVertexBarcode rhs) const {
0132 return lhs.vertexId() < rhs;
0133 }
0134 };
0135 }
0136
0137
0138 using SimVertexContainer =
0139 ::boost::container::flat_set<SimVertex, detail::CompareVertexId>;
0140
0141 }
0142
0143
0144 namespace std {
0145 template <>
0146 struct hash<ActsExamples::SimVertexBarcode> {
0147 auto operator()(ActsExamples::SimVertexBarcode barcode) const noexcept {
0148 return barcode.hash();
0149 }
0150 };
0151 }