File indexing completed on 2025-01-30 10:04:48
0001
0002
0003 #ifndef EDM4HEP_SimTrackerHit_H
0004 #define EDM4HEP_SimTrackerHit_H
0005
0006 #include "edm4hep/SimTrackerHitObj.h"
0007
0008 #include "edm4hep/Vector3d.h"
0009 #include "edm4hep/Vector3f.h"
0010 #include <cmath>
0011 #include <cstdint>
0012
0013 #include "podio/utilities/MaybeSharedPtr.h"
0014
0015 #include <cstdint>
0016 #include <ostream>
0017
0018 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0019 #include "nlohmann/json_fwd.hpp"
0020 #endif
0021
0022
0023 namespace edm4hep {
0024 class MCParticle;
0025 class MutableMCParticle;
0026 }
0027
0028 namespace edm4hep {
0029
0030 class MutableSimTrackerHit;
0031 class SimTrackerHitCollection;
0032 class SimTrackerHitCollectionData;
0033
0034
0035
0036
0037
0038 class SimTrackerHit {
0039
0040 friend class MutableSimTrackerHit;
0041 friend class SimTrackerHitCollection;
0042 friend class edm4hep::SimTrackerHitCollectionData;
0043 friend class SimTrackerHitCollectionIterator;
0044
0045 public:
0046 using mutable_type = MutableSimTrackerHit;
0047 using collection_type = SimTrackerHitCollection;
0048
0049
0050 SimTrackerHit();
0051
0052
0053 SimTrackerHit(std::uint64_t cellID, float EDep, float time, float pathLength, std::int32_t quality,
0054 edm4hep::Vector3d position, edm4hep::Vector3f momentum);
0055
0056
0057 SimTrackerHit(const SimTrackerHit& other) = default;
0058
0059
0060 SimTrackerHit& operator=(SimTrackerHit other);
0061
0062
0063
0064 MutableSimTrackerHit clone(bool cloneRelations = true) const;
0065
0066
0067 ~SimTrackerHit() = default;
0068
0069
0070 SimTrackerHit(const MutableSimTrackerHit& other);
0071
0072 static SimTrackerHit makeEmpty();
0073
0074 public:
0075
0076 std::uint64_t getCellID() const;
0077
0078
0079 float getEDep() const;
0080
0081
0082 float getTime() const;
0083
0084
0085 float getPathLength() const;
0086
0087
0088 std::int32_t getQuality() const;
0089
0090
0091 const edm4hep::Vector3d& getPosition() const;
0092
0093
0094 const edm4hep::Vector3f& getMomentum() const;
0095
0096
0097 const edm4hep::MCParticle getMCParticle() const;
0098
0099 static const int BITOverlay = 31;
0100 static const int BITProducedBySecondary = 30;
0101 bool isOverlay() const {
0102 return getQuality() & (1 << BITOverlay);
0103 }
0104 bool isProducedBySecondary() const {
0105 return getQuality() & (1 << BITProducedBySecondary);
0106 }
0107 double x() const {
0108 return getPosition()[0];
0109 }
0110 double y() const {
0111 return getPosition()[1];
0112 }
0113 double z() const {
0114 return getPosition()[2];
0115 }
0116 double rho() const {
0117 return sqrt(x() * x() + y() * y());
0118 }
0119
0120
0121 bool isAvailable() const;
0122
0123 void unlink() {
0124 m_obj = podio::utils::MaybeSharedPtr<SimTrackerHitObj>{nullptr};
0125 }
0126
0127 bool operator==(const SimTrackerHit& other) const {
0128 return m_obj == other.m_obj;
0129 }
0130 bool operator==(const MutableSimTrackerHit& other) const;
0131
0132 bool operator!=(const SimTrackerHit& other) const {
0133 return !(*this == other);
0134 }
0135 bool operator!=(const MutableSimTrackerHit& other) const {
0136 return !(*this == other);
0137 }
0138
0139
0140 bool operator<(const SimTrackerHit& other) const {
0141 return m_obj < other.m_obj;
0142 }
0143
0144 podio::ObjectID id() const {
0145 return getObjectID();
0146 }
0147
0148 const podio::ObjectID getObjectID() const;
0149
0150 friend void swap(SimTrackerHit& a, SimTrackerHit& b) {
0151 using std::swap;
0152 swap(a.m_obj, b.m_obj);
0153 }
0154
0155 private:
0156
0157 explicit SimTrackerHit(podio::utils::MaybeSharedPtr<SimTrackerHitObj> obj);
0158 SimTrackerHit(SimTrackerHitObj* obj);
0159
0160 podio::utils::MaybeSharedPtr<SimTrackerHitObj> m_obj{nullptr};
0161 };
0162
0163 std::ostream& operator<<(std::ostream& o, const SimTrackerHit& value);
0164
0165 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0166 void to_json(nlohmann::json& j, const SimTrackerHit& value);
0167 #endif
0168
0169 }
0170
0171 #endif