File indexing completed on 2025-12-13 10:09:32
0001
0002
0003 #ifndef EDM4HEP_Track_H
0004 #define EDM4HEP_Track_H
0005
0006 #include "edm4hep/TrackObj.h"
0007
0008 #include "edm4hep/TrackState.h"
0009 #include "edm4hep/TrackerHit.h"
0010 #include "podio/RelationRange.h"
0011 #include <cstdint>
0012 #include <vector>
0013
0014 #include "podio/detail/OrderKey.h"
0015 #include "podio/utilities/MaybeSharedPtr.h"
0016
0017 #include <cstdint>
0018 #include <ostream>
0019
0020 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0021 #include "nlohmann/json_fwd.hpp"
0022 #endif
0023
0024
0025 namespace edm4hep {
0026 class TrackCollection;
0027 }
0028
0029 namespace podio::detail {
0030
0031 OrderKey getOrderKey(const edm4hep::Track& obj);
0032 };
0033
0034 namespace edm4hep {
0035
0036 class MutableTrack;
0037 class TrackCollection;
0038 class TrackCollectionData;
0039
0040
0041
0042
0043
0044 class Track {
0045
0046 friend class MutableTrack;
0047 friend class TrackCollection;
0048 friend class edm4hep::TrackCollectionData;
0049 friend class TrackCollectionIterator;
0050 friend podio::detail::OrderKey podio::detail::getOrderKey(const Track& obj);
0051
0052 public:
0053 using mutable_type = MutableTrack;
0054 using collection_type = TrackCollection;
0055
0056
0057 Track() = default;
0058
0059
0060 Track(const std::int32_t type, const float chi2, const std::int32_t ndf, const std::int32_t Nholes);
0061
0062
0063 Track(const Track& other) = default;
0064
0065
0066 Track& operator=(Track other) &;
0067 Track& operator=(Track other) && = delete;
0068
0069
0070
0071 MutableTrack clone(bool cloneRelations = true) const;
0072
0073
0074 ~Track() = default;
0075
0076
0077 Track(const MutableTrack& other);
0078
0079 static Track makeEmpty();
0080
0081 public:
0082 static constexpr std::string_view typeName = "edm4hep::Track";
0083
0084
0085 std::int32_t getType() const;
0086
0087
0088 float getChi2() const;
0089
0090
0091 std::int32_t getNdf() const;
0092
0093
0094 std::int32_t getNholes() const;
0095
0096 std::size_t trackerHits_size() const;
0097 edm4hep::TrackerHit getTrackerHits(std::size_t) const;
0098 std::vector<edm4hep::TrackerHit>::const_iterator trackerHits_begin() const;
0099 std::vector<edm4hep::TrackerHit>::const_iterator trackerHits_end() const;
0100 podio::RelationRange<edm4hep::TrackerHit> getTrackerHits() const;
0101 std::size_t tracks_size() const;
0102 edm4hep::Track getTracks(std::size_t) const;
0103 std::vector<edm4hep::Track>::const_iterator tracks_begin() const;
0104 std::vector<edm4hep::Track>::const_iterator tracks_end() const;
0105 podio::RelationRange<edm4hep::Track> getTracks() const;
0106 std::size_t subdetectorHitNumbers_size() const;
0107 std::int32_t getSubdetectorHitNumbers(std::size_t) const;
0108 std::vector<std::int32_t>::const_iterator subdetectorHitNumbers_begin() const;
0109 std::vector<std::int32_t>::const_iterator subdetectorHitNumbers_end() const;
0110 podio::RelationRange<std::int32_t> getSubdetectorHitNumbers() const;
0111 std::size_t subdetectorHoleNumbers_size() const;
0112 std::int32_t getSubdetectorHoleNumbers(std::size_t) const;
0113 std::vector<std::int32_t>::const_iterator subdetectorHoleNumbers_begin() const;
0114 std::vector<std::int32_t>::const_iterator subdetectorHoleNumbers_end() const;
0115 podio::RelationRange<std::int32_t> getSubdetectorHoleNumbers() const;
0116 std::size_t trackStates_size() const;
0117 edm4hep::TrackState getTrackStates(std::size_t) const;
0118 std::vector<edm4hep::TrackState>::const_iterator trackStates_begin() const;
0119 std::vector<edm4hep::TrackState>::const_iterator trackStates_end() const;
0120 podio::RelationRange<edm4hep::TrackState> getTrackStates() const;
0121
0122
0123 bool isAvailable() const;
0124
0125 void unlink() { m_obj = podio::utils::MaybeSharedPtr<TrackObj>{nullptr}; }
0126
0127 bool operator==(const Track& other) const { return m_obj == other.m_obj; }
0128 bool operator==(const MutableTrack& other) const;
0129
0130 bool operator!=(const Track& other) const { return !(*this == other); }
0131 bool operator!=(const MutableTrack& other) const { return !(*this == other); }
0132
0133
0134 bool operator<(const Track& other) const {
0135 return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other);
0136 }
0137
0138 podio::ObjectID id() const { return getObjectID(); }
0139
0140 const podio::ObjectID getObjectID() const;
0141
0142 friend std::hash<Track>;
0143
0144 friend void swap(Track& a, Track& b) {
0145 using std::swap;
0146 swap(a.m_obj, b.m_obj);
0147 }
0148
0149 private:
0150
0151 explicit Track(podio::utils::MaybeSharedPtr<TrackObj> obj);
0152 Track(TrackObj* obj);
0153
0154 podio::utils::MaybeSharedPtr<TrackObj> m_obj{new TrackObj{}, podio::utils::MarkOwned};
0155 };
0156
0157 std::ostream& operator<<(std::ostream& o, const Track& value);
0158
0159 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0160 void to_json(nlohmann::json& j, const Track& value);
0161 #endif
0162
0163 }
0164
0165 template <>
0166 struct std::hash<edm4hep::Track> {
0167 std::size_t operator()(const edm4hep::Track& obj) const { return std::hash<edm4hep::TrackObj*>{}(obj.m_obj.get()); }
0168 };
0169
0170
0171
0172
0173 #if defined(__clang__)
0174 #pragma clang diagnostic push
0175 #pragma clang diagnostic ignored "-Wunknown-warning-option"
0176 #pragma clang diagnostic ignored "-Wdeprecated-redundant-constexpr-static-def"
0177 #pragma clang diagnostic ignored "-Wdeprecated"
0178 constexpr std::string_view edm4hep::Track::typeName;
0179 #pragma clang diagnostic pop
0180 #elif defined(__GNUC__)
0181 #pragma GCC diagnostic push
0182 #pragma GCC diagnostic ignored "-Wdeprecated"
0183 constexpr std::string_view edm4hep::Track::typeName;
0184 #pragma GCC diagnostic pop
0185 #endif
0186
0187 #endif