Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-15 08:55:58

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