File indexing completed on 2025-12-11 10:20:46
0001
0002
0003 #ifndef JANA2_TUTORIAL_PODIO_DATAMODEL_MutableSimParticle_H
0004 #define JANA2_TUTORIAL_PODIO_DATAMODEL_MutableSimParticle_H
0005
0006 #include "jana2_tutorial_podio_datamodel/SimParticleObj.h"
0007
0008 #include "jana2_tutorial_podio_datamodel/SimParticle.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 SimParticleCollection;
0022
0023
0024
0025
0026
0027
0028
0029
0030 class MutableSimParticle {
0031
0032 friend class SimParticleCollection;
0033 friend class SimParticleMutableCollectionIterator;
0034 friend class SimParticle;
0035
0036 public:
0037 using object_type = SimParticle;
0038 using collection_type = SimParticleCollection;
0039
0040
0041 MutableSimParticle() = default;
0042
0043
0044 MutableSimParticle(const double momentum_z, const double momentum_theta, const double momentum_phi, const double energy, const std::uint32_t pdg);
0045
0046
0047 MutableSimParticle(const MutableSimParticle& other) = default;
0048
0049
0050 MutableSimParticle& operator=(MutableSimParticle other) &;
0051 MutableSimParticle& operator=(MutableSimParticle other) && = delete;
0052
0053
0054
0055 MutableSimParticle clone(bool cloneRelations=true) const;
0056
0057
0058 ~MutableSimParticle() = default;
0059
0060
0061 public:
0062
0063
0064 double getMomentum_z() const;
0065
0066
0067 double getMomentum_theta() const;
0068
0069
0070 double getMomentum_phi() const;
0071
0072
0073 double getEnergy() const;
0074
0075
0076 std::uint32_t getPdg() const;
0077
0078
0079
0080
0081 void setMomentum_z(const double momentum_z);
0082
0083 double& getMomentum_z();
0084
0085 [[deprecated("use getMomentum_z instead")]]
0086 double& momentum_z();
0087
0088
0089 void setMomentum_theta(const double momentum_theta);
0090
0091 double& getMomentum_theta();
0092
0093 [[deprecated("use getMomentum_theta instead")]]
0094 double& momentum_theta();
0095
0096
0097 void setMomentum_phi(const double momentum_phi);
0098
0099 double& getMomentum_phi();
0100
0101 [[deprecated("use getMomentum_phi instead")]]
0102 double& momentum_phi();
0103
0104
0105 void setEnergy(const double energy);
0106
0107 double& getEnergy();
0108
0109 [[deprecated("use getEnergy instead")]]
0110 double& energy();
0111
0112
0113 void setPdg(const std::uint32_t pdg);
0114
0115 std::uint32_t& getPdg();
0116
0117 [[deprecated("use getPdg instead")]]
0118 std::uint32_t& pdg();
0119
0120
0121
0122
0123
0124
0125
0126 bool isAvailable() const;
0127
0128 void unlink() { m_obj = podio::utils::MaybeSharedPtr<SimParticleObj>{nullptr}; }
0129
0130 bool operator==(const MutableSimParticle& other) const { return m_obj == other.m_obj; }
0131 bool operator==(const SimParticle& other) const;
0132
0133 bool operator!=(const MutableSimParticle& other) const { return !(*this == other); }
0134 bool operator!=(const SimParticle& other) const { return !(*this == other); }
0135
0136
0137 bool operator<(const MutableSimParticle& 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<MutableSimParticle>;
0144
0145 friend void swap(MutableSimParticle& a, MutableSimParticle& b) {
0146 using std::swap;
0147 swap(a.m_obj, b.m_obj);
0148 }
0149
0150 private:
0151
0152 explicit MutableSimParticle(podio::utils::MaybeSharedPtr<SimParticleObj> obj);
0153
0154 podio::utils::MaybeSharedPtr<SimParticleObj> m_obj{new SimParticleObj{}, podio::utils::MarkOwned};
0155 };
0156
0157 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0158 void to_json(nlohmann::json& j, const MutableSimParticle& value);
0159 #endif
0160
0161
0162
0163
0164
0165 template<>
0166 struct std::hash<MutableSimParticle> {
0167 std::size_t operator()(const MutableSimParticle& obj) const {
0168 return std::hash<SimParticleObj*>{}(obj.m_obj.get());
0169 }
0170 };
0171
0172
0173 #endif