Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-11 10:13:38

0001 // AUTOMATICALLY GENERATED FILE - DO NOT EDIT
0002 
0003 #ifndef EDM4HEP_MutableTimeSeries_H
0004 #define EDM4HEP_MutableTimeSeries_H
0005 
0006 #include "edm4hep/TimeSeriesObj.h"
0007 // Make the immutable class available from its mutable version but not vice versa
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 <cstdint>
0017 
0018 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0019 #include "nlohmann/json_fwd.hpp"
0020 #endif
0021 
0022 // forward declarations
0023 namespace edm4hep {
0024 class TimeSeriesCollection;
0025 }
0026 
0027 namespace edm4hep {
0028 
0029 /** @class MutableTimeSeries
0030  *  Calibrated Detector Data
0031  *  @author: EDM4hep authors
0032  */
0033 class MutableTimeSeries {
0034 
0035   friend class TimeSeriesCollection;
0036   friend class TimeSeriesMutableCollectionIterator;
0037   friend class TimeSeries;
0038 
0039 public:
0040   using object_type = TimeSeries;
0041   using collection_type = TimeSeriesCollection;
0042 
0043   /// default constructor
0044   MutableTimeSeries() = default;
0045 
0046   /// Constructor initializing all members
0047   MutableTimeSeries(const std::uint64_t cellID, const float time, const float interval);
0048 
0049   /// copy constructor
0050   MutableTimeSeries(const MutableTimeSeries& other) = default;
0051 
0052   /// copy-assignment operator
0053   MutableTimeSeries& operator=(MutableTimeSeries other) &; // Rebind this to other's internal object
0054   MutableTimeSeries&
0055   operator=(MutableTimeSeries other) && = delete; // Prevent rebinding temporary as the changes wouldn't persist
0056 
0057   /// create a mutable deep-copy of the object with identical relations
0058   /// if cloneRelations=false, the relations are not cloned and will be empty
0059   MutableTimeSeries clone(bool cloneRelations = true) const;
0060 
0061   /// destructor
0062   ~MutableTimeSeries() = default;
0063 
0064 public:
0065   /// Access the cell id
0066   std::uint64_t getCellID() const;
0067 
0068   /// Access the begin time [ns]
0069   float getTime() const;
0070 
0071   /// Access the interval of each sampling [ns]
0072   float getInterval() const;
0073 
0074   /// Set the cell id
0075   void setCellID(const std::uint64_t cellID);
0076   /// Get mutable reference to cell id
0077   std::uint64_t& getCellID();
0078   /// Get reference to cell id
0079   [[deprecated("use getCellID instead")]] std::uint64_t& cellID();
0080 
0081   /// Set the begin time [ns]
0082   void setTime(const float time);
0083   /// Get mutable reference to begin time [ns]
0084   float& getTime();
0085   /// Get reference to begin time [ns]
0086   [[deprecated("use getTime instead")]] float& time();
0087 
0088   /// Set the interval of each sampling [ns]
0089   void setInterval(const float interval);
0090   /// Get mutable reference to interval of each sampling [ns]
0091   float& getInterval();
0092   /// Get reference to interval of each sampling [ns]
0093   [[deprecated("use getInterval instead")]] float& interval();
0094 
0095   void addToAmplitude(const float&);
0096   std::size_t amplitude_size() const;
0097   float getAmplitude(std::size_t) const;
0098   std::vector<float>::const_iterator amplitude_begin() const;
0099   std::vector<float>::const_iterator amplitude_end() const;
0100   podio::RelationRange<float> getAmplitude() const;
0101 
0102   /// check whether the object is actually available
0103   bool isAvailable() const;
0104   /// disconnect from TimeSeriesObj instance
0105   void unlink() { m_obj = podio::utils::MaybeSharedPtr<TimeSeriesObj>{nullptr}; }
0106 
0107   bool operator==(const MutableTimeSeries& other) const { return m_obj == other.m_obj; }
0108   bool operator==(const TimeSeries& other) const;
0109 
0110   bool operator!=(const MutableTimeSeries& other) const { return !(*this == other); }
0111   bool operator!=(const TimeSeries& other) const { return !(*this == other); }
0112 
0113   // less comparison operator, so that objects can be e.g. stored in sets.
0114   bool operator<(const MutableTimeSeries& other) const {
0115     return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other);
0116   }
0117 
0118   podio::ObjectID id() const { return getObjectID(); }
0119 
0120   const podio::ObjectID getObjectID() const;
0121 
0122   friend std::hash<MutableTimeSeries>;
0123 
0124   friend void swap(MutableTimeSeries& a, MutableTimeSeries& b) {
0125     using std::swap;
0126     swap(a.m_obj, b.m_obj); // swap out the internal pointers
0127   }
0128 
0129 private:
0130   /// constructor from existing TimeSeriesObj
0131   explicit MutableTimeSeries(podio::utils::MaybeSharedPtr<TimeSeriesObj> obj);
0132 
0133   podio::utils::MaybeSharedPtr<TimeSeriesObj> m_obj{new TimeSeriesObj{}, podio::utils::MarkOwned};
0134 };
0135 
0136 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0137 void to_json(nlohmann::json& j, const MutableTimeSeries& value);
0138 #endif
0139 
0140 } // namespace edm4hep
0141 
0142 template <>
0143 struct std::hash<edm4hep::MutableTimeSeries> {
0144   std::size_t operator()(const edm4hep::MutableTimeSeries& obj) const {
0145     return std::hash<edm4hep::TimeSeriesObj*>{}(obj.m_obj.get());
0146   }
0147 };
0148 
0149 #endif