Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-06-30 08:34:23

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();
0050 
0051   /// Constructor initializing all members
0052   MutableVertex(std::uint32_t type, float chi2, std::int32_t ndf, edm4hep::Vector3f position,
0053                 edm4hep::CovMatrix3f covMatrix, std::int32_t algorithmType);
0054 
0055   /// copy constructor
0056   MutableVertex(const MutableVertex& other) = default;
0057 
0058   /// copy-assignment operator
0059   MutableVertex& operator=(MutableVertex other);
0060 
0061   /// create a mutable deep-copy of the object with identical relations
0062   /// if cloneRelations=false, the relations are not cloned and will be empty
0063   MutableVertex clone(bool cloneRelations = true) const;
0064 
0065   /// destructor
0066   ~MutableVertex() = default;
0067 
0068 public:
0069   /// Access the Flagword that defines the type of the vertex, see reserved bits for more information
0070   std::uint32_t getType() const;
0071 
0072   /// Access the chi-squared of the vertex fit
0073   float getChi2() const;
0074 
0075   /// Access the number of degrees of freedom of the vertex fit
0076   std::int32_t getNdf() const;
0077 
0078   /// Access the [mm] position of the vertex
0079   const edm4hep::Vector3f& getPosition() const;
0080 
0081   /// Access the covariance matrix of the position
0082   const edm4hep::CovMatrix3f& getCovMatrix() const;
0083 
0084   /// Access the type code for the algorithm that has been used to create the vertex
0085   std::int32_t getAlgorithmType() const;
0086 
0087   /// Set the Flagword that defines the type of the vertex, see reserved bits for more information
0088   void setType(std::uint32_t value);
0089   /// Get mutable reference to Flagword that defines the type of the vertex, see reserved bits for more information
0090   std::uint32_t& getType();
0091   /// Get reference to Flagword that defines the type of the vertex, see reserved bits for more information
0092   [[deprecated("use getType instead")]] std::uint32_t& type();
0093 
0094   /// Set the chi-squared of the vertex fit
0095   void setChi2(float value);
0096   /// Get mutable reference to chi-squared of the vertex fit
0097   float& getChi2();
0098   /// Get reference to chi-squared of the vertex fit
0099   [[deprecated("use getChi2 instead")]] float& chi2();
0100 
0101   /// Set the number of degrees of freedom of the vertex fit
0102   void setNdf(std::int32_t value);
0103   /// Get mutable reference to number of degrees of freedom of the vertex fit
0104   std::int32_t& getNdf();
0105   /// Get reference to number of degrees of freedom of the vertex fit
0106   [[deprecated("use getNdf instead")]] std::int32_t& ndf();
0107 
0108   /// Set the [mm] position of the vertex
0109   void setPosition(edm4hep::Vector3f value);
0110   /// Get mutable reference to [mm] position of the vertex
0111   edm4hep::Vector3f& getPosition();
0112   /// Get reference to [mm] position of the vertex
0113   [[deprecated("use getPosition instead")]] edm4hep::Vector3f& position();
0114 
0115   /// Set the covariance matrix of the position
0116   void setCovMatrix(edm4hep::CovMatrix3f value);
0117   /// Get mutable reference to covariance matrix of the position
0118   edm4hep::CovMatrix3f& getCovMatrix();
0119   /// Get reference to covariance matrix of the position
0120   [[deprecated("use getCovMatrix instead")]] edm4hep::CovMatrix3f& covMatrix();
0121 
0122   /// Set the type code for the algorithm that has been used to create the vertex
0123   void setAlgorithmType(std::int32_t value);
0124   /// Get mutable reference to type code for the algorithm that has been used to create the vertex
0125   std::int32_t& getAlgorithmType();
0126   /// Get reference to type code for the algorithm that has been used to create the vertex
0127   [[deprecated("use getAlgorithmType instead")]] std::int32_t& algorithmType();
0128 
0129   void addToParticles(const edm4hep::ReconstructedParticle&);
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   void addToParameters(const float&);
0136   std::size_t parameters_size() const;
0137   float getParameters(std::size_t) const;
0138   std::vector<float>::const_iterator parameters_begin() const;
0139   std::vector<float>::const_iterator parameters_end() const;
0140   podio::RelationRange<float> getParameters() const;
0141 
0142   /// Get the position covariance matrix value for the two passed dimensions
0143   float getCovMatrix(edm4hep::Cartesian dimI, edm4hep::Cartesian dimJ) const {
0144     return getCovMatrix().getValue(dimI, dimJ);
0145   }
0146   // Reserved bits for the type flagword
0147   static constexpr int BITPrimaryVertex = 1;
0148   static constexpr int BITSecondaryVertex = 2;
0149   static constexpr int BITTertiaryVertex = 2;
0150 
0151   /// Check if this is a primary vertex
0152   bool isPrimary() const {
0153     return utils::checkBit(getType(), BITPrimaryVertex);
0154   }
0155   /// Check if this is a secondary vertex
0156   bool isSecondary() const {
0157     return utils::checkBit(getType(), BITSecondaryVertex);
0158   }
0159   /// Check if this is a tertiary vertex
0160   bool isTertiary() const {
0161     return utils::checkBit(getType(), BITTertiaryVertex);
0162   }
0163 
0164   /// Set the position covariance matrix value for the two passed dimensions
0165   void setCovMatrix(float value, edm4hep::Cartesian dimI, edm4hep::Cartesian dimJ) {
0166     getCovMatrix().setValue(value, dimI, dimJ);
0167   }
0168 
0169   /// Set the primary vertex flag for this vertex
0170   void setPrimary(bool value = true) {
0171     setType(utils::setBit(getType(), BITPrimaryVertex, value));
0172   }
0173   /// Set the secondary vertex flag for this vertex
0174   void setSecondary(bool value = true) {
0175     setType(utils::setBit(getType(), BITSecondaryVertex, value));
0176   }
0177   /// Set the tertiary vertex flag for this vertex
0178   void setTertiary(bool value = true) {
0179     setType(utils::setBit(getType(), BITTertiaryVertex, value));
0180   }
0181 
0182   /// check whether the object is actually available
0183   bool isAvailable() const;
0184   /// disconnect from VertexObj instance
0185   void unlink() {
0186     m_obj = podio::utils::MaybeSharedPtr<VertexObj>{nullptr};
0187   }
0188 
0189   bool operator==(const MutableVertex& other) const {
0190     return m_obj == other.m_obj;
0191   }
0192   bool operator==(const Vertex& other) const;
0193 
0194   bool operator!=(const MutableVertex& other) const {
0195     return !(*this == other);
0196   }
0197   bool operator!=(const Vertex& other) const {
0198     return !(*this == other);
0199   }
0200 
0201   // less comparison operator, so that objects can be e.g. stored in sets.
0202   bool operator<(const MutableVertex& other) const {
0203     return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other);
0204   }
0205 
0206   podio::ObjectID id() const {
0207     return getObjectID();
0208   }
0209 
0210   const podio::ObjectID getObjectID() const;
0211 
0212   friend void swap(MutableVertex& a, MutableVertex& b) {
0213     using std::swap;
0214     swap(a.m_obj, b.m_obj); // swap out the internal pointers
0215   }
0216 
0217 private:
0218   /// constructor from existing VertexObj
0219   explicit MutableVertex(podio::utils::MaybeSharedPtr<VertexObj> obj);
0220 
0221   podio::utils::MaybeSharedPtr<VertexObj> m_obj{nullptr};
0222 };
0223 
0224 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0225 void to_json(nlohmann::json& j, const MutableVertex& value);
0226 #endif
0227 
0228 } // namespace edm4hep
0229 
0230 #endif