Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/edm4hep/MutableVertex.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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