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