File indexing completed on 2024-11-15 09:35:42
0001
0002
0003 #ifndef EDM4HEP_MutableTimeSeries_H
0004 #define EDM4HEP_MutableTimeSeries_H
0005
0006 #include "edm4hep/TimeSeriesObj.h"
0007
0008 #include "edm4hep/TimeSeries.h"
0009
0010 #include "podio/RelationRange.h"
0011 #include <cstdint>
0012 #include <vector>
0013
0014 #include "podio/utilities/MaybeSharedPtr.h"
0015
0016 #include <cstddef>
0017 #include <ostream>
0018
0019 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0020 #include "nlohmann/json_fwd.hpp"
0021 #endif
0022
0023 namespace edm4hep {
0024
0025
0026
0027
0028
0029 class MutableTimeSeries {
0030
0031 friend class TimeSeriesCollection;
0032 friend class TimeSeriesMutableCollectionIterator;
0033 friend class TimeSeries;
0034
0035 public:
0036 using object_type = TimeSeries;
0037 using collection_type = TimeSeriesCollection;
0038
0039
0040 MutableTimeSeries();
0041
0042
0043 MutableTimeSeries(std::uint64_t cellID, float time, float interval);
0044
0045
0046 MutableTimeSeries(const MutableTimeSeries& other) = default;
0047
0048
0049 MutableTimeSeries& operator=(MutableTimeSeries other);
0050
0051
0052 MutableTimeSeries clone() const;
0053
0054
0055 ~MutableTimeSeries() = default;
0056
0057
0058 operator TimeSeries() const;
0059
0060 public:
0061
0062 std::uint64_t getCellID() const;
0063
0064
0065 float getTime() const;
0066
0067
0068 float getInterval() const;
0069
0070
0071 void setCellID(std::uint64_t value);
0072
0073
0074 void setTime(float value);
0075
0076
0077 void setInterval(float value);
0078
0079 void addToAmplitude(float);
0080 std::size_t amplitude_size() const;
0081 float getAmplitude(std::size_t) const;
0082 std::vector<float>::const_iterator amplitude_begin() const;
0083 std::vector<float>::const_iterator amplitude_end() const;
0084 podio::RelationRange<float> getAmplitude() const;
0085
0086
0087 bool isAvailable() const;
0088
0089 void unlink() {
0090 m_obj = podio::utils::MaybeSharedPtr<TimeSeriesObj>{nullptr};
0091 }
0092
0093 bool operator==(const MutableTimeSeries& other) const {
0094 return m_obj == other.m_obj;
0095 }
0096 bool operator==(const TimeSeries& other) const;
0097
0098
0099 bool operator<(const MutableTimeSeries& other) const {
0100 return m_obj < other.m_obj;
0101 }
0102
0103 podio::ObjectID id() const {
0104 return getObjectID();
0105 }
0106
0107 const podio::ObjectID getObjectID() const;
0108
0109 friend void swap(MutableTimeSeries& a, MutableTimeSeries& b) {
0110 using std::swap;
0111 swap(a.m_obj, b.m_obj);
0112 }
0113
0114 private:
0115
0116 explicit MutableTimeSeries(podio::utils::MaybeSharedPtr<TimeSeriesObj> obj);
0117
0118 podio::utils::MaybeSharedPtr<TimeSeriesObj> m_obj{nullptr};
0119 };
0120
0121 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0122 void to_json(nlohmann::json& j, const MutableTimeSeries& value);
0123 #endif
0124
0125 }
0126
0127 #endif