File indexing completed on 2025-12-02 09:19:52
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 [[deprecated("Use withVertexPrimary() instead")]]
0048 constexpr SimVertexBarcode setVertexPrimary(PrimaryVertexId id) {
0049 m_id = m_id.withVertexPrimary(id);
0050 return *this;
0051 }
0052
0053 [[deprecated("Use withVertexSecondary() instead")]]
0054 constexpr SimVertexBarcode setVertexSecondary(SecondaryVertexId id) {
0055 m_id = m_id.withVertexSecondary(id);
0056 return *this;
0057 }
0058
0059 [[deprecated("Use withGeneration() instead")]]
0060 constexpr SimVertexBarcode setGeneration(GenerationId id) {
0061 m_id = m_id.withGeneration(id);
0062 return *this;
0063 }
0064
0065
0066 [[nodiscard]]
0067 constexpr SimVertexBarcode withVertexPrimary(PrimaryVertexId id) const {
0068 return SimVertexBarcode(m_id.withVertexPrimary(id));
0069 }
0070
0071 [[nodiscard]]
0072 constexpr SimVertexBarcode withVertexSecondary(SecondaryVertexId id) const {
0073 return SimVertexBarcode(m_id.withVertexSecondary(id));
0074 }
0075
0076 [[nodiscard]]
0077 constexpr SimVertexBarcode withGeneration(GenerationId id) const {
0078 return SimVertexBarcode(m_id.withGeneration(id));
0079 }
0080
0081 std::size_t hash() const { return m_id.hash(); }
0082
0083 private:
0084
0085
0086 SimBarcode m_id;
0087
0088 friend constexpr bool operator<(SimVertexBarcode lhs, SimVertexBarcode rhs) {
0089 return lhs.m_id < rhs.m_id;
0090 }
0091
0092 friend constexpr bool operator==(SimVertexBarcode lhs, SimVertexBarcode rhs) {
0093 return lhs.m_id == rhs.m_id;
0094 }
0095
0096 friend inline std::ostream& operator<<(std::ostream& os,
0097 SimVertexBarcode idx) {
0098 return os << idx.m_id;
0099 }
0100 };
0101
0102
0103 struct SimVertex {
0104
0105 SimVertexBarcode id = SimVertexBarcode(SimBarcode::Invalid());
0106
0107 Acts::Vector4 position4 = Acts::Vector4::Zero();
0108
0109 ActsFatras::ProcessType process = ActsFatras::ProcessType::eUndefined;
0110
0111 SimBarcodeContainer incoming;
0112
0113 SimBarcodeContainer outgoing;
0114
0115
0116
0117
0118
0119
0120
0121
0122 SimVertex(
0123 SimVertexBarcode id_, const Acts::Vector4& position4_,
0124 ActsFatras::ProcessType process_ = ActsFatras::ProcessType::eUndefined)
0125 : id(id_), position4(position4_), process(process_) {}
0126
0127 SimVertex() = default;
0128 SimVertex(const SimVertex&) = default;
0129 SimVertex(SimVertex&&) = default;
0130 SimVertex& operator=(const SimVertex&) = default;
0131 SimVertex& operator=(SimVertex&&) = default;
0132
0133 constexpr SimVertexBarcode vertexId() const { return id; }
0134
0135 auto position() const { return position4.head<3>(); }
0136
0137 double time() const { return position4[3]; }
0138 };
0139
0140 namespace detail {
0141 struct CompareVertexId {
0142 using is_transparent = void;
0143 constexpr bool operator()(const SimVertex& lhs, const SimVertex& rhs) const {
0144 return lhs.vertexId() < rhs.vertexId();
0145 }
0146 constexpr bool operator()(SimVertexBarcode lhs, const SimVertex& rhs) const {
0147 return lhs < rhs.vertexId();
0148 }
0149 constexpr bool operator()(const SimVertex& lhs, SimVertexBarcode rhs) const {
0150 return lhs.vertexId() < rhs;
0151 }
0152 };
0153 }
0154
0155
0156 using SimVertexContainer =
0157 ::boost::container::flat_set<SimVertex, detail::CompareVertexId>;
0158
0159 }
0160
0161
0162 namespace std {
0163 template <>
0164 struct hash<ActsExamples::SimVertexBarcode> {
0165 auto operator()(ActsExamples::SimVertexBarcode barcode) const noexcept {
0166 return barcode.hash();
0167 }
0168 };
0169 }