File indexing completed on 2025-09-14 08:51:40
0001
0002
0003 #ifndef EDM4EIC_MutableTrackSegment_H
0004 #define EDM4EIC_MutableTrackSegment_H
0005
0006 #include "edm4eic/TrackSegmentObj.h"
0007
0008 #include "edm4eic/TrackSegment.h"
0009
0010 #include "edm4eic/TrackPoint.h"
0011 #include "podio/RelationRange.h"
0012 #include <vector>
0013
0014 #include "podio/utilities/MaybeSharedPtr.h"
0015
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 edm4eic {
0031
0032
0033
0034
0035
0036
0037 class MutableTrackSegment {
0038
0039 friend class TrackSegmentCollection;
0040 friend class TrackSegmentMutableCollectionIterator;
0041 friend class TrackSegment;
0042
0043 public:
0044 using object_type = TrackSegment;
0045 using collection_type = TrackSegmentCollection;
0046
0047
0048 MutableTrackSegment();
0049
0050
0051 MutableTrackSegment(const float length, const float lengthError);
0052
0053
0054 MutableTrackSegment(const MutableTrackSegment& other) = default;
0055
0056
0057 MutableTrackSegment& operator=(MutableTrackSegment other) &;
0058 MutableTrackSegment& operator=(MutableTrackSegment other) && = delete;
0059
0060
0061
0062 MutableTrackSegment clone(bool cloneRelations=true) const;
0063
0064
0065 ~MutableTrackSegment() = default;
0066
0067
0068 public:
0069
0070
0071 float getLength() const;
0072
0073
0074 float getLengthError() const;
0075
0076
0077
0078 const edm4eic::Track getTrack() const;
0079
0080
0081 void setLength(const float length);
0082
0083 float& getLength();
0084
0085 [[deprecated("use getLength instead")]]
0086 float& length();
0087
0088
0089 void setLengthError(const float lengthError);
0090
0091 float& getLengthError();
0092
0093 [[deprecated("use getLengthError instead")]]
0094 float& lengthError();
0095
0096
0097
0098 void setTrack(const edm4eic::Track& value);
0099
0100 void addToPoints(const edm4eic::TrackPoint&);
0101 std::size_t points_size() const;
0102 edm4eic::TrackPoint getPoints(std::size_t) const;
0103 std::vector<edm4eic::TrackPoint>::const_iterator points_begin() const;
0104 std::vector<edm4eic::TrackPoint>::const_iterator points_end() const;
0105 podio::RelationRange<edm4eic::TrackPoint> getPoints() const;
0106
0107
0108
0109
0110 bool isAvailable() const;
0111
0112 void unlink() { m_obj = podio::utils::MaybeSharedPtr<TrackSegmentObj>{nullptr}; }
0113
0114 bool operator==(const MutableTrackSegment& other) const { return m_obj == other.m_obj; }
0115 bool operator==(const TrackSegment& other) const;
0116
0117 bool operator!=(const MutableTrackSegment& other) const { return !(*this == other); }
0118 bool operator!=(const TrackSegment& other) const { return !(*this == other); }
0119
0120
0121 bool operator<(const MutableTrackSegment& other) const { return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other); }
0122
0123 podio::ObjectID id() const { return getObjectID(); }
0124
0125 const podio::ObjectID getObjectID() const;
0126
0127 friend std::hash<MutableTrackSegment>;
0128
0129 friend void swap(MutableTrackSegment& a, MutableTrackSegment& b) {
0130 using std::swap;
0131 swap(a.m_obj, b.m_obj);
0132 }
0133
0134 private:
0135
0136 explicit MutableTrackSegment(podio::utils::MaybeSharedPtr<TrackSegmentObj> obj);
0137
0138 podio::utils::MaybeSharedPtr<TrackSegmentObj> m_obj{nullptr};
0139 };
0140
0141 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0142 void to_json(nlohmann::json& j, const MutableTrackSegment& value);
0143 #endif
0144
0145
0146 }
0147
0148
0149
0150 template<>
0151 struct std::hash<edm4eic::MutableTrackSegment> {
0152 std::size_t operator()(const edm4eic::MutableTrackSegment& obj) const {
0153 return std::hash<edm4eic::TrackSegmentObj*>{}(obj.m_obj.get());
0154 }
0155 };
0156
0157
0158 #endif