File indexing completed on 2025-09-15 08:55:51
0001
0002
0003 #ifndef EDM4EIC_MutableVertex_H
0004 #define EDM4EIC_MutableVertex_H
0005
0006 #include "edm4eic/VertexObj.h"
0007
0008 #include "edm4eic/Vertex.h"
0009
0010 #include "edm4eic/Cov4f.h"
0011 #include "edm4eic/ReconstructedParticle.h"
0012 #include "edm4hep/Vector4f.h"
0013 #include "podio/RelationRange.h"
0014 #include <cstdint>
0015 #include <vector>
0016
0017 #include "podio/utilities/MaybeSharedPtr.h"
0018
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 edm4eic {
0032
0033
0034
0035
0036
0037
0038 class MutableVertex {
0039
0040 friend class VertexCollection;
0041 friend class VertexMutableCollectionIterator;
0042 friend class Vertex;
0043
0044 public:
0045 using object_type = Vertex;
0046 using collection_type = VertexCollection;
0047
0048
0049 MutableVertex();
0050
0051
0052 MutableVertex(const std::int32_t type, const float chi2, const int ndf, const edm4hep::Vector4f& position, const edm4eic::Cov4f& positionError);
0053
0054
0055 MutableVertex(const MutableVertex& other) = default;
0056
0057
0058 MutableVertex& operator=(MutableVertex other) &;
0059 MutableVertex& operator=(MutableVertex other) && = delete;
0060
0061
0062
0063 MutableVertex clone(bool cloneRelations=true) const;
0064
0065
0066 ~MutableVertex() = default;
0067
0068
0069 public:
0070
0071
0072 std::int32_t getType() const;
0073
0074
0075 float getChi2() const;
0076
0077
0078 int getNdf() const;
0079
0080
0081 const edm4hep::Vector4f& getPosition() const;
0082
0083
0084 const edm4eic::Cov4f& getPositionError() const;
0085
0086
0087
0088
0089 void setType(const std::int32_t type);
0090
0091 std::int32_t& getType();
0092
0093 [[deprecated("use getType instead")]]
0094 std::int32_t& type();
0095
0096
0097 void setChi2(const float chi2);
0098
0099 float& getChi2();
0100
0101 [[deprecated("use getChi2 instead")]]
0102 float& chi2();
0103
0104
0105 void setNdf(const int ndf);
0106
0107 int& getNdf();
0108
0109 [[deprecated("use getNdf instead")]]
0110 int& ndf();
0111
0112
0113 void setPosition(const edm4hep::Vector4f& position);
0114
0115 edm4hep::Vector4f& getPosition();
0116
0117 [[deprecated("use getPosition instead")]]
0118 edm4hep::Vector4f& position();
0119
0120
0121 void setPositionError(const edm4eic::Cov4f& positionError);
0122
0123 edm4eic::Cov4f& getPositionError();
0124
0125 [[deprecated("use getPositionError instead")]]
0126 edm4eic::Cov4f& positionError();
0127
0128
0129
0130 void addToAssociatedParticles(const edm4eic::ReconstructedParticle&);
0131 std::size_t associatedParticles_size() const;
0132 edm4eic::ReconstructedParticle getAssociatedParticles(std::size_t) const;
0133 std::vector<edm4eic::ReconstructedParticle>::const_iterator associatedParticles_begin() const;
0134 std::vector<edm4eic::ReconstructedParticle>::const_iterator associatedParticles_end() const;
0135 podio::RelationRange<edm4eic::ReconstructedParticle> getAssociatedParticles() const;
0136
0137
0138
0139
0140 bool isAvailable() const;
0141
0142 void unlink() { m_obj = podio::utils::MaybeSharedPtr<VertexObj>{nullptr}; }
0143
0144 bool operator==(const MutableVertex& other) const { return m_obj == other.m_obj; }
0145 bool operator==(const Vertex& other) const;
0146
0147 bool operator!=(const MutableVertex& other) const { return !(*this == other); }
0148 bool operator!=(const Vertex& other) const { return !(*this == other); }
0149
0150
0151 bool operator<(const MutableVertex& other) const { return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other); }
0152
0153 podio::ObjectID id() const { return getObjectID(); }
0154
0155 const podio::ObjectID getObjectID() const;
0156
0157 friend std::hash<MutableVertex>;
0158
0159 friend void swap(MutableVertex& a, MutableVertex& b) {
0160 using std::swap;
0161 swap(a.m_obj, b.m_obj);
0162 }
0163
0164 private:
0165
0166 explicit MutableVertex(podio::utils::MaybeSharedPtr<VertexObj> obj);
0167
0168 podio::utils::MaybeSharedPtr<VertexObj> m_obj{nullptr};
0169 };
0170
0171 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0172 void to_json(nlohmann::json& j, const MutableVertex& value);
0173 #endif
0174
0175
0176 }
0177
0178
0179
0180 template<>
0181 struct std::hash<edm4eic::MutableVertex> {
0182 std::size_t operator()(const edm4eic::MutableVertex& obj) const {
0183 return std::hash<edm4eic::VertexObj*>{}(obj.m_obj.get());
0184 }
0185 };
0186
0187
0188 #endif