Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-30 09:16:30

0001 // AUTOMATICALLY GENERATED FILE - DO NOT EDIT
0002 
0003 #ifndef EDM4HEP_MutableReconstructedParticle_H
0004 #define EDM4HEP_MutableReconstructedParticle_H
0005 
0006 #include "edm4hep/ReconstructedParticleObj.h"
0007 // Make the immutable class available from its mutable version but not vice versa
0008 #include "edm4hep/ReconstructedParticle.h"
0009 
0010 #include "edm4hep/Cluster.h"
0011 #include "edm4hep/CovMatrix4f.h"
0012 #include "edm4hep/Track.h"
0013 #include "edm4hep/Vector3f.h"
0014 #include "podio/RelationRange.h"
0015 #include <cstdint>
0016 #include <edm4hep/Constants.h>
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 // forward declarations
0028 namespace edm4hep {
0029 class ReconstructedParticleCollection;
0030 class Vertex;
0031 class MutableVertex;
0032 } // namespace edm4hep
0033 
0034 namespace edm4hep {
0035 
0036 /** @class MutableReconstructedParticle
0037  *  Reconstructed Particle
0038  *  @author: EDM4hep authors
0039  */
0040 class MutableReconstructedParticle {
0041 
0042   friend class ReconstructedParticleCollection;
0043   friend class ReconstructedParticleMutableCollectionIterator;
0044   friend class ReconstructedParticle;
0045 
0046 public:
0047   using object_type = ReconstructedParticle;
0048   using collection_type = ReconstructedParticleCollection;
0049 
0050   /// default constructor
0051   MutableReconstructedParticle() = default;
0052 
0053   /// Constructor initializing all members
0054   MutableReconstructedParticle(const std::int32_t PDG, const float energy, const edm4hep::Vector3f& momentum,
0055                                const edm4hep::Vector3f& referencePoint, const float charge, const float mass,
0056                                const float goodnessOfPID, const edm4hep::CovMatrix4f& covMatrix);
0057 
0058   /// copy constructor
0059   MutableReconstructedParticle(const MutableReconstructedParticle& other) = default;
0060 
0061   /// copy-assignment operator
0062   MutableReconstructedParticle&
0063   operator=(MutableReconstructedParticle other) &; // Rebind this to other's internal object
0064   MutableReconstructedParticle& operator=(MutableReconstructedParticle other) && =
0065       delete; // Prevent rebinding temporary as the changes wouldn't persist
0066 
0067   /// create a mutable deep-copy of the object with identical relations
0068   /// if cloneRelations=false, the relations are not cloned and will be empty
0069   MutableReconstructedParticle clone(bool cloneRelations = true) const;
0070 
0071   /// destructor
0072   ~MutableReconstructedParticle() = default;
0073 
0074 public:
0075   /// Access the PDG of the reconstructed particle.
0076   std::int32_t getPDG() const;
0077 
0078   /// Access the energy of the reconstructed particle. Four momentum state is not kept consistent internally [GeV]
0079   float getEnergy() const;
0080 
0081   /// Access the particle momentum. Four momentum state is not kept consistent internally [GeV]
0082   const edm4hep::Vector3f& getMomentum() const;
0083 
0084   /// Access the reference, i.e. where the particle has been measured [mm]
0085   const edm4hep::Vector3f& getReferencePoint() const;
0086 
0087   /// Access the charge of the reconstructed particle [e]
0088   float getCharge() const;
0089 
0090   /// Access the mass of the reconstructed particle, set independently from four vector. Four momentum state is not kept
0091   /// consistent internally [GeV]
0092   float getMass() const;
0093 
0094   /// Access the overall goodness of the PID on a scale of [0;1]
0095   float getGoodnessOfPID() const;
0096 
0097   /// Access the covariance matrix of the reconstructed particle 4vector [GeV^2]
0098   const edm4hep::CovMatrix4f& getCovMatrix() const;
0099 
0100   /// Access the decay vertex for the particle (if it is a composite particle)
0101   const edm4hep::Vertex getDecayVertex() const;
0102 
0103   /// Set the PDG of the reconstructed particle.
0104   void setPDG(const std::int32_t PDG);
0105   /// Get mutable reference to PDG of the reconstructed particle.
0106   std::int32_t& getPDG();
0107 
0108   /// Set the energy of the reconstructed particle. Four momentum state is not kept consistent internally [GeV]
0109   void setEnergy(const float energy);
0110   /// Get mutable reference to energy of the reconstructed particle. Four momentum state is not kept consistent
0111   /// internally [GeV]
0112   float& getEnergy();
0113 
0114   /// Set the particle momentum. Four momentum state is not kept consistent internally [GeV]
0115   void setMomentum(const edm4hep::Vector3f& momentum);
0116   /// Get mutable reference to particle momentum. Four momentum state is not kept consistent internally [GeV]
0117   edm4hep::Vector3f& getMomentum();
0118 
0119   /// Set the reference, i.e. where the particle has been measured [mm]
0120   void setReferencePoint(const edm4hep::Vector3f& referencePoint);
0121   /// Get mutable reference to reference, i.e. where the particle has been measured [mm]
0122   edm4hep::Vector3f& getReferencePoint();
0123 
0124   /// Set the charge of the reconstructed particle [e]
0125   void setCharge(const float charge);
0126   /// Get mutable reference to charge of the reconstructed particle [e]
0127   float& getCharge();
0128 
0129   /// Set the mass of the reconstructed particle, set independently from four vector. Four momentum state is not kept
0130   /// consistent internally [GeV]
0131   void setMass(const float mass);
0132   /// Get mutable reference to mass of the reconstructed particle, set independently from four vector. Four momentum
0133   /// state is not kept consistent internally [GeV]
0134   float& getMass();
0135 
0136   /// Set the overall goodness of the PID on a scale of [0;1]
0137   void setGoodnessOfPID(const float goodnessOfPID);
0138   /// Get mutable reference to overall goodness of the PID on a scale of [0;1]
0139   float& getGoodnessOfPID();
0140 
0141   /// Set the covariance matrix of the reconstructed particle 4vector [GeV^2]
0142   void setCovMatrix(const edm4hep::CovMatrix4f& covMatrix);
0143   /// Get mutable reference to covariance matrix of the reconstructed particle 4vector [GeV^2]
0144   edm4hep::CovMatrix4f& getCovMatrix();
0145 
0146   /// Set the decay vertex for the particle (if it is a composite particle)
0147   void setDecayVertex(const edm4hep::Vertex& value);
0148 
0149   void addToClusters(const edm4hep::Cluster&);
0150   std::size_t clusters_size() const;
0151   edm4hep::Cluster getClusters(std::size_t) const;
0152   std::vector<edm4hep::Cluster>::const_iterator clusters_begin() const;
0153   std::vector<edm4hep::Cluster>::const_iterator clusters_end() const;
0154   podio::RelationRange<edm4hep::Cluster> getClusters() const;
0155   void addToTracks(const edm4hep::Track&);
0156   std::size_t tracks_size() const;
0157   edm4hep::Track getTracks(std::size_t) const;
0158   std::vector<edm4hep::Track>::const_iterator tracks_begin() const;
0159   std::vector<edm4hep::Track>::const_iterator tracks_end() const;
0160   podio::RelationRange<edm4hep::Track> getTracks() const;
0161   void addToParticles(const edm4hep::ReconstructedParticle&);
0162   std::size_t particles_size() const;
0163   edm4hep::ReconstructedParticle getParticles(std::size_t) const;
0164   std::vector<edm4hep::ReconstructedParticle>::const_iterator particles_begin() const;
0165   std::vector<edm4hep::ReconstructedParticle>::const_iterator particles_end() const;
0166   podio::RelationRange<edm4hep::ReconstructedParticle> getParticles() const;
0167 
0168   bool isCompound() const { return particles_size() > 0; }
0169   /// Get the four momentum covariance matrix value for the two passed dimensions
0170   float getCovMatrix(edm4hep::FourMomCoords dimI, edm4hep::FourMomCoords dimJ) const {
0171     return getCovMatrix().getValue(dimI, dimJ);
0172   }
0173 
0174   // vertex where the particle decays. This method actually returns the start vertex from the first daughter particle
0175   // found.
0176   // TODO: edm4hep::Vertex  getEndVertex() { return  edm4hep::Vertex(  (getParticles(0).isAvailable() ?
0177   // getParticles(0).getStartVertex() :  edm4hep::Vertex(0,0) ) ) ; }
0178   /// Set the four momentum covariance matrix value for the two passed dimensions
0179   void setCovMatrix(float value, edm4hep::FourMomCoords dimI, edm4hep::FourMomCoords dimJ) {
0180     getCovMatrix().setValue(value, dimI, dimJ);
0181   }
0182 
0183   /// check whether the object is actually available
0184   bool isAvailable() const;
0185   /// disconnect from ReconstructedParticleObj instance
0186   void unlink() { m_obj = podio::utils::MaybeSharedPtr<ReconstructedParticleObj>{nullptr}; }
0187 
0188   constexpr bool operator==(const MutableReconstructedParticle& other) const { return m_obj == other.m_obj; }
0189   bool operator==(const ReconstructedParticle& other) const;
0190 
0191   constexpr bool operator!=(const MutableReconstructedParticle& other) const { return !(*this == other); }
0192   bool operator!=(const ReconstructedParticle& other) const { return !(*this == other); }
0193 
0194   // less comparison operator, so that objects can be e.g. stored in sets.
0195   bool operator<(const MutableReconstructedParticle& other) const {
0196     return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other);
0197   }
0198 
0199   podio::ObjectID id() const { return getObjectID(); }
0200 
0201   const podio::ObjectID getObjectID() const;
0202 
0203   friend std::hash<MutableReconstructedParticle>;
0204 
0205   friend void swap(MutableReconstructedParticle& a, MutableReconstructedParticle& b) {
0206     using std::swap;
0207     swap(a.m_obj, b.m_obj); // swap out the internal pointers
0208   }
0209 
0210 private:
0211   /// constructor from existing ReconstructedParticleObj
0212   explicit MutableReconstructedParticle(podio::utils::MaybeSharedPtr<ReconstructedParticleObj> obj);
0213 
0214   podio::utils::MaybeSharedPtr<ReconstructedParticleObj> m_obj{new ReconstructedParticleObj{}, podio::utils::MarkOwned};
0215 };
0216 
0217 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0218 void to_json(nlohmann::json& j, const MutableReconstructedParticle& value);
0219 #endif
0220 
0221 } // namespace edm4hep
0222 
0223 template <>
0224 struct std::hash<edm4hep::MutableReconstructedParticle> {
0225   std::size_t operator()(const edm4hep::MutableReconstructedParticle& obj) const {
0226     return std::hash<edm4hep::ReconstructedParticleObj*>{}(obj.m_obj.get());
0227   }
0228 };
0229 
0230 #endif