Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-13 10:09:30

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