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