File indexing completed on 2026-09-02 09:05:44
0001
0002
0003 #ifndef EDM4EIC_MutableMCRecoClusterParticleAssociation_H
0004 #define EDM4EIC_MutableMCRecoClusterParticleAssociation_H
0005
0006 #include "edm4eic/MCRecoClusterParticleAssociationObj.h"
0007
0008 #include "edm4eic/MCRecoClusterParticleAssociation.h"
0009
0010 #include <edm4eic/Cluster.h>
0011 #include <edm4hep/MCParticle.h>
0012
0013 #include "podio/utilities/MaybeSharedPtr.h"
0014
0015 #include <cstdint>
0016
0017 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0018 #include "nlohmann/json_fwd.hpp"
0019 #endif
0020
0021
0022 namespace edm4eic {
0023 class MCRecoClusterParticleAssociationCollection;
0024 class Cluster;
0025 class MutableCluster;
0026 }
0027 namespace edm4hep {
0028 class MCParticle;
0029 class MutableMCParticle;
0030 }
0031
0032
0033 namespace edm4eic {
0034
0035
0036
0037
0038
0039
0040 class MutableMCRecoClusterParticleAssociation {
0041
0042 friend class MCRecoClusterParticleAssociationCollection;
0043 friend class MCRecoClusterParticleAssociationMutableCollectionIterator;
0044 friend class MCRecoClusterParticleAssociation;
0045
0046 public:
0047 using object_type = MCRecoClusterParticleAssociation;
0048 using collection_type = MCRecoClusterParticleAssociationCollection;
0049
0050
0051 MutableMCRecoClusterParticleAssociation() = default;
0052
0053
0054 MutableMCRecoClusterParticleAssociation(const float weight);
0055
0056
0057 MutableMCRecoClusterParticleAssociation(const MutableMCRecoClusterParticleAssociation& other) = default;
0058
0059
0060 MutableMCRecoClusterParticleAssociation& operator=(MutableMCRecoClusterParticleAssociation other) &;
0061 MutableMCRecoClusterParticleAssociation& operator=(MutableMCRecoClusterParticleAssociation other) && = delete;
0062
0063
0064
0065 MutableMCRecoClusterParticleAssociation clone(bool cloneRelations=true) const;
0066
0067
0068 ~MutableMCRecoClusterParticleAssociation() = default;
0069
0070
0071 public:
0072
0073
0074 float getWeight() const;
0075
0076
0077
0078 const edm4eic::Cluster getRec() const;
0079
0080 const edm4hep::MCParticle getSim() const;
0081
0082
0083 void setWeight(const float weight);
0084
0085 float& getWeight();
0086
0087
0088
0089 void setRec(const edm4eic::Cluster& value);
0090
0091 void setSim(const edm4hep::MCParticle& value);
0092
0093
0094 [[deprecated("use getSim().getObjectID().index instead")]] int getSimID() const { return getSim().getObjectID().index; }
0095 [[deprecated("use getRec().getObjectID().index instead")]] int getRecID() const { return getRec().getObjectID().index; }
0096
0097
0098 [[deprecated("use setSim() instead; this function does nothing")]] void setSimID(int) { }
0099 [[deprecated("use setRec() instead; this function does nothing")]] void setRecID(int) { }
0100
0101
0102
0103 bool isAvailable() const;
0104
0105 void unlink() { m_obj = podio::utils::MaybeSharedPtr<MCRecoClusterParticleAssociationObj>{nullptr}; }
0106
0107 constexpr bool operator==(const MutableMCRecoClusterParticleAssociation& other) const { return m_obj == other.m_obj; }
0108 bool operator==(const MCRecoClusterParticleAssociation& other) const;
0109
0110 constexpr bool operator!=(const MutableMCRecoClusterParticleAssociation& other) const { return !(*this == other); }
0111 bool operator!=(const MCRecoClusterParticleAssociation& other) const { return !(*this == other); }
0112
0113
0114 bool operator<(const MutableMCRecoClusterParticleAssociation& other) const { return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other); }
0115
0116 podio::ObjectID id() const { return getObjectID(); }
0117
0118 const podio::ObjectID getObjectID() const;
0119
0120 friend std::hash<MutableMCRecoClusterParticleAssociation>;
0121
0122 friend void swap(MutableMCRecoClusterParticleAssociation& a, MutableMCRecoClusterParticleAssociation& b) {
0123 using std::swap;
0124 swap(a.m_obj, b.m_obj);
0125 }
0126
0127 private:
0128
0129 explicit MutableMCRecoClusterParticleAssociation(podio::utils::MaybeSharedPtr<MCRecoClusterParticleAssociationObj> obj);
0130
0131 podio::utils::MaybeSharedPtr<MCRecoClusterParticleAssociationObj> m_obj{new MCRecoClusterParticleAssociationObj{}, podio::utils::MarkOwned};
0132 };
0133
0134 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0135 void to_json(nlohmann::json& j, const MutableMCRecoClusterParticleAssociation& value);
0136 #endif
0137
0138
0139 }
0140
0141
0142
0143 template<>
0144 struct std::hash<edm4eic::MutableMCRecoClusterParticleAssociation> {
0145 std::size_t operator()(const edm4eic::MutableMCRecoClusterParticleAssociation& obj) const {
0146 return std::hash<edm4eic::MCRecoClusterParticleAssociationObj*>{}(obj.m_obj.get());
0147 }
0148 };
0149
0150
0151 #endif