Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:55:37

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