File indexing completed on 2025-07-11 08:30:16
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();
0063
0064
0065 ReconstructedParticle(std::int32_t PDG, float energy, edm4hep::Vector3f momentum, edm4hep::Vector3f referencePoint,
0066 float charge, float mass, float goodnessOfPID, edm4hep::CovMatrix4f covMatrix);
0067
0068
0069 ReconstructedParticle(const ReconstructedParticle& other) = default;
0070
0071
0072 ReconstructedParticle& operator=(ReconstructedParticle other);
0073
0074
0075
0076 MutableReconstructedParticle clone(bool cloneRelations = true) const;
0077
0078
0079 ~ReconstructedParticle() = default;
0080
0081
0082 ReconstructedParticle(const MutableReconstructedParticle& other);
0083
0084 static ReconstructedParticle makeEmpty();
0085
0086 public:
0087 static constexpr auto typeName = "edm4hep::ReconstructedParticle";
0088
0089
0090 std::int32_t getPDG() const;
0091
0092
0093 float getEnergy() const;
0094
0095
0096 const edm4hep::Vector3f& getMomentum() const;
0097
0098
0099 const edm4hep::Vector3f& getReferencePoint() const;
0100
0101
0102 float getCharge() const;
0103
0104
0105
0106 float getMass() const;
0107
0108
0109 float getGoodnessOfPID() const;
0110
0111
0112 const edm4hep::CovMatrix4f& getCovMatrix() const;
0113
0114
0115 const edm4hep::Vertex getDecayVertex() const;
0116
0117 std::size_t clusters_size() const;
0118 edm4hep::Cluster getClusters(std::size_t) const;
0119 std::vector<edm4hep::Cluster>::const_iterator clusters_begin() const;
0120 std::vector<edm4hep::Cluster>::const_iterator clusters_end() const;
0121 podio::RelationRange<edm4hep::Cluster> getClusters() const;
0122 std::size_t tracks_size() const;
0123 edm4hep::Track getTracks(std::size_t) const;
0124 std::vector<edm4hep::Track>::const_iterator tracks_begin() const;
0125 std::vector<edm4hep::Track>::const_iterator tracks_end() const;
0126 podio::RelationRange<edm4hep::Track> getTracks() const;
0127 std::size_t particles_size() const;
0128 edm4hep::ReconstructedParticle getParticles(std::size_t) const;
0129 std::vector<edm4hep::ReconstructedParticle>::const_iterator particles_begin() const;
0130 std::vector<edm4hep::ReconstructedParticle>::const_iterator particles_end() const;
0131 podio::RelationRange<edm4hep::ReconstructedParticle> getParticles() const;
0132
0133 bool isCompound() const {
0134 return particles_size() > 0;
0135 }
0136 [[deprecated("use setPDG instead")]] int32_t getType() const {
0137 return getPDG();
0138 }
0139
0140 float getCovMatrix(edm4hep::FourMomCoords dimI, edm4hep::FourMomCoords dimJ) const {
0141 return getCovMatrix().getValue(dimI, dimJ);
0142 }
0143
0144
0145 bool isAvailable() const;
0146
0147 void unlink() {
0148 m_obj = podio::utils::MaybeSharedPtr<ReconstructedParticleObj>{nullptr};
0149 }
0150
0151 bool operator==(const ReconstructedParticle& other) const {
0152 return m_obj == other.m_obj;
0153 }
0154 bool operator==(const MutableReconstructedParticle& other) const;
0155
0156 bool operator!=(const ReconstructedParticle& other) const {
0157 return !(*this == other);
0158 }
0159 bool operator!=(const MutableReconstructedParticle& other) const {
0160 return !(*this == other);
0161 }
0162
0163
0164 bool operator<(const ReconstructedParticle& other) const {
0165 return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other);
0166 }
0167
0168 podio::ObjectID id() const {
0169 return getObjectID();
0170 }
0171
0172 const podio::ObjectID getObjectID() const;
0173
0174 friend void swap(ReconstructedParticle& a, ReconstructedParticle& b) {
0175 using std::swap;
0176 swap(a.m_obj, b.m_obj);
0177 }
0178
0179 private:
0180
0181 explicit ReconstructedParticle(podio::utils::MaybeSharedPtr<ReconstructedParticleObj> obj);
0182 ReconstructedParticle(ReconstructedParticleObj* obj);
0183
0184 podio::utils::MaybeSharedPtr<ReconstructedParticleObj> m_obj{nullptr};
0185 };
0186
0187 std::ostream& operator<<(std::ostream& o, const ReconstructedParticle& value);
0188
0189 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0190 void to_json(nlohmann::json& j, const ReconstructedParticle& value);
0191 #endif
0192
0193 }
0194
0195 #endif