Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-30 10:14:56

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) noexcept = default;
0053 
0054   /// move constructor
0055   MutableCaloHitContribution(MutableCaloHitContribution&& other) noexcept = default;
0056 
0057   /// copy-assignment operator
0058   MutableCaloHitContribution& operator=(MutableCaloHitContribution other) &; // Rebind this to other's internal object
0059   MutableCaloHitContribution& operator=(MutableCaloHitContribution other) && =
0060       delete; // Prevent rebinding temporary as the changes wouldn't persist
0061 
0062   /// create a mutable deep-copy of the object with identical relations
0063   /// if cloneRelations=false, the relations are not cloned and will be empty
0064   MutableCaloHitContribution clone(bool cloneRelations = true) const;
0065 
0066   /// destructor
0067   ~MutableCaloHitContribution() = default;
0068 
0069 public:
0070   /// Access the PDG code of the shower particle that caused this contribution
0071   std::int32_t getPDG() const;
0072 
0073   /// Access the energy of this contribution [GeV]
0074   float getEnergy() const;
0075 
0076   /// Access the time of this contribution [ns]
0077   float getTime() const;
0078 
0079   /// Access the position of this energy deposition (step) [mm]
0080   const edm4hep::Vector3f& getStepPosition() const;
0081 
0082   /// Access the Geant4 step length for this contribution [mm]
0083   float getStepLength() const;
0084 
0085   /// Access the MCParticle responsible for this contribution to the hit. Only particles that are kept in the MCParticle
0086   /// record will appear here. Hence, this will point to the first mother appearing in the record.
0087   const edm4hep::MCParticle getParticle() const;
0088 
0089   /// Set the PDG code of the shower particle that caused this contribution
0090   void setPDG(const std::int32_t PDG);
0091   /// Get mutable reference to PDG code of the shower particle that caused this contribution
0092   std::int32_t& getPDG();
0093 
0094   /// Set the energy of this contribution [GeV]
0095   void setEnergy(const float energy);
0096   /// Get mutable reference to energy of this contribution [GeV]
0097   float& getEnergy();
0098 
0099   /// Set the time of this contribution [ns]
0100   void setTime(const float time);
0101   /// Get mutable reference to time of this contribution [ns]
0102   float& getTime();
0103 
0104   /// Set the position of this energy deposition (step) [mm]
0105   void setStepPosition(const edm4hep::Vector3f& stepPosition);
0106   /// Get mutable reference to position of this energy deposition (step) [mm]
0107   edm4hep::Vector3f& getStepPosition();
0108 
0109   /// Set the Geant4 step length for this contribution [mm]
0110   void setStepLength(const float stepLength);
0111   /// Get mutable reference to Geant4 step length for this contribution [mm]
0112   float& getStepLength();
0113 
0114   /// Set the MCParticle responsible for this contribution to the hit. Only particles that are kept in the MCParticle
0115   /// record will appear here. Hence, this will point to the first mother appearing in the record.
0116   void setParticle(const edm4hep::MCParticle& value);
0117 
0118   /// check whether the object is actually available
0119   bool isAvailable() const;
0120   /// disconnect from CaloHitContributionObj instance
0121   void unlink() { m_obj = podio::utils::MaybeSharedPtr<CaloHitContributionObj>{nullptr}; }
0122 
0123   constexpr bool operator==(const MutableCaloHitContribution& other) const { return m_obj == other.m_obj; }
0124   bool operator==(const CaloHitContribution& other) const;
0125 
0126   constexpr bool operator!=(const MutableCaloHitContribution& other) const { return !(*this == other); }
0127   bool operator!=(const CaloHitContribution& other) const { return !(*this == other); }
0128 
0129   // less comparison operator, so that objects can be e.g. stored in sets.
0130   bool operator<(const MutableCaloHitContribution& other) const {
0131     return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other);
0132   }
0133 
0134   podio::ObjectID id() const { return getObjectID(); }
0135 
0136   const podio::ObjectID getObjectID() const;
0137 
0138   friend std::hash<MutableCaloHitContribution>;
0139 
0140   friend void swap(MutableCaloHitContribution& a, MutableCaloHitContribution& b) {
0141     using std::swap;
0142     swap(a.m_obj, b.m_obj); // swap out the internal pointers
0143   }
0144 
0145 private:
0146   /// constructor from existing CaloHitContributionObj
0147   explicit MutableCaloHitContribution(podio::utils::MaybeSharedPtr<CaloHitContributionObj> obj);
0148 
0149   podio::utils::MaybeSharedPtr<CaloHitContributionObj> m_obj{new CaloHitContributionObj{}, podio::utils::MarkOwned};
0150 };
0151 
0152 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0153 void to_json(nlohmann::json& j, const MutableCaloHitContribution& value);
0154 #endif
0155 
0156 } // namespace edm4hep
0157 
0158 template <>
0159 struct std::hash<edm4hep::MutableCaloHitContribution> {
0160   std::size_t operator()(const edm4hep::MutableCaloHitContribution& obj) const {
0161     return std::hash<edm4hep::CaloHitContributionObj*>{}(obj.m_obj.get());
0162   }
0163 };
0164 
0165 #endif