File indexing completed on 2025-01-30 09:32:31
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 Value = SimBarcode::Value;
0022
0023 constexpr SimVertexBarcode() = default;
0024 constexpr SimVertexBarcode(Value encoded) : m_id(SimBarcode(encoded)) {}
0025 constexpr SimVertexBarcode(SimBarcode vertexId)
0026 : m_id(vertexId.setParticle(0).setSubParticle(0)) {
0027 if (vertexId != vertexId.vertexId()) {
0028 throw std::invalid_argument("SimVertexBarcode: invalid vertexId");
0029 }
0030 }
0031
0032
0033 constexpr Value value() const { return m_id.value(); }
0034
0035
0036 constexpr SimBarcode barcode() const { return m_id; }
0037
0038
0039 constexpr Value vertexPrimary() const { return m_id.vertexPrimary(); }
0040
0041 constexpr Value vertexSecondary() const { return m_id.vertexSecondary(); }
0042
0043 constexpr Value generation() const { return m_id.generation(); }
0044
0045
0046 constexpr SimVertexBarcode& setVertexPrimary(Value id) {
0047 return m_id.setVertexPrimary(id), *this;
0048 }
0049
0050 constexpr SimVertexBarcode& setVertexSecondary(Value id) {
0051 return m_id.setVertexSecondary(id), *this;
0052 }
0053
0054 constexpr SimVertexBarcode& setGeneration(Value id) {
0055 return m_id.setGeneration(id), *this;
0056 }
0057
0058 private:
0059
0060
0061 SimBarcode m_id = 0;
0062
0063 friend constexpr bool operator<(SimVertexBarcode lhs, SimVertexBarcode rhs) {
0064 return lhs.m_id < rhs.m_id;
0065 }
0066 friend constexpr bool operator==(SimVertexBarcode lhs, SimVertexBarcode rhs) {
0067 return lhs.m_id == rhs.m_id;
0068 }
0069 friend constexpr bool operator!=(SimVertexBarcode lhs, SimVertexBarcode rhs) {
0070 return lhs.m_id != rhs.m_id;
0071 }
0072 friend inline std::ostream& operator<<(std::ostream& os,
0073 SimVertexBarcode idx) {
0074 return os << idx.m_id;
0075 }
0076 };
0077
0078
0079 struct SimVertex {
0080 using Scalar = Acts::ActsScalar;
0081 using Vector4 = Acts::ActsVector<4>;
0082
0083
0084 SimVertexBarcode id;
0085
0086 Vector4 position4 = Vector4::Zero();
0087
0088 ActsFatras::ProcessType process = ActsFatras::ProcessType::eUndefined;
0089
0090 SimBarcodeContainer incoming;
0091
0092 SimBarcodeContainer outgoing;
0093
0094
0095
0096
0097
0098
0099
0100
0101 SimVertex(
0102 SimVertexBarcode id_, const Vector4& position4_,
0103 ActsFatras::ProcessType process_ = ActsFatras::ProcessType::eUndefined)
0104 : id(id_), position4(position4_), process(process_) {}
0105
0106 SimVertex() = default;
0107 SimVertex(const SimVertex&) = default;
0108 SimVertex(SimVertex&&) = default;
0109 SimVertex& operator=(const SimVertex&) = default;
0110 SimVertex& operator=(SimVertex&&) = default;
0111
0112 constexpr SimVertexBarcode vertexId() const { return id; }
0113
0114 auto position() const { return position4.head<3>(); }
0115
0116 Scalar time() const { return position4[3]; }
0117 };
0118
0119 namespace detail {
0120 struct CompareVertexId {
0121 using is_transparent = void;
0122 constexpr bool operator()(const SimVertex& lhs, const SimVertex& rhs) const {
0123 return lhs.vertexId() < rhs.vertexId();
0124 }
0125 constexpr bool operator()(SimVertexBarcode lhs, const SimVertex& rhs) const {
0126 return lhs < rhs.vertexId();
0127 }
0128 constexpr bool operator()(const SimVertex& lhs, SimVertexBarcode rhs) const {
0129 return lhs.vertexId() < rhs;
0130 }
0131 };
0132 }
0133
0134
0135 using SimVertexContainer =
0136 ::boost::container::flat_set<SimVertex, detail::CompareVertexId>;
0137
0138 }