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