File indexing completed on 2025-09-16 08:53:25
0001
0002
0003 #ifndef EDM4EIC_MutableTrack_H
0004 #define EDM4EIC_MutableTrack_H
0005
0006 #include "edm4eic/TrackObj.h"
0007
0008 #include "edm4eic/Track.h"
0009
0010 #include "edm4eic/Cov6f.h"
0011 #include "edm4eic/Measurement2D.h"
0012 #include "edm4hep/Vector3f.h"
0013 #include "podio/RelationRange.h"
0014 #include <cstdint>
0015 #include <vector>
0016
0017 #include "podio/utilities/MaybeSharedPtr.h"
0018
0019 #include <cstdint>
0020
0021 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0022 #include "nlohmann/json_fwd.hpp"
0023 #endif
0024
0025
0026 namespace edm4eic {
0027 class TrackCollection;
0028 class Trajectory;
0029 class MutableTrajectory;
0030 }
0031
0032
0033 namespace edm4eic {
0034
0035
0036
0037
0038
0039
0040 class MutableTrack {
0041
0042 friend class TrackCollection;
0043 friend class TrackMutableCollectionIterator;
0044 friend class Track;
0045
0046 public:
0047 using object_type = Track;
0048 using collection_type = TrackCollection;
0049
0050
0051 MutableTrack();
0052
0053
0054 MutableTrack(const std::int32_t type, const edm4hep::Vector3f& position, const edm4hep::Vector3f& momentum, const edm4eic::Cov6f& positionMomentumCovariance, const float time, const float timeError, const float charge, const float chi2, const std::uint32_t ndf, const std::int32_t pdg);
0055
0056
0057 MutableTrack(const MutableTrack& other) = default;
0058
0059
0060 MutableTrack& operator=(MutableTrack other) &;
0061 MutableTrack& operator=(MutableTrack other) && = delete;
0062
0063
0064
0065 MutableTrack clone(bool cloneRelations=true) const;
0066
0067
0068 ~MutableTrack() = default;
0069
0070
0071 public:
0072
0073
0074 std::int32_t getType() const;
0075
0076
0077 const edm4hep::Vector3f& getPosition() const;
0078
0079
0080 const edm4hep::Vector3f& getMomentum() const;
0081
0082
0083 const edm4eic::Cov6f& getPositionMomentumCovariance() const;
0084
0085
0086 float getTime() const;
0087
0088
0089 float getTimeError() const;
0090
0091
0092 float getCharge() const;
0093
0094
0095 float getChi2() const;
0096
0097
0098 std::uint32_t getNdf() const;
0099
0100
0101 std::int32_t getPdg() const;
0102
0103
0104
0105 const edm4eic::Trajectory getTrajectory() const;
0106
0107
0108 void setType(const std::int32_t type);
0109
0110 std::int32_t& getType();
0111
0112 [[deprecated("use getType instead")]]
0113 std::int32_t& type();
0114
0115
0116 void setPosition(const edm4hep::Vector3f& position);
0117
0118 edm4hep::Vector3f& getPosition();
0119
0120 [[deprecated("use getPosition instead")]]
0121 edm4hep::Vector3f& position();
0122
0123
0124 void setMomentum(const edm4hep::Vector3f& momentum);
0125
0126 edm4hep::Vector3f& getMomentum();
0127
0128 [[deprecated("use getMomentum instead")]]
0129 edm4hep::Vector3f& momentum();
0130
0131
0132 void setPositionMomentumCovariance(const edm4eic::Cov6f& positionMomentumCovariance);
0133
0134 edm4eic::Cov6f& getPositionMomentumCovariance();
0135
0136 [[deprecated("use getPositionMomentumCovariance instead")]]
0137 edm4eic::Cov6f& positionMomentumCovariance();
0138
0139
0140 void setTime(const float time);
0141
0142 float& getTime();
0143
0144 [[deprecated("use getTime instead")]]
0145 float& time();
0146
0147
0148 void setTimeError(const float timeError);
0149
0150 float& getTimeError();
0151
0152 [[deprecated("use getTimeError instead")]]
0153 float& timeError();
0154
0155
0156 void setCharge(const float charge);
0157
0158 float& getCharge();
0159
0160 [[deprecated("use getCharge instead")]]
0161 float& charge();
0162
0163
0164 void setChi2(const float chi2);
0165
0166 float& getChi2();
0167
0168 [[deprecated("use getChi2 instead")]]
0169 float& chi2();
0170
0171
0172 void setNdf(const std::uint32_t ndf);
0173
0174 std::uint32_t& getNdf();
0175
0176 [[deprecated("use getNdf instead")]]
0177 std::uint32_t& ndf();
0178
0179
0180 void setPdg(const std::int32_t pdg);
0181
0182 std::int32_t& getPdg();
0183
0184 [[deprecated("use getPdg instead")]]
0185 std::int32_t& pdg();
0186
0187
0188
0189 void setTrajectory(const edm4eic::Trajectory& value);
0190
0191 void addToMeasurements(const edm4eic::Measurement2D&);
0192 std::size_t measurements_size() const;
0193 edm4eic::Measurement2D getMeasurements(std::size_t) const;
0194 std::vector<edm4eic::Measurement2D>::const_iterator measurements_begin() const;
0195 std::vector<edm4eic::Measurement2D>::const_iterator measurements_end() const;
0196 podio::RelationRange<edm4eic::Measurement2D> getMeasurements() const;
0197 void addToTracks(const edm4eic::Track&);
0198 std::size_t tracks_size() const;
0199 edm4eic::Track getTracks(std::size_t) const;
0200 std::vector<edm4eic::Track>::const_iterator tracks_begin() const;
0201 std::vector<edm4eic::Track>::const_iterator tracks_end() const;
0202 podio::RelationRange<edm4eic::Track> getTracks() const;
0203
0204
0205
0206
0207 bool isAvailable() const;
0208
0209 void unlink() { m_obj = podio::utils::MaybeSharedPtr<TrackObj>{nullptr}; }
0210
0211 bool operator==(const MutableTrack& other) const { return m_obj == other.m_obj; }
0212 bool operator==(const Track& other) const;
0213
0214 bool operator!=(const MutableTrack& other) const { return !(*this == other); }
0215 bool operator!=(const Track& other) const { return !(*this == other); }
0216
0217
0218 bool operator<(const MutableTrack& other) const { return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other); }
0219
0220 podio::ObjectID id() const { return getObjectID(); }
0221
0222 const podio::ObjectID getObjectID() const;
0223
0224 friend std::hash<MutableTrack>;
0225
0226 friend void swap(MutableTrack& a, MutableTrack& b) {
0227 using std::swap;
0228 swap(a.m_obj, b.m_obj);
0229 }
0230
0231 private:
0232
0233 explicit MutableTrack(podio::utils::MaybeSharedPtr<TrackObj> obj);
0234
0235 podio::utils::MaybeSharedPtr<TrackObj> m_obj{nullptr};
0236 };
0237
0238 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0239 void to_json(nlohmann::json& j, const MutableTrack& value);
0240 #endif
0241
0242
0243 }
0244
0245
0246
0247 template<>
0248 struct std::hash<edm4eic::MutableTrack> {
0249 std::size_t operator()(const edm4eic::MutableTrack& obj) const {
0250 return std::hash<edm4eic::TrackObj*>{}(obj.m_obj.get());
0251 }
0252 };
0253
0254
0255 #endif