Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-02 08:13:52

0001 // AUTOMATICALLY GENERATED FILE - DO NOT EDIT
0002 
0003 #ifndef EDM4HEP_ReconstructedParticle_H
0004 #define EDM4HEP_ReconstructedParticle_H
0005 
0006 #include "edm4hep/ReconstructedParticleObj.h"
0007 
0008 #include "edm4hep/Cluster.h"
0009 #include "edm4hep/CovMatrix4f.h"
0010 #include "edm4hep/Track.h"
0011 #include "edm4hep/Vector3f.h"
0012 #include "podio/RelationRange.h"
0013 #include <cstdint>
0014 #include <edm4hep/Constants.h>
0015 #include <vector>
0016 
0017 #include "podio/detail/OrderKey.h"
0018 #include "podio/utilities/MaybeSharedPtr.h"
0019 
0020 #include <cstdint>
0021 #include <ostream>
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 podio::detail {
0035 // Internal function used in less comparison operators of the datatypes and interface types
0036 OrderKey getOrderKey(const edm4hep::ReconstructedParticle& obj);
0037 }; // namespace podio::detail
0038 
0039 namespace edm4hep {
0040 
0041 class MutableReconstructedParticle;
0042 class ReconstructedParticleCollection;
0043 class ReconstructedParticleCollectionData;
0044 
0045 /** @class ReconstructedParticle
0046  *  Reconstructed Particle
0047  *  @author: EDM4hep authors
0048  */
0049 class ReconstructedParticle {
0050 
0051   friend class MutableReconstructedParticle;
0052   friend class ReconstructedParticleCollection;
0053   friend class edm4hep::ReconstructedParticleCollectionData;
0054   friend class ReconstructedParticleCollectionIterator;
0055   friend podio::detail::OrderKey podio::detail::getOrderKey(const ReconstructedParticle& obj);
0056 
0057 public:
0058   using mutable_type = MutableReconstructedParticle;
0059   using collection_type = ReconstructedParticleCollection;
0060 
0061   /// default constructor
0062   ReconstructedParticle() = default;
0063 
0064   /// Constructor initializing all members
0065   ReconstructedParticle(const std::int32_t PDG, const float energy, const edm4hep::Vector3f& momentum,
0066                         const edm4hep::Vector3f& referencePoint, const float charge, const float mass,
0067                         const float goodnessOfPID, const edm4hep::CovMatrix4f& covMatrix);
0068 
0069   /// copy constructor
0070   ReconstructedParticle(const ReconstructedParticle& other) = default;
0071 
0072   /// copy-assignment operator
0073   ReconstructedParticle& operator=(ReconstructedParticle other) &; // Rebind this to other's internal object
0074   ReconstructedParticle&
0075   operator=(ReconstructedParticle other) && = delete; // Prevent rebinding temporary as the changes wouldn't persist
0076 
0077   /// create a mutable deep-copy of the object with identical relations
0078   /// if cloneRelations=false, the relations are not cloned and will be empty
0079   MutableReconstructedParticle clone(bool cloneRelations = true) const;
0080 
0081   /// destructor
0082   ~ReconstructedParticle() = default;
0083 
0084   /// converting constructor from mutable object
0085   ReconstructedParticle(const MutableReconstructedParticle& other);
0086 
0087   static ReconstructedParticle makeEmpty();
0088 
0089 public:
0090   static constexpr std::string_view typeName = "edm4hep::ReconstructedParticle";
0091 
0092   /// Access the PDG of the reconstructed particle.
0093   std::int32_t getPDG() const;
0094 
0095   /// Access the energy of the reconstructed particle. Four momentum state is not kept consistent internally [GeV]
0096   float getEnergy() const;
0097 
0098   /// Access the particle momentum. Four momentum state is not kept consistent internally [GeV]
0099   const edm4hep::Vector3f& getMomentum() const;
0100 
0101   /// Access the reference, i.e. where the particle has been measured [mm]
0102   const edm4hep::Vector3f& getReferencePoint() const;
0103 
0104   /// Access the charge of the reconstructed particle [e]
0105   float getCharge() const;
0106 
0107   /// Access the mass of the reconstructed particle, set independently from four vector. Four momentum state is not kept
0108   /// consistent internally [GeV]
0109   float getMass() const;
0110 
0111   /// Access the overall goodness of the PID on a scale of [0;1]
0112   float getGoodnessOfPID() const;
0113 
0114   /// Access the covariance matrix of the reconstructed particle 4vector [GeV^2]
0115   const edm4hep::CovMatrix4f& getCovMatrix() const;
0116 
0117   /// Access the decay vertex for the particle (if it is a composite particle)
0118   const edm4hep::Vertex getDecayVertex() const;
0119 
0120   std::size_t clusters_size() const;
0121   edm4hep::Cluster getClusters(std::size_t) const;
0122   std::vector<edm4hep::Cluster>::const_iterator clusters_begin() const;
0123   std::vector<edm4hep::Cluster>::const_iterator clusters_end() const;
0124   podio::RelationRange<edm4hep::Cluster> getClusters() const;
0125   std::size_t tracks_size() const;
0126   edm4hep::Track getTracks(std::size_t) const;
0127   std::vector<edm4hep::Track>::const_iterator tracks_begin() const;
0128   std::vector<edm4hep::Track>::const_iterator tracks_end() const;
0129   podio::RelationRange<edm4hep::Track> getTracks() const;
0130   std::size_t particles_size() const;
0131   edm4hep::ReconstructedParticle getParticles(std::size_t) const;
0132   std::vector<edm4hep::ReconstructedParticle>::const_iterator particles_begin() const;
0133   std::vector<edm4hep::ReconstructedParticle>::const_iterator particles_end() const;
0134   podio::RelationRange<edm4hep::ReconstructedParticle> getParticles() const;
0135 
0136   bool isCompound() const { return particles_size() > 0; }
0137   /// Get the four momentum covariance matrix value for the two passed dimensions
0138   float getCovMatrix(edm4hep::FourMomCoords dimI, edm4hep::FourMomCoords dimJ) const {
0139     return getCovMatrix().getValue(dimI, dimJ);
0140   }
0141 
0142   /// check whether the object is actually available
0143   bool isAvailable() const;
0144   /// disconnect from ReconstructedParticleObj instance
0145   void unlink() { m_obj = podio::utils::MaybeSharedPtr<ReconstructedParticleObj>{nullptr}; }
0146 
0147   bool operator==(const ReconstructedParticle& other) const { return m_obj == other.m_obj; }
0148   bool operator==(const MutableReconstructedParticle& other) const;
0149 
0150   bool operator!=(const ReconstructedParticle& other) const { return !(*this == other); }
0151   bool operator!=(const MutableReconstructedParticle& other) const { return !(*this == other); }
0152 
0153   // less comparison operator, so that objects can be e.g. stored in sets.
0154   bool operator<(const ReconstructedParticle& other) const {
0155     return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other);
0156   }
0157 
0158   podio::ObjectID id() const { return getObjectID(); }
0159 
0160   const podio::ObjectID getObjectID() const;
0161 
0162   friend std::hash<ReconstructedParticle>;
0163 
0164   friend void swap(ReconstructedParticle& a, ReconstructedParticle& b) {
0165     using std::swap;
0166     swap(a.m_obj, b.m_obj); // swap out the internal pointers
0167   }
0168 
0169 private:
0170   /// constructor from existing ReconstructedParticleObj
0171   explicit ReconstructedParticle(podio::utils::MaybeSharedPtr<ReconstructedParticleObj> obj);
0172   ReconstructedParticle(ReconstructedParticleObj* obj);
0173 
0174   podio::utils::MaybeSharedPtr<ReconstructedParticleObj> m_obj{new ReconstructedParticleObj{}, podio::utils::MarkOwned};
0175 };
0176 
0177 std::ostream& operator<<(std::ostream& o, const ReconstructedParticle& value);
0178 
0179 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0180 void to_json(nlohmann::json& j, const ReconstructedParticle& value);
0181 #endif
0182 
0183 } // namespace edm4hep
0184 
0185 template <>
0186 struct std::hash<edm4hep::ReconstructedParticle> {
0187   std::size_t operator()(const edm4hep::ReconstructedParticle& obj) const {
0188     return std::hash<edm4hep::ReconstructedParticleObj*>{}(obj.m_obj.get());
0189   }
0190 };
0191 
0192 // This is needed to avoid triggering opening every library in LD_LIBRARY_PATH
0193 // until it's fixed in ROOT. See https://github.com/root-project/root/issues/18489
0194 // and https://github.com/AIDASoft/podio/issues/770
0195 #if defined(__clang__)
0196 #pragma clang diagnostic push
0197 #pragma clang diagnostic ignored "-Wunknown-warning-option"
0198 #pragma clang diagnostic ignored "-Wdeprecated-redundant-constexpr-static-def"
0199 #pragma clang diagnostic ignored "-Wdeprecated"
0200 constexpr std::string_view edm4hep::ReconstructedParticle::typeName;
0201 #pragma clang diagnostic pop
0202 #elif defined(__GNUC__)
0203 #pragma GCC diagnostic push
0204 #pragma GCC diagnostic ignored "-Wdeprecated"
0205 constexpr std::string_view edm4hep::ReconstructedParticle::typeName;
0206 #pragma GCC diagnostic pop
0207 #endif
0208 
0209 #endif