File indexing completed on 2025-09-17 08:55:01
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(const std::uint64_t surface, const edm4hep::Vector2f& loc, const float time, const edm4eic::Cov3f& covariance);
0053
0054
0055 MutableMeasurement2D(const MutableMeasurement2D& other) = default;
0056
0057
0058 MutableMeasurement2D& operator=(MutableMeasurement2D other) &;
0059 MutableMeasurement2D& operator=(MutableMeasurement2D other) && = delete;
0060
0061
0062
0063 MutableMeasurement2D clone(bool cloneRelations=true) const;
0064
0065
0066 ~MutableMeasurement2D() = default;
0067
0068
0069 public:
0070
0071
0072 std::uint64_t getSurface() const;
0073
0074
0075 const edm4hep::Vector2f& getLoc() const;
0076
0077
0078 float getTime() const;
0079
0080
0081 const edm4eic::Cov3f& getCovariance() const;
0082
0083
0084
0085
0086 void setSurface(const std::uint64_t surface);
0087
0088 std::uint64_t& getSurface();
0089
0090 [[deprecated("use getSurface instead")]]
0091 std::uint64_t& surface();
0092
0093
0094 void setLoc(const edm4hep::Vector2f& loc);
0095
0096 edm4hep::Vector2f& getLoc();
0097
0098 [[deprecated("use getLoc instead")]]
0099 edm4hep::Vector2f& loc();
0100
0101
0102 void setTime(const float time);
0103
0104 float& getTime();
0105
0106 [[deprecated("use getTime instead")]]
0107 float& time();
0108
0109
0110 void setCovariance(const edm4eic::Cov3f& covariance);
0111
0112 edm4eic::Cov3f& getCovariance();
0113
0114 [[deprecated("use getCovariance instead")]]
0115 edm4eic::Cov3f& covariance();
0116
0117
0118
0119 void addToHits(const edm4eic::TrackerHit&);
0120 std::size_t hits_size() const;
0121 edm4eic::TrackerHit getHits(std::size_t) const;
0122 std::vector<edm4eic::TrackerHit>::const_iterator hits_begin() const;
0123 std::vector<edm4eic::TrackerHit>::const_iterator hits_end() const;
0124 podio::RelationRange<edm4eic::TrackerHit> getHits() const;
0125 void addToWeights(const float&);
0126 std::size_t weights_size() const;
0127 float getWeights(std::size_t) const;
0128 std::vector<float>::const_iterator weights_begin() const;
0129 std::vector<float>::const_iterator weights_end() const;
0130 podio::RelationRange<float> getWeights() const;
0131
0132
0133
0134
0135 bool isAvailable() const;
0136
0137 void unlink() { m_obj = podio::utils::MaybeSharedPtr<Measurement2DObj>{nullptr}; }
0138
0139 bool operator==(const MutableMeasurement2D& other) const { return m_obj == other.m_obj; }
0140 bool operator==(const Measurement2D& other) const;
0141
0142 bool operator!=(const MutableMeasurement2D& other) const { return !(*this == other); }
0143 bool operator!=(const Measurement2D& other) const { return !(*this == other); }
0144
0145
0146 bool operator<(const MutableMeasurement2D& other) const { return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other); }
0147
0148 podio::ObjectID id() const { return getObjectID(); }
0149
0150 const podio::ObjectID getObjectID() const;
0151
0152 friend std::hash<MutableMeasurement2D>;
0153
0154 friend void swap(MutableMeasurement2D& a, MutableMeasurement2D& b) {
0155 using std::swap;
0156 swap(a.m_obj, b.m_obj);
0157 }
0158
0159 private:
0160
0161 explicit MutableMeasurement2D(podio::utils::MaybeSharedPtr<Measurement2DObj> obj);
0162
0163 podio::utils::MaybeSharedPtr<Measurement2DObj> m_obj{nullptr};
0164 };
0165
0166 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0167 void to_json(nlohmann::json& j, const MutableMeasurement2D& value);
0168 #endif
0169
0170
0171 }
0172
0173
0174
0175 template<>
0176 struct std::hash<edm4eic::MutableMeasurement2D> {
0177 std::size_t operator()(const edm4eic::MutableMeasurement2D& obj) const {
0178 return std::hash<edm4eic::Measurement2DObj*>{}(obj.m_obj.get());
0179 }
0180 };
0181
0182
0183 #endif