File indexing completed on 2025-01-18 09:55:33
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
0014 #include <ostream>
0015 #include <cstdint>
0016
0017 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0018 #include "nlohmann/json_fwd.hpp"
0019 #endif
0020
0021
0022 namespace edm4eic {
0023 class Track;
0024 class MutableTrack;
0025 }
0026
0027
0028 namespace edm4eic {
0029
0030 class MutableTrackSegment;
0031 class TrackSegmentCollection;
0032 class TrackSegmentCollectionData;
0033
0034
0035
0036
0037
0038 class TrackSegment {
0039
0040 friend class MutableTrackSegment;
0041 friend class TrackSegmentCollection;
0042 friend class edm4eic::TrackSegmentCollectionData;
0043 friend class TrackSegmentCollectionIterator;
0044
0045 public:
0046 using mutable_type = MutableTrackSegment;
0047 using collection_type = TrackSegmentCollection;
0048
0049
0050 TrackSegment();
0051
0052
0053 TrackSegment(float length, float lengthError);
0054
0055
0056 TrackSegment(const TrackSegment& other) = default;
0057
0058
0059 TrackSegment& operator=(TrackSegment other);
0060
0061
0062
0063 MutableTrackSegment clone(bool cloneRelations=true) const;
0064
0065
0066 ~TrackSegment() = default;
0067
0068
0069 TrackSegment(const MutableTrackSegment& other);
0070
0071 static TrackSegment makeEmpty();
0072
0073 public:
0074
0075
0076 float getLength() const;
0077
0078
0079 float getLengthError() const;
0080
0081
0082
0083 const edm4eic::Track getTrack() const;
0084
0085 std::size_t points_size() const;
0086 edm4eic::TrackPoint getPoints(std::size_t) const;
0087 std::vector<edm4eic::TrackPoint>::const_iterator points_begin() const;
0088 std::vector<edm4eic::TrackPoint>::const_iterator points_end() const;
0089 podio::RelationRange<edm4eic::TrackPoint> getPoints() const;
0090
0091
0092
0093 bool isAvailable() const;
0094
0095 void unlink() { m_obj = podio::utils::MaybeSharedPtr<TrackSegmentObj>{nullptr}; }
0096
0097 bool operator==(const TrackSegment& other) const { return m_obj == other.m_obj; }
0098 bool operator==(const MutableTrackSegment& other) const;
0099
0100 bool operator!=(const TrackSegment& other) const { return !(*this == other); }
0101 bool operator!=(const MutableTrackSegment& other) const { return !(*this == other); }
0102
0103
0104 bool operator<(const TrackSegment& other) const { return m_obj < other.m_obj; }
0105
0106 podio::ObjectID id() const { return getObjectID(); }
0107
0108 const podio::ObjectID getObjectID() const;
0109
0110 friend void swap(TrackSegment& a, TrackSegment& b) {
0111 using std::swap;
0112 swap(a.m_obj, b.m_obj);
0113 }
0114
0115 private:
0116
0117 explicit TrackSegment(podio::utils::MaybeSharedPtr<TrackSegmentObj> obj);
0118 TrackSegment(TrackSegmentObj* obj);
0119
0120 podio::utils::MaybeSharedPtr<TrackSegmentObj> m_obj{nullptr};
0121 };
0122
0123 std::ostream& operator<<(std::ostream& o, const TrackSegment& value);
0124
0125 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0126 void to_json(nlohmann::json& j, const TrackSegment& value);
0127 #endif
0128
0129
0130 }
0131
0132
0133 #endif