File indexing completed on 2025-07-11 08:30: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();
0047
0048
0049 MutableParticleID(std::int32_t type, std::int32_t PDG, std::int32_t algorithmType, float likelihood);
0050
0051
0052 MutableParticleID(const MutableParticleID& other) = default;
0053
0054
0055 MutableParticleID& operator=(MutableParticleID other);
0056
0057
0058
0059 MutableParticleID clone(bool cloneRelations = true) const;
0060
0061
0062 ~MutableParticleID() = default;
0063
0064 public:
0065
0066 std::int32_t getType() const;
0067
0068
0069 std::int32_t getPDG() const;
0070
0071
0072 std::int32_t getAlgorithmType() const;
0073
0074
0075 float getLikelihood() const;
0076
0077
0078 const edm4hep::ReconstructedParticle getParticle() const;
0079
0080
0081 void setType(std::int32_t value);
0082
0083 std::int32_t& getType();
0084
0085 [[deprecated("use getType instead")]] std::int32_t& type();
0086
0087
0088 void setPDG(std::int32_t value);
0089
0090 std::int32_t& getPDG();
0091
0092 [[deprecated("use getPDG instead")]] std::int32_t& PDG();
0093
0094
0095 void setAlgorithmType(std::int32_t value);
0096
0097 std::int32_t& getAlgorithmType();
0098
0099 [[deprecated("use getAlgorithmType instead")]] std::int32_t& algorithmType();
0100
0101
0102 void setLikelihood(float value);
0103
0104 float& getLikelihood();
0105
0106 [[deprecated("use getLikelihood instead")]] float& likelihood();
0107
0108
0109 void setParticle(const edm4hep::ReconstructedParticle& value);
0110
0111 void addToParameters(const float&);
0112 std::size_t parameters_size() const;
0113 float getParameters(std::size_t) const;
0114 std::vector<float>::const_iterator parameters_begin() const;
0115 std::vector<float>::const_iterator parameters_end() const;
0116 podio::RelationRange<float> getParameters() const;
0117
0118
0119 bool isAvailable() const;
0120
0121 void unlink() {
0122 m_obj = podio::utils::MaybeSharedPtr<ParticleIDObj>{nullptr};
0123 }
0124
0125 bool operator==(const MutableParticleID& other) const {
0126 return m_obj == other.m_obj;
0127 }
0128 bool operator==(const ParticleID& other) const;
0129
0130 bool operator!=(const MutableParticleID& other) const {
0131 return !(*this == other);
0132 }
0133 bool operator!=(const ParticleID& other) const {
0134 return !(*this == other);
0135 }
0136
0137
0138 bool operator<(const MutableParticleID& other) const {
0139 return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other);
0140 }
0141
0142 podio::ObjectID id() const {
0143 return getObjectID();
0144 }
0145
0146 const podio::ObjectID getObjectID() const;
0147
0148 friend void swap(MutableParticleID& a, MutableParticleID& b) {
0149 using std::swap;
0150 swap(a.m_obj, b.m_obj);
0151 }
0152
0153 private:
0154
0155 explicit MutableParticleID(podio::utils::MaybeSharedPtr<ParticleIDObj> obj);
0156
0157 podio::utils::MaybeSharedPtr<ParticleIDObj> m_obj{nullptr};
0158 };
0159
0160 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0161 void to_json(nlohmann::json& j, const MutableParticleID& value);
0162 #endif
0163
0164 }
0165
0166 #endif