File indexing completed on 2026-11-20 10:16:15
0001
0002
0003 #ifndef EDM4EIC_Vertex_H
0004 #define EDM4EIC_Vertex_H
0005
0006 #include "edm4eic/VertexObj.h"
0007
0008 #include "edm4eic/Cov4f.h"
0009 #include "edm4eic/ReconstructedParticle.h"
0010 #include "edm4hep/Vector4f.h"
0011 #include "podio/RelationRange.h"
0012 #include <cstdint>
0013 #include <vector>
0014
0015 #include "podio/utilities/MaybeSharedPtr.h"
0016 #include "podio/detail/OrderKey.h"
0017
0018 #include <ostream>
0019 #include <cstdint>
0020
0021 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0022 #include "nlohmann/json_fwd.hpp"
0023 #endif
0024
0025
0026 namespace edm4eic {
0027 class VertexCollection;
0028 }
0029
0030
0031 namespace podio::detail {
0032
0033 OrderKey getOrderKey(const edm4eic::Vertex& obj);
0034 };
0035
0036 namespace edm4eic {
0037
0038 class MutableVertex;
0039 class VertexCollection;
0040 class VertexCollectionData;
0041
0042
0043
0044
0045
0046 class Vertex {
0047
0048 friend class MutableVertex;
0049 friend class VertexCollection;
0050 friend class edm4eic::VertexCollectionData;
0051 friend class VertexCollectionIterator;
0052 friend podio::detail::OrderKey podio::detail::getOrderKey(const Vertex & obj);
0053
0054 public:
0055 using mutable_type = MutableVertex;
0056 using collection_type = VertexCollection;
0057
0058
0059 Vertex() = default;
0060
0061
0062 Vertex(const std::int32_t type, const float chi2, const float ndf, const edm4hep::Vector4f& position, const edm4eic::Cov4f& positionError);
0063
0064
0065 Vertex(const Vertex& other) noexcept = default;
0066
0067
0068 Vertex(Vertex&& other) noexcept = default;
0069
0070
0071 Vertex& operator=(Vertex other) &;
0072 Vertex& operator=(Vertex other) && = delete;
0073
0074
0075
0076 MutableVertex clone(bool cloneRelations=true) const;
0077
0078
0079 ~Vertex() = default;
0080
0081
0082 Vertex(const MutableVertex& other);
0083
0084 static Vertex makeEmpty();
0085
0086 public:
0087
0088 static constexpr std::string_view typeName = "edm4eic::Vertex";
0089
0090
0091 std::int32_t getType() const;
0092
0093
0094 float getChi2() const;
0095
0096
0097 float getNdf() const;
0098
0099
0100 const edm4hep::Vector4f& getPosition() const;
0101
0102
0103 const edm4eic::Cov4f& getPositionError() const;
0104
0105
0106
0107 std::size_t associatedParticles_size() const;
0108 edm4eic::ReconstructedParticle getAssociatedParticles(std::size_t) const;
0109 std::vector<edm4eic::ReconstructedParticle>::const_iterator associatedParticles_begin() const;
0110 std::vector<edm4eic::ReconstructedParticle>::const_iterator associatedParticles_end() const;
0111 podio::RelationRange<edm4eic::ReconstructedParticle> getAssociatedParticles() const;
0112
0113
0114
0115 bool isAvailable() const;
0116
0117 void unlink() { m_obj = podio::utils::MaybeSharedPtr<VertexObj>{nullptr}; }
0118
0119 constexpr bool operator==(const Vertex& other) const { return m_obj == other.m_obj; }
0120 bool operator==(const MutableVertex& other) const;
0121
0122 constexpr bool operator!=(const Vertex& other) const { return !(*this == other); }
0123 bool operator!=(const MutableVertex& other) const { return !(*this == other); }
0124
0125
0126 bool operator<(const Vertex& other) const { return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other); }
0127
0128 podio::ObjectID id() const { return getObjectID(); }
0129
0130 const podio::ObjectID getObjectID() const;
0131
0132 friend std::hash<Vertex>;
0133
0134 friend void swap(Vertex& a, Vertex& b) {
0135 using std::swap;
0136 swap(a.m_obj, b.m_obj);
0137 }
0138
0139 private:
0140
0141 explicit Vertex(podio::utils::MaybeSharedPtr<VertexObj> obj);
0142 Vertex(VertexObj* obj);
0143
0144 podio::utils::MaybeSharedPtr<VertexObj> m_obj{new VertexObj{}, podio::utils::MarkOwned};
0145 };
0146
0147 std::ostream& operator<<(std::ostream& o, const Vertex& value);
0148
0149 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0150 void to_json(nlohmann::json& j, const Vertex& value);
0151 #endif
0152
0153
0154 }
0155
0156
0157
0158 template<>
0159 struct std::hash<edm4eic::Vertex> {
0160 std::size_t operator()(const edm4eic::Vertex& obj) const {
0161 return std::hash<edm4eic::VertexObj*>{}(obj.m_obj.get());
0162 }
0163 };
0164
0165
0166
0167
0168
0169 #if defined(__clang__)
0170 #pragma clang diagnostic push
0171 #pragma clang diagnostic ignored "-Wunknown-warning-option"
0172 #pragma clang diagnostic ignored "-Wdeprecated-redundant-constexpr-static-def"
0173 #pragma clang diagnostic ignored "-Wdeprecated"
0174 constexpr std::string_view edm4eic::Vertex::typeName;
0175 #pragma clang diagnostic pop
0176 #elif defined(__GNUC__)
0177 #pragma GCC diagnostic push
0178 #pragma GCC diagnostic ignored "-Wdeprecated"
0179 constexpr std::string_view edm4eic::Vertex::typeName;
0180 #pragma GCC diagnostic pop
0181 #endif
0182
0183
0184 #endif