File indexing completed on 2025-06-30 08:34:19
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(std::int32_t type, float chi2, int ndf, edm4hep::Vector4f position, edm4eic::Cov4f positionError);
0063
0064
0065 Vertex(const Vertex& other) = default;
0066
0067
0068 Vertex& operator=(Vertex other);
0069
0070
0071
0072 MutableVertex clone(bool cloneRelations=true) const;
0073
0074
0075 ~Vertex() = default;
0076
0077
0078 Vertex(const MutableVertex& other);
0079
0080 static Vertex makeEmpty();
0081
0082 public:
0083
0084 static constexpr auto typeName = "edm4eic::Vertex";
0085
0086
0087 std::int32_t getType() const;
0088
0089
0090 float getChi2() const;
0091
0092
0093 int getNdf() const;
0094
0095
0096 const edm4hep::Vector4f& getPosition() const;
0097
0098
0099 const edm4eic::Cov4f& getPositionError() const;
0100
0101
0102
0103 std::size_t associatedParticles_size() const;
0104 edm4eic::ReconstructedParticle getAssociatedParticles(std::size_t) const;
0105 std::vector<edm4eic::ReconstructedParticle>::const_iterator associatedParticles_begin() const;
0106 std::vector<edm4eic::ReconstructedParticle>::const_iterator associatedParticles_end() const;
0107 podio::RelationRange<edm4eic::ReconstructedParticle> getAssociatedParticles() const;
0108
0109
0110
0111 bool isAvailable() const;
0112
0113 void unlink() { m_obj = podio::utils::MaybeSharedPtr<VertexObj>{nullptr}; }
0114
0115 bool operator==(const Vertex& other) const { return m_obj == other.m_obj; }
0116 bool operator==(const MutableVertex& other) const;
0117
0118 bool operator!=(const Vertex& other) const { return !(*this == other); }
0119 bool operator!=(const MutableVertex& other) const { return !(*this == other); }
0120
0121
0122 bool operator<(const Vertex& other) const { return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other); }
0123
0124 podio::ObjectID id() const { return getObjectID(); }
0125
0126 const podio::ObjectID getObjectID() const;
0127
0128 friend void swap(Vertex& a, Vertex& b) {
0129 using std::swap;
0130 swap(a.m_obj, b.m_obj);
0131 }
0132
0133 private:
0134
0135 explicit Vertex(podio::utils::MaybeSharedPtr<VertexObj> obj);
0136 Vertex(VertexObj* obj);
0137
0138 podio::utils::MaybeSharedPtr<VertexObj> m_obj{nullptr};
0139 };
0140
0141 std::ostream& operator<<(std::ostream& o, const Vertex& value);
0142
0143 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0144 void to_json(nlohmann::json& j, const Vertex& value);
0145 #endif
0146
0147
0148 }
0149
0150
0151 #endif