Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-31 09:24:26

0001 // AUTOMATICALLY GENERATED FILE - DO NOT EDIT
0002 
0003 #ifndef EDM4HEP_MutableSimTrackerHit_H
0004 #define EDM4HEP_MutableSimTrackerHit_H
0005 
0006 #include "edm4hep/SimTrackerHitObj.h"
0007 // Make the immutable class available from its mutable version but not vice versa
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 #include <edm4hep/utils/bit_utils.h>
0016 
0017 #include "podio/utilities/MaybeSharedPtr.h"
0018 
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 } // namespace edm4hep
0031 
0032 namespace edm4hep {
0033 
0034 /** @class MutableSimTrackerHit
0035  *  Simulated tracker hit
0036  *  @author: EDM4hep authors
0037  */
0038 class MutableSimTrackerHit {
0039 
0040   friend class SimTrackerHitCollection;
0041   friend class SimTrackerHitMutableCollectionIterator;
0042   friend class SimTrackerHit;
0043 
0044 public:
0045   using object_type = SimTrackerHit;
0046   using collection_type = SimTrackerHitCollection;
0047 
0048   /// default constructor
0049   MutableSimTrackerHit() = default;
0050 
0051   /// Constructor initializing all members
0052   MutableSimTrackerHit(const std::uint64_t cellID, const float eDep, const float time, const float pathLength,
0053                        const std::int32_t quality, const edm4hep::Vector3d& position,
0054                        const edm4hep::Vector3f& momentum);
0055 
0056   /// copy constructor
0057   MutableSimTrackerHit(const MutableSimTrackerHit& other) = default;
0058 
0059   /// copy-assignment operator
0060   MutableSimTrackerHit& operator=(MutableSimTrackerHit other) &; // Rebind this to other's internal object
0061   MutableSimTrackerHit&
0062   operator=(MutableSimTrackerHit other) && = delete; // Prevent rebinding temporary as the changes wouldn't persist
0063 
0064   /// create a mutable deep-copy of the object with identical relations
0065   /// if cloneRelations=false, the relations are not cloned and will be empty
0066   MutableSimTrackerHit clone(bool cloneRelations = true) const;
0067 
0068   /// destructor
0069   ~MutableSimTrackerHit() = default;
0070 
0071 public:
0072   /// Access the ID of the sensor that created this hit
0073   std::uint64_t getCellID() const;
0074 
0075   /// Access the energy deposited in the hit [GeV]
0076   float getEDep() const;
0077 
0078   /// Access the proper time of the hit in the lab frame [ns]
0079   float getTime() const;
0080 
0081   /// Access the path length of the particle in the sensitive material that resulted in this hit
0082   float getPathLength() const;
0083 
0084   /// Access the quality bit flag
0085   std::int32_t getQuality() const;
0086 
0087   /// Access the the hit position [mm]
0088   const edm4hep::Vector3d& getPosition() const;
0089 
0090   /// Access the the 3-momentum of the particle at the hits position [GeV]
0091   const edm4hep::Vector3f& getMomentum() const;
0092 
0093   /// Access the MCParticle that caused the hit
0094   const edm4hep::MCParticle getParticle() const;
0095 
0096   /// Set the ID of the sensor that created this hit
0097   void setCellID(const std::uint64_t cellID);
0098   /// Get mutable reference to ID of the sensor that created this hit
0099   std::uint64_t& getCellID();
0100 
0101   /// Set the energy deposited in the hit [GeV]
0102   void setEDep(const float eDep);
0103   /// Get mutable reference to energy deposited in the hit [GeV]
0104   float& getEDep();
0105 
0106   /// Set the proper time of the hit in the lab frame [ns]
0107   void setTime(const float time);
0108   /// Get mutable reference to proper time of the hit in the lab frame [ns]
0109   float& getTime();
0110 
0111   /// Set the path length of the particle in the sensitive material that resulted in this hit
0112   void setPathLength(const float pathLength);
0113   /// Get mutable reference to path length of the particle in the sensitive material that resulted in this hit
0114   float& getPathLength();
0115 
0116   /// Set the quality bit flag
0117   void setQuality(const std::int32_t quality);
0118   /// Get mutable reference to quality bit flag
0119   std::int32_t& getQuality();
0120 
0121   /// Set the the hit position [mm]
0122   void setPosition(const edm4hep::Vector3d& position);
0123   /// Get mutable reference to the hit position [mm]
0124   edm4hep::Vector3d& getPosition();
0125 
0126   /// Set the the 3-momentum of the particle at the hits position [GeV]
0127   void setMomentum(const edm4hep::Vector3f& momentum);
0128   /// Get mutable reference to the 3-momentum of the particle at the hits position [GeV]
0129   edm4hep::Vector3f& getMomentum();
0130 
0131   /// Set the MCParticle that caused the hit
0132   void setParticle(const edm4hep::MCParticle& value);
0133 
0134   static constexpr int BITOverlay = 31;
0135   static constexpr int BITProducedBySecondary = 30;
0136   bool isOverlay() const { return getQuality() & (1 << BITOverlay); }
0137   bool isProducedBySecondary() const { return getQuality() & (1 << BITProducedBySecondary); }
0138   double x() const { return getPosition()[0]; }
0139   double y() const { return getPosition()[1]; }
0140   double z() const { return getPosition()[2]; }
0141   double rho() const { return std::hypot(x(), y()); }
0142 
0143   void setOverlay(bool val) { setQuality(utils::setBit(getQuality(), BITOverlay, val)); }
0144   void setProducedBySecondary(bool val) { setQuality(utils::setBit(getQuality(), BITProducedBySecondary, val)); }
0145 
0146   /// check whether the object is actually available
0147   bool isAvailable() const;
0148   /// disconnect from SimTrackerHitObj instance
0149   void unlink() { m_obj = podio::utils::MaybeSharedPtr<SimTrackerHitObj>{nullptr}; }
0150 
0151   constexpr bool operator==(const MutableSimTrackerHit& other) const { return m_obj == other.m_obj; }
0152   bool operator==(const SimTrackerHit& other) const;
0153 
0154   constexpr bool operator!=(const MutableSimTrackerHit& other) const { return !(*this == other); }
0155   bool operator!=(const SimTrackerHit& other) const { return !(*this == other); }
0156 
0157   // less comparison operator, so that objects can be e.g. stored in sets.
0158   bool operator<(const MutableSimTrackerHit& other) const {
0159     return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other);
0160   }
0161 
0162   podio::ObjectID id() const { return getObjectID(); }
0163 
0164   const podio::ObjectID getObjectID() const;
0165 
0166   friend std::hash<MutableSimTrackerHit>;
0167 
0168   friend void swap(MutableSimTrackerHit& a, MutableSimTrackerHit& b) {
0169     using std::swap;
0170     swap(a.m_obj, b.m_obj); // swap out the internal pointers
0171   }
0172 
0173 private:
0174   /// constructor from existing SimTrackerHitObj
0175   explicit MutableSimTrackerHit(podio::utils::MaybeSharedPtr<SimTrackerHitObj> obj);
0176 
0177   podio::utils::MaybeSharedPtr<SimTrackerHitObj> m_obj{new SimTrackerHitObj{}, podio::utils::MarkOwned};
0178 };
0179 
0180 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0181 void to_json(nlohmann::json& j, const MutableSimTrackerHit& value);
0182 #endif
0183 
0184 } // namespace edm4hep
0185 
0186 template <>
0187 struct std::hash<edm4hep::MutableSimTrackerHit> {
0188   std::size_t operator()(const edm4hep::MutableSimTrackerHit& obj) const {
0189     return std::hash<edm4hep::SimTrackerHitObj*>{}(obj.m_obj.get());
0190   }
0191 };
0192 
0193 #endif