File indexing completed on 2025-07-05 08:52:37
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();
0058
0059
0060 Track(std::int32_t type, float chi2, std::int32_t ndf, std::int32_t Nholes);
0061
0062
0063 Track(const Track& other) = default;
0064
0065
0066 Track& operator=(Track other);
0067
0068
0069
0070 MutableTrack clone(bool cloneRelations = true) const;
0071
0072
0073 ~Track() = default;
0074
0075
0076 Track(const MutableTrack& other);
0077
0078 static Track makeEmpty();
0079
0080 public:
0081 static constexpr auto typeName = "edm4hep::Track";
0082
0083
0084 std::int32_t getType() const;
0085
0086
0087 float getChi2() const;
0088
0089
0090 std::int32_t getNdf() const;
0091
0092
0093 std::int32_t getNholes() const;
0094
0095 std::size_t trackerHits_size() const;
0096 edm4hep::TrackerHit getTrackerHits(std::size_t) const;
0097 std::vector<edm4hep::TrackerHit>::const_iterator trackerHits_begin() const;
0098 std::vector<edm4hep::TrackerHit>::const_iterator trackerHits_end() const;
0099 podio::RelationRange<edm4hep::TrackerHit> getTrackerHits() const;
0100 std::size_t tracks_size() const;
0101 edm4hep::Track getTracks(std::size_t) const;
0102 std::vector<edm4hep::Track>::const_iterator tracks_begin() const;
0103 std::vector<edm4hep::Track>::const_iterator tracks_end() const;
0104 podio::RelationRange<edm4hep::Track> getTracks() const;
0105 std::size_t subdetectorHitNumbers_size() const;
0106 std::int32_t getSubdetectorHitNumbers(std::size_t) const;
0107 std::vector<std::int32_t>::const_iterator subdetectorHitNumbers_begin() const;
0108 std::vector<std::int32_t>::const_iterator subdetectorHitNumbers_end() const;
0109 podio::RelationRange<std::int32_t> getSubdetectorHitNumbers() const;
0110 std::size_t subdetectorHoleNumbers_size() const;
0111 std::int32_t getSubdetectorHoleNumbers(std::size_t) const;
0112 std::vector<std::int32_t>::const_iterator subdetectorHoleNumbers_begin() const;
0113 std::vector<std::int32_t>::const_iterator subdetectorHoleNumbers_end() const;
0114 podio::RelationRange<std::int32_t> getSubdetectorHoleNumbers() const;
0115 std::size_t trackStates_size() const;
0116 edm4hep::TrackState getTrackStates(std::size_t) const;
0117 std::vector<edm4hep::TrackState>::const_iterator trackStates_begin() const;
0118 std::vector<edm4hep::TrackState>::const_iterator trackStates_end() const;
0119 podio::RelationRange<edm4hep::TrackState> getTrackStates() const;
0120
0121
0122 bool isAvailable() const;
0123
0124 void unlink() {
0125 m_obj = podio::utils::MaybeSharedPtr<TrackObj>{nullptr};
0126 }
0127
0128 bool operator==(const Track& other) const {
0129 return m_obj == other.m_obj;
0130 }
0131 bool operator==(const MutableTrack& other) const;
0132
0133 bool operator!=(const Track& other) const {
0134 return !(*this == other);
0135 }
0136 bool operator!=(const MutableTrack& other) const {
0137 return !(*this == other);
0138 }
0139
0140
0141 bool operator<(const Track& other) const {
0142 return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other);
0143 }
0144
0145 podio::ObjectID id() const {
0146 return getObjectID();
0147 }
0148
0149 const podio::ObjectID getObjectID() const;
0150
0151 friend void swap(Track& a, Track& b) {
0152 using std::swap;
0153 swap(a.m_obj, b.m_obj);
0154 }
0155
0156 private:
0157
0158 explicit Track(podio::utils::MaybeSharedPtr<TrackObj> obj);
0159 Track(TrackObj* obj);
0160
0161 podio::utils::MaybeSharedPtr<TrackObj> m_obj{nullptr};
0162 };
0163
0164 std::ostream& operator<<(std::ostream& o, const Track& value);
0165
0166 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0167 void to_json(nlohmann::json& j, const Track& value);
0168 #endif
0169
0170 }
0171
0172 #endif