File indexing completed on 2026-04-17 08:20:52
0001
0002
0003 #ifndef EDM4EIC_MutableRawCALOROCHit_H
0004 #define EDM4EIC_MutableRawCALOROCHit_H
0005
0006 #include "edm4eic/RawCALOROCHitObj.h"
0007
0008 #include "edm4eic/RawCALOROCHit.h"
0009
0010 #include "edm4eic/CALOROC1ASample.h"
0011 #include "edm4eic/CALOROC1BSample.h"
0012 #include "podio/RelationRange.h"
0013 #include <cstdint>
0014 #include <vector>
0015
0016 #include "podio/utilities/MaybeSharedPtr.h"
0017
0018 #include <cstdint>
0019
0020 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0021 #include "nlohmann/json_fwd.hpp"
0022 #endif
0023
0024
0025 namespace edm4eic {
0026 class RawCALOROCHitCollection;
0027 }
0028
0029
0030 namespace edm4eic {
0031
0032
0033
0034
0035
0036
0037 class MutableRawCALOROCHit {
0038
0039 friend class RawCALOROCHitCollection;
0040 friend class RawCALOROCHitMutableCollectionIterator;
0041 friend class RawCALOROCHit;
0042
0043 public:
0044 using object_type = RawCALOROCHit;
0045 using collection_type = RawCALOROCHitCollection;
0046
0047
0048 MutableRawCALOROCHit() = default;
0049
0050
0051 MutableRawCALOROCHit(const std::uint64_t cellID, const std::int32_t samplePhase, const std::int32_t timeStamp);
0052
0053
0054 MutableRawCALOROCHit(const MutableRawCALOROCHit& other) = default;
0055
0056
0057 MutableRawCALOROCHit& operator=(MutableRawCALOROCHit other) &;
0058 MutableRawCALOROCHit& operator=(MutableRawCALOROCHit other) && = delete;
0059
0060
0061
0062 MutableRawCALOROCHit clone(bool cloneRelations=true) const;
0063
0064
0065 ~MutableRawCALOROCHit() = default;
0066
0067
0068 public:
0069
0070
0071 std::uint64_t getCellID() const;
0072
0073
0074 std::int32_t getSamplePhase() const;
0075
0076
0077 std::int32_t getTimeStamp() const;
0078
0079
0080
0081
0082 void setCellID(const std::uint64_t cellID);
0083
0084 std::uint64_t& getCellID();
0085
0086 [[deprecated("use getCellID instead")]]
0087 std::uint64_t& cellID();
0088
0089
0090 void setSamplePhase(const std::int32_t samplePhase);
0091
0092 std::int32_t& getSamplePhase();
0093
0094 [[deprecated("use getSamplePhase instead")]]
0095 std::int32_t& samplePhase();
0096
0097
0098 void setTimeStamp(const std::int32_t timeStamp);
0099
0100 std::int32_t& getTimeStamp();
0101
0102 [[deprecated("use getTimeStamp instead")]]
0103 std::int32_t& timeStamp();
0104
0105
0106
0107 void addToASamples(const edm4eic::CALOROC1ASample&);
0108 std::size_t aSamples_size() const;
0109 edm4eic::CALOROC1ASample getASamples(std::size_t) const;
0110 std::vector<edm4eic::CALOROC1ASample>::const_iterator aSamples_begin() const;
0111 std::vector<edm4eic::CALOROC1ASample>::const_iterator aSamples_end() const;
0112 podio::RelationRange<edm4eic::CALOROC1ASample> getASamples() const;
0113 void addToBSamples(const edm4eic::CALOROC1BSample&);
0114 std::size_t bSamples_size() const;
0115 edm4eic::CALOROC1BSample getBSamples(std::size_t) const;
0116 std::vector<edm4eic::CALOROC1BSample>::const_iterator bSamples_begin() const;
0117 std::vector<edm4eic::CALOROC1BSample>::const_iterator bSamples_end() const;
0118 podio::RelationRange<edm4eic::CALOROC1BSample> getBSamples() const;
0119
0120
0121
0122
0123 bool isAvailable() const;
0124
0125 void unlink() { m_obj = podio::utils::MaybeSharedPtr<RawCALOROCHitObj>{nullptr}; }
0126
0127 bool operator==(const MutableRawCALOROCHit& other) const { return m_obj == other.m_obj; }
0128 bool operator==(const RawCALOROCHit& other) const;
0129
0130 bool operator!=(const MutableRawCALOROCHit& other) const { return !(*this == other); }
0131 bool operator!=(const RawCALOROCHit& other) const { return !(*this == other); }
0132
0133
0134 bool operator<(const MutableRawCALOROCHit& other) const { return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other); }
0135
0136 podio::ObjectID id() const { return getObjectID(); }
0137
0138 const podio::ObjectID getObjectID() const;
0139
0140 friend std::hash<MutableRawCALOROCHit>;
0141
0142 friend void swap(MutableRawCALOROCHit& a, MutableRawCALOROCHit& b) {
0143 using std::swap;
0144 swap(a.m_obj, b.m_obj);
0145 }
0146
0147 private:
0148
0149 explicit MutableRawCALOROCHit(podio::utils::MaybeSharedPtr<RawCALOROCHitObj> obj);
0150
0151 podio::utils::MaybeSharedPtr<RawCALOROCHitObj> m_obj{new RawCALOROCHitObj{}, podio::utils::MarkOwned};
0152 };
0153
0154 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0155 void to_json(nlohmann::json& j, const MutableRawCALOROCHit& value);
0156 #endif
0157
0158
0159 }
0160
0161
0162
0163 template<>
0164 struct std::hash<edm4eic::MutableRawCALOROCHit> {
0165 std::size_t operator()(const edm4eic::MutableRawCALOROCHit& obj) const {
0166 return std::hash<edm4eic::RawCALOROCHitObj*>{}(obj.m_obj.get());
0167 }
0168 };
0169
0170
0171 #endif