File indexing completed on 2025-12-15 10:12:01
0001
0002
0003 #ifndef EDM4EIC_CalorimeterHit_H
0004 #define EDM4EIC_CalorimeterHit_H
0005
0006 #include "edm4eic/CalorimeterHitObj.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 CalorimeterHitCollection;
0024 }
0025 namespace edm4hep {
0026 class RawCalorimeterHit;
0027 class MutableRawCalorimeterHit;
0028 }
0029
0030
0031 namespace podio::detail {
0032
0033 OrderKey getOrderKey(const edm4eic::CalorimeterHit& obj);
0034 };
0035
0036 namespace edm4eic {
0037
0038 class MutableCalorimeterHit;
0039 class CalorimeterHitCollection;
0040 class CalorimeterHitCollectionData;
0041
0042
0043
0044
0045
0046 class CalorimeterHit {
0047
0048 friend class MutableCalorimeterHit;
0049 friend class CalorimeterHitCollection;
0050 friend class edm4eic::CalorimeterHitCollectionData;
0051 friend class CalorimeterHitCollectionIterator;
0052 friend podio::detail::OrderKey podio::detail::getOrderKey(const CalorimeterHit & obj);
0053
0054 public:
0055 using mutable_type = MutableCalorimeterHit;
0056 using collection_type = CalorimeterHitCollection;
0057
0058
0059 CalorimeterHit() = default;
0060
0061
0062 CalorimeterHit(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);
0063
0064
0065 CalorimeterHit(const CalorimeterHit& other) = default;
0066
0067
0068 CalorimeterHit& operator=(CalorimeterHit other) &;
0069 CalorimeterHit& operator=(CalorimeterHit other) && = delete;
0070
0071
0072
0073 MutableCalorimeterHit clone(bool cloneRelations=true) const;
0074
0075
0076 ~CalorimeterHit() = default;
0077
0078
0079 CalorimeterHit(const MutableCalorimeterHit& other);
0080
0081 static CalorimeterHit makeEmpty();
0082
0083 public:
0084
0085 static constexpr std::string_view typeName = "edm4eic::CalorimeterHit";
0086
0087
0088 std::uint64_t getCellID() const;
0089
0090
0091 float getEnergy() const;
0092
0093
0094 float getEnergyError() const;
0095
0096
0097 float getTime() const;
0098
0099
0100 float getTimeError() const;
0101
0102
0103 const edm4hep::Vector3f& getPosition() const;
0104
0105
0106 const edm4hep::Vector3f& getDimension() const;
0107
0108
0109 std::int32_t getSector() const;
0110
0111
0112 std::int32_t getLayer() const;
0113
0114
0115 const edm4hep::Vector3f& getLocal() const;
0116
0117
0118
0119 const edm4hep::RawCalorimeterHit getRawHit() const;
0120
0121
0122
0123
0124 bool isAvailable() const;
0125
0126 void unlink() { m_obj = podio::utils::MaybeSharedPtr<CalorimeterHitObj>{nullptr}; }
0127
0128 bool operator==(const CalorimeterHit& other) const { return m_obj == other.m_obj; }
0129 bool operator==(const MutableCalorimeterHit& other) const;
0130
0131 bool operator!=(const CalorimeterHit& other) const { return !(*this == other); }
0132 bool operator!=(const MutableCalorimeterHit& other) const { return !(*this == other); }
0133
0134
0135 bool operator<(const CalorimeterHit& other) const { return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other); }
0136
0137 podio::ObjectID id() const { return getObjectID(); }
0138
0139 const podio::ObjectID getObjectID() const;
0140
0141 friend std::hash<CalorimeterHit>;
0142
0143 friend void swap(CalorimeterHit& a, CalorimeterHit& b) {
0144 using std::swap;
0145 swap(a.m_obj, b.m_obj);
0146 }
0147
0148 private:
0149
0150 explicit CalorimeterHit(podio::utils::MaybeSharedPtr<CalorimeterHitObj> obj);
0151 CalorimeterHit(CalorimeterHitObj* obj);
0152
0153 podio::utils::MaybeSharedPtr<CalorimeterHitObj> m_obj{new CalorimeterHitObj{}, podio::utils::MarkOwned};
0154 };
0155
0156 std::ostream& operator<<(std::ostream& o, const CalorimeterHit& value);
0157
0158 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0159 void to_json(nlohmann::json& j, const CalorimeterHit& value);
0160 #endif
0161
0162
0163 }
0164
0165
0166
0167 template<>
0168 struct std::hash<edm4eic::CalorimeterHit> {
0169 std::size_t operator()(const edm4eic::CalorimeterHit& obj) const {
0170 return std::hash<edm4eic::CalorimeterHitObj*>{}(obj.m_obj.get());
0171 }
0172 };
0173
0174
0175
0176
0177
0178 #if defined(__clang__)
0179 #pragma clang diagnostic push
0180 #pragma clang diagnostic ignored "-Wunknown-warning-option"
0181 #pragma clang diagnostic ignored "-Wdeprecated-redundant-constexpr-static-def"
0182 #pragma clang diagnostic ignored "-Wdeprecated"
0183 constexpr std::string_view edm4eic::CalorimeterHit::typeName;
0184 #pragma clang diagnostic pop
0185 #elif defined(__GNUC__)
0186 #pragma GCC diagnostic push
0187 #pragma GCC diagnostic ignored "-Wdeprecated"
0188 constexpr std::string_view edm4eic::CalorimeterHit::typeName;
0189 #pragma GCC diagnostic pop
0190 #endif
0191
0192
0193 #endif