File indexing completed on 2025-12-11 10:20:46
0001
0002
0003 #ifndef JANA2_TUTORIAL_PODIO_DATAMODEL_SimParticle_H
0004 #define JANA2_TUTORIAL_PODIO_DATAMODEL_SimParticle_H
0005
0006 #include "jana2_tutorial_podio_datamodel/SimParticleObj.h"
0007
0008 #include <cstdint>
0009
0010 #include "podio/utilities/MaybeSharedPtr.h"
0011 #include "podio/detail/OrderKey.h"
0012
0013 #include <ostream>
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 namespace podio::detail {
0025
0026 OrderKey getOrderKey(const ::SimParticle& obj);
0027 };
0028
0029
0030 class MutableSimParticle;
0031 class SimParticleCollection;
0032 class SimParticleCollectionData;
0033
0034
0035
0036
0037
0038 class SimParticle {
0039
0040 friend class MutableSimParticle;
0041 friend class SimParticleCollection;
0042 friend class SimParticleCollectionData;
0043 friend class SimParticleCollectionIterator;
0044 friend podio::detail::OrderKey podio::detail::getOrderKey(const SimParticle & obj);
0045
0046 public:
0047 using mutable_type = MutableSimParticle;
0048 using collection_type = SimParticleCollection;
0049
0050
0051 SimParticle() = default;
0052
0053
0054 SimParticle(const double momentum_z, const double momentum_theta, const double momentum_phi, const double energy, const std::uint32_t pdg);
0055
0056
0057 SimParticle(const SimParticle& other) = default;
0058
0059
0060 SimParticle& operator=(SimParticle other) &;
0061 SimParticle& operator=(SimParticle other) && = delete;
0062
0063
0064
0065 MutableSimParticle clone(bool cloneRelations=true) const;
0066
0067
0068 ~SimParticle() = default;
0069
0070
0071 SimParticle(const MutableSimParticle& other);
0072
0073 static SimParticle makeEmpty();
0074
0075 public:
0076
0077 static constexpr std::string_view typeName = "SimParticle";
0078
0079
0080 double getMomentum_z() const;
0081
0082
0083 double getMomentum_theta() const;
0084
0085
0086 double getMomentum_phi() const;
0087
0088
0089 double getEnergy() const;
0090
0091
0092 std::uint32_t getPdg() const;
0093
0094
0095
0096
0097
0098
0099 bool isAvailable() const;
0100
0101 void unlink() { m_obj = podio::utils::MaybeSharedPtr<SimParticleObj>{nullptr}; }
0102
0103 bool operator==(const SimParticle& other) const { return m_obj == other.m_obj; }
0104 bool operator==(const MutableSimParticle& other) const;
0105
0106 bool operator!=(const SimParticle& other) const { return !(*this == other); }
0107 bool operator!=(const MutableSimParticle& other) const { return !(*this == other); }
0108
0109
0110 bool operator<(const SimParticle& other) const { return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other); }
0111
0112 podio::ObjectID id() const { return getObjectID(); }
0113
0114 const podio::ObjectID getObjectID() const;
0115
0116 friend std::hash<SimParticle>;
0117
0118 friend void swap(SimParticle& a, SimParticle& b) {
0119 using std::swap;
0120 swap(a.m_obj, b.m_obj);
0121 }
0122
0123 private:
0124
0125 explicit SimParticle(podio::utils::MaybeSharedPtr<SimParticleObj> obj);
0126 SimParticle(SimParticleObj* obj);
0127
0128 podio::utils::MaybeSharedPtr<SimParticleObj> m_obj{new SimParticleObj{}, podio::utils::MarkOwned};
0129 };
0130
0131 std::ostream& operator<<(std::ostream& o, const SimParticle& value);
0132
0133 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0134 void to_json(nlohmann::json& j, const SimParticle& value);
0135 #endif
0136
0137
0138
0139
0140
0141 template<>
0142 struct std::hash<SimParticle> {
0143 std::size_t operator()(const SimParticle& obj) const {
0144 return std::hash<SimParticleObj*>{}(obj.m_obj.get());
0145 }
0146 };
0147
0148
0149
0150
0151
0152 #if defined(__clang__)
0153 #pragma clang diagnostic push
0154 #pragma clang diagnostic ignored "-Wunknown-warning-option"
0155 #pragma clang diagnostic ignored "-Wdeprecated-redundant-constexpr-static-def"
0156 #pragma clang diagnostic ignored "-Wdeprecated"
0157 constexpr std::string_view SimParticle::typeName;
0158 #pragma clang diagnostic pop
0159 #elif defined(__GNUC__)
0160 #pragma GCC diagnostic push
0161 #pragma GCC diagnostic ignored "-Wdeprecated"
0162 constexpr std::string_view SimParticle::typeName;
0163 #pragma GCC diagnostic pop
0164 #endif
0165
0166
0167 #endif