File indexing completed on 2025-09-17 08:55:07
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();
0060
0061
0062 Vertex(const std::int32_t type, const float chi2, const int ndf, const edm4hep::Vector4f& position, const edm4eic::Cov4f& positionError);
0063
0064
0065 Vertex(const Vertex& other) = default;
0066
0067
0068 Vertex& operator=(Vertex other) &;
0069 Vertex& operator=(Vertex other) && = delete;
0070
0071
0072
0073 MutableVertex clone(bool cloneRelations=true) const;
0074
0075
0076 ~Vertex() = default;
0077
0078
0079 Vertex(const MutableVertex& other);
0080
0081 static Vertex makeEmpty();
0082
0083 public:
0084
0085 static constexpr std::string_view typeName = "edm4eic::Vertex";
0086
0087
0088 std::int32_t getType() const;
0089
0090
0091 float getChi2() const;
0092
0093
0094 int getNdf() const;
0095
0096
0097 const edm4hep::Vector4f& getPosition() const;
0098
0099
0100 const edm4eic::Cov4f& getPositionError() const;
0101
0102
0103
0104 std::size_t associatedParticles_size() const;
0105 edm4eic::ReconstructedParticle getAssociatedParticles(std::size_t) const;
0106 std::vector<edm4eic::ReconstructedParticle>::const_iterator associatedParticles_begin() const;
0107 std::vector<edm4eic::ReconstructedParticle>::const_iterator associatedParticles_end() const;
0108 podio::RelationRange<edm4eic::ReconstructedParticle> getAssociatedParticles() const;
0109
0110
0111
0112 bool isAvailable() const;
0113
0114 void unlink() { m_obj = podio::utils::MaybeSharedPtr<VertexObj>{nullptr}; }
0115
0116 bool operator==(const Vertex& other) const { return m_obj == other.m_obj; }
0117 bool operator==(const MutableVertex& other) const;
0118
0119 bool operator!=(const Vertex& other) const { return !(*this == other); }
0120 bool operator!=(const MutableVertex& other) const { return !(*this == other); }
0121
0122
0123 bool operator<(const Vertex& other) const { return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other); }
0124
0125 podio::ObjectID id() const { return getObjectID(); }
0126
0127 const podio::ObjectID getObjectID() const;
0128
0129 friend std::hash<Vertex>;
0130
0131 friend void swap(Vertex& a, Vertex& b) {
0132 using std::swap;
0133 swap(a.m_obj, b.m_obj);
0134 }
0135
0136 private:
0137
0138 explicit Vertex(podio::utils::MaybeSharedPtr<VertexObj> obj);
0139 Vertex(VertexObj* obj);
0140
0141 podio::utils::MaybeSharedPtr<VertexObj> m_obj{nullptr};
0142 };
0143
0144 std::ostream& operator<<(std::ostream& o, const Vertex& value);
0145
0146 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0147 void to_json(nlohmann::json& j, const Vertex& value);
0148 #endif
0149
0150
0151 }
0152
0153
0154
0155 template<>
0156 struct std::hash<edm4eic::Vertex> {
0157 std::size_t operator()(const edm4eic::Vertex& obj) const {
0158 return std::hash<edm4eic::VertexObj*>{}(obj.m_obj.get());
0159 }
0160 };
0161
0162
0163
0164
0165
0166 #if defined(__clang__)
0167 #pragma clang diagnostic push
0168 #pragma clang diagnostic ignored "-Wunknown-warning-option"
0169 #pragma clang diagnostic ignored "-Wdeprecated-redundant-constexpr-static-def"
0170 #pragma clang diagnostic ignored "-Wdeprecated"
0171 constexpr std::string_view edm4eic::Vertex::typeName;
0172 #pragma clang diagnostic pop
0173 #elif defined(__GNUC__)
0174 #pragma GCC diagnostic push
0175 #pragma GCC diagnostic ignored "-Wdeprecated"
0176 constexpr std::string_view edm4eic::Vertex::typeName;
0177 #pragma GCC diagnostic pop
0178 #endif
0179
0180 #endif