Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-13 08:54:45

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