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