File indexing completed on 2025-06-03 08:33:22
0001
0002
0003 #ifndef EDM4HEP_CaloHitMCParticleLink_H
0004 #define EDM4HEP_CaloHitMCParticleLink_H
0005
0006 #include "edm4hep/CaloHitMCParticleLinkObj.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 CaloHitMCParticleLinkCollection;
0021 class CalorimeterHit;
0022 class MutableCalorimeterHit;
0023 class MCParticle;
0024 class MutableMCParticle;
0025 }
0026
0027 namespace podio::detail {
0028
0029 OrderKey getOrderKey(const edm4hep::CaloHitMCParticleLink& obj);
0030 };
0031
0032 namespace edm4hep {
0033
0034 class MutableCaloHitMCParticleLink;
0035 class CaloHitMCParticleLinkCollection;
0036 class CaloHitMCParticleLinkCollectionData;
0037
0038
0039
0040
0041
0042 class CaloHitMCParticleLink {
0043
0044 friend class MutableCaloHitMCParticleLink;
0045 friend class CaloHitMCParticleLinkCollection;
0046 friend class edm4hep::CaloHitMCParticleLinkCollectionData;
0047 friend class CaloHitMCParticleLinkCollectionIterator;
0048 friend podio::detail::OrderKey podio::detail::getOrderKey(const CaloHitMCParticleLink& obj);
0049
0050 public:
0051 using mutable_type = MutableCaloHitMCParticleLink;
0052 using collection_type = CaloHitMCParticleLinkCollection;
0053
0054
0055 CaloHitMCParticleLink();
0056
0057
0058 CaloHitMCParticleLink(float weight);
0059
0060
0061 CaloHitMCParticleLink(const CaloHitMCParticleLink& other) = default;
0062
0063
0064 CaloHitMCParticleLink& operator=(CaloHitMCParticleLink other);
0065
0066
0067
0068 MutableCaloHitMCParticleLink clone(bool cloneRelations = true) const;
0069
0070
0071 ~CaloHitMCParticleLink() = default;
0072
0073
0074 CaloHitMCParticleLink(const MutableCaloHitMCParticleLink& other);
0075
0076 static CaloHitMCParticleLink makeEmpty();
0077
0078 public:
0079 static constexpr auto typeName = "edm4hep::CaloHitMCParticleLink";
0080
0081
0082 float getWeight() const;
0083
0084
0085 const edm4hep::CalorimeterHit getFrom() const;
0086
0087 const edm4hep::MCParticle getTo() const;
0088
0089 [[deprecated("use getFrom instead")]] edm4hep::CalorimeterHit 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<CaloHitMCParticleLinkObj>{nullptr};
0097 }
0098
0099 bool operator==(const CaloHitMCParticleLink& other) const {
0100 return m_obj == other.m_obj;
0101 }
0102 bool operator==(const MutableCaloHitMCParticleLink& other) const;
0103
0104 bool operator!=(const CaloHitMCParticleLink& other) const {
0105 return !(*this == other);
0106 }
0107 bool operator!=(const MutableCaloHitMCParticleLink& other) const {
0108 return !(*this == other);
0109 }
0110
0111
0112 bool operator<(const CaloHitMCParticleLink& 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(CaloHitMCParticleLink& a, CaloHitMCParticleLink& b) {
0123 using std::swap;
0124 swap(a.m_obj, b.m_obj);
0125 }
0126
0127 private:
0128
0129 explicit CaloHitMCParticleLink(podio::utils::MaybeSharedPtr<CaloHitMCParticleLinkObj> obj);
0130 CaloHitMCParticleLink(CaloHitMCParticleLinkObj* obj);
0131
0132 podio::utils::MaybeSharedPtr<CaloHitMCParticleLinkObj> m_obj{nullptr};
0133 };
0134
0135 std::ostream& operator<<(std::ostream& o, const CaloHitMCParticleLink& value);
0136
0137 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0138 void to_json(nlohmann::json& j, const CaloHitMCParticleLink& value);
0139 #endif
0140
0141 }
0142
0143 #endif