File indexing completed on 2026-04-17 08:20:52
0001
0002
0003 #ifndef EDM4EIC_MutableJet_H
0004 #define EDM4EIC_MutableJet_H
0005
0006 #include "edm4eic/JetObj.h"
0007
0008 #include "edm4eic/Jet.h"
0009
0010 #include "edm4eic/ReconstructedParticle.h"
0011 #include "edm4hep/Vector3f.h"
0012 #include "podio/RelationRange.h"
0013 #include <cstdint>
0014 #include <vector>
0015
0016 #include "podio/utilities/MaybeSharedPtr.h"
0017
0018 #include <cstdint>
0019
0020 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0021 #include "nlohmann/json_fwd.hpp"
0022 #endif
0023
0024
0025 namespace edm4eic {
0026 class JetCollection;
0027 }
0028
0029
0030 namespace edm4eic {
0031
0032
0033
0034
0035
0036
0037 class MutableJet {
0038
0039 friend class JetCollection;
0040 friend class JetMutableCollectionIterator;
0041 friend class Jet;
0042
0043 public:
0044 using object_type = Jet;
0045 using collection_type = JetCollection;
0046
0047
0048 MutableJet() = default;
0049
0050
0051 MutableJet(const std::uint32_t type, const float area, const float energy, const float backgroundEnergyDensity, const edm4hep::Vector3f& momentum);
0052
0053
0054 MutableJet(const MutableJet& other) = default;
0055
0056
0057 MutableJet& operator=(MutableJet other) &;
0058 MutableJet& operator=(MutableJet other) && = delete;
0059
0060
0061
0062 MutableJet clone(bool cloneRelations=true) const;
0063
0064
0065 ~MutableJet() = default;
0066
0067
0068 public:
0069
0070
0071 std::uint32_t getType() const;
0072
0073
0074 float getArea() const;
0075
0076
0077 float getEnergy() const;
0078
0079
0080 float getBackgroundEnergyDensity() const;
0081
0082
0083 const edm4hep::Vector3f& getMomentum() const;
0084
0085
0086
0087
0088 void setType(const std::uint32_t type);
0089
0090 std::uint32_t& getType();
0091
0092 [[deprecated("use getType instead")]]
0093 std::uint32_t& type();
0094
0095
0096 void setArea(const float area);
0097
0098 float& getArea();
0099
0100 [[deprecated("use getArea instead")]]
0101 float& area();
0102
0103
0104 void setEnergy(const float energy);
0105
0106 float& getEnergy();
0107
0108 [[deprecated("use getEnergy instead")]]
0109 float& energy();
0110
0111
0112 void setBackgroundEnergyDensity(const float backgroundEnergyDensity);
0113
0114 float& getBackgroundEnergyDensity();
0115
0116 [[deprecated("use getBackgroundEnergyDensity instead")]]
0117 float& backgroundEnergyDensity();
0118
0119
0120 void setMomentum(const edm4hep::Vector3f& momentum);
0121
0122 edm4hep::Vector3f& getMomentum();
0123
0124 [[deprecated("use getMomentum instead")]]
0125 edm4hep::Vector3f& momentum();
0126
0127
0128
0129 void addToConstituents(const edm4eic::ReconstructedParticle&);
0130 std::size_t constituents_size() const;
0131 edm4eic::ReconstructedParticle getConstituents(std::size_t) const;
0132 std::vector<edm4eic::ReconstructedParticle>::const_iterator constituents_begin() const;
0133 std::vector<edm4eic::ReconstructedParticle>::const_iterator constituents_end() const;
0134 podio::RelationRange<edm4eic::ReconstructedParticle> getConstituents() const;
0135
0136
0137 float getBackgroundEnergy() const { return getArea() * getBackgroundEnergyDensity(); }
0138
0139
0140
0141
0142 bool isAvailable() const;
0143
0144 void unlink() { m_obj = podio::utils::MaybeSharedPtr<JetObj>{nullptr}; }
0145
0146 bool operator==(const MutableJet& other) const { return m_obj == other.m_obj; }
0147 bool operator==(const Jet& other) const;
0148
0149 bool operator!=(const MutableJet& other) const { return !(*this == other); }
0150 bool operator!=(const Jet& other) const { return !(*this == other); }
0151
0152
0153 bool operator<(const MutableJet& other) const { return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other); }
0154
0155 podio::ObjectID id() const { return getObjectID(); }
0156
0157 const podio::ObjectID getObjectID() const;
0158
0159 friend std::hash<MutableJet>;
0160
0161 friend void swap(MutableJet& a, MutableJet& b) {
0162 using std::swap;
0163 swap(a.m_obj, b.m_obj);
0164 }
0165
0166 private:
0167
0168 explicit MutableJet(podio::utils::MaybeSharedPtr<JetObj> obj);
0169
0170 podio::utils::MaybeSharedPtr<JetObj> m_obj{new JetObj{}, podio::utils::MarkOwned};
0171 };
0172
0173 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0174 void to_json(nlohmann::json& j, const MutableJet& value);
0175 #endif
0176
0177
0178 }
0179
0180
0181
0182 template<>
0183 struct std::hash<edm4eic::MutableJet> {
0184 std::size_t operator()(const edm4eic::MutableJet& obj) const {
0185 return std::hash<edm4eic::JetObj*>{}(obj.m_obj.get());
0186 }
0187 };
0188
0189
0190 #endif