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