File indexing completed on 2025-12-11 10:20:46
0001
0002
0003 #ifndef JANA2_TUTORIAL_PODIO_DATAMODEL_MutableCalorimeterCluster_H
0004 #define JANA2_TUTORIAL_PODIO_DATAMODEL_MutableCalorimeterCluster_H
0005
0006 #include "jana2_tutorial_podio_datamodel/CalorimeterClusterObj.h"
0007
0008 #include "jana2_tutorial_podio_datamodel/CalorimeterCluster.h"
0009
0010 #include "jana2_tutorial_podio_datamodel/CalorimeterHit.h"
0011 #include "podio/RelationRange.h"
0012 #include <cstdint>
0013 #include <vector>
0014
0015 #include "podio/utilities/MaybeSharedPtr.h"
0016
0017 #include <cstdint>
0018
0019 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0020 #include "nlohmann/json_fwd.hpp"
0021 #endif
0022
0023
0024 class CalorimeterClusterCollection;
0025
0026
0027
0028
0029
0030
0031
0032
0033 class MutableCalorimeterCluster {
0034
0035 friend class CalorimeterClusterCollection;
0036 friend class CalorimeterClusterMutableCollectionIterator;
0037 friend class CalorimeterCluster;
0038
0039 public:
0040 using object_type = CalorimeterCluster;
0041 using collection_type = CalorimeterClusterCollection;
0042
0043
0044 MutableCalorimeterCluster() = default;
0045
0046
0047 MutableCalorimeterCluster(const double x_center, const double y_center, const double z_center, const double energy, const std::uint64_t time_begin, const std::uint64_t time_end);
0048
0049
0050 MutableCalorimeterCluster(const MutableCalorimeterCluster& other) = default;
0051
0052
0053 MutableCalorimeterCluster& operator=(MutableCalorimeterCluster other) &;
0054 MutableCalorimeterCluster& operator=(MutableCalorimeterCluster other) && = delete;
0055
0056
0057
0058 MutableCalorimeterCluster clone(bool cloneRelations=true) const;
0059
0060
0061 ~MutableCalorimeterCluster() = default;
0062
0063
0064 public:
0065
0066
0067 double getX_center() const;
0068
0069
0070 double getY_center() const;
0071
0072
0073 double getZ_center() const;
0074
0075
0076 double getEnergy() const;
0077
0078
0079 std::uint64_t getTime_begin() const;
0080
0081
0082 std::uint64_t getTime_end() const;
0083
0084
0085
0086
0087 void setX_center(const double x_center);
0088
0089 double& getX_center();
0090
0091 [[deprecated("use getX_center instead")]]
0092 double& x_center();
0093
0094
0095 void setY_center(const double y_center);
0096
0097 double& getY_center();
0098
0099 [[deprecated("use getY_center instead")]]
0100 double& y_center();
0101
0102
0103 void setZ_center(const double z_center);
0104
0105 double& getZ_center();
0106
0107 [[deprecated("use getZ_center instead")]]
0108 double& z_center();
0109
0110
0111 void setEnergy(const double energy);
0112
0113 double& getEnergy();
0114
0115 [[deprecated("use getEnergy instead")]]
0116 double& energy();
0117
0118
0119 void setTime_begin(const std::uint64_t time_begin);
0120
0121 std::uint64_t& getTime_begin();
0122
0123 [[deprecated("use getTime_begin instead")]]
0124 std::uint64_t& time_begin();
0125
0126
0127 void setTime_end(const std::uint64_t time_end);
0128
0129 std::uint64_t& getTime_end();
0130
0131 [[deprecated("use getTime_end instead")]]
0132 std::uint64_t& time_end();
0133
0134
0135
0136 void addToHits(const CalorimeterHit&);
0137 std::size_t hits_size() const;
0138 CalorimeterHit getHits(std::size_t) const;
0139 std::vector<CalorimeterHit>::const_iterator hits_begin() const;
0140 std::vector<CalorimeterHit>::const_iterator hits_end() const;
0141 podio::RelationRange<CalorimeterHit> getHits() const;
0142 void addToClusters(const CalorimeterCluster&);
0143 std::size_t clusters_size() const;
0144 CalorimeterCluster getClusters(std::size_t) const;
0145 std::vector<CalorimeterCluster>::const_iterator clusters_begin() const;
0146 std::vector<CalorimeterCluster>::const_iterator clusters_end() const;
0147 podio::RelationRange<CalorimeterCluster> getClusters() const;
0148
0149
0150
0151
0152 bool isAvailable() const;
0153
0154 void unlink() { m_obj = podio::utils::MaybeSharedPtr<CalorimeterClusterObj>{nullptr}; }
0155
0156 bool operator==(const MutableCalorimeterCluster& other) const { return m_obj == other.m_obj; }
0157 bool operator==(const CalorimeterCluster& other) const;
0158
0159 bool operator!=(const MutableCalorimeterCluster& other) const { return !(*this == other); }
0160 bool operator!=(const CalorimeterCluster& other) const { return !(*this == other); }
0161
0162
0163 bool operator<(const MutableCalorimeterCluster& other) const { return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other); }
0164
0165 podio::ObjectID id() const { return getObjectID(); }
0166
0167 const podio::ObjectID getObjectID() const;
0168
0169 friend std::hash<MutableCalorimeterCluster>;
0170
0171 friend void swap(MutableCalorimeterCluster& a, MutableCalorimeterCluster& b) {
0172 using std::swap;
0173 swap(a.m_obj, b.m_obj);
0174 }
0175
0176 private:
0177
0178 explicit MutableCalorimeterCluster(podio::utils::MaybeSharedPtr<CalorimeterClusterObj> obj);
0179
0180 podio::utils::MaybeSharedPtr<CalorimeterClusterObj> m_obj{new CalorimeterClusterObj{}, podio::utils::MarkOwned};
0181 };
0182
0183 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0184 void to_json(nlohmann::json& j, const MutableCalorimeterCluster& value);
0185 #endif
0186
0187
0188
0189
0190
0191 template<>
0192 struct std::hash<MutableCalorimeterCluster> {
0193 std::size_t operator()(const MutableCalorimeterCluster& obj) const {
0194 return std::hash<CalorimeterClusterObj*>{}(obj.m_obj.get());
0195 }
0196 };
0197
0198
0199 #endif