File indexing completed on 2026-11-18 10:28:14
0001
0002
0003 #ifndef EDM4HEP_MutableParticleID_H
0004 #define EDM4HEP_MutableParticleID_H
0005
0006 #include "edm4hep/ParticleIDObj.h"
0007
0008 #include "edm4hep/ParticleID.h"
0009
0010 #include "podio/RelationRange.h"
0011 #include <cstdint>
0012 #include <vector>
0013
0014 #include "podio/utilities/MaybeSharedPtr.h"
0015
0016 #include <cstdint>
0017
0018 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0019 #include "nlohmann/json_fwd.hpp"
0020 #endif
0021
0022
0023 namespace edm4hep {
0024 class ParticleIDCollection;
0025 class ReconstructedParticle;
0026 class MutableReconstructedParticle;
0027 }
0028
0029 namespace edm4hep {
0030
0031
0032
0033
0034
0035 class MutableParticleID {
0036
0037 friend class ParticleIDCollection;
0038 friend class ParticleIDMutableCollectionIterator;
0039 friend class ParticleID;
0040
0041 public:
0042 using object_type = ParticleID;
0043 using collection_type = ParticleIDCollection;
0044
0045
0046 MutableParticleID() = default;
0047
0048
0049 MutableParticleID(const std::int32_t type, const std::int32_t PDG, const std::int32_t algorithmType,
0050 const float likelihood);
0051
0052
0053 MutableParticleID(const MutableParticleID& other) noexcept = default;
0054
0055
0056 MutableParticleID(MutableParticleID&& other) noexcept = default;
0057
0058
0059 MutableParticleID& operator=(MutableParticleID other) &;
0060 MutableParticleID&
0061 operator=(MutableParticleID other) && = delete;
0062
0063
0064
0065 MutableParticleID clone(bool cloneRelations = true) const;
0066
0067
0068 ~MutableParticleID() = default;
0069
0070 public:
0071
0072 std::int32_t getType() const;
0073
0074
0075 std::int32_t getPDG() const;
0076
0077
0078 std::int32_t getAlgorithmType() const;
0079
0080
0081 float getLikelihood() const;
0082
0083
0084 const edm4hep::ReconstructedParticle getParticle() const;
0085
0086
0087 void setType(const std::int32_t type);
0088
0089 std::int32_t& getType();
0090
0091
0092 void setPDG(const std::int32_t PDG);
0093
0094 std::int32_t& getPDG();
0095
0096
0097 void setAlgorithmType(const std::int32_t algorithmType);
0098
0099 std::int32_t& getAlgorithmType();
0100
0101
0102 void setLikelihood(const float likelihood);
0103
0104 float& getLikelihood();
0105
0106
0107 void setParticle(const edm4hep::ReconstructedParticle& value);
0108
0109 void addToParameters(const float&);
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 bool isAvailable() const;
0118
0119 void unlink() { m_obj = podio::utils::MaybeSharedPtr<ParticleIDObj>{nullptr}; }
0120
0121 constexpr bool operator==(const MutableParticleID& other) const { return m_obj == other.m_obj; }
0122 bool operator==(const ParticleID& other) const;
0123
0124 constexpr bool operator!=(const MutableParticleID& other) const { return !(*this == other); }
0125 bool operator!=(const ParticleID& other) const { return !(*this == other); }
0126
0127
0128 bool operator<(const MutableParticleID& other) const {
0129 return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other);
0130 }
0131
0132 podio::ObjectID id() const { return getObjectID(); }
0133
0134 const podio::ObjectID getObjectID() const;
0135
0136 friend std::hash<MutableParticleID>;
0137
0138 friend void swap(MutableParticleID& a, MutableParticleID& b) {
0139 using std::swap;
0140 swap(a.m_obj, b.m_obj);
0141 }
0142
0143 private:
0144
0145 explicit MutableParticleID(podio::utils::MaybeSharedPtr<ParticleIDObj> obj);
0146
0147 podio::utils::MaybeSharedPtr<ParticleIDObj> m_obj{new ParticleIDObj{}, podio::utils::MarkOwned};
0148 };
0149
0150 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0151 void to_json(nlohmann::json& j, const MutableParticleID& value);
0152 #endif
0153
0154 }
0155
0156 template <>
0157 struct std::hash<edm4hep::MutableParticleID> {
0158 std::size_t operator()(const edm4hep::MutableParticleID& obj) const {
0159 return std::hash<edm4hep::ParticleIDObj*>{}(obj.m_obj.get());
0160 }
0161 };
0162
0163 #endif