File indexing completed on 2025-01-18 09:55:37
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 namespace edm4hep {
0023
0024
0025
0026
0027
0028 class MutableParticleID {
0029
0030 friend class ParticleIDCollection;
0031 friend class ParticleIDMutableCollectionIterator;
0032 friend class ParticleID;
0033
0034 public:
0035 using object_type = ParticleID;
0036 using collection_type = ParticleIDCollection;
0037
0038
0039 MutableParticleID();
0040
0041
0042 MutableParticleID(std::int32_t type, std::int32_t PDG, std::int32_t algorithmType, float likelihood);
0043
0044
0045 MutableParticleID(const MutableParticleID& other) = default;
0046
0047
0048 MutableParticleID& operator=(MutableParticleID other);
0049
0050
0051
0052 MutableParticleID clone(bool cloneRelations = true) const;
0053
0054
0055 ~MutableParticleID() = default;
0056
0057 public:
0058
0059 std::int32_t getType() const;
0060
0061
0062 std::int32_t getPDG() const;
0063
0064
0065 std::int32_t getAlgorithmType() const;
0066
0067
0068 float getLikelihood() const;
0069
0070
0071 void setType(std::int32_t value);
0072
0073 std::int32_t& getType();
0074
0075 [[deprecated("use getType instead")]] std::int32_t& type();
0076
0077
0078 void setPDG(std::int32_t value);
0079
0080 std::int32_t& getPDG();
0081
0082 [[deprecated("use getPDG instead")]] std::int32_t& PDG();
0083
0084
0085 void setAlgorithmType(std::int32_t value);
0086
0087 std::int32_t& getAlgorithmType();
0088
0089 [[deprecated("use getAlgorithmType instead")]] std::int32_t& algorithmType();
0090
0091
0092 void setLikelihood(float value);
0093
0094 float& getLikelihood();
0095
0096 [[deprecated("use getLikelihood instead")]] float& likelihood();
0097
0098 void addToParameters(const float&);
0099 std::size_t parameters_size() const;
0100 float getParameters(std::size_t) const;
0101 std::vector<float>::const_iterator parameters_begin() const;
0102 std::vector<float>::const_iterator parameters_end() const;
0103 podio::RelationRange<float> getParameters() const;
0104
0105
0106 bool isAvailable() const;
0107
0108 void unlink() {
0109 m_obj = podio::utils::MaybeSharedPtr<ParticleIDObj>{nullptr};
0110 }
0111
0112 bool operator==(const MutableParticleID& other) const {
0113 return m_obj == other.m_obj;
0114 }
0115 bool operator==(const ParticleID& other) const;
0116
0117 bool operator!=(const MutableParticleID& other) const {
0118 return !(*this == other);
0119 }
0120 bool operator!=(const ParticleID& other) const {
0121 return !(*this == other);
0122 }
0123
0124
0125 bool operator<(const MutableParticleID& other) const {
0126 return m_obj < other.m_obj;
0127 }
0128
0129 podio::ObjectID id() const {
0130 return getObjectID();
0131 }
0132
0133 const podio::ObjectID getObjectID() const;
0134
0135 friend void swap(MutableParticleID& a, MutableParticleID& b) {
0136 using std::swap;
0137 swap(a.m_obj, b.m_obj);
0138 }
0139
0140 private:
0141
0142 explicit MutableParticleID(podio::utils::MaybeSharedPtr<ParticleIDObj> obj);
0143
0144 podio::utils::MaybeSharedPtr<ParticleIDObj> m_obj{nullptr};
0145 };
0146
0147 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0148 void to_json(nlohmann::json& j, const MutableParticleID& value);
0149 #endif
0150
0151 }
0152
0153 #endif