File indexing completed on 2026-12-02 10:00:30
0001
0002
0003 #ifndef EDM4EIC_MCRecoTrackParticleAssociation_H
0004 #define EDM4EIC_MCRecoTrackParticleAssociation_H
0005
0006 #include "edm4eic/MCRecoTrackParticleAssociationObj.h"
0007
0008 #include <edm4eic/Track.h>
0009 #include <edm4hep/MCParticle.h>
0010
0011 #include "podio/utilities/MaybeSharedPtr.h"
0012 #include "podio/detail/OrderKey.h"
0013
0014 #include <ostream>
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 MCRecoTrackParticleAssociationCollection;
0024 class Track;
0025 class MutableTrack;
0026 }
0027 namespace edm4hep {
0028 class MCParticle;
0029 class MutableMCParticle;
0030 }
0031
0032
0033 namespace podio::detail {
0034
0035 OrderKey getOrderKey(const edm4eic::MCRecoTrackParticleAssociation& obj);
0036 };
0037
0038 namespace edm4eic {
0039
0040 class MutableMCRecoTrackParticleAssociation;
0041 class MCRecoTrackParticleAssociationCollection;
0042 class MCRecoTrackParticleAssociationCollectionData;
0043
0044
0045
0046
0047
0048 class MCRecoTrackParticleAssociation {
0049
0050 friend class MutableMCRecoTrackParticleAssociation;
0051 friend class MCRecoTrackParticleAssociationCollection;
0052 friend class edm4eic::MCRecoTrackParticleAssociationCollectionData;
0053 friend class MCRecoTrackParticleAssociationCollectionIterator;
0054 friend podio::detail::OrderKey podio::detail::getOrderKey(const MCRecoTrackParticleAssociation & obj);
0055
0056 public:
0057 using mutable_type = MutableMCRecoTrackParticleAssociation;
0058 using collection_type = MCRecoTrackParticleAssociationCollection;
0059
0060
0061 MCRecoTrackParticleAssociation() = default;
0062
0063
0064 MCRecoTrackParticleAssociation(const float weight);
0065
0066
0067 MCRecoTrackParticleAssociation(const MCRecoTrackParticleAssociation& other) noexcept = default;
0068
0069
0070 MCRecoTrackParticleAssociation(MCRecoTrackParticleAssociation&& other) noexcept = default;
0071
0072
0073 MCRecoTrackParticleAssociation& operator=(MCRecoTrackParticleAssociation other) &;
0074 MCRecoTrackParticleAssociation& operator=(MCRecoTrackParticleAssociation other) && = delete;
0075
0076
0077
0078 MutableMCRecoTrackParticleAssociation clone(bool cloneRelations=true) const;
0079
0080
0081 ~MCRecoTrackParticleAssociation() = default;
0082
0083
0084 MCRecoTrackParticleAssociation(const MutableMCRecoTrackParticleAssociation& other);
0085
0086 static MCRecoTrackParticleAssociation makeEmpty();
0087
0088 public:
0089
0090 static constexpr std::string_view typeName = "edm4eic::MCRecoTrackParticleAssociation";
0091
0092
0093 float getWeight() const;
0094
0095
0096
0097 const edm4eic::Track getRec() const;
0098
0099 const edm4hep::MCParticle getSim() const;
0100
0101
0102 [[deprecated("use getSim().getObjectID().index instead")]] int getSimID() const { return getSim().getObjectID().index; }
0103 [[deprecated("use getRec().getObjectID().index instead")]] int getRecID() const { return getRec().getObjectID().index; }
0104
0105
0106
0107 bool isAvailable() const;
0108
0109 void unlink() { m_obj = podio::utils::MaybeSharedPtr<MCRecoTrackParticleAssociationObj>{nullptr}; }
0110
0111 constexpr bool operator==(const MCRecoTrackParticleAssociation& other) const { return m_obj == other.m_obj; }
0112 bool operator==(const MutableMCRecoTrackParticleAssociation& other) const;
0113
0114 constexpr bool operator!=(const MCRecoTrackParticleAssociation& other) const { return !(*this == other); }
0115 bool operator!=(const MutableMCRecoTrackParticleAssociation& other) const { return !(*this == other); }
0116
0117
0118 bool operator<(const MCRecoTrackParticleAssociation& other) const { return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other); }
0119
0120 podio::ObjectID id() const { return getObjectID(); }
0121
0122 const podio::ObjectID getObjectID() const;
0123
0124 friend std::hash<MCRecoTrackParticleAssociation>;
0125
0126 friend void swap(MCRecoTrackParticleAssociation& a, MCRecoTrackParticleAssociation& b) {
0127 using std::swap;
0128 swap(a.m_obj, b.m_obj);
0129 }
0130
0131 private:
0132
0133 explicit MCRecoTrackParticleAssociation(podio::utils::MaybeSharedPtr<MCRecoTrackParticleAssociationObj> obj);
0134 MCRecoTrackParticleAssociation(MCRecoTrackParticleAssociationObj* obj);
0135
0136 podio::utils::MaybeSharedPtr<MCRecoTrackParticleAssociationObj> m_obj{new MCRecoTrackParticleAssociationObj{}, podio::utils::MarkOwned};
0137 };
0138
0139 std::ostream& operator<<(std::ostream& o, const MCRecoTrackParticleAssociation& value);
0140
0141 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0142 void to_json(nlohmann::json& j, const MCRecoTrackParticleAssociation& value);
0143 #endif
0144
0145
0146 }
0147
0148
0149
0150 template<>
0151 struct std::hash<edm4eic::MCRecoTrackParticleAssociation> {
0152 std::size_t operator()(const edm4eic::MCRecoTrackParticleAssociation& obj) const {
0153 return std::hash<edm4eic::MCRecoTrackParticleAssociationObj*>{}(obj.m_obj.get());
0154 }
0155 };
0156
0157
0158
0159
0160
0161 #if defined(__clang__)
0162 #pragma clang diagnostic push
0163 #pragma clang diagnostic ignored "-Wunknown-warning-option"
0164 #pragma clang diagnostic ignored "-Wdeprecated-redundant-constexpr-static-def"
0165 #pragma clang diagnostic ignored "-Wdeprecated"
0166 constexpr std::string_view edm4eic::MCRecoTrackParticleAssociation::typeName;
0167 #pragma clang diagnostic pop
0168 #elif defined(__GNUC__)
0169 #pragma GCC diagnostic push
0170 #pragma GCC diagnostic ignored "-Wdeprecated"
0171 constexpr std::string_view edm4eic::MCRecoTrackParticleAssociation::typeName;
0172 #pragma GCC diagnostic pop
0173 #endif
0174
0175
0176 #endif