File indexing completed on 2025-09-18 09:10:54
0001
0002
0003 #ifndef EDM4HEP_MutableRawTimeSeries_H
0004 #define EDM4HEP_MutableRawTimeSeries_H
0005
0006 #include "edm4hep/RawTimeSeriesObj.h"
0007
0008 #include "edm4hep/RawTimeSeries.h"
0009
0010 #include "podio/RelationRange.h"
0011 #include <cstdint>
0012 #include <vector>
0013
0014 #include "podio/utilities/MaybeSharedPtr.h"
0015
0016 #include <cstdint>
0017
0018 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0019 #include "nlohmann/json_fwd.hpp"
0020 #endif
0021
0022
0023 namespace edm4hep {
0024 class RawTimeSeriesCollection;
0025 }
0026
0027
0028 namespace edm4hep {
0029
0030
0031
0032
0033
0034
0035 class MutableRawTimeSeries {
0036
0037 friend class RawTimeSeriesCollection;
0038 friend class RawTimeSeriesMutableCollectionIterator;
0039 friend class RawTimeSeries;
0040
0041 public:
0042 using object_type = RawTimeSeries;
0043 using collection_type = RawTimeSeriesCollection;
0044
0045
0046 MutableRawTimeSeries();
0047
0048
0049 MutableRawTimeSeries(const std::uint64_t cellID, const std::int32_t quality, const float time, const float charge, const float interval);
0050
0051
0052 MutableRawTimeSeries(const MutableRawTimeSeries& other) = default;
0053
0054
0055 MutableRawTimeSeries& operator=(MutableRawTimeSeries other) &;
0056 MutableRawTimeSeries& operator=(MutableRawTimeSeries other) && = delete;
0057
0058
0059
0060 MutableRawTimeSeries clone(bool cloneRelations=true) const;
0061
0062
0063 ~MutableRawTimeSeries() = default;
0064
0065
0066 public:
0067
0068
0069 std::uint64_t getCellID() const;
0070
0071
0072 std::int32_t getQuality() const;
0073
0074
0075 float getTime() const;
0076
0077
0078 float getCharge() const;
0079
0080
0081 float getInterval() const;
0082
0083
0084
0085
0086 void setCellID(const std::uint64_t cellID);
0087
0088 std::uint64_t& getCellID();
0089
0090 [[deprecated("use getCellID instead")]]
0091 std::uint64_t& cellID();
0092
0093
0094 void setQuality(const std::int32_t quality);
0095
0096 std::int32_t& getQuality();
0097
0098 [[deprecated("use getQuality instead")]]
0099 std::int32_t& quality();
0100
0101
0102 void setTime(const float time);
0103
0104 float& getTime();
0105
0106 [[deprecated("use getTime instead")]]
0107 float& time();
0108
0109
0110 void setCharge(const float charge);
0111
0112 float& getCharge();
0113
0114 [[deprecated("use getCharge instead")]]
0115 float& charge();
0116
0117
0118 void setInterval(const float interval);
0119
0120 float& getInterval();
0121
0122 [[deprecated("use getInterval instead")]]
0123 float& interval();
0124
0125
0126
0127 void addToAdcCounts(const std::int32_t&);
0128 std::size_t adcCounts_size() const;
0129 std::int32_t getAdcCounts(std::size_t) const;
0130 std::vector<std::int32_t>::const_iterator adcCounts_begin() const;
0131 std::vector<std::int32_t>::const_iterator adcCounts_end() const;
0132 podio::RelationRange<std::int32_t> getAdcCounts() const;
0133
0134
0135
0136
0137 bool isAvailable() const;
0138
0139 void unlink() { m_obj = podio::utils::MaybeSharedPtr<RawTimeSeriesObj>{nullptr}; }
0140
0141 bool operator==(const MutableRawTimeSeries& other) const { return m_obj == other.m_obj; }
0142 bool operator==(const RawTimeSeries& other) const;
0143
0144 bool operator!=(const MutableRawTimeSeries& other) const { return !(*this == other); }
0145 bool operator!=(const RawTimeSeries& other) const { return !(*this == other); }
0146
0147
0148 bool operator<(const MutableRawTimeSeries& other) const { return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other); }
0149
0150 podio::ObjectID id() const { return getObjectID(); }
0151
0152 const podio::ObjectID getObjectID() const;
0153
0154 friend std::hash<MutableRawTimeSeries>;
0155
0156 friend void swap(MutableRawTimeSeries& a, MutableRawTimeSeries& b) {
0157 using std::swap;
0158 swap(a.m_obj, b.m_obj);
0159 }
0160
0161 private:
0162
0163 explicit MutableRawTimeSeries(podio::utils::MaybeSharedPtr<RawTimeSeriesObj> obj);
0164
0165 podio::utils::MaybeSharedPtr<RawTimeSeriesObj> m_obj{nullptr};
0166 };
0167
0168 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0169 void to_json(nlohmann::json& j, const MutableRawTimeSeries& value);
0170 #endif
0171
0172
0173 }
0174
0175
0176
0177 template<>
0178 struct std::hash<edm4hep::MutableRawTimeSeries> {
0179 std::size_t operator()(const edm4hep::MutableRawTimeSeries& obj) const {
0180 return std::hash<edm4hep::RawTimeSeriesObj*>{}(obj.m_obj.get());
0181 }
0182 };
0183
0184
0185 #endif