File indexing completed on 2026-11-29 10:41:52
0001
0002
0003 #ifndef EDM4EIC_TrackSegment_H
0004 #define EDM4EIC_TrackSegment_H
0005
0006 #include "edm4eic/TrackSegmentObj.h"
0007
0008 #include "edm4eic/TrackPoint.h"
0009 #include "podio/RelationRange.h"
0010 #include <vector>
0011
0012 #include "podio/utilities/MaybeSharedPtr.h"
0013 #include "podio/detail/OrderKey.h"
0014
0015 #include <ostream>
0016 #include <cstdint>
0017
0018 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0019 #include "nlohmann/json_fwd.hpp"
0020 #endif
0021
0022
0023 namespace edm4eic {
0024 class TrackSegmentCollection;
0025 class Track;
0026 class MutableTrack;
0027 }
0028
0029
0030 namespace podio::detail {
0031
0032 OrderKey getOrderKey(const edm4eic::TrackSegment& obj);
0033 };
0034
0035 namespace edm4eic {
0036
0037 class MutableTrackSegment;
0038 class TrackSegmentCollection;
0039 class TrackSegmentCollectionData;
0040
0041
0042
0043
0044
0045 class TrackSegment {
0046
0047 friend class MutableTrackSegment;
0048 friend class TrackSegmentCollection;
0049 friend class edm4eic::TrackSegmentCollectionData;
0050 friend class TrackSegmentCollectionIterator;
0051 friend podio::detail::OrderKey podio::detail::getOrderKey(const TrackSegment & obj);
0052
0053 public:
0054 using mutable_type = MutableTrackSegment;
0055 using collection_type = TrackSegmentCollection;
0056
0057
0058 TrackSegment() = default;
0059
0060
0061 TrackSegment(const float length, const float lengthError);
0062
0063
0064 TrackSegment(const TrackSegment& other) noexcept = default;
0065
0066
0067 TrackSegment(TrackSegment&& other) noexcept = default;
0068
0069
0070 TrackSegment& operator=(TrackSegment other) &;
0071 TrackSegment& operator=(TrackSegment other) && = delete;
0072
0073
0074
0075 MutableTrackSegment clone(bool cloneRelations=true) const;
0076
0077
0078 ~TrackSegment() = default;
0079
0080
0081 TrackSegment(const MutableTrackSegment& other);
0082
0083 static TrackSegment makeEmpty();
0084
0085 public:
0086
0087 static constexpr std::string_view typeName = "edm4eic::TrackSegment";
0088
0089
0090 float getLength() const;
0091
0092
0093 float getLengthError() const;
0094
0095
0096
0097 const edm4eic::Track getTrack() const;
0098
0099 std::size_t points_size() const;
0100 edm4eic::TrackPoint getPoints(std::size_t) const;
0101 std::vector<edm4eic::TrackPoint>::const_iterator points_begin() const;
0102 std::vector<edm4eic::TrackPoint>::const_iterator points_end() const;
0103 podio::RelationRange<edm4eic::TrackPoint> getPoints() const;
0104
0105
0106
0107 bool isAvailable() const;
0108
0109 void unlink() { m_obj = podio::utils::MaybeSharedPtr<TrackSegmentObj>{nullptr}; }
0110
0111 constexpr bool operator==(const TrackSegment& other) const { return m_obj == other.m_obj; }
0112 bool operator==(const MutableTrackSegment& other) const;
0113
0114 constexpr bool operator!=(const TrackSegment& other) const { return !(*this == other); }
0115 bool operator!=(const MutableTrackSegment& other) const { return !(*this == other); }
0116
0117
0118 bool operator<(const TrackSegment& other) const { return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other); }
0119
0120 podio::ObjectID id() const { return getObjectID(); }
0121
0122 const podio::ObjectID getObjectID() const;
0123
0124 friend std::hash<TrackSegment>;
0125
0126 friend void swap(TrackSegment& a, TrackSegment& b) {
0127 using std::swap;
0128 swap(a.m_obj, b.m_obj);
0129 }
0130
0131 private:
0132
0133 explicit TrackSegment(podio::utils::MaybeSharedPtr<TrackSegmentObj> obj);
0134 TrackSegment(TrackSegmentObj* obj);
0135
0136 podio::utils::MaybeSharedPtr<TrackSegmentObj> m_obj{new TrackSegmentObj{}, podio::utils::MarkOwned};
0137 };
0138
0139 std::ostream& operator<<(std::ostream& o, const TrackSegment& value);
0140
0141 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0142 void to_json(nlohmann::json& j, const TrackSegment& value);
0143 #endif
0144
0145
0146 }
0147
0148
0149
0150 template<>
0151 struct std::hash<edm4eic::TrackSegment> {
0152 std::size_t operator()(const edm4eic::TrackSegment& obj) const {
0153 return std::hash<edm4eic::TrackSegmentObj*>{}(obj.m_obj.get());
0154 }
0155 };
0156
0157
0158
0159
0160
0161 #if defined(__clang__)
0162 #pragma clang diagnostic push
0163 #pragma clang diagnostic ignored "-Wunknown-warning-option"
0164 #pragma clang diagnostic ignored "-Wdeprecated-redundant-constexpr-static-def"
0165 #pragma clang diagnostic ignored "-Wdeprecated"
0166 constexpr std::string_view edm4eic::TrackSegment::typeName;
0167 #pragma clang diagnostic pop
0168 #elif defined(__GNUC__)
0169 #pragma GCC diagnostic push
0170 #pragma GCC diagnostic ignored "-Wdeprecated"
0171 constexpr std::string_view edm4eic::TrackSegment::typeName;
0172 #pragma GCC diagnostic pop
0173 #endif
0174
0175
0176 #endif