File indexing completed on 2025-01-18 09:55:38
0001
0002
0003 #ifndef EDM4HEP_MutableVertex_H
0004 #define EDM4HEP_MutableVertex_H
0005
0006 #include "edm4hep/VertexObj.h"
0007
0008 #include "edm4hep/Vertex.h"
0009
0010 #include "edm4hep/Vector3f.h"
0011 #include "podio/RelationRange.h"
0012 #include <array>
0013 #include <cstdint>
0014 #include <vector>
0015
0016 #include "podio/utilities/MaybeSharedPtr.h"
0017
0018 #include <cstdint>
0019
0020 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0021 #include "nlohmann/json_fwd.hpp"
0022 #endif
0023
0024
0025 namespace edm4hep {
0026 class ReconstructedParticle;
0027 class MutableReconstructedParticle;
0028 }
0029
0030 namespace edm4hep {
0031
0032
0033
0034
0035
0036 class MutableVertex {
0037
0038 friend class VertexCollection;
0039 friend class VertexMutableCollectionIterator;
0040 friend class Vertex;
0041
0042 public:
0043 using object_type = Vertex;
0044 using collection_type = VertexCollection;
0045
0046
0047 MutableVertex();
0048
0049
0050 MutableVertex(std::int32_t primary, float chi2, float probability, edm4hep::Vector3f position,
0051 std::array<float, 6> covMatrix, std::int32_t algorithmType);
0052
0053
0054 MutableVertex(const MutableVertex& other) = default;
0055
0056
0057 MutableVertex& operator=(MutableVertex other);
0058
0059
0060
0061 MutableVertex clone(bool cloneRelations = true) const;
0062
0063
0064 ~MutableVertex() = default;
0065
0066 public:
0067
0068 std::int32_t getPrimary() const;
0069
0070
0071 float getChi2() const;
0072
0073
0074 float getProbability() const;
0075
0076
0077 const edm4hep::Vector3f& getPosition() const;
0078
0079
0080
0081 const std::array<float, 6>& getCovMatrix() const;
0082
0083
0084 float getCovMatrix(size_t i) const;
0085
0086
0087 std::int32_t getAlgorithmType() const;
0088
0089
0090 const edm4hep::ReconstructedParticle getAssociatedParticle() const;
0091
0092
0093 void setPrimary(std::int32_t value);
0094
0095 std::int32_t& getPrimary();
0096
0097 [[deprecated("use getPrimary instead")]] std::int32_t& primary();
0098
0099
0100 void setChi2(float value);
0101
0102 float& getChi2();
0103
0104 [[deprecated("use getChi2 instead")]] float& chi2();
0105
0106
0107 void setProbability(float value);
0108
0109 float& getProbability();
0110
0111 [[deprecated("use getProbability instead")]] float& probability();
0112
0113
0114 void setPosition(edm4hep::Vector3f value);
0115
0116 edm4hep::Vector3f& getPosition();
0117
0118 [[deprecated("use getPosition instead")]] edm4hep::Vector3f& position();
0119
0120
0121
0122 void setCovMatrix(std::array<float, 6> value);
0123 void setCovMatrix(size_t i, float value);
0124
0125
0126 std::array<float, 6>& getCovMatrix();
0127
0128
0129 [[deprecated("use getCovMatrix instead")]] std::array<float, 6>& covMatrix();
0130
0131
0132
0133 void setAlgorithmType(std::int32_t value);
0134
0135
0136 std::int32_t& getAlgorithmType();
0137
0138
0139 [[deprecated("use getAlgorithmType instead")]] std::int32_t& algorithmType();
0140
0141
0142 void setAssociatedParticle(const edm4hep::ReconstructedParticle& value);
0143
0144 void addToParameters(const float&);
0145 std::size_t parameters_size() const;
0146 float getParameters(std::size_t) const;
0147 std::vector<float>::const_iterator parameters_begin() const;
0148 std::vector<float>::const_iterator parameters_end() const;
0149 podio::RelationRange<float> getParameters() const;
0150
0151
0152 bool isAvailable() const;
0153
0154 void unlink() {
0155 m_obj = podio::utils::MaybeSharedPtr<VertexObj>{nullptr};
0156 }
0157
0158 bool operator==(const MutableVertex& other) const {
0159 return m_obj == other.m_obj;
0160 }
0161 bool operator==(const Vertex& other) const;
0162
0163 bool operator!=(const MutableVertex& other) const {
0164 return !(*this == other);
0165 }
0166 bool operator!=(const Vertex& other) const {
0167 return !(*this == other);
0168 }
0169
0170
0171 bool operator<(const MutableVertex& other) const {
0172 return m_obj < other.m_obj;
0173 }
0174
0175 podio::ObjectID id() const {
0176 return getObjectID();
0177 }
0178
0179 const podio::ObjectID getObjectID() const;
0180
0181 friend void swap(MutableVertex& a, MutableVertex& b) {
0182 using std::swap;
0183 swap(a.m_obj, b.m_obj);
0184 }
0185
0186 private:
0187
0188 explicit MutableVertex(podio::utils::MaybeSharedPtr<VertexObj> obj);
0189
0190 podio::utils::MaybeSharedPtr<VertexObj> m_obj{nullptr};
0191 };
0192
0193 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0194 void to_json(nlohmann::json& j, const MutableVertex& value);
0195 #endif
0196
0197 }
0198
0199 #endif