File indexing completed on 2025-07-03 08:34:33
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(std::int32_t type, edm4hep::Vector3f position, edm4hep::Vector3f momentum, edm4eic::Cov6f positionMomentumCovariance, float time, float timeError, float charge, float chi2, std::uint32_t ndf, std::int32_t pdg);
0055
0056
0057 MutableTrack(const MutableTrack& other) = default;
0058
0059
0060 MutableTrack& operator=(MutableTrack other);
0061
0062
0063
0064 MutableTrack clone(bool cloneRelations=true) const;
0065
0066
0067 ~MutableTrack() = default;
0068
0069
0070 public:
0071
0072
0073 std::int32_t getType() const;
0074
0075
0076 const edm4hep::Vector3f& getPosition() const;
0077
0078
0079 const edm4hep::Vector3f& getMomentum() const;
0080
0081
0082 const edm4eic::Cov6f& getPositionMomentumCovariance() const;
0083
0084
0085 float getTime() const;
0086
0087
0088 float getTimeError() const;
0089
0090
0091 float getCharge() const;
0092
0093
0094 float getChi2() const;
0095
0096
0097 std::uint32_t getNdf() const;
0098
0099
0100 std::int32_t getPdg() const;
0101
0102
0103
0104 const edm4eic::Trajectory getTrajectory() const;
0105
0106
0107 void setType(std::int32_t value);
0108
0109 std::int32_t& getType();
0110
0111 [[deprecated("use getType instead")]]
0112 std::int32_t& type();
0113
0114
0115 void setPosition(edm4hep::Vector3f value);
0116
0117 edm4hep::Vector3f& getPosition();
0118
0119 [[deprecated("use getPosition instead")]]
0120 edm4hep::Vector3f& position();
0121
0122
0123 void setMomentum(edm4hep::Vector3f value);
0124
0125 edm4hep::Vector3f& getMomentum();
0126
0127 [[deprecated("use getMomentum instead")]]
0128 edm4hep::Vector3f& momentum();
0129
0130
0131 void setPositionMomentumCovariance(edm4eic::Cov6f value);
0132
0133 edm4eic::Cov6f& getPositionMomentumCovariance();
0134
0135 [[deprecated("use getPositionMomentumCovariance instead")]]
0136 edm4eic::Cov6f& positionMomentumCovariance();
0137
0138
0139 void setTime(float value);
0140
0141 float& getTime();
0142
0143 [[deprecated("use getTime instead")]]
0144 float& time();
0145
0146
0147 void setTimeError(float value);
0148
0149 float& getTimeError();
0150
0151 [[deprecated("use getTimeError instead")]]
0152 float& timeError();
0153
0154
0155 void setCharge(float value);
0156
0157 float& getCharge();
0158
0159 [[deprecated("use getCharge instead")]]
0160 float& charge();
0161
0162
0163 void setChi2(float value);
0164
0165 float& getChi2();
0166
0167 [[deprecated("use getChi2 instead")]]
0168 float& chi2();
0169
0170
0171 void setNdf(std::uint32_t value);
0172
0173 std::uint32_t& getNdf();
0174
0175 [[deprecated("use getNdf instead")]]
0176 std::uint32_t& ndf();
0177
0178
0179 void setPdg(std::int32_t value);
0180
0181 std::int32_t& getPdg();
0182
0183 [[deprecated("use getPdg instead")]]
0184 std::int32_t& pdg();
0185
0186
0187
0188 void setTrajectory(const edm4eic::Trajectory& value);
0189
0190 void addToMeasurements(const edm4eic::Measurement2D&);
0191 std::size_t measurements_size() const;
0192 edm4eic::Measurement2D getMeasurements(std::size_t) const;
0193 std::vector<edm4eic::Measurement2D>::const_iterator measurements_begin() const;
0194 std::vector<edm4eic::Measurement2D>::const_iterator measurements_end() const;
0195 podio::RelationRange<edm4eic::Measurement2D> getMeasurements() const;
0196 void addToTracks(const edm4eic::Track&);
0197 std::size_t tracks_size() const;
0198 edm4eic::Track getTracks(std::size_t) const;
0199 std::vector<edm4eic::Track>::const_iterator tracks_begin() const;
0200 std::vector<edm4eic::Track>::const_iterator tracks_end() const;
0201 podio::RelationRange<edm4eic::Track> getTracks() const;
0202
0203
0204
0205
0206 bool isAvailable() const;
0207
0208 void unlink() { m_obj = podio::utils::MaybeSharedPtr<TrackObj>{nullptr}; }
0209
0210 bool operator==(const MutableTrack& other) const { return m_obj == other.m_obj; }
0211 bool operator==(const Track& other) const;
0212
0213 bool operator!=(const MutableTrack& other) const { return !(*this == other); }
0214 bool operator!=(const Track& other) const { return !(*this == other); }
0215
0216
0217 bool operator<(const MutableTrack& other) const { return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other); }
0218
0219 podio::ObjectID id() const { return getObjectID(); }
0220
0221 const podio::ObjectID getObjectID() const;
0222
0223 friend void swap(MutableTrack& a, MutableTrack& b) {
0224 using std::swap;
0225 swap(a.m_obj, b.m_obj);
0226 }
0227
0228 private:
0229
0230 explicit MutableTrack(podio::utils::MaybeSharedPtr<TrackObj> obj);
0231
0232 podio::utils::MaybeSharedPtr<TrackObj> m_obj{nullptr};
0233 };
0234
0235 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0236 void to_json(nlohmann::json& j, const MutableTrack& value);
0237 #endif
0238
0239
0240 }
0241
0242
0243 #endif