File indexing completed on 2025-12-16 10:13:00
0001
0002
0003 #ifndef EDM4HEP_MutableTrackerHit3D_H
0004 #define EDM4HEP_MutableTrackerHit3D_H
0005
0006 #include "edm4hep/TrackerHit3DObj.h"
0007
0008 #include "edm4hep/TrackerHit3D.h"
0009
0010 #include "edm4hep/CovMatrix3f.h"
0011 #include "edm4hep/Vector3d.h"
0012 #include <cstdint>
0013 #include <edm4hep/Constants.h>
0014
0015 #include "podio/utilities/MaybeSharedPtr.h"
0016
0017 #include <cstdint>
0018
0019 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0020 #include "nlohmann/json_fwd.hpp"
0021 #endif
0022
0023
0024 namespace edm4hep {
0025 class TrackerHit3DCollection;
0026 class TrackerHit;
0027 }
0028
0029 namespace edm4hep {
0030
0031
0032
0033
0034
0035 class MutableTrackerHit3D {
0036
0037 friend class TrackerHit3DCollection;
0038 friend class TrackerHit3DMutableCollectionIterator;
0039 friend class TrackerHit3D;
0040
0041 public:
0042 using object_type = TrackerHit3D;
0043 using collection_type = TrackerHit3DCollection;
0044
0045
0046 MutableTrackerHit3D() = default;
0047
0048
0049 MutableTrackerHit3D(const std::uint64_t cellID, const std::int32_t type, const std::int32_t quality, const float time,
0050 const float eDep, const float eDepError, const edm4hep::Vector3d& position,
0051 const edm4hep::CovMatrix3f& covMatrix);
0052
0053
0054 MutableTrackerHit3D(const MutableTrackerHit3D& other) = default;
0055
0056
0057 MutableTrackerHit3D& operator=(MutableTrackerHit3D other) &;
0058 MutableTrackerHit3D&
0059 operator=(MutableTrackerHit3D other) && = delete;
0060
0061
0062
0063 MutableTrackerHit3D clone(bool cloneRelations = true) const;
0064
0065
0066 ~MutableTrackerHit3D() = default;
0067
0068 public:
0069
0070 std::uint64_t getCellID() const;
0071
0072
0073 std::int32_t getType() const;
0074
0075
0076 std::int32_t getQuality() const;
0077
0078
0079 float getTime() const;
0080
0081
0082 float getEDep() const;
0083
0084
0085 float getEDepError() const;
0086
0087
0088 const edm4hep::Vector3d& getPosition() const;
0089
0090
0091 const edm4hep::CovMatrix3f& getCovMatrix() const;
0092
0093
0094 void setCellID(const std::uint64_t cellID);
0095
0096 std::uint64_t& getCellID();
0097
0098 [[deprecated("use getCellID instead")]] std::uint64_t& cellID();
0099
0100
0101 void setType(const std::int32_t type);
0102
0103 std::int32_t& getType();
0104
0105 [[deprecated("use getType instead")]] std::int32_t& type();
0106
0107
0108 void setQuality(const std::int32_t quality);
0109
0110 std::int32_t& getQuality();
0111
0112 [[deprecated("use getQuality instead")]] std::int32_t& quality();
0113
0114
0115 void setTime(const float time);
0116
0117 float& getTime();
0118
0119 [[deprecated("use getTime instead")]] float& time();
0120
0121
0122 void setEDep(const float eDep);
0123
0124 float& getEDep();
0125
0126 [[deprecated("use getEDep instead")]] float& eDep();
0127
0128
0129 void setEDepError(const float eDepError);
0130
0131 float& getEDepError();
0132
0133 [[deprecated("use getEDepError instead")]] float& eDepError();
0134
0135
0136 void setPosition(const edm4hep::Vector3d& position);
0137
0138 edm4hep::Vector3d& getPosition();
0139
0140 [[deprecated("use getPosition instead")]] edm4hep::Vector3d& position();
0141
0142
0143 void setCovMatrix(const edm4hep::CovMatrix3f& covMatrix);
0144
0145 edm4hep::CovMatrix3f& getCovMatrix();
0146
0147 [[deprecated("use getCovMatrix instead")]] edm4hep::CovMatrix3f& covMatrix();
0148
0149
0150 float getCovMatrix(edm4hep::Cartesian dimI, edm4hep::Cartesian dimJ) const {
0151 return getCovMatrix().getValue(dimI, dimJ);
0152 }
0153
0154
0155 void setCovMatrix(float value, edm4hep::Cartesian dimI, edm4hep::Cartesian dimJ) {
0156 getCovMatrix().setValue(value, dimI, dimJ);
0157 }
0158
0159
0160 bool isAvailable() const;
0161
0162 void unlink() { m_obj = podio::utils::MaybeSharedPtr<TrackerHit3DObj>{nullptr}; }
0163
0164 bool operator==(const MutableTrackerHit3D& other) const { return m_obj == other.m_obj; }
0165 bool operator==(const TrackerHit3D& other) const;
0166
0167 bool operator!=(const MutableTrackerHit3D& other) const { return !(*this == other); }
0168 bool operator!=(const TrackerHit3D& other) const { return !(*this == other); }
0169
0170
0171 bool operator<(const MutableTrackerHit3D& other) const {
0172 return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other);
0173 }
0174
0175 podio::ObjectID id() const { return getObjectID(); }
0176
0177 const podio::ObjectID getObjectID() const;
0178
0179 friend std::hash<MutableTrackerHit3D>;
0180
0181 friend void swap(MutableTrackerHit3D& a, MutableTrackerHit3D& b) {
0182 using std::swap;
0183 swap(a.m_obj, b.m_obj);
0184 }
0185
0186 private:
0187
0188 explicit MutableTrackerHit3D(podio::utils::MaybeSharedPtr<TrackerHit3DObj> obj);
0189
0190 podio::utils::MaybeSharedPtr<TrackerHit3DObj> m_obj{new TrackerHit3DObj{}, podio::utils::MarkOwned};
0191 };
0192
0193 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0194 void to_json(nlohmann::json& j, const MutableTrackerHit3D& value);
0195 #endif
0196
0197 }
0198
0199 template <>
0200 struct std::hash<edm4hep::MutableTrackerHit3D> {
0201 std::size_t operator()(const edm4hep::MutableTrackerHit3D& obj) const {
0202 return std::hash<edm4hep::TrackerHit3DObj*>{}(obj.m_obj.get());
0203 }
0204 };
0205
0206 #endif