File indexing completed on 2025-12-11 10:20:46
0001
0002
0003 #ifndef JANA2_TUTORIAL_PODIO_DATAMODEL_CalorimeterHit_H
0004 #define JANA2_TUTORIAL_PODIO_DATAMODEL_CalorimeterHit_H
0005
0006 #include "jana2_tutorial_podio_datamodel/CalorimeterHitObj.h"
0007
0008 #include <cstdint>
0009
0010 #include "podio/utilities/MaybeSharedPtr.h"
0011 #include "podio/detail/OrderKey.h"
0012
0013 #include <ostream>
0014 #include <cstdint>
0015
0016 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0017 #include "nlohmann/json_fwd.hpp"
0018 #endif
0019
0020
0021 class CalorimeterHitCollection;
0022
0023
0024 namespace podio::detail {
0025
0026 OrderKey getOrderKey(const ::CalorimeterHit& obj);
0027 };
0028
0029
0030 class MutableCalorimeterHit;
0031 class CalorimeterHitCollection;
0032 class CalorimeterHitCollectionData;
0033
0034
0035
0036
0037
0038 class CalorimeterHit {
0039
0040 friend class MutableCalorimeterHit;
0041 friend class CalorimeterHitCollection;
0042 friend class CalorimeterHitCollectionData;
0043 friend class CalorimeterHitCollectionIterator;
0044 friend podio::detail::OrderKey podio::detail::getOrderKey(const CalorimeterHit & obj);
0045
0046 public:
0047 using mutable_type = MutableCalorimeterHit;
0048 using collection_type = CalorimeterHitCollection;
0049
0050
0051 CalorimeterHit() = default;
0052
0053
0054 CalorimeterHit(const std::uint64_t cell_id, const std::uint64_t row, const std::uint64_t col, const double x, const double y, const double z, const double energy, const std::uint64_t time);
0055
0056
0057 CalorimeterHit(const CalorimeterHit& other) = default;
0058
0059
0060 CalorimeterHit& operator=(CalorimeterHit other) &;
0061 CalorimeterHit& operator=(CalorimeterHit other) && = delete;
0062
0063
0064
0065 MutableCalorimeterHit clone(bool cloneRelations=true) const;
0066
0067
0068 ~CalorimeterHit() = default;
0069
0070
0071 CalorimeterHit(const MutableCalorimeterHit& other);
0072
0073 static CalorimeterHit makeEmpty();
0074
0075 public:
0076
0077 static constexpr std::string_view typeName = "CalorimeterHit";
0078
0079
0080 std::uint64_t getCell_id() const;
0081
0082
0083 std::uint64_t getRow() const;
0084
0085
0086 std::uint64_t getCol() const;
0087
0088
0089 double getX() const;
0090
0091
0092 double getY() const;
0093
0094
0095 double getZ() const;
0096
0097
0098 double getEnergy() const;
0099
0100
0101 std::uint64_t getTime() const;
0102
0103
0104
0105
0106
0107
0108 bool isAvailable() const;
0109
0110 void unlink() { m_obj = podio::utils::MaybeSharedPtr<CalorimeterHitObj>{nullptr}; }
0111
0112 bool operator==(const CalorimeterHit& other) const { return m_obj == other.m_obj; }
0113 bool operator==(const MutableCalorimeterHit& other) const;
0114
0115 bool operator!=(const CalorimeterHit& other) const { return !(*this == other); }
0116 bool operator!=(const MutableCalorimeterHit& other) const { return !(*this == other); }
0117
0118
0119 bool operator<(const CalorimeterHit& other) const { return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other); }
0120
0121 podio::ObjectID id() const { return getObjectID(); }
0122
0123 const podio::ObjectID getObjectID() const;
0124
0125 friend std::hash<CalorimeterHit>;
0126
0127 friend void swap(CalorimeterHit& a, CalorimeterHit& b) {
0128 using std::swap;
0129 swap(a.m_obj, b.m_obj);
0130 }
0131
0132 private:
0133
0134 explicit CalorimeterHit(podio::utils::MaybeSharedPtr<CalorimeterHitObj> obj);
0135 CalorimeterHit(CalorimeterHitObj* obj);
0136
0137 podio::utils::MaybeSharedPtr<CalorimeterHitObj> m_obj{new CalorimeterHitObj{}, podio::utils::MarkOwned};
0138 };
0139
0140 std::ostream& operator<<(std::ostream& o, const CalorimeterHit& value);
0141
0142 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0143 void to_json(nlohmann::json& j, const CalorimeterHit& value);
0144 #endif
0145
0146
0147
0148
0149
0150 template<>
0151 struct std::hash<CalorimeterHit> {
0152 std::size_t operator()(const CalorimeterHit& obj) const {
0153 return std::hash<CalorimeterHitObj*>{}(obj.m_obj.get());
0154 }
0155 };
0156
0157
0158
0159
0160
0161 #if defined(__clang__)
0162 #pragma clang diagnostic push
0163 #pragma clang diagnostic ignored "-Wunknown-warning-option"
0164 #pragma clang diagnostic ignored "-Wdeprecated-redundant-constexpr-static-def"
0165 #pragma clang diagnostic ignored "-Wdeprecated"
0166 constexpr std::string_view CalorimeterHit::typeName;
0167 #pragma clang diagnostic pop
0168 #elif defined(__GNUC__)
0169 #pragma GCC diagnostic push
0170 #pragma GCC diagnostic ignored "-Wdeprecated"
0171 constexpr std::string_view CalorimeterHit::typeName;
0172 #pragma GCC diagnostic pop
0173 #endif
0174
0175
0176 #endif