File indexing completed on 2025-12-11 10:20:46
0001
0002
0003 #ifndef JANA2_TUTORIAL_PODIO_DATAMODEL_MutableADCHit_H
0004 #define JANA2_TUTORIAL_PODIO_DATAMODEL_MutableADCHit_H
0005
0006 #include "jana2_tutorial_podio_datamodel/ADCHitObj.h"
0007
0008 #include "jana2_tutorial_podio_datamodel/ADCHit.h"
0009
0010 #include <cstdint>
0011
0012 #include "podio/utilities/MaybeSharedPtr.h"
0013
0014 #include <cstdint>
0015
0016 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0017 #include "nlohmann/json_fwd.hpp"
0018 #endif
0019
0020
0021 class ADCHitCollection;
0022
0023
0024
0025
0026
0027
0028
0029
0030 class MutableADCHit {
0031
0032 friend class ADCHitCollection;
0033 friend class ADCHitMutableCollectionIterator;
0034 friend class ADCHit;
0035
0036 public:
0037 using object_type = ADCHit;
0038 using collection_type = ADCHitCollection;
0039
0040
0041 MutableADCHit() = default;
0042
0043
0044 MutableADCHit(const std::uint32_t crate, const std::uint32_t slot, const std::uint32_t channel, const std::uint32_t energy, const std::uint32_t timestamp);
0045
0046
0047 MutableADCHit(const MutableADCHit& other) = default;
0048
0049
0050 MutableADCHit& operator=(MutableADCHit other) &;
0051 MutableADCHit& operator=(MutableADCHit other) && = delete;
0052
0053
0054
0055 MutableADCHit clone(bool cloneRelations=true) const;
0056
0057
0058 ~MutableADCHit() = default;
0059
0060
0061 public:
0062
0063
0064 std::uint32_t getCrate() const;
0065
0066
0067 std::uint32_t getSlot() const;
0068
0069
0070 std::uint32_t getChannel() const;
0071
0072
0073 std::uint32_t getEnergy() const;
0074
0075
0076 std::uint32_t getTimestamp() const;
0077
0078
0079
0080
0081 void setCrate(const std::uint32_t crate);
0082
0083 std::uint32_t& getCrate();
0084
0085 [[deprecated("use getCrate instead")]]
0086 std::uint32_t& crate();
0087
0088
0089 void setSlot(const std::uint32_t slot);
0090
0091 std::uint32_t& getSlot();
0092
0093 [[deprecated("use getSlot instead")]]
0094 std::uint32_t& slot();
0095
0096
0097 void setChannel(const std::uint32_t channel);
0098
0099 std::uint32_t& getChannel();
0100
0101 [[deprecated("use getChannel instead")]]
0102 std::uint32_t& channel();
0103
0104
0105 void setEnergy(const std::uint32_t energy);
0106
0107 std::uint32_t& getEnergy();
0108
0109 [[deprecated("use getEnergy instead")]]
0110 std::uint32_t& energy();
0111
0112
0113 void setTimestamp(const std::uint32_t timestamp);
0114
0115 std::uint32_t& getTimestamp();
0116
0117 [[deprecated("use getTimestamp instead")]]
0118 std::uint32_t& timestamp();
0119
0120
0121
0122
0123
0124
0125
0126 bool isAvailable() const;
0127
0128 void unlink() { m_obj = podio::utils::MaybeSharedPtr<ADCHitObj>{nullptr}; }
0129
0130 bool operator==(const MutableADCHit& other) const { return m_obj == other.m_obj; }
0131 bool operator==(const ADCHit& other) const;
0132
0133 bool operator!=(const MutableADCHit& other) const { return !(*this == other); }
0134 bool operator!=(const ADCHit& other) const { return !(*this == other); }
0135
0136
0137 bool operator<(const MutableADCHit& other) const { return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other); }
0138
0139 podio::ObjectID id() const { return getObjectID(); }
0140
0141 const podio::ObjectID getObjectID() const;
0142
0143 friend std::hash<MutableADCHit>;
0144
0145 friend void swap(MutableADCHit& a, MutableADCHit& b) {
0146 using std::swap;
0147 swap(a.m_obj, b.m_obj);
0148 }
0149
0150 private:
0151
0152 explicit MutableADCHit(podio::utils::MaybeSharedPtr<ADCHitObj> obj);
0153
0154 podio::utils::MaybeSharedPtr<ADCHitObj> m_obj{new ADCHitObj{}, podio::utils::MarkOwned};
0155 };
0156
0157 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0158 void to_json(nlohmann::json& j, const MutableADCHit& value);
0159 #endif
0160
0161
0162
0163
0164
0165 template<>
0166 struct std::hash<MutableADCHit> {
0167 std::size_t operator()(const MutableADCHit& obj) const {
0168 return std::hash<ADCHitObj*>{}(obj.m_obj.get());
0169 }
0170 };
0171
0172
0173 #endif