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