File indexing completed on 2025-12-16 09:23:45
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/ProcessType.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::ProcessType process = ActsFatras::ProcessType::eUndefined;
0091
0092 SimBarcodeContainer incoming;
0093
0094 SimBarcodeContainer outgoing;
0095
0096
0097
0098
0099
0100
0101
0102
0103 SimVertex(
0104 SimVertexBarcode id_, const Acts::Vector4& position4_,
0105 ActsFatras::ProcessType process_ = ActsFatras::ProcessType::eUndefined)
0106 : id(id_), position4(position4_), process(process_) {}
0107
0108 SimVertex() = default;
0109 SimVertex(const SimVertex&) = default;
0110 SimVertex(SimVertex&&) = default;
0111 SimVertex& operator=(const SimVertex&) = default;
0112 SimVertex& operator=(SimVertex&&) = default;
0113
0114 constexpr SimVertexBarcode vertexId() const { return id; }
0115
0116 auto position() const { return position4.head<3>(); }
0117
0118 double time() const { return position4[3]; }
0119 };
0120
0121 namespace detail {
0122 struct CompareVertexId {
0123 using is_transparent = void;
0124 constexpr bool operator()(const SimVertex& lhs, const SimVertex& rhs) const {
0125 return lhs.vertexId() < rhs.vertexId();
0126 }
0127 constexpr bool operator()(SimVertexBarcode lhs, const SimVertex& rhs) const {
0128 return lhs < rhs.vertexId();
0129 }
0130 constexpr bool operator()(const SimVertex& lhs, SimVertexBarcode rhs) const {
0131 return lhs.vertexId() < rhs;
0132 }
0133 };
0134 }
0135
0136
0137 using SimVertexContainer =
0138 ::boost::container::flat_set<SimVertex, detail::CompareVertexId>;
0139
0140 }
0141
0142
0143 namespace std {
0144 template <>
0145 struct hash<ActsExamples::SimVertexBarcode> {
0146 auto operator()(ActsExamples::SimVertexBarcode barcode) const noexcept {
0147 return barcode.hash();
0148 }
0149 };
0150 }