Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-16 08:53:34

0001 // AUTOMATICALLY GENERATED FILE - DO NOT EDIT
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 <edm4hep/MCParticle.h>
0011 #include <edm4hep/MCParticle.h>
0012 #include <cmath>
0013 #include <cstdint>
0014 
0015 #include "podio/utilities/MaybeSharedPtr.h"
0016 #include "podio/detail/OrderKey.h"
0017 
0018 #include <ostream>
0019 #include <cstdint>
0020 
0021 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0022 #include "nlohmann/json_fwd.hpp"
0023 #endif
0024 
0025 // forward declarations
0026 namespace edm4hep {
0027 class SimTrackerHitCollection;
0028 class MCParticle;
0029 class MutableMCParticle;
0030 }
0031 
0032 
0033 namespace podio::detail {
0034 // Internal function used in less comparison operators of the datatypes and interface types
0035 OrderKey getOrderKey(const edm4hep::SimTrackerHit& obj);
0036 };
0037 
0038 namespace edm4hep {
0039 
0040 class MutableSimTrackerHit;
0041 class SimTrackerHitCollection;
0042 class SimTrackerHitCollectionData;
0043 
0044 /** @class SimTrackerHit
0045  *  Simulated tracker hit
0046  *  @author: EDM4hep authors
0047  */
0048 class SimTrackerHit {
0049 
0050   friend class MutableSimTrackerHit;
0051   friend class SimTrackerHitCollection;
0052   friend class edm4hep::SimTrackerHitCollectionData;
0053   friend class SimTrackerHitCollectionIterator;
0054   friend podio::detail::OrderKey podio::detail::getOrderKey(const SimTrackerHit & obj);
0055 
0056 public:
0057   using mutable_type = MutableSimTrackerHit;
0058   using collection_type = SimTrackerHitCollection;
0059 
0060   /// default constructor
0061   SimTrackerHit();
0062 
0063   /// Constructor initializing all members
0064   SimTrackerHit(const std::uint64_t cellID, const float eDep, const float time, const float pathLength, const std::int32_t quality, const edm4hep::Vector3d& position, const edm4hep::Vector3f& momentum);
0065 
0066   /// copy constructor
0067   SimTrackerHit(const SimTrackerHit& other) = default;
0068 
0069   /// copy-assignment operator
0070   SimTrackerHit& operator=(SimTrackerHit other) &; // Rebind this to other's internal object
0071   SimTrackerHit& operator=(SimTrackerHit other) && = delete; // Prevent rebinding temporary as the changes wouldn't persist
0072 
0073   /// create a mutable deep-copy of the object with identical relations
0074   /// if cloneRelations=false, the relations are not cloned and will be empty
0075   MutableSimTrackerHit clone(bool cloneRelations=true) const;
0076 
0077   /// destructor
0078   ~SimTrackerHit() = default;
0079 
0080   /// converting constructor from mutable object
0081   SimTrackerHit(const MutableSimTrackerHit& other);
0082 
0083   static SimTrackerHit makeEmpty();
0084 
0085 public:
0086 
0087   static constexpr std::string_view typeName = "edm4hep::SimTrackerHit";
0088 
0089   /// Access the ID of the sensor that created this hit
0090   std::uint64_t getCellID() const;
0091 
0092   /// Access the energy deposited in the hit [GeV]
0093   float getEDep() const;
0094 
0095   /// Access the proper time of the hit in the lab frame [ns]
0096   float getTime() const;
0097 
0098   /// Access the path length of the particle in the sensitive material that resulted in this hit
0099   float getPathLength() const;
0100 
0101   /// Access the quality bit flag
0102   std::int32_t getQuality() const;
0103 
0104   /// Access the the hit position [mm]
0105   const edm4hep::Vector3d& getPosition() const;
0106 
0107   /// Access the the 3-momentum of the particle at the hits position [GeV]
0108   const edm4hep::Vector3f& getMomentum() const;
0109 
0110 
0111   /// Access the MCParticle that caused the hit
0112   const edm4hep::MCParticle getParticle() const;
0113 
0114 
0115  static const int  BITOverlay = 31;
0116  static const int  BITProducedBySecondary = 30;
0117  bool isOverlay() const { return getQuality() & (1 << BITOverlay) ; }
0118  bool isProducedBySecondary() const { return getQuality() & (1 << BITProducedBySecondary) ; }
0119  double x() const {return getPosition()[0];}
0120  double y() const {return getPosition()[1];}
0121  double z() const {return getPosition()[2];}
0122  double rho() const {return sqrt(x()*x() + y()*y());}
0123  [[deprecated("use getParticle instead")]] edm4hep::MCParticle getMCParticle() const { return getParticle(); }
0124  
0125 
0126   /// check whether the object is actually available
0127   bool isAvailable() const;
0128   /// disconnect from SimTrackerHitObj instance
0129   void unlink() { m_obj = podio::utils::MaybeSharedPtr<SimTrackerHitObj>{nullptr}; }
0130 
0131   bool operator==(const SimTrackerHit& other) const { return m_obj == other.m_obj; }
0132   bool operator==(const MutableSimTrackerHit& other) const;
0133 
0134   bool operator!=(const SimTrackerHit& other) const { return !(*this == other); }
0135   bool operator!=(const MutableSimTrackerHit& other) const { return !(*this == other); }
0136 
0137   // less comparison operator, so that objects can be e.g. stored in sets.
0138   bool operator<(const SimTrackerHit& other) const { return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other); }
0139 
0140   podio::ObjectID id() const { return getObjectID(); }
0141 
0142   const podio::ObjectID getObjectID() const;
0143 
0144   friend std::hash<SimTrackerHit>;
0145 
0146   friend void swap(SimTrackerHit& a, SimTrackerHit& b) {
0147     using std::swap;
0148     swap(a.m_obj, b.m_obj); // swap out the internal pointers
0149   }
0150 
0151 private:
0152   /// constructor from existing SimTrackerHitObj
0153   explicit SimTrackerHit(podio::utils::MaybeSharedPtr<SimTrackerHitObj> obj);
0154   SimTrackerHit(SimTrackerHitObj* obj);
0155 
0156   podio::utils::MaybeSharedPtr<SimTrackerHitObj> m_obj{nullptr};
0157 };
0158 
0159 std::ostream& operator<<(std::ostream& o, const SimTrackerHit& value);
0160 
0161 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0162 void to_json(nlohmann::json& j, const SimTrackerHit& value);
0163 #endif
0164 
0165 
0166 } // namespace edm4hep
0167 
0168 
0169 
0170 template<>
0171 struct std::hash<edm4hep::SimTrackerHit> {
0172   std::size_t operator()(const edm4hep::SimTrackerHit& obj) const {
0173     return std::hash<edm4hep::SimTrackerHitObj*>{}(obj.m_obj.get());
0174   }
0175 };
0176 
0177 
0178 // This is needed to avoid triggering opening every library in LD_LIBRARY_PATH
0179 // until it's fixed in ROOT. See https://github.com/root-project/root/issues/18489
0180 // and https://github.com/AIDASoft/podio/issues/770
0181 #if defined(__clang__)
0182 #pragma clang diagnostic push
0183 #pragma clang diagnostic ignored "-Wunknown-warning-option"
0184 #pragma clang diagnostic ignored "-Wdeprecated-redundant-constexpr-static-def"
0185 #pragma clang diagnostic ignored "-Wdeprecated"
0186 constexpr std::string_view edm4hep::SimTrackerHit::typeName;
0187 #pragma clang diagnostic pop
0188 #elif defined(__GNUC__)
0189 #pragma GCC diagnostic push
0190 #pragma GCC diagnostic ignored "-Wdeprecated"
0191 constexpr std::string_view edm4hep::SimTrackerHit::typeName;
0192 #pragma GCC diagnostic pop
0193 #endif
0194 
0195 #endif