File indexing completed on 2026-05-02 08:13:52
0001
0002
0003 #ifndef EDM4HEP_ReconstructedParticle_H
0004 #define EDM4HEP_ReconstructedParticle_H
0005
0006 #include "edm4hep/ReconstructedParticleObj.h"
0007
0008 #include "edm4hep/Cluster.h"
0009 #include "edm4hep/CovMatrix4f.h"
0010 #include "edm4hep/Track.h"
0011 #include "edm4hep/Vector3f.h"
0012 #include "podio/RelationRange.h"
0013 #include <cstdint>
0014 #include <edm4hep/Constants.h>
0015 #include <vector>
0016
0017 #include "podio/detail/OrderKey.h"
0018 #include "podio/utilities/MaybeSharedPtr.h"
0019
0020 #include <cstdint>
0021 #include <ostream>
0022
0023 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0024 #include "nlohmann/json_fwd.hpp"
0025 #endif
0026
0027
0028 namespace edm4hep {
0029 class ReconstructedParticleCollection;
0030 class Vertex;
0031 class MutableVertex;
0032 }
0033
0034 namespace podio::detail {
0035
0036 OrderKey getOrderKey(const edm4hep::ReconstructedParticle& obj);
0037 };
0038
0039 namespace edm4hep {
0040
0041 class MutableReconstructedParticle;
0042 class ReconstructedParticleCollection;
0043 class ReconstructedParticleCollectionData;
0044
0045
0046
0047
0048
0049 class ReconstructedParticle {
0050
0051 friend class MutableReconstructedParticle;
0052 friend class ReconstructedParticleCollection;
0053 friend class edm4hep::ReconstructedParticleCollectionData;
0054 friend class ReconstructedParticleCollectionIterator;
0055 friend podio::detail::OrderKey podio::detail::getOrderKey(const ReconstructedParticle& obj);
0056
0057 public:
0058 using mutable_type = MutableReconstructedParticle;
0059 using collection_type = ReconstructedParticleCollection;
0060
0061
0062 ReconstructedParticle() = default;
0063
0064
0065 ReconstructedParticle(const std::int32_t PDG, const float energy, const edm4hep::Vector3f& momentum,
0066 const edm4hep::Vector3f& referencePoint, const float charge, const float mass,
0067 const float goodnessOfPID, const edm4hep::CovMatrix4f& covMatrix);
0068
0069
0070 ReconstructedParticle(const ReconstructedParticle& other) = default;
0071
0072
0073 ReconstructedParticle& operator=(ReconstructedParticle other) &;
0074 ReconstructedParticle&
0075 operator=(ReconstructedParticle other) && = delete;
0076
0077
0078
0079 MutableReconstructedParticle clone(bool cloneRelations = true) const;
0080
0081
0082 ~ReconstructedParticle() = default;
0083
0084
0085 ReconstructedParticle(const MutableReconstructedParticle& other);
0086
0087 static ReconstructedParticle makeEmpty();
0088
0089 public:
0090 static constexpr std::string_view typeName = "edm4hep::ReconstructedParticle";
0091
0092
0093 std::int32_t getPDG() const;
0094
0095
0096 float getEnergy() const;
0097
0098
0099 const edm4hep::Vector3f& getMomentum() const;
0100
0101
0102 const edm4hep::Vector3f& getReferencePoint() const;
0103
0104
0105 float getCharge() const;
0106
0107
0108
0109 float getMass() const;
0110
0111
0112 float getGoodnessOfPID() const;
0113
0114
0115 const edm4hep::CovMatrix4f& getCovMatrix() const;
0116
0117
0118 const edm4hep::Vertex getDecayVertex() const;
0119
0120 std::size_t clusters_size() const;
0121 edm4hep::Cluster getClusters(std::size_t) const;
0122 std::vector<edm4hep::Cluster>::const_iterator clusters_begin() const;
0123 std::vector<edm4hep::Cluster>::const_iterator clusters_end() const;
0124 podio::RelationRange<edm4hep::Cluster> getClusters() const;
0125 std::size_t tracks_size() const;
0126 edm4hep::Track getTracks(std::size_t) const;
0127 std::vector<edm4hep::Track>::const_iterator tracks_begin() const;
0128 std::vector<edm4hep::Track>::const_iterator tracks_end() const;
0129 podio::RelationRange<edm4hep::Track> getTracks() const;
0130 std::size_t particles_size() const;
0131 edm4hep::ReconstructedParticle getParticles(std::size_t) const;
0132 std::vector<edm4hep::ReconstructedParticle>::const_iterator particles_begin() const;
0133 std::vector<edm4hep::ReconstructedParticle>::const_iterator particles_end() const;
0134 podio::RelationRange<edm4hep::ReconstructedParticle> getParticles() const;
0135
0136 bool isCompound() const { return particles_size() > 0; }
0137
0138 float getCovMatrix(edm4hep::FourMomCoords dimI, edm4hep::FourMomCoords dimJ) const {
0139 return getCovMatrix().getValue(dimI, dimJ);
0140 }
0141
0142
0143 bool isAvailable() const;
0144
0145 void unlink() { m_obj = podio::utils::MaybeSharedPtr<ReconstructedParticleObj>{nullptr}; }
0146
0147 bool operator==(const ReconstructedParticle& other) const { return m_obj == other.m_obj; }
0148 bool operator==(const MutableReconstructedParticle& other) const;
0149
0150 bool operator!=(const ReconstructedParticle& other) const { return !(*this == other); }
0151 bool operator!=(const MutableReconstructedParticle& other) const { return !(*this == other); }
0152
0153
0154 bool operator<(const ReconstructedParticle& other) const {
0155 return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other);
0156 }
0157
0158 podio::ObjectID id() const { return getObjectID(); }
0159
0160 const podio::ObjectID getObjectID() const;
0161
0162 friend std::hash<ReconstructedParticle>;
0163
0164 friend void swap(ReconstructedParticle& a, ReconstructedParticle& b) {
0165 using std::swap;
0166 swap(a.m_obj, b.m_obj);
0167 }
0168
0169 private:
0170
0171 explicit ReconstructedParticle(podio::utils::MaybeSharedPtr<ReconstructedParticleObj> obj);
0172 ReconstructedParticle(ReconstructedParticleObj* obj);
0173
0174 podio::utils::MaybeSharedPtr<ReconstructedParticleObj> m_obj{new ReconstructedParticleObj{}, podio::utils::MarkOwned};
0175 };
0176
0177 std::ostream& operator<<(std::ostream& o, const ReconstructedParticle& value);
0178
0179 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0180 void to_json(nlohmann::json& j, const ReconstructedParticle& value);
0181 #endif
0182
0183 }
0184
0185 template <>
0186 struct std::hash<edm4hep::ReconstructedParticle> {
0187 std::size_t operator()(const edm4hep::ReconstructedParticle& obj) const {
0188 return std::hash<edm4hep::ReconstructedParticleObj*>{}(obj.m_obj.get());
0189 }
0190 };
0191
0192
0193
0194
0195 #if defined(__clang__)
0196 #pragma clang diagnostic push
0197 #pragma clang diagnostic ignored "-Wunknown-warning-option"
0198 #pragma clang diagnostic ignored "-Wdeprecated-redundant-constexpr-static-def"
0199 #pragma clang diagnostic ignored "-Wdeprecated"
0200 constexpr std::string_view edm4hep::ReconstructedParticle::typeName;
0201 #pragma clang diagnostic pop
0202 #elif defined(__GNUC__)
0203 #pragma GCC diagnostic push
0204 #pragma GCC diagnostic ignored "-Wdeprecated"
0205 constexpr std::string_view edm4hep::ReconstructedParticle::typeName;
0206 #pragma GCC diagnostic pop
0207 #endif
0208
0209 #endif