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