File indexing completed on 2025-06-30 08:34:22
0001
0002
0003 #ifndef EDM4HEP_MutableSimTrackerHit_H
0004 #define EDM4HEP_MutableSimTrackerHit_H
0005
0006 #include "edm4hep/SimTrackerHitObj.h"
0007
0008 #include "edm4hep/SimTrackerHit.h"
0009
0010 #include "edm4hep/Vector3d.h"
0011 #include "edm4hep/Vector3f.h"
0012 #include <cmath>
0013 #include <cstdint>
0014 #include <edm4hep/MCParticle.h>
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 edm4hep {
0026 class SimTrackerHitCollection;
0027 class MCParticle;
0028 class MutableMCParticle;
0029 }
0030
0031 namespace edm4hep {
0032
0033
0034
0035
0036
0037 class MutableSimTrackerHit {
0038
0039 friend class SimTrackerHitCollection;
0040 friend class SimTrackerHitMutableCollectionIterator;
0041 friend class SimTrackerHit;
0042
0043 public:
0044 using object_type = SimTrackerHit;
0045 using collection_type = SimTrackerHitCollection;
0046
0047
0048 MutableSimTrackerHit();
0049
0050
0051 MutableSimTrackerHit(std::uint64_t cellID, float eDep, float time, float pathLength, std::int32_t quality,
0052 edm4hep::Vector3d position, edm4hep::Vector3f momentum);
0053
0054
0055 MutableSimTrackerHit(const MutableSimTrackerHit& other) = default;
0056
0057
0058 MutableSimTrackerHit& operator=(MutableSimTrackerHit other);
0059
0060
0061
0062 MutableSimTrackerHit clone(bool cloneRelations = true) const;
0063
0064
0065 ~MutableSimTrackerHit() = default;
0066
0067 public:
0068
0069 std::uint64_t getCellID() const;
0070
0071
0072 float getEDep() const;
0073
0074
0075 float getTime() const;
0076
0077
0078 float getPathLength() const;
0079
0080
0081 std::int32_t getQuality() const;
0082
0083
0084 const edm4hep::Vector3d& getPosition() const;
0085
0086
0087 const edm4hep::Vector3f& getMomentum() const;
0088
0089
0090 const edm4hep::MCParticle getParticle() const;
0091
0092
0093 void setCellID(std::uint64_t value);
0094
0095 std::uint64_t& getCellID();
0096
0097 [[deprecated("use getCellID instead")]] std::uint64_t& cellID();
0098
0099
0100 void setEDep(float value);
0101
0102 float& getEDep();
0103
0104 [[deprecated("use getEDep instead")]] float& eDep();
0105
0106
0107 void setTime(float value);
0108
0109 float& getTime();
0110
0111 [[deprecated("use getTime instead")]] float& time();
0112
0113
0114 void setPathLength(float value);
0115
0116 float& getPathLength();
0117
0118 [[deprecated("use getPathLength instead")]] float& pathLength();
0119
0120
0121 void setQuality(std::int32_t value);
0122
0123 std::int32_t& getQuality();
0124
0125 [[deprecated("use getQuality instead")]] std::int32_t& quality();
0126
0127
0128 void setPosition(edm4hep::Vector3d value);
0129
0130 edm4hep::Vector3d& getPosition();
0131
0132 [[deprecated("use getPosition instead")]] edm4hep::Vector3d& position();
0133
0134
0135 void setMomentum(edm4hep::Vector3f value);
0136
0137 edm4hep::Vector3f& getMomentum();
0138
0139 [[deprecated("use getMomentum instead")]] edm4hep::Vector3f& momentum();
0140
0141
0142 void setParticle(const edm4hep::MCParticle& value);
0143
0144 static const int BITOverlay = 31;
0145 static const int BITProducedBySecondary = 30;
0146 bool isOverlay() const {
0147 return getQuality() & (1 << BITOverlay);
0148 }
0149 bool isProducedBySecondary() const {
0150 return getQuality() & (1 << BITProducedBySecondary);
0151 }
0152 double x() const {
0153 return getPosition()[0];
0154 }
0155 double y() const {
0156 return getPosition()[1];
0157 }
0158 double z() const {
0159 return getPosition()[2];
0160 }
0161 double rho() const {
0162 return sqrt(x() * x() + y() * y());
0163 }
0164 [[deprecated("use getParticle instead")]] edm4hep::MCParticle getMCParticle() const {
0165 return getParticle();
0166 }
0167
0168 int32_t set_bit(int32_t val, int num, bool bitval) {
0169 return (val & ~(1 << num)) | (bitval << num);
0170 }
0171 void setOverlay(bool val) {
0172 setQuality(set_bit(getQuality(), BITOverlay, val));
0173 }
0174 void setProducedBySecondary(bool val) {
0175 setQuality(set_bit(getQuality(), BITProducedBySecondary, val));
0176 }
0177 [[deprecated("use setParticle instead")]] void setMCParticle(edm4hep::MCParticle particle) {
0178 setParticle(std::move(particle));
0179 }
0180
0181
0182 bool isAvailable() const;
0183
0184 void unlink() {
0185 m_obj = podio::utils::MaybeSharedPtr<SimTrackerHitObj>{nullptr};
0186 }
0187
0188 bool operator==(const MutableSimTrackerHit& other) const {
0189 return m_obj == other.m_obj;
0190 }
0191 bool operator==(const SimTrackerHit& other) const;
0192
0193 bool operator!=(const MutableSimTrackerHit& other) const {
0194 return !(*this == other);
0195 }
0196 bool operator!=(const SimTrackerHit& other) const {
0197 return !(*this == other);
0198 }
0199
0200
0201 bool operator<(const MutableSimTrackerHit& other) const {
0202 return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other);
0203 }
0204
0205 podio::ObjectID id() const {
0206 return getObjectID();
0207 }
0208
0209 const podio::ObjectID getObjectID() const;
0210
0211 friend void swap(MutableSimTrackerHit& a, MutableSimTrackerHit& b) {
0212 using std::swap;
0213 swap(a.m_obj, b.m_obj);
0214 }
0215
0216 private:
0217
0218 explicit MutableSimTrackerHit(podio::utils::MaybeSharedPtr<SimTrackerHitObj> obj);
0219
0220 podio::utils::MaybeSharedPtr<SimTrackerHitObj> m_obj{nullptr};
0221 };
0222
0223 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0224 void to_json(nlohmann::json& j, const MutableSimTrackerHit& value);
0225 #endif
0226
0227 }
0228
0229 #endif