File indexing completed on 2026-09-13 09:07:06
0001
0002
0003 #ifndef EDM4EIC_MutableReconstructedParticle_H
0004 #define EDM4EIC_MutableReconstructedParticle_H
0005
0006 #include "edm4eic/ReconstructedParticleObj.h"
0007
0008 #include "edm4eic/ReconstructedParticle.h"
0009
0010 #include "edm4eic/Cluster.h"
0011 #include "edm4eic/Cov4f.h"
0012 #include "edm4eic/Track.h"
0013 #include "edm4hep/ParticleID.h"
0014 #include "edm4hep/Vector3f.h"
0015 #include "podio/RelationRange.h"
0016 #include <cstdint>
0017 #include <vector>
0018
0019 #include "podio/utilities/MaybeSharedPtr.h"
0020
0021 #include <cstdint>
0022
0023 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0024 #include "nlohmann/json_fwd.hpp"
0025 #endif
0026
0027
0028 namespace edm4eic {
0029 class ReconstructedParticleCollection;
0030 class Vertex;
0031 class MutableVertex;
0032 }
0033 namespace edm4hep {
0034 class ParticleID;
0035 class MutableParticleID;
0036 }
0037
0038
0039 namespace edm4eic {
0040
0041
0042
0043
0044
0045
0046 class MutableReconstructedParticle {
0047
0048 friend class ReconstructedParticleCollection;
0049 friend class ReconstructedParticleMutableCollectionIterator;
0050 friend class ReconstructedParticle;
0051
0052 public:
0053 using object_type = ReconstructedParticle;
0054 using collection_type = ReconstructedParticleCollection;
0055
0056
0057 MutableReconstructedParticle() = default;
0058
0059
0060 MutableReconstructedParticle(const std::int32_t type, const float energy, const edm4hep::Vector3f& momentum, const edm4hep::Vector3f& referencePoint, const float charge, const float mass, const float goodnessOfPID, const edm4eic::Cov4f& covMatrix, const std::int32_t PDG);
0061
0062
0063 MutableReconstructedParticle(const MutableReconstructedParticle& other) = default;
0064
0065
0066 MutableReconstructedParticle& operator=(MutableReconstructedParticle other) &;
0067 MutableReconstructedParticle& operator=(MutableReconstructedParticle other) && = delete;
0068
0069
0070
0071 MutableReconstructedParticle clone(bool cloneRelations=true) const;
0072
0073
0074 ~MutableReconstructedParticle() = default;
0075
0076
0077 public:
0078
0079
0080 std::int32_t getType() const;
0081
0082
0083 float getEnergy() const;
0084
0085
0086 const edm4hep::Vector3f& getMomentum() const;
0087
0088
0089 const edm4hep::Vector3f& getReferencePoint() const;
0090
0091
0092 float getCharge() const;
0093
0094
0095 float getMass() const;
0096
0097
0098 float getGoodnessOfPID() const;
0099
0100
0101 const edm4eic::Cov4f& getCovMatrix() const;
0102
0103
0104 std::int32_t getPDG() const;
0105
0106
0107
0108 const edm4eic::Vertex getStartVertex() const;
0109
0110 const edm4hep::ParticleID getParticleIDUsed() const;
0111
0112
0113 void setType(const std::int32_t type);
0114
0115 std::int32_t& getType();
0116
0117
0118 void setEnergy(const float energy);
0119
0120 float& getEnergy();
0121
0122
0123 void setMomentum(const edm4hep::Vector3f& momentum);
0124
0125 edm4hep::Vector3f& getMomentum();
0126
0127
0128 void setReferencePoint(const edm4hep::Vector3f& referencePoint);
0129
0130 edm4hep::Vector3f& getReferencePoint();
0131
0132
0133 void setCharge(const float charge);
0134
0135 float& getCharge();
0136
0137
0138 void setMass(const float mass);
0139
0140 float& getMass();
0141
0142
0143 void setGoodnessOfPID(const float goodnessOfPID);
0144
0145 float& getGoodnessOfPID();
0146
0147
0148 void setCovMatrix(const edm4eic::Cov4f& covMatrix);
0149
0150 edm4eic::Cov4f& getCovMatrix();
0151
0152
0153 void setPDG(const std::int32_t PDG);
0154
0155 std::int32_t& getPDG();
0156
0157
0158
0159 void setStartVertex(const edm4eic::Vertex& value);
0160
0161 void setParticleIDUsed(const edm4hep::ParticleID& value);
0162
0163 void addToClusters(const edm4eic::Cluster&);
0164 std::size_t clusters_size() const;
0165 edm4eic::Cluster getClusters(std::size_t) const;
0166 std::vector<edm4eic::Cluster>::const_iterator clusters_begin() const;
0167 std::vector<edm4eic::Cluster>::const_iterator clusters_end() const;
0168 podio::RelationRange<edm4eic::Cluster> getClusters() const;
0169 void addToTracks(const edm4eic::Track&);
0170 std::size_t tracks_size() const;
0171 edm4eic::Track getTracks(std::size_t) const;
0172 std::vector<edm4eic::Track>::const_iterator tracks_begin() const;
0173 std::vector<edm4eic::Track>::const_iterator tracks_end() const;
0174 podio::RelationRange<edm4eic::Track> getTracks() const;
0175 void addToParticles(const edm4eic::ReconstructedParticle&);
0176 std::size_t particles_size() const;
0177 edm4eic::ReconstructedParticle getParticles(std::size_t) const;
0178 std::vector<edm4eic::ReconstructedParticle>::const_iterator particles_begin() const;
0179 std::vector<edm4eic::ReconstructedParticle>::const_iterator particles_end() const;
0180 podio::RelationRange<edm4eic::ReconstructedParticle> getParticles() const;
0181 void addToParticleIDs(const edm4hep::ParticleID&);
0182 std::size_t particleIDs_size() const;
0183 edm4hep::ParticleID getParticleIDs(std::size_t) const;
0184 std::vector<edm4hep::ParticleID>::const_iterator particleIDs_begin() const;
0185 std::vector<edm4hep::ParticleID>::const_iterator particleIDs_end() const;
0186 podio::RelationRange<edm4hep::ParticleID> getParticleIDs() const;
0187
0188 bool isCompound() const {return particles_size() > 0;}
0189
0190
0191
0192
0193 bool isAvailable() const;
0194
0195 void unlink() { m_obj = podio::utils::MaybeSharedPtr<ReconstructedParticleObj>{nullptr}; }
0196
0197 constexpr bool operator==(const MutableReconstructedParticle& other) const { return m_obj == other.m_obj; }
0198 bool operator==(const ReconstructedParticle& other) const;
0199
0200 constexpr bool operator!=(const MutableReconstructedParticle& other) const { return !(*this == other); }
0201 bool operator!=(const ReconstructedParticle& other) const { return !(*this == other); }
0202
0203
0204 bool operator<(const MutableReconstructedParticle& other) const { return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other); }
0205
0206 podio::ObjectID id() const { return getObjectID(); }
0207
0208 const podio::ObjectID getObjectID() const;
0209
0210 friend std::hash<MutableReconstructedParticle>;
0211
0212 friend void swap(MutableReconstructedParticle& a, MutableReconstructedParticle& b) {
0213 using std::swap;
0214 swap(a.m_obj, b.m_obj);
0215 }
0216
0217 private:
0218
0219 explicit MutableReconstructedParticle(podio::utils::MaybeSharedPtr<ReconstructedParticleObj> obj);
0220
0221 podio::utils::MaybeSharedPtr<ReconstructedParticleObj> m_obj{new ReconstructedParticleObj{}, podio::utils::MarkOwned};
0222 };
0223
0224 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0225 void to_json(nlohmann::json& j, const MutableReconstructedParticle& value);
0226 #endif
0227
0228
0229 }
0230
0231
0232
0233 template<>
0234 struct std::hash<edm4eic::MutableReconstructedParticle> {
0235 std::size_t operator()(const edm4eic::MutableReconstructedParticle& obj) const {
0236 return std::hash<edm4eic::ReconstructedParticleObj*>{}(obj.m_obj.get());
0237 }
0238 };
0239
0240
0241 #endif