File indexing completed on 2025-01-18 09:55:38
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/ParticleID.h"
0010 #include "edm4hep/Track.h"
0011 #include "edm4hep/Vector3f.h"
0012 #include "podio/RelationRange.h"
0013 #include <array>
0014 #include <cstdint>
0015 #include <vector>
0016
0017 #include "podio/utilities/MaybeSharedPtr.h"
0018
0019 #include <cstdint>
0020 #include <ostream>
0021
0022 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0023 #include "nlohmann/json_fwd.hpp"
0024 #endif
0025
0026
0027 namespace edm4hep {
0028 class Vertex;
0029 class MutableVertex;
0030 class ParticleID;
0031 class MutableParticleID;
0032 }
0033
0034 namespace edm4hep {
0035
0036 class MutableReconstructedParticle;
0037 class ReconstructedParticleCollection;
0038 class ReconstructedParticleCollectionData;
0039
0040
0041
0042
0043
0044 class ReconstructedParticle {
0045
0046 friend class MutableReconstructedParticle;
0047 friend class ReconstructedParticleCollection;
0048 friend class edm4hep::ReconstructedParticleCollectionData;
0049 friend class ReconstructedParticleCollectionIterator;
0050
0051 public:
0052 using mutable_type = MutableReconstructedParticle;
0053 using collection_type = ReconstructedParticleCollection;
0054
0055
0056 ReconstructedParticle();
0057
0058
0059 ReconstructedParticle(std::int32_t type, float energy, edm4hep::Vector3f momentum, edm4hep::Vector3f referencePoint,
0060 float charge, float mass, float goodnessOfPID, std::array<float, 10> covMatrix);
0061
0062
0063 ReconstructedParticle(const ReconstructedParticle& other) = default;
0064
0065
0066 ReconstructedParticle& operator=(ReconstructedParticle other);
0067
0068
0069
0070 MutableReconstructedParticle clone(bool cloneRelations = true) const;
0071
0072
0073 ~ReconstructedParticle() = default;
0074
0075
0076 ReconstructedParticle(const MutableReconstructedParticle& other);
0077
0078 static ReconstructedParticle makeEmpty();
0079
0080 public:
0081
0082
0083 std::int32_t getType() const;
0084
0085
0086 float getEnergy() const;
0087
0088
0089 const edm4hep::Vector3f& getMomentum() const;
0090
0091
0092 const edm4hep::Vector3f& getReferencePoint() const;
0093
0094
0095 float getCharge() const;
0096
0097
0098
0099 float getMass() const;
0100
0101
0102 float getGoodnessOfPID() const;
0103
0104
0105
0106 const std::array<float, 10>& getCovMatrix() const;
0107
0108
0109 float getCovMatrix(size_t i) const;
0110
0111
0112 const edm4hep::Vertex getStartVertex() const;
0113
0114 const edm4hep::ParticleID getParticleIDUsed() const;
0115
0116 std::size_t clusters_size() const;
0117 edm4hep::Cluster getClusters(std::size_t) const;
0118 std::vector<edm4hep::Cluster>::const_iterator clusters_begin() const;
0119 std::vector<edm4hep::Cluster>::const_iterator clusters_end() const;
0120 podio::RelationRange<edm4hep::Cluster> getClusters() const;
0121 std::size_t tracks_size() const;
0122 edm4hep::Track getTracks(std::size_t) const;
0123 std::vector<edm4hep::Track>::const_iterator tracks_begin() const;
0124 std::vector<edm4hep::Track>::const_iterator tracks_end() const;
0125 podio::RelationRange<edm4hep::Track> getTracks() const;
0126 std::size_t particles_size() const;
0127 edm4hep::ReconstructedParticle getParticles(std::size_t) const;
0128 std::vector<edm4hep::ReconstructedParticle>::const_iterator particles_begin() const;
0129 std::vector<edm4hep::ReconstructedParticle>::const_iterator particles_end() const;
0130 podio::RelationRange<edm4hep::ReconstructedParticle> getParticles() const;
0131 std::size_t particleIDs_size() const;
0132 edm4hep::ParticleID getParticleIDs(std::size_t) const;
0133 std::vector<edm4hep::ParticleID>::const_iterator particleIDs_begin() const;
0134 std::vector<edm4hep::ParticleID>::const_iterator particleIDs_end() const;
0135 podio::RelationRange<edm4hep::ParticleID> getParticleIDs() const;
0136
0137 bool isCompound() const {
0138 return particles_size() > 0;
0139 }
0140
0141
0142 bool isAvailable() const;
0143
0144 void unlink() {
0145 m_obj = podio::utils::MaybeSharedPtr<ReconstructedParticleObj>{nullptr};
0146 }
0147
0148 bool operator==(const ReconstructedParticle& other) const {
0149 return m_obj == other.m_obj;
0150 }
0151 bool operator==(const MutableReconstructedParticle& other) const;
0152
0153 bool operator!=(const ReconstructedParticle& other) const {
0154 return !(*this == other);
0155 }
0156 bool operator!=(const MutableReconstructedParticle& other) const {
0157 return !(*this == other);
0158 }
0159
0160
0161 bool operator<(const ReconstructedParticle& other) const {
0162 return m_obj < other.m_obj;
0163 }
0164
0165 podio::ObjectID id() const {
0166 return getObjectID();
0167 }
0168
0169 const podio::ObjectID getObjectID() const;
0170
0171 friend void swap(ReconstructedParticle& a, ReconstructedParticle& b) {
0172 using std::swap;
0173 swap(a.m_obj, b.m_obj);
0174 }
0175
0176 private:
0177
0178 explicit ReconstructedParticle(podio::utils::MaybeSharedPtr<ReconstructedParticleObj> obj);
0179 ReconstructedParticle(ReconstructedParticleObj* obj);
0180
0181 podio::utils::MaybeSharedPtr<ReconstructedParticleObj> m_obj{nullptr};
0182 };
0183
0184 std::ostream& operator<<(std::ostream& o, const ReconstructedParticle& value);
0185
0186 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0187 void to_json(nlohmann::json& j, const ReconstructedParticle& value);
0188 #endif
0189
0190 }
0191
0192 #endif