File indexing completed on 2026-05-04 08:36:55
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 [[deprecated("use getWeight instead")]]
0088 float& weight();
0089
0090
0091
0092 void setRec(const edm4eic::Cluster& value);
0093
0094 void setSim(const edm4hep::MCParticle& value);
0095
0096
0097 [[deprecated("use getSim().getObjectID().index instead")]] int getSimID() const { return getSim().getObjectID().index; }
0098 [[deprecated("use getRec().getObjectID().index instead")]] int getRecID() const { return getRec().getObjectID().index; }
0099
0100
0101 [[deprecated("use setSim() instead; this function does nothing")]] void setSimID(int) { }
0102 [[deprecated("use setRec() instead; this function does nothing")]] void setRecID(int) { }
0103
0104
0105
0106 bool isAvailable() const;
0107
0108 void unlink() { m_obj = podio::utils::MaybeSharedPtr<MCRecoClusterParticleAssociationObj>{nullptr}; }
0109
0110 bool operator==(const MutableMCRecoClusterParticleAssociation& other) const { return m_obj == other.m_obj; }
0111 bool operator==(const MCRecoClusterParticleAssociation& other) const;
0112
0113 bool operator!=(const MutableMCRecoClusterParticleAssociation& other) const { return !(*this == other); }
0114 bool operator!=(const MCRecoClusterParticleAssociation& other) const { return !(*this == other); }
0115
0116
0117 bool operator<(const MutableMCRecoClusterParticleAssociation& other) const { return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other); }
0118
0119 podio::ObjectID id() const { return getObjectID(); }
0120
0121 const podio::ObjectID getObjectID() const;
0122
0123 friend std::hash<MutableMCRecoClusterParticleAssociation>;
0124
0125 friend void swap(MutableMCRecoClusterParticleAssociation& a, MutableMCRecoClusterParticleAssociation& b) {
0126 using std::swap;
0127 swap(a.m_obj, b.m_obj);
0128 }
0129
0130 private:
0131
0132 explicit MutableMCRecoClusterParticleAssociation(podio::utils::MaybeSharedPtr<MCRecoClusterParticleAssociationObj> obj);
0133
0134 podio::utils::MaybeSharedPtr<MCRecoClusterParticleAssociationObj> m_obj{new MCRecoClusterParticleAssociationObj{}, podio::utils::MarkOwned};
0135 };
0136
0137 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0138 void to_json(nlohmann::json& j, const MutableMCRecoClusterParticleAssociation& value);
0139 #endif
0140
0141
0142 }
0143
0144
0145
0146 template<>
0147 struct std::hash<edm4eic::MutableMCRecoClusterParticleAssociation> {
0148 std::size_t operator()(const edm4eic::MutableMCRecoClusterParticleAssociation& obj) const {
0149 return std::hash<edm4eic::MCRecoClusterParticleAssociationObj*>{}(obj.m_obj.get());
0150 }
0151 };
0152
0153
0154 #endif