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