File indexing completed on 2025-06-03 08:33:26
0001
0002
0003 #ifndef EDM4HEP_RecoMCParticleLink_H
0004 #define EDM4HEP_RecoMCParticleLink_H
0005
0006 #include "edm4hep/RecoMCParticleLinkObj.h"
0007
0008 #include "podio/detail/OrderKey.h"
0009 #include "podio/utilities/MaybeSharedPtr.h"
0010
0011 #include <cstdint>
0012 #include <ostream>
0013
0014 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0015 #include "nlohmann/json_fwd.hpp"
0016 #endif
0017
0018
0019 namespace edm4hep {
0020 class RecoMCParticleLinkCollection;
0021 class ReconstructedParticle;
0022 class MutableReconstructedParticle;
0023 class MCParticle;
0024 class MutableMCParticle;
0025 }
0026
0027 namespace podio::detail {
0028
0029 OrderKey getOrderKey(const edm4hep::RecoMCParticleLink& obj);
0030 };
0031
0032 namespace edm4hep {
0033
0034 class MutableRecoMCParticleLink;
0035 class RecoMCParticleLinkCollection;
0036 class RecoMCParticleLinkCollectionData;
0037
0038
0039
0040
0041
0042 class RecoMCParticleLink {
0043
0044 friend class MutableRecoMCParticleLink;
0045 friend class RecoMCParticleLinkCollection;
0046 friend class edm4hep::RecoMCParticleLinkCollectionData;
0047 friend class RecoMCParticleLinkCollectionIterator;
0048 friend podio::detail::OrderKey podio::detail::getOrderKey(const RecoMCParticleLink& obj);
0049
0050 public:
0051 using mutable_type = MutableRecoMCParticleLink;
0052 using collection_type = RecoMCParticleLinkCollection;
0053
0054
0055 RecoMCParticleLink();
0056
0057
0058 RecoMCParticleLink(float weight);
0059
0060
0061 RecoMCParticleLink(const RecoMCParticleLink& other) = default;
0062
0063
0064 RecoMCParticleLink& operator=(RecoMCParticleLink other);
0065
0066
0067
0068 MutableRecoMCParticleLink clone(bool cloneRelations = true) const;
0069
0070
0071 ~RecoMCParticleLink() = default;
0072
0073
0074 RecoMCParticleLink(const MutableRecoMCParticleLink& other);
0075
0076 static RecoMCParticleLink makeEmpty();
0077
0078 public:
0079 static constexpr auto typeName = "edm4hep::RecoMCParticleLink";
0080
0081
0082 float getWeight() const;
0083
0084
0085 const edm4hep::ReconstructedParticle getFrom() const;
0086
0087 const edm4hep::MCParticle getTo() const;
0088
0089 [[deprecated("use getFrom instead")]] edm4hep::ReconstructedParticle getRec() const;
0090 [[deprecated("use getTo instead")]] edm4hep::MCParticle getSim() const;
0091
0092
0093 bool isAvailable() const;
0094
0095 void unlink() {
0096 m_obj = podio::utils::MaybeSharedPtr<RecoMCParticleLinkObj>{nullptr};
0097 }
0098
0099 bool operator==(const RecoMCParticleLink& other) const {
0100 return m_obj == other.m_obj;
0101 }
0102 bool operator==(const MutableRecoMCParticleLink& other) const;
0103
0104 bool operator!=(const RecoMCParticleLink& other) const {
0105 return !(*this == other);
0106 }
0107 bool operator!=(const MutableRecoMCParticleLink& other) const {
0108 return !(*this == other);
0109 }
0110
0111
0112 bool operator<(const RecoMCParticleLink& other) const {
0113 return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other);
0114 }
0115
0116 podio::ObjectID id() const {
0117 return getObjectID();
0118 }
0119
0120 const podio::ObjectID getObjectID() const;
0121
0122 friend void swap(RecoMCParticleLink& a, RecoMCParticleLink& b) {
0123 using std::swap;
0124 swap(a.m_obj, b.m_obj);
0125 }
0126
0127 private:
0128
0129 explicit RecoMCParticleLink(podio::utils::MaybeSharedPtr<RecoMCParticleLinkObj> obj);
0130 RecoMCParticleLink(RecoMCParticleLinkObj* obj);
0131
0132 podio::utils::MaybeSharedPtr<RecoMCParticleLinkObj> m_obj{nullptr};
0133 };
0134
0135 std::ostream& operator<<(std::ostream& o, const RecoMCParticleLink& value);
0136
0137 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0138 void to_json(nlohmann::json& j, const RecoMCParticleLink& value);
0139 #endif
0140
0141 }
0142
0143 #endif