File indexing completed on 2026-10-04 09:03:31
0001
0002
0003 #ifndef EDM4EIC_MutablePMTHit_H
0004 #define EDM4EIC_MutablePMTHit_H
0005
0006 #include "edm4eic/PMTHitObj.h"
0007
0008 #include "edm4eic/PMTHit.h"
0009
0010 #include "edm4hep/Vector3f.h"
0011 #include <cstdint>
0012
0013 #include "podio/utilities/MaybeSharedPtr.h"
0014
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 edm4eic {
0028
0029
0030
0031
0032
0033
0034 class MutablePMTHit {
0035
0036 friend class PMTHitCollection;
0037 friend class PMTHitMutableCollectionIterator;
0038 friend class PMTHit;
0039
0040 public:
0041 using object_type = PMTHit;
0042 using collection_type = PMTHitCollection;
0043
0044
0045 MutablePMTHit() = default;
0046
0047
0048 MutablePMTHit(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);
0049
0050
0051 MutablePMTHit(const MutablePMTHit& other) = default;
0052
0053
0054 MutablePMTHit& operator=(MutablePMTHit other) &;
0055 MutablePMTHit& operator=(MutablePMTHit other) && = delete;
0056
0057
0058
0059 MutablePMTHit clone(bool cloneRelations=true) const;
0060
0061
0062 ~MutablePMTHit() = default;
0063
0064
0065 public:
0066
0067
0068 std::uint64_t getCellID() const;
0069
0070
0071 float getNpe() const;
0072
0073
0074 float getTime() const;
0075
0076
0077 float getTimeError() const;
0078
0079
0080 const edm4hep::Vector3f& getPosition() const;
0081
0082
0083 const edm4hep::Vector3f& getDimension() const;
0084
0085
0086 std::int32_t getSector() const;
0087
0088
0089 const edm4hep::Vector3f& getLocal() const;
0090
0091
0092
0093
0094 void setCellID(const std::uint64_t cellID);
0095
0096 std::uint64_t& getCellID();
0097
0098
0099 void setNpe(const float npe);
0100
0101 float& getNpe();
0102
0103
0104 void setTime(const float time);
0105
0106 float& getTime();
0107
0108
0109 void setTimeError(const float timeError);
0110
0111 float& getTimeError();
0112
0113
0114 void setPosition(const edm4hep::Vector3f& position);
0115
0116 edm4hep::Vector3f& getPosition();
0117
0118
0119 void setDimension(const edm4hep::Vector3f& dimension);
0120
0121 edm4hep::Vector3f& getDimension();
0122
0123
0124 void setSector(const std::int32_t sector);
0125
0126 std::int32_t& getSector();
0127
0128
0129 void setLocal(const edm4hep::Vector3f& local);
0130
0131 edm4hep::Vector3f& getLocal();
0132
0133
0134
0135
0136
0137
0138
0139 bool isAvailable() const;
0140
0141 void unlink() { m_obj = podio::utils::MaybeSharedPtr<PMTHitObj>{nullptr}; }
0142
0143 constexpr bool operator==(const MutablePMTHit& other) const { return m_obj == other.m_obj; }
0144 bool operator==(const PMTHit& other) const;
0145
0146 constexpr bool operator!=(const MutablePMTHit& other) const { return !(*this == other); }
0147 bool operator!=(const PMTHit& other) const { return !(*this == other); }
0148
0149
0150 bool operator<(const MutablePMTHit& other) const { return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other); }
0151
0152 podio::ObjectID id() const { return getObjectID(); }
0153
0154 const podio::ObjectID getObjectID() const;
0155
0156 friend std::hash<MutablePMTHit>;
0157
0158 friend void swap(MutablePMTHit& a, MutablePMTHit& b) {
0159 using std::swap;
0160 swap(a.m_obj, b.m_obj);
0161 }
0162
0163 private:
0164
0165 explicit MutablePMTHit(podio::utils::MaybeSharedPtr<PMTHitObj> obj);
0166
0167 podio::utils::MaybeSharedPtr<PMTHitObj> m_obj{new PMTHitObj{}, podio::utils::MarkOwned};
0168 };
0169
0170 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0171 void to_json(nlohmann::json& j, const MutablePMTHit& value);
0172 #endif
0173
0174
0175 }
0176
0177
0178
0179 template<>
0180 struct std::hash<edm4eic::MutablePMTHit> {
0181 std::size_t operator()(const edm4eic::MutablePMTHit& obj) const {
0182 return std::hash<edm4eic::PMTHitObj*>{}(obj.m_obj.get());
0183 }
0184 };
0185
0186
0187 #endif