File indexing completed on 2025-07-09 08:30:09
0001
0002
0003 #ifndef EDM4EIC_MutableMeasurement2D_H
0004 #define EDM4EIC_MutableMeasurement2D_H
0005
0006 #include "edm4eic/Measurement2DObj.h"
0007
0008 #include "edm4eic/Measurement2D.h"
0009
0010 #include "edm4eic/Cov3f.h"
0011 #include "edm4eic/TrackerHit.h"
0012 #include "edm4hep/Vector2f.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 Measurement2DCollection;
0028 }
0029
0030
0031 namespace edm4eic {
0032
0033
0034
0035
0036
0037
0038 class MutableMeasurement2D {
0039
0040 friend class Measurement2DCollection;
0041 friend class Measurement2DMutableCollectionIterator;
0042 friend class Measurement2D;
0043
0044 public:
0045 using object_type = Measurement2D;
0046 using collection_type = Measurement2DCollection;
0047
0048
0049 MutableMeasurement2D();
0050
0051
0052 MutableMeasurement2D(std::uint64_t surface, edm4hep::Vector2f loc, float time, edm4eic::Cov3f covariance);
0053
0054
0055 MutableMeasurement2D(const MutableMeasurement2D& other) = default;
0056
0057
0058 MutableMeasurement2D& operator=(MutableMeasurement2D other);
0059
0060
0061
0062 MutableMeasurement2D clone(bool cloneRelations=true) const;
0063
0064
0065 ~MutableMeasurement2D() = default;
0066
0067
0068 public:
0069
0070
0071 std::uint64_t getSurface() const;
0072
0073
0074 const edm4hep::Vector2f& getLoc() const;
0075
0076
0077 float getTime() const;
0078
0079
0080 const edm4eic::Cov3f& getCovariance() const;
0081
0082
0083
0084
0085 void setSurface(std::uint64_t value);
0086
0087 std::uint64_t& getSurface();
0088
0089 [[deprecated("use getSurface instead")]]
0090 std::uint64_t& surface();
0091
0092
0093 void setLoc(edm4hep::Vector2f value);
0094
0095 edm4hep::Vector2f& getLoc();
0096
0097 [[deprecated("use getLoc instead")]]
0098 edm4hep::Vector2f& loc();
0099
0100
0101 void setTime(float value);
0102
0103 float& getTime();
0104
0105 [[deprecated("use getTime instead")]]
0106 float& time();
0107
0108
0109 void setCovariance(edm4eic::Cov3f value);
0110
0111 edm4eic::Cov3f& getCovariance();
0112
0113 [[deprecated("use getCovariance instead")]]
0114 edm4eic::Cov3f& covariance();
0115
0116
0117
0118 void addToHits(const edm4eic::TrackerHit&);
0119 std::size_t hits_size() const;
0120 edm4eic::TrackerHit getHits(std::size_t) const;
0121 std::vector<edm4eic::TrackerHit>::const_iterator hits_begin() const;
0122 std::vector<edm4eic::TrackerHit>::const_iterator hits_end() const;
0123 podio::RelationRange<edm4eic::TrackerHit> getHits() const;
0124 void addToWeights(const float&);
0125 std::size_t weights_size() const;
0126 float getWeights(std::size_t) const;
0127 std::vector<float>::const_iterator weights_begin() const;
0128 std::vector<float>::const_iterator weights_end() const;
0129 podio::RelationRange<float> getWeights() const;
0130
0131
0132
0133
0134 bool isAvailable() const;
0135
0136 void unlink() { m_obj = podio::utils::MaybeSharedPtr<Measurement2DObj>{nullptr}; }
0137
0138 bool operator==(const MutableMeasurement2D& other) const { return m_obj == other.m_obj; }
0139 bool operator==(const Measurement2D& other) const;
0140
0141 bool operator!=(const MutableMeasurement2D& other) const { return !(*this == other); }
0142 bool operator!=(const Measurement2D& other) const { return !(*this == other); }
0143
0144
0145 bool operator<(const MutableMeasurement2D& other) const { return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other); }
0146
0147 podio::ObjectID id() const { return getObjectID(); }
0148
0149 const podio::ObjectID getObjectID() const;
0150
0151 friend void swap(MutableMeasurement2D& a, MutableMeasurement2D& b) {
0152 using std::swap;
0153 swap(a.m_obj, b.m_obj);
0154 }
0155
0156 private:
0157
0158 explicit MutableMeasurement2D(podio::utils::MaybeSharedPtr<Measurement2DObj> obj);
0159
0160 podio::utils::MaybeSharedPtr<Measurement2DObj> m_obj{nullptr};
0161 };
0162
0163 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0164 void to_json(nlohmann::json& j, const MutableMeasurement2D& value);
0165 #endif
0166
0167
0168 }
0169
0170
0171 #endif