Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-29 10:41:47

0001 // AUTOMATICALLY GENERATED FILE - DO NOT EDIT
0002 
0003 #ifndef EDM4EIC_MutableVertex_H
0004 #define EDM4EIC_MutableVertex_H
0005 
0006 #include "edm4eic/VertexObj.h"
0007 // Make the immutable class available from its mutable version but not vice versa
0008 #include "edm4eic/Vertex.h"
0009 
0010 #include "edm4eic/Cov4f.h"
0011 #include "edm4eic/ReconstructedParticle.h"
0012 #include "edm4hep/Vector4f.h"
0013 #include "podio/RelationRange.h"
0014 #include <cstdint>
0015 #include <vector>
0016 
0017 #include "podio/utilities/MaybeSharedPtr.h"
0018 
0019 #include <cstdint>
0020 
0021 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0022 #include "nlohmann/json_fwd.hpp"
0023 #endif
0024 
0025 // forward declarations
0026 namespace edm4eic {
0027 class VertexCollection;
0028 }
0029 
0030 
0031 namespace edm4eic {
0032 
0033 
0034 /** @class MutableVertex
0035  *  EIC vertex
0036  *  @author: J. Osborn
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::int32_t type, const float chi2, const float ndf, const edm4hep::Vector4f& position, const edm4eic::Cov4f& positionError);
0053 
0054   /// copy constructor
0055   MutableVertex(const MutableVertex& other) noexcept = default;
0056 
0057   /// move constructor
0058   MutableVertex(MutableVertex&& other) noexcept = default;
0059 
0060   /// copy-assignment operator
0061   MutableVertex& operator=(MutableVertex other) &; // Rebind this to other's internal object
0062   MutableVertex& operator=(MutableVertex other) && = delete; // Prevent rebinding temporary as the changes wouldn't persist
0063 
0064   /// create a mutable deep-copy of the object with identical relations
0065   /// if cloneRelations=false, the relations are not cloned and will be empty
0066   MutableVertex clone(bool cloneRelations=true) const;
0067 
0068   /// destructor
0069   ~MutableVertex() = default;
0070 
0071 
0072 public:
0073 
0074   /// Access the Type flag, to identify what type of vertex it is (e.g. primary, secondary, generated, etc.)
0075   std::int32_t getType() const;
0076 
0077   /// Access the Chi-squared of the vertex fit
0078   float getChi2() const;
0079 
0080   /// Access the Ndf of the vertex fit, float allows for fractional numbers seen from AMVF - consistent with Acts EDM
0081   float getNdf() const;
0082 
0083   /// Access the position [mm] + time t0 [ns] of the vertex. Time is 4th component in vector
0084   const edm4hep::Vector4f& getPosition() const;
0085 
0086   /// Access the Covariance matrix of the position+time. Time is 4th component, similarly to 4vector
0087   const edm4eic::Cov4f& getPositionError() const;
0088 
0089 
0090 
0091   /// Set the Type flag, to identify what type of vertex it is (e.g. primary, secondary, generated, etc.)
0092   void setType(const std::int32_t type);
0093   /// Get mutable reference to Type flag, to identify what type of vertex it is (e.g. primary, secondary, generated, etc.)
0094   std::int32_t& getType();
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 
0101   /// Set the Ndf of the vertex fit, float allows for fractional numbers seen from AMVF - consistent with Acts EDM
0102   void setNdf(const float ndf);
0103   /// Get mutable reference to Ndf of the vertex fit, float allows for fractional numbers seen from AMVF - consistent with Acts EDM
0104   float& getNdf();
0105 
0106   /// Set the position [mm] + time t0 [ns] of the vertex. Time is 4th component in vector
0107   void setPosition(const edm4hep::Vector4f& position);
0108   /// Get mutable reference to position [mm] + time t0 [ns] of the vertex. Time is 4th component in vector
0109   edm4hep::Vector4f& getPosition();
0110 
0111   /// Set the Covariance matrix of the position+time. Time is 4th component, similarly to 4vector
0112   void setPositionError(const edm4eic::Cov4f& positionError);
0113   /// Get mutable reference to Covariance matrix of the position+time. Time is 4th component, similarly to 4vector
0114   edm4eic::Cov4f& getPositionError();
0115 
0116 
0117 
0118   void addToAssociatedParticles(const edm4eic::ReconstructedParticle&);
0119   std::size_t associatedParticles_size() const;
0120   edm4eic::ReconstructedParticle getAssociatedParticles(std::size_t) const;
0121   std::vector<edm4eic::ReconstructedParticle>::const_iterator associatedParticles_begin() const;
0122   std::vector<edm4eic::ReconstructedParticle>::const_iterator associatedParticles_end() const;
0123   podio::RelationRange<edm4eic::ReconstructedParticle> getAssociatedParticles() const;
0124 
0125 
0126 
0127   /// check whether the object is actually available
0128   bool isAvailable() const;
0129   /// disconnect from VertexObj instance
0130   void unlink() { m_obj = podio::utils::MaybeSharedPtr<VertexObj>{nullptr}; }
0131 
0132   constexpr bool operator==(const MutableVertex& other) const { return m_obj == other.m_obj; }
0133   bool operator==(const Vertex& other) const;
0134 
0135   constexpr bool operator!=(const MutableVertex& other) const { return !(*this == other); }
0136   bool operator!=(const Vertex& other) const { return !(*this == other); }
0137 
0138   // less comparison operator, so that objects can be e.g. stored in sets.
0139   bool operator<(const MutableVertex& other) const { return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other); }
0140 
0141   podio::ObjectID id() const { return getObjectID(); }
0142 
0143   const podio::ObjectID getObjectID() const;
0144 
0145   friend std::hash<MutableVertex>;
0146 
0147   friend void swap(MutableVertex& a, MutableVertex& b) {
0148     using std::swap;
0149     swap(a.m_obj, b.m_obj); // swap out the internal pointers
0150   }
0151 
0152 private:
0153   /// constructor from existing VertexObj
0154   explicit MutableVertex(podio::utils::MaybeSharedPtr<VertexObj> obj);
0155 
0156   podio::utils::MaybeSharedPtr<VertexObj> m_obj{new VertexObj{}, podio::utils::MarkOwned};
0157 };
0158 
0159 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0160 void to_json(nlohmann::json& j, const MutableVertex& value);
0161 #endif
0162 
0163 
0164 } // namespace edm4eic
0165 
0166 
0167 
0168 template<>
0169 struct std::hash<edm4eic::MutableVertex> {
0170   std::size_t operator()(const edm4eic::MutableVertex& obj) const {
0171     return std::hash<edm4eic::VertexObj*>{}(obj.m_obj.get());
0172   }
0173 };
0174 
0175 
0176 #endif