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