File indexing completed on 2026-09-28 09:10:42
0001
0002
0003 #ifndef EDM4HEP_MutableCalorimeterHit_H
0004 #define EDM4HEP_MutableCalorimeterHit_H
0005
0006 #include "edm4hep/CalorimeterHitObj.h"
0007
0008 #include "edm4hep/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 edm4hep {
0023 class CalorimeterHitCollection;
0024 }
0025
0026 namespace edm4hep {
0027
0028
0029
0030
0031
0032 class MutableCalorimeterHit {
0033
0034 friend class CalorimeterHitCollection;
0035 friend class CalorimeterHitMutableCollectionIterator;
0036 friend class CalorimeterHit;
0037
0038 public:
0039 using object_type = CalorimeterHit;
0040 using collection_type = CalorimeterHitCollection;
0041
0042
0043 MutableCalorimeterHit() = default;
0044
0045
0046 MutableCalorimeterHit(const std::uint64_t cellID, const float energy, const float energyError, const float time,
0047 const edm4hep::Vector3f& position, const std::int32_t type);
0048
0049
0050 MutableCalorimeterHit(const MutableCalorimeterHit& other) = default;
0051
0052
0053 MutableCalorimeterHit& operator=(MutableCalorimeterHit other) &;
0054 MutableCalorimeterHit&
0055 operator=(MutableCalorimeterHit other) && = delete;
0056
0057
0058
0059 MutableCalorimeterHit clone(bool cloneRelations = true) const;
0060
0061
0062 ~MutableCalorimeterHit() = default;
0063
0064 public:
0065
0066 std::uint64_t getCellID() const;
0067
0068
0069 float getEnergy() const;
0070
0071
0072 float getEnergyError() const;
0073
0074
0075 float getTime() const;
0076
0077
0078 const edm4hep::Vector3f& getPosition() const;
0079
0080
0081 std::int32_t getType() const;
0082
0083
0084 void setCellID(const std::uint64_t cellID);
0085
0086 std::uint64_t& getCellID();
0087
0088
0089 void setEnergy(const float energy);
0090
0091 float& getEnergy();
0092
0093
0094 void setEnergyError(const float energyError);
0095
0096 float& getEnergyError();
0097
0098
0099 void setTime(const float time);
0100
0101 float& getTime();
0102
0103
0104 void setPosition(const edm4hep::Vector3f& position);
0105
0106 edm4hep::Vector3f& getPosition();
0107
0108
0109 void setType(const std::int32_t type);
0110
0111 std::int32_t& getType();
0112
0113
0114 bool isAvailable() const;
0115
0116 void unlink() { m_obj = podio::utils::MaybeSharedPtr<CalorimeterHitObj>{nullptr}; }
0117
0118 constexpr bool operator==(const MutableCalorimeterHit& other) const { return m_obj == other.m_obj; }
0119 bool operator==(const CalorimeterHit& other) const;
0120
0121 constexpr bool operator!=(const MutableCalorimeterHit& other) const { return !(*this == other); }
0122 bool operator!=(const CalorimeterHit& other) const { return !(*this == other); }
0123
0124
0125 bool operator<(const MutableCalorimeterHit& other) const {
0126 return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other);
0127 }
0128
0129 podio::ObjectID id() const { return getObjectID(); }
0130
0131 const podio::ObjectID getObjectID() const;
0132
0133 friend std::hash<MutableCalorimeterHit>;
0134
0135 friend void swap(MutableCalorimeterHit& a, MutableCalorimeterHit& b) {
0136 using std::swap;
0137 swap(a.m_obj, b.m_obj);
0138 }
0139
0140 private:
0141
0142 explicit MutableCalorimeterHit(podio::utils::MaybeSharedPtr<CalorimeterHitObj> obj);
0143
0144 podio::utils::MaybeSharedPtr<CalorimeterHitObj> m_obj{new CalorimeterHitObj{}, podio::utils::MarkOwned};
0145 };
0146
0147 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0148 void to_json(nlohmann::json& j, const MutableCalorimeterHit& value);
0149 #endif
0150
0151 }
0152
0153 template <>
0154 struct std::hash<edm4hep::MutableCalorimeterHit> {
0155 std::size_t operator()(const edm4hep::MutableCalorimeterHit& obj) const {
0156 return std::hash<edm4hep::CalorimeterHitObj*>{}(obj.m_obj.get());
0157 }
0158 };
0159
0160 #endif