Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-03 08:34:40

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();
0052 
0053   /// Constructor initializing all members
0054   MutableReconstructedParticle(std::int32_t PDG, float energy, edm4hep::Vector3f momentum,
0055                                edm4hep::Vector3f referencePoint, float charge, float mass, float goodnessOfPID,
0056                                edm4hep::CovMatrix4f covMatrix);
0057 
0058   /// copy constructor
0059   MutableReconstructedParticle(const MutableReconstructedParticle& other) = default;
0060 
0061   /// copy-assignment operator
0062   MutableReconstructedParticle& operator=(MutableReconstructedParticle other);
0063 
0064   /// create a mutable deep-copy of the object with identical relations
0065   /// if cloneRelations=false, the relations are not cloned and will be empty
0066   MutableReconstructedParticle clone(bool cloneRelations = true) const;
0067 
0068   /// destructor
0069   ~MutableReconstructedParticle() = default;
0070 
0071 public:
0072   /// Access the PDG of the reconstructed particle.
0073   std::int32_t getPDG() const;
0074 
0075   /// Access the energy of the reconstructed particle. Four momentum state is not kept consistent internally [GeV]
0076   float getEnergy() const;
0077 
0078   /// Access the particle momentum. Four momentum state is not kept consistent internally [GeV]
0079   const edm4hep::Vector3f& getMomentum() const;
0080 
0081   /// Access the reference, i.e. where the particle has been measured [mm]
0082   const edm4hep::Vector3f& getReferencePoint() const;
0083 
0084   /// Access the charge of the reconstructed particle
0085   float getCharge() const;
0086 
0087   /// Access the mass of the reconstructed particle, set independently from four vector. Four momentum state is not kept
0088   /// consistent internally [GeV]
0089   float getMass() const;
0090 
0091   /// Access the overall goodness of the PID on a scale of [0;1]
0092   float getGoodnessOfPID() const;
0093 
0094   /// Access the covariance matrix of the reconstructed particle 4vector
0095   const edm4hep::CovMatrix4f& getCovMatrix() const;
0096 
0097   /// Access the decay vertex for the particle (if it is a composite particle)
0098   const edm4hep::Vertex getDecayVertex() const;
0099 
0100   /// Set the PDG of the reconstructed particle.
0101   void setPDG(std::int32_t value);
0102   /// Get mutable reference to PDG of the reconstructed particle.
0103   std::int32_t& getPDG();
0104   /// Get reference to PDG of the reconstructed particle.
0105   [[deprecated("use getPDG instead")]] std::int32_t& PDG();
0106 
0107   /// Set the energy of the reconstructed particle. Four momentum state is not kept consistent internally [GeV]
0108   void setEnergy(float value);
0109   /// Get mutable reference to energy of the reconstructed particle. Four momentum state is not kept consistent
0110   /// internally [GeV]
0111   float& getEnergy();
0112   /// Get reference to energy of the reconstructed particle. Four momentum state is not kept consistent internally [GeV]
0113   [[deprecated("use getEnergy instead")]] float& energy();
0114 
0115   /// Set the particle momentum. Four momentum state is not kept consistent internally [GeV]
0116   void setMomentum(edm4hep::Vector3f value);
0117   /// Get mutable reference to particle momentum. Four momentum state is not kept consistent internally [GeV]
0118   edm4hep::Vector3f& getMomentum();
0119   /// Get reference to particle momentum. Four momentum state is not kept consistent internally [GeV]
0120   [[deprecated("use getMomentum instead")]] edm4hep::Vector3f& momentum();
0121 
0122   /// Set the reference, i.e. where the particle has been measured [mm]
0123   void setReferencePoint(edm4hep::Vector3f value);
0124   /// Get mutable reference to reference, i.e. where the particle has been measured [mm]
0125   edm4hep::Vector3f& getReferencePoint();
0126   /// Get reference to reference, i.e. where the particle has been measured [mm]
0127   [[deprecated("use getReferencePoint instead")]] edm4hep::Vector3f& referencePoint();
0128 
0129   /// Set the charge of the reconstructed particle
0130   void setCharge(float value);
0131   /// Get mutable reference to charge of the reconstructed particle
0132   float& getCharge();
0133   /// Get reference to charge of the reconstructed particle
0134   [[deprecated("use getCharge instead")]] float& charge();
0135 
0136   /// Set the mass of the reconstructed particle, set independently from four vector. Four momentum state is not kept
0137   /// consistent internally [GeV]
0138   void setMass(float value);
0139   /// Get mutable reference to mass of the reconstructed particle, set independently from four vector. Four momentum
0140   /// state is not kept consistent internally [GeV]
0141   float& getMass();
0142   /// Get reference to mass of the reconstructed particle, set independently from four vector. Four momentum state is
0143   /// not kept consistent internally [GeV]
0144   [[deprecated("use getMass instead")]] float& mass();
0145 
0146   /// Set the overall goodness of the PID on a scale of [0;1]
0147   void setGoodnessOfPID(float value);
0148   /// Get mutable reference to overall goodness of the PID on a scale of [0;1]
0149   float& getGoodnessOfPID();
0150   /// Get reference to overall goodness of the PID on a scale of [0;1]
0151   [[deprecated("use getGoodnessOfPID instead")]] float& goodnessOfPID();
0152 
0153   /// Set the covariance matrix of the reconstructed particle 4vector
0154   void setCovMatrix(edm4hep::CovMatrix4f value);
0155   /// Get mutable reference to covariance matrix of the reconstructed particle 4vector
0156   edm4hep::CovMatrix4f& getCovMatrix();
0157   /// Get reference to covariance matrix of the reconstructed particle 4vector
0158   [[deprecated("use getCovMatrix instead")]] edm4hep::CovMatrix4f& covMatrix();
0159 
0160   /// Set the decay vertex for the particle (if it is a composite particle)
0161   void setDecayVertex(const edm4hep::Vertex& value);
0162 
0163   void addToClusters(const edm4hep::Cluster&);
0164   std::size_t clusters_size() const;
0165   edm4hep::Cluster getClusters(std::size_t) const;
0166   std::vector<edm4hep::Cluster>::const_iterator clusters_begin() const;
0167   std::vector<edm4hep::Cluster>::const_iterator clusters_end() const;
0168   podio::RelationRange<edm4hep::Cluster> getClusters() const;
0169   void addToTracks(const edm4hep::Track&);
0170   std::size_t tracks_size() const;
0171   edm4hep::Track getTracks(std::size_t) const;
0172   std::vector<edm4hep::Track>::const_iterator tracks_begin() const;
0173   std::vector<edm4hep::Track>::const_iterator tracks_end() const;
0174   podio::RelationRange<edm4hep::Track> getTracks() const;
0175   void addToParticles(const edm4hep::ReconstructedParticle&);
0176   std::size_t particles_size() const;
0177   edm4hep::ReconstructedParticle getParticles(std::size_t) const;
0178   std::vector<edm4hep::ReconstructedParticle>::const_iterator particles_begin() const;
0179   std::vector<edm4hep::ReconstructedParticle>::const_iterator particles_end() const;
0180   podio::RelationRange<edm4hep::ReconstructedParticle> getParticles() const;
0181 
0182   bool isCompound() const {
0183     return particles_size() > 0;
0184   }
0185   [[deprecated("use setPDG instead")]] int32_t getType() const {
0186     return getPDG();
0187   }
0188   /// Get the four momentum covariance matrix value for the two passed dimensions
0189   float getCovMatrix(edm4hep::FourMomCoords dimI, edm4hep::FourMomCoords dimJ) const {
0190     return getCovMatrix().getValue(dimI, dimJ);
0191   }
0192 
0193   // vertex where the particle decays. This method actually returns the start vertex from the first daughter particle
0194   // found.
0195   // TODO: edm4hep::Vertex  getEndVertex() { return  edm4hep::Vertex(  (getParticles(0).isAvailable() ?
0196   // getParticles(0).getStartVertex() :  edm4hep::Vertex(0,0) ) ) ; }
0197   [[deprecated("use setPDG instead")]] void setType(int32_t pdg) {
0198     setPDG(pdg);
0199   }
0200   /// Set the four momentum covariance matrix value for the two passed dimensions
0201   void setCovMatrix(float value, edm4hep::FourMomCoords dimI, edm4hep::FourMomCoords dimJ) {
0202     getCovMatrix().setValue(value, dimI, dimJ);
0203   }
0204 
0205   /// check whether the object is actually available
0206   bool isAvailable() const;
0207   /// disconnect from ReconstructedParticleObj instance
0208   void unlink() {
0209     m_obj = podio::utils::MaybeSharedPtr<ReconstructedParticleObj>{nullptr};
0210   }
0211 
0212   bool operator==(const MutableReconstructedParticle& other) const {
0213     return m_obj == other.m_obj;
0214   }
0215   bool operator==(const ReconstructedParticle& other) const;
0216 
0217   bool operator!=(const MutableReconstructedParticle& other) const {
0218     return !(*this == other);
0219   }
0220   bool operator!=(const ReconstructedParticle& other) const {
0221     return !(*this == other);
0222   }
0223 
0224   // less comparison operator, so that objects can be e.g. stored in sets.
0225   bool operator<(const MutableReconstructedParticle& other) const {
0226     return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other);
0227   }
0228 
0229   podio::ObjectID id() const {
0230     return getObjectID();
0231   }
0232 
0233   const podio::ObjectID getObjectID() const;
0234 
0235   friend void swap(MutableReconstructedParticle& a, MutableReconstructedParticle& b) {
0236     using std::swap;
0237     swap(a.m_obj, b.m_obj); // swap out the internal pointers
0238   }
0239 
0240 private:
0241   /// constructor from existing ReconstructedParticleObj
0242   explicit MutableReconstructedParticle(podio::utils::MaybeSharedPtr<ReconstructedParticleObj> obj);
0243 
0244   podio::utils::MaybeSharedPtr<ReconstructedParticleObj> m_obj{nullptr};
0245 };
0246 
0247 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0248 void to_json(nlohmann::json& j, const MutableReconstructedParticle& value);
0249 #endif
0250 
0251 } // namespace edm4hep
0252 
0253 #endif