File indexing completed on 2025-12-11 10:20:46
0001
0002
0003 #ifndef JANA2_TUTORIAL_PODIO_DATAMODEL_MutableCalorimeterHit_H
0004 #define JANA2_TUTORIAL_PODIO_DATAMODEL_MutableCalorimeterHit_H
0005
0006 #include "jana2_tutorial_podio_datamodel/CalorimeterHitObj.h"
0007
0008 #include "jana2_tutorial_podio_datamodel/CalorimeterHit.h"
0009
0010 #include <cstdint>
0011
0012 #include "podio/utilities/MaybeSharedPtr.h"
0013
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
0025
0026
0027
0028
0029
0030 class MutableCalorimeterHit {
0031
0032 friend class CalorimeterHitCollection;
0033 friend class CalorimeterHitMutableCollectionIterator;
0034 friend class CalorimeterHit;
0035
0036 public:
0037 using object_type = CalorimeterHit;
0038 using collection_type = CalorimeterHitCollection;
0039
0040
0041 MutableCalorimeterHit() = default;
0042
0043
0044 MutableCalorimeterHit(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);
0045
0046
0047 MutableCalorimeterHit(const MutableCalorimeterHit& other) = default;
0048
0049
0050 MutableCalorimeterHit& operator=(MutableCalorimeterHit other) &;
0051 MutableCalorimeterHit& operator=(MutableCalorimeterHit other) && = delete;
0052
0053
0054
0055 MutableCalorimeterHit clone(bool cloneRelations=true) const;
0056
0057
0058 ~MutableCalorimeterHit() = default;
0059
0060
0061 public:
0062
0063
0064 std::uint64_t getCell_id() const;
0065
0066
0067 std::uint64_t getRow() const;
0068
0069
0070 std::uint64_t getCol() const;
0071
0072
0073 double getX() const;
0074
0075
0076 double getY() const;
0077
0078
0079 double getZ() const;
0080
0081
0082 double getEnergy() const;
0083
0084
0085 std::uint64_t getTime() const;
0086
0087
0088
0089
0090 void setCell_id(const std::uint64_t cell_id);
0091
0092 std::uint64_t& getCell_id();
0093
0094 [[deprecated("use getCell_id instead")]]
0095 std::uint64_t& cell_id();
0096
0097
0098 void setRow(const std::uint64_t row);
0099
0100 std::uint64_t& getRow();
0101
0102 [[deprecated("use getRow instead")]]
0103 std::uint64_t& row();
0104
0105
0106 void setCol(const std::uint64_t col);
0107
0108 std::uint64_t& getCol();
0109
0110 [[deprecated("use getCol instead")]]
0111 std::uint64_t& col();
0112
0113
0114 void setX(const double x);
0115
0116 double& getX();
0117
0118 [[deprecated("use getX instead")]]
0119 double& x();
0120
0121
0122 void setY(const double y);
0123
0124 double& getY();
0125
0126 [[deprecated("use getY instead")]]
0127 double& y();
0128
0129
0130 void setZ(const double z);
0131
0132 double& getZ();
0133
0134 [[deprecated("use getZ instead")]]
0135 double& z();
0136
0137
0138 void setEnergy(const double energy);
0139
0140 double& getEnergy();
0141
0142 [[deprecated("use getEnergy instead")]]
0143 double& energy();
0144
0145
0146 void setTime(const std::uint64_t time);
0147
0148 std::uint64_t& getTime();
0149
0150 [[deprecated("use getTime instead")]]
0151 std::uint64_t& time();
0152
0153
0154
0155
0156
0157
0158
0159 bool isAvailable() const;
0160
0161 void unlink() { m_obj = podio::utils::MaybeSharedPtr<CalorimeterHitObj>{nullptr}; }
0162
0163 bool operator==(const MutableCalorimeterHit& other) const { return m_obj == other.m_obj; }
0164 bool operator==(const CalorimeterHit& other) const;
0165
0166 bool operator!=(const MutableCalorimeterHit& other) const { return !(*this == other); }
0167 bool operator!=(const CalorimeterHit& other) const { return !(*this == other); }
0168
0169
0170 bool operator<(const MutableCalorimeterHit& other) const { return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other); }
0171
0172 podio::ObjectID id() const { return getObjectID(); }
0173
0174 const podio::ObjectID getObjectID() const;
0175
0176 friend std::hash<MutableCalorimeterHit>;
0177
0178 friend void swap(MutableCalorimeterHit& a, MutableCalorimeterHit& b) {
0179 using std::swap;
0180 swap(a.m_obj, b.m_obj);
0181 }
0182
0183 private:
0184
0185 explicit MutableCalorimeterHit(podio::utils::MaybeSharedPtr<CalorimeterHitObj> obj);
0186
0187 podio::utils::MaybeSharedPtr<CalorimeterHitObj> m_obj{new CalorimeterHitObj{}, podio::utils::MarkOwned};
0188 };
0189
0190 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0191 void to_json(nlohmann::json& j, const MutableCalorimeterHit& value);
0192 #endif
0193
0194
0195
0196
0197
0198 template<>
0199 struct std::hash<MutableCalorimeterHit> {
0200 std::size_t operator()(const MutableCalorimeterHit& obj) const {
0201 return std::hash<CalorimeterHitObj*>{}(obj.m_obj.get());
0202 }
0203 };
0204
0205
0206 #endif