File indexing completed on 2026-11-17 10:09:21
0001
0002
0003 #ifndef EDM4EIC_MutableMCRecoParticleAssociation_H
0004 #define EDM4EIC_MutableMCRecoParticleAssociation_H
0005
0006 #include "edm4eic/MCRecoParticleAssociationObj.h"
0007
0008 #include "edm4eic/MCRecoParticleAssociation.h"
0009
0010 #include <edm4eic/ReconstructedParticle.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 MCRecoParticleAssociationCollection;
0024 class ReconstructedParticle;
0025 class MutableReconstructedParticle;
0026 }
0027 namespace edm4hep {
0028 class MCParticle;
0029 class MutableMCParticle;
0030 }
0031
0032
0033 namespace edm4eic {
0034
0035
0036
0037
0038
0039
0040 class MutableMCRecoParticleAssociation {
0041
0042 friend class MCRecoParticleAssociationCollection;
0043 friend class MCRecoParticleAssociationMutableCollectionIterator;
0044 friend class MCRecoParticleAssociation;
0045
0046 public:
0047 using object_type = MCRecoParticleAssociation;
0048 using collection_type = MCRecoParticleAssociationCollection;
0049
0050
0051 MutableMCRecoParticleAssociation() = default;
0052
0053
0054 MutableMCRecoParticleAssociation(const float weight);
0055
0056
0057 MutableMCRecoParticleAssociation(const MutableMCRecoParticleAssociation& other) = default;
0058
0059
0060 MutableMCRecoParticleAssociation& operator=(MutableMCRecoParticleAssociation other) &;
0061 MutableMCRecoParticleAssociation& operator=(MutableMCRecoParticleAssociation other) && = delete;
0062
0063
0064
0065 MutableMCRecoParticleAssociation clone(bool cloneRelations=true) const;
0066
0067
0068 ~MutableMCRecoParticleAssociation() = default;
0069
0070
0071 public:
0072
0073
0074 float getWeight() const;
0075
0076
0077
0078 const edm4eic::ReconstructedParticle 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::ReconstructedParticle& 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<MCRecoParticleAssociationObj>{nullptr}; }
0106
0107 constexpr bool operator==(const MutableMCRecoParticleAssociation& other) const { return m_obj == other.m_obj; }
0108 bool operator==(const MCRecoParticleAssociation& other) const;
0109
0110 constexpr bool operator!=(const MutableMCRecoParticleAssociation& other) const { return !(*this == other); }
0111 bool operator!=(const MCRecoParticleAssociation& other) const { return !(*this == other); }
0112
0113
0114 bool operator<(const MutableMCRecoParticleAssociation& 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<MutableMCRecoParticleAssociation>;
0121
0122 friend void swap(MutableMCRecoParticleAssociation& a, MutableMCRecoParticleAssociation& b) {
0123 using std::swap;
0124 swap(a.m_obj, b.m_obj);
0125 }
0126
0127 private:
0128
0129 explicit MutableMCRecoParticleAssociation(podio::utils::MaybeSharedPtr<MCRecoParticleAssociationObj> obj);
0130
0131 podio::utils::MaybeSharedPtr<MCRecoParticleAssociationObj> m_obj{new MCRecoParticleAssociationObj{}, podio::utils::MarkOwned};
0132 };
0133
0134 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0135 void to_json(nlohmann::json& j, const MutableMCRecoParticleAssociation& value);
0136 #endif
0137
0138
0139 }
0140
0141
0142
0143 template<>
0144 struct std::hash<edm4eic::MutableMCRecoParticleAssociation> {
0145 std::size_t operator()(const edm4eic::MutableMCRecoParticleAssociation& obj) const {
0146 return std::hash<edm4eic::MCRecoParticleAssociationObj*>{}(obj.m_obj.get());
0147 }
0148 };
0149
0150
0151 #endif