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