Warning, file /include/edm4hep/MutableSimTrackerHit.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
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() = default;
0049
0050
0051 MutableSimTrackerHit(const std::uint64_t cellID, const float eDep, const float time, const float pathLength,
0052 const std::int32_t quality, const edm4hep::Vector3d& position,
0053 const edm4hep::Vector3f& momentum);
0054
0055
0056 MutableSimTrackerHit(const MutableSimTrackerHit& other) = default;
0057
0058
0059 MutableSimTrackerHit& operator=(MutableSimTrackerHit other) &;
0060 MutableSimTrackerHit&
0061 operator=(MutableSimTrackerHit other) && = delete;
0062
0063
0064
0065 MutableSimTrackerHit clone(bool cloneRelations = true) const;
0066
0067
0068 ~MutableSimTrackerHit() = default;
0069
0070 public:
0071
0072 std::uint64_t getCellID() const;
0073
0074
0075 float getEDep() const;
0076
0077
0078 float getTime() const;
0079
0080
0081 float getPathLength() const;
0082
0083
0084 std::int32_t getQuality() const;
0085
0086
0087 const edm4hep::Vector3d& getPosition() const;
0088
0089
0090 const edm4hep::Vector3f& getMomentum() const;
0091
0092
0093 const edm4hep::MCParticle getParticle() const;
0094
0095
0096 void setCellID(const std::uint64_t cellID);
0097
0098 std::uint64_t& getCellID();
0099
0100 [[deprecated("use getCellID instead")]] std::uint64_t& cellID();
0101
0102
0103 void setEDep(const float eDep);
0104
0105 float& getEDep();
0106
0107 [[deprecated("use getEDep instead")]] float& eDep();
0108
0109
0110 void setTime(const float time);
0111
0112 float& getTime();
0113
0114 [[deprecated("use getTime instead")]] float& time();
0115
0116
0117 void setPathLength(const float pathLength);
0118
0119 float& getPathLength();
0120
0121 [[deprecated("use getPathLength instead")]] float& pathLength();
0122
0123
0124 void setQuality(const std::int32_t quality);
0125
0126 std::int32_t& getQuality();
0127
0128 [[deprecated("use getQuality instead")]] std::int32_t& quality();
0129
0130
0131 void setPosition(const edm4hep::Vector3d& position);
0132
0133 edm4hep::Vector3d& getPosition();
0134
0135 [[deprecated("use getPosition instead")]] edm4hep::Vector3d& position();
0136
0137
0138 void setMomentum(const edm4hep::Vector3f& momentum);
0139
0140 edm4hep::Vector3f& getMomentum();
0141
0142 [[deprecated("use getMomentum instead")]] edm4hep::Vector3f& momentum();
0143
0144
0145 void setParticle(const edm4hep::MCParticle& value);
0146
0147 static const int BITOverlay = 31;
0148 static const int BITProducedBySecondary = 30;
0149 bool isOverlay() const { return getQuality() & (1 << BITOverlay); }
0150 bool isProducedBySecondary() const { return getQuality() & (1 << BITProducedBySecondary); }
0151 double x() const { return getPosition()[0]; }
0152 double y() const { return getPosition()[1]; }
0153 double z() const { return getPosition()[2]; }
0154 double rho() const { return std::hypot(x(), y()); }
0155
0156 int32_t set_bit(int32_t val, int num, bool bitval) { return (val & ~(1 << num)) | (bitval << num); }
0157 void setOverlay(bool val) { setQuality(set_bit(getQuality(), BITOverlay, val)); }
0158 void setProducedBySecondary(bool val) { setQuality(set_bit(getQuality(), BITProducedBySecondary, val)); }
0159
0160
0161 bool isAvailable() const;
0162
0163 void unlink() { m_obj = podio::utils::MaybeSharedPtr<SimTrackerHitObj>{nullptr}; }
0164
0165 bool operator==(const MutableSimTrackerHit& other) const { return m_obj == other.m_obj; }
0166 bool operator==(const SimTrackerHit& other) const;
0167
0168 bool operator!=(const MutableSimTrackerHit& other) const { return !(*this == other); }
0169 bool operator!=(const SimTrackerHit& other) const { return !(*this == other); }
0170
0171
0172 bool operator<(const MutableSimTrackerHit& other) const {
0173 return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other);
0174 }
0175
0176 podio::ObjectID id() const { return getObjectID(); }
0177
0178 const podio::ObjectID getObjectID() const;
0179
0180 friend std::hash<MutableSimTrackerHit>;
0181
0182 friend void swap(MutableSimTrackerHit& a, MutableSimTrackerHit& b) {
0183 using std::swap;
0184 swap(a.m_obj, b.m_obj);
0185 }
0186
0187 private:
0188
0189 explicit MutableSimTrackerHit(podio::utils::MaybeSharedPtr<SimTrackerHitObj> obj);
0190
0191 podio::utils::MaybeSharedPtr<SimTrackerHitObj> m_obj{new SimTrackerHitObj{}, podio::utils::MarkOwned};
0192 };
0193
0194 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0195 void to_json(nlohmann::json& j, const MutableSimTrackerHit& value);
0196 #endif
0197
0198 }
0199
0200 template <>
0201 struct std::hash<edm4hep::MutableSimTrackerHit> {
0202 std::size_t operator()(const edm4hep::MutableSimTrackerHit& obj) const {
0203 return std::hash<edm4hep::SimTrackerHitObj*>{}(obj.m_obj.get());
0204 }
0205 };
0206
0207 #endif