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