File indexing completed on 2026-12-05 10:56:50
0001
0002
0003 #ifndef EDM4EIC_MutableCalorimeterHit_H
0004 #define EDM4EIC_MutableCalorimeterHit_H
0005
0006 #include "edm4eic/CalorimeterHitObj.h"
0007
0008 #include "edm4eic/CalorimeterHit.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 CalorimeterHitCollection;
0024 }
0025 namespace edm4hep {
0026 class RawCalorimeterHit;
0027 class MutableRawCalorimeterHit;
0028 }
0029
0030
0031 namespace edm4eic {
0032
0033
0034
0035
0036
0037
0038 class MutableCalorimeterHit {
0039
0040 friend class CalorimeterHitCollection;
0041 friend class CalorimeterHitMutableCollectionIterator;
0042 friend class CalorimeterHit;
0043
0044 public:
0045 using object_type = CalorimeterHit;
0046 using collection_type = CalorimeterHitCollection;
0047
0048
0049 MutableCalorimeterHit() = default;
0050
0051
0052 MutableCalorimeterHit(const std::uint64_t cellID, const float energy, const float energyError, const float time, const float timeError, const edm4hep::Vector3f& position, const edm4hep::Vector3f& dimension, const std::int32_t sector, const std::int32_t layer, const edm4hep::Vector3f& local);
0053
0054
0055 MutableCalorimeterHit(const MutableCalorimeterHit& other) noexcept = default;
0056
0057
0058 MutableCalorimeterHit(MutableCalorimeterHit&& other) noexcept = default;
0059
0060
0061 MutableCalorimeterHit& operator=(MutableCalorimeterHit other) &;
0062 MutableCalorimeterHit& operator=(MutableCalorimeterHit other) && = delete;
0063
0064
0065
0066 MutableCalorimeterHit clone(bool cloneRelations=true) const;
0067
0068
0069 ~MutableCalorimeterHit() = default;
0070
0071
0072 public:
0073
0074
0075 std::uint64_t getCellID() const;
0076
0077
0078 float getEnergy() const;
0079
0080
0081 float getEnergyError() const;
0082
0083
0084 float getTime() const;
0085
0086
0087 float getTimeError() const;
0088
0089
0090 const edm4hep::Vector3f& getPosition() const;
0091
0092
0093 const edm4hep::Vector3f& getDimension() const;
0094
0095
0096 std::int32_t getSector() const;
0097
0098
0099 std::int32_t getLayer() const;
0100
0101
0102 const edm4hep::Vector3f& getLocal() const;
0103
0104
0105
0106 const edm4hep::RawCalorimeterHit getRawHit() const;
0107
0108
0109 void setCellID(const std::uint64_t cellID);
0110
0111 std::uint64_t& getCellID();
0112
0113
0114 void setEnergy(const float energy);
0115
0116 float& getEnergy();
0117
0118
0119 void setEnergyError(const float energyError);
0120
0121 float& getEnergyError();
0122
0123
0124 void setTime(const float time);
0125
0126 float& getTime();
0127
0128
0129 void setTimeError(const float timeError);
0130
0131 float& getTimeError();
0132
0133
0134 void setPosition(const edm4hep::Vector3f& position);
0135
0136 edm4hep::Vector3f& getPosition();
0137
0138
0139 void setDimension(const edm4hep::Vector3f& dimension);
0140
0141 edm4hep::Vector3f& getDimension();
0142
0143
0144 void setSector(const std::int32_t sector);
0145
0146 std::int32_t& getSector();
0147
0148
0149 void setLayer(const std::int32_t layer);
0150
0151 std::int32_t& getLayer();
0152
0153
0154 void setLocal(const edm4hep::Vector3f& local);
0155
0156 edm4hep::Vector3f& getLocal();
0157
0158
0159
0160 void setRawHit(const edm4hep::RawCalorimeterHit& value);
0161
0162
0163
0164
0165
0166 bool isAvailable() const;
0167
0168 void unlink() { m_obj = podio::utils::MaybeSharedPtr<CalorimeterHitObj>{nullptr}; }
0169
0170 constexpr bool operator==(const MutableCalorimeterHit& other) const { return m_obj == other.m_obj; }
0171 bool operator==(const CalorimeterHit& other) const;
0172
0173 constexpr bool operator!=(const MutableCalorimeterHit& other) const { return !(*this == other); }
0174 bool operator!=(const CalorimeterHit& other) const { return !(*this == other); }
0175
0176
0177 bool operator<(const MutableCalorimeterHit& other) const { return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other); }
0178
0179 podio::ObjectID id() const { return getObjectID(); }
0180
0181 const podio::ObjectID getObjectID() const;
0182
0183 friend std::hash<MutableCalorimeterHit>;
0184
0185 friend void swap(MutableCalorimeterHit& a, MutableCalorimeterHit& b) {
0186 using std::swap;
0187 swap(a.m_obj, b.m_obj);
0188 }
0189
0190 private:
0191
0192 explicit MutableCalorimeterHit(podio::utils::MaybeSharedPtr<CalorimeterHitObj> obj);
0193
0194 podio::utils::MaybeSharedPtr<CalorimeterHitObj> m_obj{new CalorimeterHitObj{}, podio::utils::MarkOwned};
0195 };
0196
0197 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0198 void to_json(nlohmann::json& j, const MutableCalorimeterHit& value);
0199 #endif
0200
0201
0202 }
0203
0204
0205
0206 template<>
0207 struct std::hash<edm4eic::MutableCalorimeterHit> {
0208 std::size_t operator()(const edm4eic::MutableCalorimeterHit& obj) const {
0209 return std::hash<edm4eic::CalorimeterHitObj*>{}(obj.m_obj.get());
0210 }
0211 };
0212
0213
0214 #endif