File indexing completed on 2025-10-31 08:59:56
0001
0002
0003 #ifndef EDM4EIC_TrackerHit_H
0004 #define EDM4EIC_TrackerHit_H
0005
0006 #include "edm4eic/TrackerHitObj.h"
0007
0008 #include "edm4eic/CovDiag3f.h"
0009 #include "edm4hep/Vector3f.h"
0010 #include <cstdint>
0011
0012 #include "podio/utilities/MaybeSharedPtr.h"
0013 #include "podio/detail/OrderKey.h"
0014
0015 #include <ostream>
0016 #include <cstdint>
0017
0018 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0019 #include "nlohmann/json_fwd.hpp"
0020 #endif
0021
0022
0023 namespace edm4eic {
0024 class TrackerHitCollection;
0025 class RawTrackerHit;
0026 class MutableRawTrackerHit;
0027 }
0028
0029
0030 namespace podio::detail {
0031
0032 OrderKey getOrderKey(const edm4eic::TrackerHit& obj);
0033 };
0034
0035 namespace edm4eic {
0036
0037 class MutableTrackerHit;
0038 class TrackerHitCollection;
0039 class TrackerHitCollectionData;
0040
0041
0042
0043
0044
0045 class TrackerHit {
0046
0047 friend class MutableTrackerHit;
0048 friend class TrackerHitCollection;
0049 friend class edm4eic::TrackerHitCollectionData;
0050 friend class TrackerHitCollectionIterator;
0051 friend podio::detail::OrderKey podio::detail::getOrderKey(const TrackerHit & obj);
0052
0053 public:
0054 using mutable_type = MutableTrackerHit;
0055 using collection_type = TrackerHitCollection;
0056
0057
0058 TrackerHit();
0059
0060
0061 TrackerHit(const std::uint64_t cellID, const edm4hep::Vector3f& position, const edm4eic::CovDiag3f& positionError, const float time, const float timeError, const float edep, const float edepError);
0062
0063
0064 TrackerHit(const TrackerHit& other) = default;
0065
0066
0067 TrackerHit& operator=(TrackerHit other) &;
0068 TrackerHit& operator=(TrackerHit other) && = delete;
0069
0070
0071
0072 MutableTrackerHit clone(bool cloneRelations=true) const;
0073
0074
0075 ~TrackerHit() = default;
0076
0077
0078 TrackerHit(const MutableTrackerHit& other);
0079
0080 static TrackerHit makeEmpty();
0081
0082 public:
0083
0084 static constexpr std::string_view typeName = "edm4eic::TrackerHit";
0085
0086
0087 std::uint64_t getCellID() const;
0088
0089
0090 const edm4hep::Vector3f& getPosition() const;
0091
0092
0093 const edm4eic::CovDiag3f& getPositionError() const;
0094
0095
0096 float getTime() const;
0097
0098
0099 float getTimeError() const;
0100
0101
0102 float getEdep() const;
0103
0104
0105 float getEdepError() const;
0106
0107
0108
0109 const edm4eic::RawTrackerHit getRawHit() const;
0110
0111
0112
0113
0114 bool isAvailable() const;
0115
0116 void unlink() { m_obj = podio::utils::MaybeSharedPtr<TrackerHitObj>{nullptr}; }
0117
0118 bool operator==(const TrackerHit& other) const { return m_obj == other.m_obj; }
0119 bool operator==(const MutableTrackerHit& other) const;
0120
0121 bool operator!=(const TrackerHit& other) const { return !(*this == other); }
0122 bool operator!=(const MutableTrackerHit& other) const { return !(*this == other); }
0123
0124
0125 bool operator<(const TrackerHit& other) const { return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other); }
0126
0127 podio::ObjectID id() const { return getObjectID(); }
0128
0129 const podio::ObjectID getObjectID() const;
0130
0131 friend std::hash<TrackerHit>;
0132
0133 friend void swap(TrackerHit& a, TrackerHit& b) {
0134 using std::swap;
0135 swap(a.m_obj, b.m_obj);
0136 }
0137
0138 private:
0139
0140 explicit TrackerHit(podio::utils::MaybeSharedPtr<TrackerHitObj> obj);
0141 TrackerHit(TrackerHitObj* obj);
0142
0143 podio::utils::MaybeSharedPtr<TrackerHitObj> m_obj{nullptr};
0144 };
0145
0146 std::ostream& operator<<(std::ostream& o, const TrackerHit& value);
0147
0148 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0149 void to_json(nlohmann::json& j, const TrackerHit& value);
0150 #endif
0151
0152
0153 }
0154
0155
0156
0157 template<>
0158 struct std::hash<edm4eic::TrackerHit> {
0159 std::size_t operator()(const edm4eic::TrackerHit& obj) const {
0160 return std::hash<edm4eic::TrackerHitObj*>{}(obj.m_obj.get());
0161 }
0162 };
0163
0164
0165
0166
0167
0168 #if defined(__clang__)
0169 #pragma clang diagnostic push
0170 #pragma clang diagnostic ignored "-Wunknown-warning-option"
0171 #pragma clang diagnostic ignored "-Wdeprecated-redundant-constexpr-static-def"
0172 #pragma clang diagnostic ignored "-Wdeprecated"
0173 constexpr std::string_view edm4eic::TrackerHit::typeName;
0174 #pragma clang diagnostic pop
0175 #elif defined(__GNUC__)
0176 #pragma GCC diagnostic push
0177 #pragma GCC diagnostic ignored "-Wdeprecated"
0178 constexpr std::string_view edm4eic::TrackerHit::typeName;
0179 #pragma GCC diagnostic pop
0180 #endif
0181
0182 #endif