Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-04 08:21:42

0001 // AUTOMATICALLY GENERATED FILE - DO NOT EDIT
0002 
0003 #ifndef EDM4HEP_MutableCaloHitContribution_H
0004 #define EDM4HEP_MutableCaloHitContribution_H
0005 
0006 #include "edm4hep/CaloHitContributionObj.h"
0007 // Make the immutable class available from its mutable version but not vice versa
0008 #include "edm4hep/CaloHitContribution.h"
0009 
0010 #include "edm4hep/Vector3f.h"
0011 #include <cstdint>
0012 
0013 #include "podio/utilities/MaybeSharedPtr.h"
0014 
0015 #include <cstdint>
0016 
0017 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0018 #include "nlohmann/json_fwd.hpp"
0019 #endif
0020 
0021 // forward declarations
0022 namespace edm4hep {
0023 class CaloHitContributionCollection;
0024 class MCParticle;
0025 class MutableMCParticle;
0026 } // namespace edm4hep
0027 
0028 namespace edm4hep {
0029 
0030 /** @class MutableCaloHitContribution
0031  *  Monte Carlo contribution to SimCalorimeterHit
0032  *  @author: EDM4hep authors
0033  */
0034 class MutableCaloHitContribution {
0035 
0036   friend class CaloHitContributionCollection;
0037   friend class CaloHitContributionMutableCollectionIterator;
0038   friend class CaloHitContribution;
0039 
0040 public:
0041   using object_type = CaloHitContribution;
0042   using collection_type = CaloHitContributionCollection;
0043 
0044   /// default constructor
0045   MutableCaloHitContribution() = default;
0046 
0047   /// Constructor initializing all members
0048   MutableCaloHitContribution(const std::int32_t PDG, const float energy, const float time,
0049                              const edm4hep::Vector3f& stepPosition, const float stepLength);
0050 
0051   /// copy constructor
0052   MutableCaloHitContribution(const MutableCaloHitContribution& other) = default;
0053 
0054   /// copy-assignment operator
0055   MutableCaloHitContribution& operator=(MutableCaloHitContribution other) &; // Rebind this to other's internal object
0056   MutableCaloHitContribution& operator=(MutableCaloHitContribution other) && =
0057       delete; // Prevent rebinding temporary as the changes wouldn't persist
0058 
0059   /// create a mutable deep-copy of the object with identical relations
0060   /// if cloneRelations=false, the relations are not cloned and will be empty
0061   MutableCaloHitContribution clone(bool cloneRelations = true) const;
0062 
0063   /// destructor
0064   ~MutableCaloHitContribution() = default;
0065 
0066 public:
0067   /// Access the PDG code of the shower particle that caused this contribution
0068   std::int32_t getPDG() const;
0069 
0070   /// Access the energy of this contribution [GeV]
0071   float getEnergy() const;
0072 
0073   /// Access the time of this contribution [ns]
0074   float getTime() const;
0075 
0076   /// Access the position of this energy deposition (step) [mm]
0077   const edm4hep::Vector3f& getStepPosition() const;
0078 
0079   /// Access the Geant4 step length for this contribution [mm]
0080   float getStepLength() const;
0081 
0082   /// Access the MCParticle responsible for this contribution to the hit. Only particles that are kept in the MCParticle
0083   /// record will appear here. Hence, this will point to the first mother appearing in the record.
0084   const edm4hep::MCParticle getParticle() const;
0085 
0086   /// Set the PDG code of the shower particle that caused this contribution
0087   void setPDG(const std::int32_t PDG);
0088   /// Get mutable reference to PDG code of the shower particle that caused this contribution
0089   std::int32_t& getPDG();
0090   /// Get reference to PDG code of the shower particle that caused this contribution
0091   [[deprecated("use getPDG instead")]] std::int32_t& PDG();
0092 
0093   /// Set the energy of this contribution [GeV]
0094   void setEnergy(const float energy);
0095   /// Get mutable reference to energy of this contribution [GeV]
0096   float& getEnergy();
0097   /// Get reference to energy of this contribution [GeV]
0098   [[deprecated("use getEnergy instead")]] float& energy();
0099 
0100   /// Set the time of this contribution [ns]
0101   void setTime(const float time);
0102   /// Get mutable reference to time of this contribution [ns]
0103   float& getTime();
0104   /// Get reference to time of this contribution [ns]
0105   [[deprecated("use getTime instead")]] float& time();
0106 
0107   /// Set the position of this energy deposition (step) [mm]
0108   void setStepPosition(const edm4hep::Vector3f& stepPosition);
0109   /// Get mutable reference to position of this energy deposition (step) [mm]
0110   edm4hep::Vector3f& getStepPosition();
0111   /// Get reference to position of this energy deposition (step) [mm]
0112   [[deprecated("use getStepPosition instead")]] edm4hep::Vector3f& stepPosition();
0113 
0114   /// Set the Geant4 step length for this contribution [mm]
0115   void setStepLength(const float stepLength);
0116   /// Get mutable reference to Geant4 step length for this contribution [mm]
0117   float& getStepLength();
0118   /// Get reference to Geant4 step length for this contribution [mm]
0119   [[deprecated("use getStepLength instead")]] float& stepLength();
0120 
0121   /// Set the MCParticle responsible for this contribution to the hit. Only particles that are kept in the MCParticle
0122   /// record will appear here. Hence, this will point to the first mother appearing in the record.
0123   void setParticle(const edm4hep::MCParticle& value);
0124 
0125   /// check whether the object is actually available
0126   bool isAvailable() const;
0127   /// disconnect from CaloHitContributionObj instance
0128   void unlink() { m_obj = podio::utils::MaybeSharedPtr<CaloHitContributionObj>{nullptr}; }
0129 
0130   bool operator==(const MutableCaloHitContribution& other) const { return m_obj == other.m_obj; }
0131   bool operator==(const CaloHitContribution& other) const;
0132 
0133   bool operator!=(const MutableCaloHitContribution& other) const { return !(*this == other); }
0134   bool operator!=(const CaloHitContribution& other) const { return !(*this == other); }
0135 
0136   // less comparison operator, so that objects can be e.g. stored in sets.
0137   bool operator<(const MutableCaloHitContribution& other) const {
0138     return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other);
0139   }
0140 
0141   podio::ObjectID id() const { return getObjectID(); }
0142 
0143   const podio::ObjectID getObjectID() const;
0144 
0145   friend std::hash<MutableCaloHitContribution>;
0146 
0147   friend void swap(MutableCaloHitContribution& a, MutableCaloHitContribution& b) {
0148     using std::swap;
0149     swap(a.m_obj, b.m_obj); // swap out the internal pointers
0150   }
0151 
0152 private:
0153   /// constructor from existing CaloHitContributionObj
0154   explicit MutableCaloHitContribution(podio::utils::MaybeSharedPtr<CaloHitContributionObj> obj);
0155 
0156   podio::utils::MaybeSharedPtr<CaloHitContributionObj> m_obj{new CaloHitContributionObj{}, podio::utils::MarkOwned};
0157 };
0158 
0159 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0160 void to_json(nlohmann::json& j, const MutableCaloHitContribution& value);
0161 #endif
0162 
0163 } // namespace edm4hep
0164 
0165 template <>
0166 struct std::hash<edm4hep::MutableCaloHitContribution> {
0167   std::size_t operator()(const edm4hep::MutableCaloHitContribution& obj) const {
0168     return std::hash<edm4hep::CaloHitContributionObj*>{}(obj.m_obj.get());
0169   }
0170 };
0171 
0172 #endif