Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-16 08:53:25

0001 // AUTOMATICALLY GENERATED FILE - DO NOT EDIT
0002 
0003 #ifndef EDM4EIC_MutableTrack_H
0004 #define EDM4EIC_MutableTrack_H
0005 
0006 #include "edm4eic/TrackObj.h"
0007 // Make the immutable class available from its mutable version but not vice versa
0008 #include "edm4eic/Track.h"
0009 
0010 #include "edm4eic/Cov6f.h"
0011 #include "edm4eic/Measurement2D.h"
0012 #include "edm4hep/Vector3f.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 TrackCollection;
0028 class Trajectory;
0029 class MutableTrajectory;
0030 }
0031 
0032 
0033 namespace edm4eic {
0034 
0035 
0036 /** @class MutableTrack
0037  *  Track information at the vertex
0038  *  @author: S. Joosten, J. Osborn
0039  */
0040 class MutableTrack {
0041 
0042   friend class TrackCollection;
0043   friend class TrackMutableCollectionIterator;
0044   friend class Track;
0045 
0046 public:
0047   using object_type = Track;
0048   using collection_type = TrackCollection;
0049 
0050   /// default constructor
0051   MutableTrack();
0052 
0053   /// Constructor initializing all members
0054   MutableTrack(const std::int32_t type, const edm4hep::Vector3f& position, const edm4hep::Vector3f& momentum, const edm4eic::Cov6f& positionMomentumCovariance, const float time, const float timeError, const float charge, const float chi2, const std::uint32_t ndf, const std::int32_t pdg);
0055 
0056   /// copy constructor
0057   MutableTrack(const MutableTrack& other) = default;
0058 
0059   /// copy-assignment operator
0060   MutableTrack& operator=(MutableTrack other) &; // Rebind this to other's internal object
0061   MutableTrack& operator=(MutableTrack 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   MutableTrack clone(bool cloneRelations=true) const;
0066 
0067   /// destructor
0068   ~MutableTrack() = default;
0069 
0070 
0071 public:
0072 
0073   /// Access the Flag that defines the type of track
0074   std::int32_t getType() const;
0075 
0076   /// Access the Track 3-position at the vertex
0077   const edm4hep::Vector3f& getPosition() const;
0078 
0079   /// Access the Track 3-momentum at the vertex [GeV]
0080   const edm4hep::Vector3f& getMomentum() const;
0081 
0082   /// Access the Covariance matrix in basis [x,y,z,px,py,pz]
0083   const edm4eic::Cov6f& getPositionMomentumCovariance() const;
0084 
0085   /// Access the Track time at the vertex [ns]
0086   float getTime() const;
0087 
0088   /// Access the Error on the track vertex time
0089   float getTimeError() const;
0090 
0091   /// Access the Particle charge
0092   float getCharge() const;
0093 
0094   /// Access the Total chi2
0095   float getChi2() const;
0096 
0097   /// Access the Number of degrees of freedom
0098   std::uint32_t getNdf() const;
0099 
0100   /// Access the PDG particle ID hypothesis
0101   std::int32_t getPdg() const;
0102 
0103 
0104   /// Access the Trajectory of this track
0105   const edm4eic::Trajectory getTrajectory() const;
0106 
0107   /// Set the Flag that defines the type of track
0108   void setType(const std::int32_t type);
0109   /// Get mutable reference to Flag that defines the type of track
0110   std::int32_t& getType();
0111   /// Get reference to Flag that defines the type of track
0112   [[deprecated("use getType instead")]]
0113   std::int32_t& type();
0114 
0115   /// Set the Track 3-position at the vertex
0116   void setPosition(const edm4hep::Vector3f& position);
0117   /// Get mutable reference to Track 3-position at the vertex
0118   edm4hep::Vector3f& getPosition();
0119   /// Get reference to Track 3-position at the vertex
0120   [[deprecated("use getPosition instead")]]
0121   edm4hep::Vector3f& position();
0122 
0123   /// Set the Track 3-momentum at the vertex [GeV]
0124   void setMomentum(const edm4hep::Vector3f& momentum);
0125   /// Get mutable reference to Track 3-momentum at the vertex [GeV]
0126   edm4hep::Vector3f& getMomentum();
0127   /// Get reference to Track 3-momentum at the vertex [GeV]
0128   [[deprecated("use getMomentum instead")]]
0129   edm4hep::Vector3f& momentum();
0130 
0131   /// Set the Covariance matrix in basis [x,y,z,px,py,pz]
0132   void setPositionMomentumCovariance(const edm4eic::Cov6f& positionMomentumCovariance);
0133   /// Get mutable reference to Covariance matrix in basis [x,y,z,px,py,pz]
0134   edm4eic::Cov6f& getPositionMomentumCovariance();
0135   /// Get reference to Covariance matrix in basis [x,y,z,px,py,pz]
0136   [[deprecated("use getPositionMomentumCovariance instead")]]
0137   edm4eic::Cov6f& positionMomentumCovariance();
0138 
0139   /// Set the Track time at the vertex [ns]
0140   void setTime(const float time);
0141   /// Get mutable reference to Track time at the vertex [ns]
0142   float& getTime();
0143   /// Get reference to Track time at the vertex [ns]
0144   [[deprecated("use getTime instead")]]
0145   float& time();
0146 
0147   /// Set the Error on the track vertex time
0148   void setTimeError(const float timeError);
0149   /// Get mutable reference to Error on the track vertex time
0150   float& getTimeError();
0151   /// Get reference to Error on the track vertex time
0152   [[deprecated("use getTimeError instead")]]
0153   float& timeError();
0154 
0155   /// Set the Particle charge
0156   void setCharge(const float charge);
0157   /// Get mutable reference to Particle charge
0158   float& getCharge();
0159   /// Get reference to Particle charge
0160   [[deprecated("use getCharge instead")]]
0161   float& charge();
0162 
0163   /// Set the Total chi2
0164   void setChi2(const float chi2);
0165   /// Get mutable reference to Total chi2
0166   float& getChi2();
0167   /// Get reference to Total chi2
0168   [[deprecated("use getChi2 instead")]]
0169   float& chi2();
0170 
0171   /// Set the Number of degrees of freedom
0172   void setNdf(const std::uint32_t ndf);
0173   /// Get mutable reference to Number of degrees of freedom
0174   std::uint32_t& getNdf();
0175   /// Get reference to Number of degrees of freedom
0176   [[deprecated("use getNdf instead")]]
0177   std::uint32_t& ndf();
0178 
0179   /// Set the PDG particle ID hypothesis
0180   void setPdg(const std::int32_t pdg);
0181   /// Get mutable reference to PDG particle ID hypothesis
0182   std::int32_t& getPdg();
0183   /// Get reference to PDG particle ID hypothesis
0184   [[deprecated("use getPdg instead")]]
0185   std::int32_t& pdg();
0186 
0187 
0188   /// Set the Trajectory of this track
0189   void setTrajectory(const edm4eic::Trajectory& value);
0190 
0191   void addToMeasurements(const edm4eic::Measurement2D&);
0192   std::size_t measurements_size() const;
0193   edm4eic::Measurement2D getMeasurements(std::size_t) const;
0194   std::vector<edm4eic::Measurement2D>::const_iterator measurements_begin() const;
0195   std::vector<edm4eic::Measurement2D>::const_iterator measurements_end() const;
0196   podio::RelationRange<edm4eic::Measurement2D> getMeasurements() const;
0197   void addToTracks(const edm4eic::Track&);
0198   std::size_t tracks_size() const;
0199   edm4eic::Track getTracks(std::size_t) const;
0200   std::vector<edm4eic::Track>::const_iterator tracks_begin() const;
0201   std::vector<edm4eic::Track>::const_iterator tracks_end() const;
0202   podio::RelationRange<edm4eic::Track> getTracks() const;
0203 
0204 
0205 
0206   /// check whether the object is actually available
0207   bool isAvailable() const;
0208   /// disconnect from TrackObj instance
0209   void unlink() { m_obj = podio::utils::MaybeSharedPtr<TrackObj>{nullptr}; }
0210 
0211   bool operator==(const MutableTrack& other) const { return m_obj == other.m_obj; }
0212   bool operator==(const Track& other) const;
0213 
0214   bool operator!=(const MutableTrack& other) const { return !(*this == other); }
0215   bool operator!=(const Track& other) const { return !(*this == other); }
0216 
0217   // less comparison operator, so that objects can be e.g. stored in sets.
0218   bool operator<(const MutableTrack& other) const { return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other); }
0219 
0220   podio::ObjectID id() const { return getObjectID(); }
0221 
0222   const podio::ObjectID getObjectID() const;
0223 
0224   friend std::hash<MutableTrack>;
0225 
0226   friend void swap(MutableTrack& a, MutableTrack& b) {
0227     using std::swap;
0228     swap(a.m_obj, b.m_obj); // swap out the internal pointers
0229   }
0230 
0231 private:
0232   /// constructor from existing TrackObj
0233   explicit MutableTrack(podio::utils::MaybeSharedPtr<TrackObj> obj);
0234 
0235   podio::utils::MaybeSharedPtr<TrackObj> m_obj{nullptr};
0236 };
0237 
0238 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0239 void to_json(nlohmann::json& j, const MutableTrack& value);
0240 #endif
0241 
0242 
0243 } // namespace edm4eic
0244 
0245 
0246 
0247 template<>
0248 struct std::hash<edm4eic::MutableTrack> {
0249   std::size_t operator()(const edm4eic::MutableTrack& obj) const {
0250     return std::hash<edm4eic::TrackObj*>{}(obj.m_obj.get());
0251   }
0252 };
0253 
0254 
0255 #endif