Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 08:55:05

0001 // AUTOMATICALLY GENERATED FILE - DO NOT EDIT
0002 
0003 #ifndef EDM4EIC_Track_H
0004 #define EDM4EIC_Track_H
0005 
0006 #include "edm4eic/TrackObj.h"
0007 
0008 #include "edm4eic/Cov6f.h"
0009 #include "edm4eic/Measurement2D.h"
0010 #include "edm4hep/Vector3f.h"
0011 #include "podio/RelationRange.h"
0012 #include <cstdint>
0013 #include <vector>
0014 
0015 #include "podio/utilities/MaybeSharedPtr.h"
0016 #include "podio/detail/OrderKey.h"
0017 
0018 #include <ostream>
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 podio::detail {
0034 // Internal function used in less comparison operators of the datatypes and interface types
0035 OrderKey getOrderKey(const edm4eic::Track& obj);
0036 };
0037 
0038 namespace edm4eic {
0039 
0040 class MutableTrack;
0041 class TrackCollection;
0042 class TrackCollectionData;
0043 
0044 /** @class Track
0045  *  Track information at the vertex
0046  *  @author: S. Joosten, J. Osborn
0047  */
0048 class Track {
0049 
0050   friend class MutableTrack;
0051   friend class TrackCollection;
0052   friend class edm4eic::TrackCollectionData;
0053   friend class TrackCollectionIterator;
0054   friend podio::detail::OrderKey podio::detail::getOrderKey(const Track & obj);
0055 
0056 public:
0057   using mutable_type = MutableTrack;
0058   using collection_type = TrackCollection;
0059 
0060   /// default constructor
0061   Track();
0062 
0063   /// Constructor initializing all members
0064   Track(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);
0065 
0066   /// copy constructor
0067   Track(const Track& other) = default;
0068 
0069   /// copy-assignment operator
0070   Track& operator=(Track other) &; // Rebind this to other's internal object
0071   Track& operator=(Track other) && = delete; // Prevent rebinding temporary as the changes wouldn't persist
0072 
0073   /// create a mutable deep-copy of the object with identical relations
0074   /// if cloneRelations=false, the relations are not cloned and will be empty
0075   MutableTrack clone(bool cloneRelations=true) const;
0076 
0077   /// destructor
0078   ~Track() = default;
0079 
0080   /// converting constructor from mutable object
0081   Track(const MutableTrack& other);
0082 
0083   static Track makeEmpty();
0084 
0085 public:
0086 
0087   static constexpr std::string_view typeName = "edm4eic::Track";
0088 
0089   /// Access the Flag that defines the type of track
0090   std::int32_t getType() const;
0091 
0092   /// Access the Track 3-position at the vertex
0093   const edm4hep::Vector3f& getPosition() const;
0094 
0095   /// Access the Track 3-momentum at the vertex [GeV]
0096   const edm4hep::Vector3f& getMomentum() const;
0097 
0098   /// Access the Covariance matrix in basis [x,y,z,px,py,pz]
0099   const edm4eic::Cov6f& getPositionMomentumCovariance() const;
0100 
0101   /// Access the Track time at the vertex [ns]
0102   float getTime() const;
0103 
0104   /// Access the Error on the track vertex time
0105   float getTimeError() const;
0106 
0107   /// Access the Particle charge
0108   float getCharge() const;
0109 
0110   /// Access the Total chi2
0111   float getChi2() const;
0112 
0113   /// Access the Number of degrees of freedom
0114   std::uint32_t getNdf() const;
0115 
0116   /// Access the PDG particle ID hypothesis
0117   std::int32_t getPdg() const;
0118 
0119 
0120   /// Access the Trajectory of this track
0121   const edm4eic::Trajectory getTrajectory() const;
0122 
0123   std::size_t measurements_size() const;
0124   edm4eic::Measurement2D getMeasurements(std::size_t) const;
0125   std::vector<edm4eic::Measurement2D>::const_iterator measurements_begin() const;
0126   std::vector<edm4eic::Measurement2D>::const_iterator measurements_end() const;
0127   podio::RelationRange<edm4eic::Measurement2D> getMeasurements() const;
0128   std::size_t tracks_size() const;
0129   edm4eic::Track getTracks(std::size_t) const;
0130   std::vector<edm4eic::Track>::const_iterator tracks_begin() const;
0131   std::vector<edm4eic::Track>::const_iterator tracks_end() const;
0132   podio::RelationRange<edm4eic::Track> getTracks() const;
0133 
0134 
0135   /// check whether the object is actually available
0136   bool isAvailable() const;
0137   /// disconnect from TrackObj instance
0138   void unlink() { m_obj = podio::utils::MaybeSharedPtr<TrackObj>{nullptr}; }
0139 
0140   bool operator==(const Track& other) const { return m_obj == other.m_obj; }
0141   bool operator==(const MutableTrack& other) const;
0142 
0143   bool operator!=(const Track& other) const { return !(*this == other); }
0144   bool operator!=(const MutableTrack& other) const { return !(*this == other); }
0145 
0146   // less comparison operator, so that objects can be e.g. stored in sets.
0147   bool operator<(const Track& other) const { return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other); }
0148 
0149   podio::ObjectID id() const { return getObjectID(); }
0150 
0151   const podio::ObjectID getObjectID() const;
0152 
0153   friend std::hash<Track>;
0154 
0155   friend void swap(Track& a, Track& b) {
0156     using std::swap;
0157     swap(a.m_obj, b.m_obj); // swap out the internal pointers
0158   }
0159 
0160 private:
0161   /// constructor from existing TrackObj
0162   explicit Track(podio::utils::MaybeSharedPtr<TrackObj> obj);
0163   Track(TrackObj* obj);
0164 
0165   podio::utils::MaybeSharedPtr<TrackObj> m_obj{nullptr};
0166 };
0167 
0168 std::ostream& operator<<(std::ostream& o, const Track& value);
0169 
0170 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0171 void to_json(nlohmann::json& j, const Track& value);
0172 #endif
0173 
0174 
0175 } // namespace edm4eic
0176 
0177 
0178 
0179 template<>
0180 struct std::hash<edm4eic::Track> {
0181   std::size_t operator()(const edm4eic::Track& obj) const {
0182     return std::hash<edm4eic::TrackObj*>{}(obj.m_obj.get());
0183   }
0184 };
0185 
0186 
0187 // This is needed to avoid triggering opening every library in LD_LIBRARY_PATH
0188 // until it's fixed in ROOT. See https://github.com/root-project/root/issues/18489
0189 // and https://github.com/AIDASoft/podio/issues/770
0190 #if defined(__clang__)
0191 #pragma clang diagnostic push
0192 #pragma clang diagnostic ignored "-Wunknown-warning-option"
0193 #pragma clang diagnostic ignored "-Wdeprecated-redundant-constexpr-static-def"
0194 #pragma clang diagnostic ignored "-Wdeprecated"
0195 constexpr std::string_view edm4eic::Track::typeName;
0196 #pragma clang diagnostic pop
0197 #elif defined(__GNUC__)
0198 #pragma GCC diagnostic push
0199 #pragma GCC diagnostic ignored "-Wdeprecated"
0200 constexpr std::string_view edm4eic::Track::typeName;
0201 #pragma GCC diagnostic pop
0202 #endif
0203 
0204 #endif