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