File indexing completed on 2025-07-13 08:31:30
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 "podio/RelationRange.h"
0012 #include <cstdint>
0013 #include <edm4hep/Constants.h>
0014 #include <edm4hep/utils/bit_utils.h>
0015 #include <vector>
0016
0017 #include "podio/detail/OrderKey.h"
0018 #include "podio/utilities/MaybeSharedPtr.h"
0019
0020 #include <cstdint>
0021 #include <ostream>
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 namespace podio::detail {
0033
0034 OrderKey getOrderKey(const edm4hep::Vertex& obj);
0035 };
0036
0037 namespace edm4hep {
0038
0039 class MutableVertex;
0040 class VertexCollection;
0041 class VertexCollectionData;
0042
0043
0044
0045
0046
0047 class Vertex {
0048
0049 friend class MutableVertex;
0050 friend class VertexCollection;
0051 friend class edm4hep::VertexCollectionData;
0052 friend class VertexCollectionIterator;
0053 friend podio::detail::OrderKey podio::detail::getOrderKey(const Vertex& obj);
0054
0055 public:
0056 using mutable_type = MutableVertex;
0057 using collection_type = VertexCollection;
0058
0059
0060 Vertex();
0061
0062
0063 Vertex(std::uint32_t type, float chi2, std::int32_t ndf, edm4hep::Vector3f position, edm4hep::CovMatrix3f covMatrix,
0064 std::int32_t algorithmType);
0065
0066
0067 Vertex(const Vertex& other) = default;
0068
0069
0070 Vertex& operator=(Vertex other);
0071
0072
0073
0074 MutableVertex clone(bool cloneRelations = true) const;
0075
0076
0077 ~Vertex() = default;
0078
0079
0080 Vertex(const MutableVertex& other);
0081
0082 static Vertex makeEmpty();
0083
0084 public:
0085 static constexpr auto typeName = "edm4hep::Vertex";
0086
0087
0088 std::uint32_t getType() const;
0089
0090
0091 float getChi2() const;
0092
0093
0094 std::int32_t getNdf() const;
0095
0096
0097 const edm4hep::Vector3f& getPosition() const;
0098
0099
0100 const edm4hep::CovMatrix3f& getCovMatrix() const;
0101
0102
0103 std::int32_t getAlgorithmType() const;
0104
0105 std::size_t particles_size() const;
0106 edm4hep::ReconstructedParticle getParticles(std::size_t) const;
0107 std::vector<edm4hep::ReconstructedParticle>::const_iterator particles_begin() const;
0108 std::vector<edm4hep::ReconstructedParticle>::const_iterator particles_end() const;
0109 podio::RelationRange<edm4hep::ReconstructedParticle> getParticles() const;
0110 std::size_t parameters_size() const;
0111 float getParameters(std::size_t) const;
0112 std::vector<float>::const_iterator parameters_begin() const;
0113 std::vector<float>::const_iterator parameters_end() const;
0114 podio::RelationRange<float> getParameters() const;
0115
0116
0117 float getCovMatrix(edm4hep::Cartesian dimI, edm4hep::Cartesian dimJ) const {
0118 return getCovMatrix().getValue(dimI, dimJ);
0119 }
0120
0121 static constexpr int BITPrimaryVertex = 1;
0122 static constexpr int BITSecondaryVertex = 2;
0123 static constexpr int BITTertiaryVertex = 2;
0124
0125
0126 bool isPrimary() const {
0127 return utils::checkBit(getType(), BITPrimaryVertex);
0128 }
0129
0130 bool isSecondary() const {
0131 return utils::checkBit(getType(), BITSecondaryVertex);
0132 }
0133
0134 bool isTertiary() const {
0135 return utils::checkBit(getType(), BITTertiaryVertex);
0136 }
0137
0138
0139 bool isAvailable() const;
0140
0141 void unlink() {
0142 m_obj = podio::utils::MaybeSharedPtr<VertexObj>{nullptr};
0143 }
0144
0145 bool operator==(const Vertex& other) const {
0146 return m_obj == other.m_obj;
0147 }
0148 bool operator==(const MutableVertex& other) const;
0149
0150 bool operator!=(const Vertex& other) const {
0151 return !(*this == other);
0152 }
0153 bool operator!=(const MutableVertex& other) const {
0154 return !(*this == other);
0155 }
0156
0157
0158 bool operator<(const Vertex& other) const {
0159 return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other);
0160 }
0161
0162 podio::ObjectID id() const {
0163 return getObjectID();
0164 }
0165
0166 const podio::ObjectID getObjectID() const;
0167
0168 friend void swap(Vertex& a, Vertex& b) {
0169 using std::swap;
0170 swap(a.m_obj, b.m_obj);
0171 }
0172
0173 private:
0174
0175 explicit Vertex(podio::utils::MaybeSharedPtr<VertexObj> obj);
0176 Vertex(VertexObj* obj);
0177
0178 podio::utils::MaybeSharedPtr<VertexObj> m_obj{nullptr};
0179 };
0180
0181 std::ostream& operator<<(std::ostream& o, const Vertex& value);
0182
0183 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0184 void to_json(nlohmann::json& j, const Vertex& value);
0185 #endif
0186
0187 }
0188
0189 #endif