Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-06-30 08:34:22

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 
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 // forward declarations
0025 namespace edm4hep {
0026 class SimTrackerHitCollection;
0027 class MCParticle;
0028 class MutableMCParticle;
0029 } // namespace edm4hep
0030 
0031 namespace edm4hep {
0032 
0033 /** @class MutableSimTrackerHit
0034  *  Simulated tracker hit
0035  *  @author: EDM4hep authors
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   /// default constructor
0048   MutableSimTrackerHit();
0049 
0050   /// Constructor initializing all members
0051   MutableSimTrackerHit(std::uint64_t cellID, float eDep, float time, float pathLength, std::int32_t quality,
0052                        edm4hep::Vector3d position, edm4hep::Vector3f momentum);
0053 
0054   /// copy constructor
0055   MutableSimTrackerHit(const MutableSimTrackerHit& other) = default;
0056 
0057   /// copy-assignment operator
0058   MutableSimTrackerHit& operator=(MutableSimTrackerHit other);
0059 
0060   /// create a mutable deep-copy of the object with identical relations
0061   /// if cloneRelations=false, the relations are not cloned and will be empty
0062   MutableSimTrackerHit clone(bool cloneRelations = true) const;
0063 
0064   /// destructor
0065   ~MutableSimTrackerHit() = default;
0066 
0067 public:
0068   /// Access the ID of the sensor that created this hit
0069   std::uint64_t getCellID() const;
0070 
0071   /// Access the energy deposited in the hit [GeV]
0072   float getEDep() const;
0073 
0074   /// Access the proper time of the hit in the lab frame [ns]
0075   float getTime() const;
0076 
0077   /// Access the path length of the particle in the sensitive material that resulted in this hit
0078   float getPathLength() const;
0079 
0080   /// Access the quality bit flag
0081   std::int32_t getQuality() const;
0082 
0083   /// Access the the hit position [mm]
0084   const edm4hep::Vector3d& getPosition() const;
0085 
0086   /// Access the the 3-momentum of the particle at the hits position [GeV]
0087   const edm4hep::Vector3f& getMomentum() const;
0088 
0089   /// Access the MCParticle that caused the hit
0090   const edm4hep::MCParticle getParticle() const;
0091 
0092   /// Set the ID of the sensor that created this hit
0093   void setCellID(std::uint64_t value);
0094   /// Get mutable reference to ID of the sensor that created this hit
0095   std::uint64_t& getCellID();
0096   /// Get reference to ID of the sensor that created this hit
0097   [[deprecated("use getCellID instead")]] std::uint64_t& cellID();
0098 
0099   /// Set the energy deposited in the hit [GeV]
0100   void setEDep(float value);
0101   /// Get mutable reference to energy deposited in the hit [GeV]
0102   float& getEDep();
0103   /// Get reference to energy deposited in the hit [GeV]
0104   [[deprecated("use getEDep instead")]] float& eDep();
0105 
0106   /// Set the proper time of the hit in the lab frame [ns]
0107   void setTime(float value);
0108   /// Get mutable reference to proper time of the hit in the lab frame [ns]
0109   float& getTime();
0110   /// Get reference to proper time of the hit in the lab frame [ns]
0111   [[deprecated("use getTime instead")]] float& time();
0112 
0113   /// Set the path length of the particle in the sensitive material that resulted in this hit
0114   void setPathLength(float value);
0115   /// Get mutable reference to path length of the particle in the sensitive material that resulted in this hit
0116   float& getPathLength();
0117   /// Get reference to path length of the particle in the sensitive material that resulted in this hit
0118   [[deprecated("use getPathLength instead")]] float& pathLength();
0119 
0120   /// Set the quality bit flag
0121   void setQuality(std::int32_t value);
0122   /// Get mutable reference to quality bit flag
0123   std::int32_t& getQuality();
0124   /// Get reference to quality bit flag
0125   [[deprecated("use getQuality instead")]] std::int32_t& quality();
0126 
0127   /// Set the the hit position [mm]
0128   void setPosition(edm4hep::Vector3d value);
0129   /// Get mutable reference to the hit position [mm]
0130   edm4hep::Vector3d& getPosition();
0131   /// Get reference to the hit position [mm]
0132   [[deprecated("use getPosition instead")]] edm4hep::Vector3d& position();
0133 
0134   /// Set the the 3-momentum of the particle at the hits position [GeV]
0135   void setMomentum(edm4hep::Vector3f value);
0136   /// Get mutable reference to the 3-momentum of the particle at the hits position [GeV]
0137   edm4hep::Vector3f& getMomentum();
0138   /// Get reference to the 3-momentum of the particle at the hits position [GeV]
0139   [[deprecated("use getMomentum instead")]] edm4hep::Vector3f& momentum();
0140 
0141   /// Set the MCParticle that caused the hit
0142   void setParticle(const edm4hep::MCParticle& value);
0143 
0144   static const int BITOverlay = 31;
0145   static const int BITProducedBySecondary = 30;
0146   bool isOverlay() const {
0147     return getQuality() & (1 << BITOverlay);
0148   }
0149   bool isProducedBySecondary() const {
0150     return getQuality() & (1 << BITProducedBySecondary);
0151   }
0152   double x() const {
0153     return getPosition()[0];
0154   }
0155   double y() const {
0156     return getPosition()[1];
0157   }
0158   double z() const {
0159     return getPosition()[2];
0160   }
0161   double rho() const {
0162     return sqrt(x() * x() + y() * y());
0163   }
0164   [[deprecated("use getParticle instead")]] edm4hep::MCParticle getMCParticle() const {
0165     return getParticle();
0166   }
0167 
0168   int32_t set_bit(int32_t val, int num, bool bitval) {
0169     return (val & ~(1 << num)) | (bitval << num);
0170   }
0171   void setOverlay(bool val) {
0172     setQuality(set_bit(getQuality(), BITOverlay, val));
0173   }
0174   void setProducedBySecondary(bool val) {
0175     setQuality(set_bit(getQuality(), BITProducedBySecondary, val));
0176   }
0177   [[deprecated("use setParticle instead")]] void setMCParticle(edm4hep::MCParticle particle) {
0178     setParticle(std::move(particle));
0179   }
0180 
0181   /// check whether the object is actually available
0182   bool isAvailable() const;
0183   /// disconnect from SimTrackerHitObj instance
0184   void unlink() {
0185     m_obj = podio::utils::MaybeSharedPtr<SimTrackerHitObj>{nullptr};
0186   }
0187 
0188   bool operator==(const MutableSimTrackerHit& other) const {
0189     return m_obj == other.m_obj;
0190   }
0191   bool operator==(const SimTrackerHit& other) const;
0192 
0193   bool operator!=(const MutableSimTrackerHit& other) const {
0194     return !(*this == other);
0195   }
0196   bool operator!=(const SimTrackerHit& other) const {
0197     return !(*this == other);
0198   }
0199 
0200   // less comparison operator, so that objects can be e.g. stored in sets.
0201   bool operator<(const MutableSimTrackerHit& other) const {
0202     return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other);
0203   }
0204 
0205   podio::ObjectID id() const {
0206     return getObjectID();
0207   }
0208 
0209   const podio::ObjectID getObjectID() const;
0210 
0211   friend void swap(MutableSimTrackerHit& a, MutableSimTrackerHit& b) {
0212     using std::swap;
0213     swap(a.m_obj, b.m_obj); // swap out the internal pointers
0214   }
0215 
0216 private:
0217   /// constructor from existing SimTrackerHitObj
0218   explicit MutableSimTrackerHit(podio::utils::MaybeSharedPtr<SimTrackerHitObj> obj);
0219 
0220   podio::utils::MaybeSharedPtr<SimTrackerHitObj> m_obj{nullptr};
0221 };
0222 
0223 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0224 void to_json(nlohmann::json& j, const MutableSimTrackerHit& value);
0225 #endif
0226 
0227 } // namespace edm4hep
0228 
0229 #endif