Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-12-02 10:00:45

0001 // AUTOMATICALLY GENERATED FILE - DO NOT EDIT
0002 
0003 #ifndef EDM4HEP_Vertex_H
0004 #define EDM4HEP_Vertex_H
0005 
0006 #include "edm4hep/VertexObj.h"
0007 
0008 #include "edm4hep/CovMatrix3f.h"
0009 #include "edm4hep/ReconstructedParticle.h"
0010 #include "edm4hep/Vector3f.h"
0011 #include "podio/RelationRange.h"
0012 #include <cstdint>
0013 #include <edm4hep/Constants.h>
0014 #include <edm4hep/utils/bit_utils.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 VertexCollection;
0030 }
0031 
0032 namespace podio::detail {
0033 // Internal function used in less comparison operators of the datatypes and interface types
0034 OrderKey getOrderKey(const edm4hep::Vertex& obj);
0035 }; // namespace podio::detail
0036 
0037 namespace edm4hep {
0038 
0039 class MutableVertex;
0040 class VertexCollection;
0041 class VertexCollectionData;
0042 
0043 /** @class Vertex
0044  *  Vertex
0045  *  @author: EDM4hep authors
0046  */
0047 class Vertex {
0048 
0049   friend class MutableVertex;
0050   friend class VertexCollection;
0051   friend class edm4hep::VertexCollectionData;
0052   friend class VertexCollectionIterator;
0053   friend podio::detail::OrderKey podio::detail::getOrderKey(const Vertex& obj);
0054 
0055 public:
0056   using mutable_type = MutableVertex;
0057   using collection_type = VertexCollection;
0058 
0059   /// default constructor
0060   Vertex() = default;
0061 
0062   /// Constructor initializing all members
0063   Vertex(const std::uint32_t type, const float chi2, const std::int32_t ndf, const edm4hep::Vector3f& position,
0064          const edm4hep::CovMatrix3f& covMatrix, const std::int32_t algorithmType);
0065 
0066   /// copy constructor
0067   Vertex(const Vertex& other) noexcept = default;
0068 
0069   /// move constructor
0070   Vertex(Vertex&& other) noexcept = default;
0071 
0072   /// copy-assignment operator
0073   Vertex& operator=(Vertex other) &;           // Rebind this to other's internal object
0074   Vertex& operator=(Vertex other) && = delete; // Prevent rebinding temporary as the changes wouldn't persist
0075 
0076   /// create a mutable deep-copy of the object with identical relations
0077   /// if cloneRelations=false, the relations are not cloned and will be empty
0078   MutableVertex clone(bool cloneRelations = true) const;
0079 
0080   /// destructor
0081   ~Vertex() = default;
0082 
0083   /// converting constructor from mutable object
0084   Vertex(const MutableVertex& other);
0085 
0086   static Vertex makeEmpty();
0087 
0088 public:
0089   static constexpr std::string_view typeName = "edm4hep::Vertex";
0090 
0091   /// Access the flagword that defines the type of the vertex, see reserved bits for more information
0092   std::uint32_t getType() const;
0093 
0094   /// Access the chi-squared of the vertex fit
0095   float getChi2() const;
0096 
0097   /// Access the number of degrees of freedom of the vertex fit
0098   std::int32_t getNdf() const;
0099 
0100   /// Access the position of the vertex [mm]
0101   const edm4hep::Vector3f& getPosition() const;
0102 
0103   /// Access the covariance matrix of the position [mm^2]
0104   const edm4hep::CovMatrix3f& getCovMatrix() const;
0105 
0106   /// Access the type code for the algorithm that has been used to create the vertex
0107   std::int32_t getAlgorithmType() const;
0108 
0109   std::size_t particles_size() const;
0110   edm4hep::ReconstructedParticle getParticles(std::size_t) const;
0111   std::vector<edm4hep::ReconstructedParticle>::const_iterator particles_begin() const;
0112   std::vector<edm4hep::ReconstructedParticle>::const_iterator particles_end() const;
0113   podio::RelationRange<edm4hep::ReconstructedParticle> getParticles() const;
0114   std::size_t parameters_size() const;
0115   float getParameters(std::size_t) const;
0116   std::vector<float>::const_iterator parameters_begin() const;
0117   std::vector<float>::const_iterator parameters_end() const;
0118   podio::RelationRange<float> getParameters() const;
0119 
0120   /// Get the position covariance matrix value for the two passed dimensions
0121   float getCovMatrix(edm4hep::Cartesian dimI, edm4hep::Cartesian dimJ) const {
0122     return getCovMatrix().getValue(dimI, dimJ);
0123   }
0124   // Reserved bits for the type flagword
0125   static constexpr int BITPrimaryVertex = 1;
0126   static constexpr int BITSecondaryVertex = 2;
0127   static constexpr int BITTertiaryVertex = 3;
0128 
0129   /// Check if this is a primary vertex
0130   bool isPrimary() const { return utils::checkBit(getType(), BITPrimaryVertex); }
0131   /// Check if this is a secondary vertex
0132   bool isSecondary() const { return utils::checkBit(getType(), BITSecondaryVertex); }
0133   /// Check if this is a tertiary vertex
0134   bool isTertiary() const { return utils::checkBit(getType(), BITTertiaryVertex); }
0135 
0136   /// check whether the object is actually available
0137   bool isAvailable() const;
0138   /// disconnect from VertexObj instance
0139   void unlink() { m_obj = podio::utils::MaybeSharedPtr<VertexObj>{nullptr}; }
0140 
0141   constexpr bool operator==(const Vertex& other) const { return m_obj == other.m_obj; }
0142   bool operator==(const MutableVertex& other) const;
0143 
0144   constexpr bool operator!=(const Vertex& other) const { return !(*this == other); }
0145   bool operator!=(const MutableVertex& other) const { return !(*this == other); }
0146 
0147   // less comparison operator, so that objects can be e.g. stored in sets.
0148   bool operator<(const Vertex& other) const {
0149     return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other);
0150   }
0151 
0152   podio::ObjectID id() const { return getObjectID(); }
0153 
0154   const podio::ObjectID getObjectID() const;
0155 
0156   friend std::hash<Vertex>;
0157 
0158   friend void swap(Vertex& a, Vertex& b) {
0159     using std::swap;
0160     swap(a.m_obj, b.m_obj); // swap out the internal pointers
0161   }
0162 
0163 private:
0164   /// constructor from existing VertexObj
0165   explicit Vertex(podio::utils::MaybeSharedPtr<VertexObj> obj);
0166   Vertex(VertexObj* obj);
0167 
0168   podio::utils::MaybeSharedPtr<VertexObj> m_obj{new VertexObj{}, podio::utils::MarkOwned};
0169 };
0170 
0171 std::ostream& operator<<(std::ostream& o, const Vertex& value);
0172 
0173 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0174 void to_json(nlohmann::json& j, const Vertex& value);
0175 #endif
0176 
0177 } // namespace edm4hep
0178 
0179 template <>
0180 struct std::hash<edm4hep::Vertex> {
0181   std::size_t operator()(const edm4hep::Vertex& obj) const { return std::hash<edm4hep::VertexObj*>{}(obj.m_obj.get()); }
0182 };
0183 
0184 // This is needed to avoid triggering opening every library in LD_LIBRARY_PATH
0185 // until it's fixed in ROOT. See https://github.com/root-project/root/issues/18489
0186 // and https://github.com/AIDASoft/podio/issues/770
0187 #if defined(__clang__)
0188 #pragma clang diagnostic push
0189 #pragma clang diagnostic ignored "-Wunknown-warning-option"
0190 #pragma clang diagnostic ignored "-Wdeprecated-redundant-constexpr-static-def"
0191 #pragma clang diagnostic ignored "-Wdeprecated"
0192 constexpr std::string_view edm4hep::Vertex::typeName;
0193 #pragma clang diagnostic pop
0194 #elif defined(__GNUC__)
0195 #pragma GCC diagnostic push
0196 #pragma GCC diagnostic ignored "-Wdeprecated"
0197 constexpr std::string_view edm4hep::Vertex::typeName;
0198 #pragma GCC diagnostic pop
0199 #endif
0200 
0201 #endif