Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-15 10:12:12

0001 // AUTOMATICALLY GENERATED FILE - DO NOT EDIT
0002 
0003 #ifndef EDM4HEP_CaloHitContribution_H
0004 #define EDM4HEP_CaloHitContribution_H
0005 
0006 #include "edm4hep/CaloHitContributionObj.h"
0007 
0008 #include "edm4hep/Vector3f.h"
0009 #include <cstdint>
0010 
0011 #include "podio/detail/OrderKey.h"
0012 #include "podio/utilities/MaybeSharedPtr.h"
0013 
0014 #include <cstdint>
0015 #include <ostream>
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 podio::detail {
0029 // Internal function used in less comparison operators of the datatypes and interface types
0030 OrderKey getOrderKey(const edm4hep::CaloHitContribution& obj);
0031 }; // namespace podio::detail
0032 
0033 namespace edm4hep {
0034 
0035 class MutableCaloHitContribution;
0036 class CaloHitContributionCollection;
0037 class CaloHitContributionCollectionData;
0038 
0039 /** @class CaloHitContribution
0040  *  Monte Carlo contribution to SimCalorimeterHit
0041  *  @author: EDM4hep authors
0042  */
0043 class CaloHitContribution {
0044 
0045   friend class MutableCaloHitContribution;
0046   friend class CaloHitContributionCollection;
0047   friend class edm4hep::CaloHitContributionCollectionData;
0048   friend class CaloHitContributionCollectionIterator;
0049   friend podio::detail::OrderKey podio::detail::getOrderKey(const CaloHitContribution& obj);
0050 
0051 public:
0052   using mutable_type = MutableCaloHitContribution;
0053   using collection_type = CaloHitContributionCollection;
0054 
0055   /// default constructor
0056   CaloHitContribution() = default;
0057 
0058   /// Constructor initializing all members
0059   CaloHitContribution(const std::int32_t PDG, const float energy, const float time,
0060                       const edm4hep::Vector3f& stepPosition, const float stepLength);
0061 
0062   /// copy constructor
0063   CaloHitContribution(const CaloHitContribution& other) = default;
0064 
0065   /// copy-assignment operator
0066   CaloHitContribution& operator=(CaloHitContribution other) &; // Rebind this to other's internal object
0067   CaloHitContribution&
0068   operator=(CaloHitContribution other) && = delete; // Prevent rebinding temporary as the changes wouldn't persist
0069 
0070   /// create a mutable deep-copy of the object with identical relations
0071   /// if cloneRelations=false, the relations are not cloned and will be empty
0072   MutableCaloHitContribution clone(bool cloneRelations = true) const;
0073 
0074   /// destructor
0075   ~CaloHitContribution() = default;
0076 
0077   /// converting constructor from mutable object
0078   CaloHitContribution(const MutableCaloHitContribution& other);
0079 
0080   static CaloHitContribution makeEmpty();
0081 
0082 public:
0083   static constexpr std::string_view typeName = "edm4hep::CaloHitContribution";
0084 
0085   /// Access the PDG code of the shower particle that caused this contribution
0086   std::int32_t getPDG() const;
0087 
0088   /// Access the energy of this contribution [GeV]
0089   float getEnergy() const;
0090 
0091   /// Access the time of this contribution [ns]
0092   float getTime() const;
0093 
0094   /// Access the position of this energy deposition (step) [mm]
0095   const edm4hep::Vector3f& getStepPosition() const;
0096 
0097   /// Access the Geant4 step length for this contribution [mm]
0098   float getStepLength() const;
0099 
0100   /// Access the MCParticle responsible for this contribution to the hit. Only particles that are kept in the MCParticle
0101   /// record will appear here. Hence, this will point to the first mother appearing in the record.
0102   const edm4hep::MCParticle getParticle() const;
0103 
0104   /// check whether the object is actually available
0105   bool isAvailable() const;
0106   /// disconnect from CaloHitContributionObj instance
0107   void unlink() { m_obj = podio::utils::MaybeSharedPtr<CaloHitContributionObj>{nullptr}; }
0108 
0109   bool operator==(const CaloHitContribution& other) const { return m_obj == other.m_obj; }
0110   bool operator==(const MutableCaloHitContribution& other) const;
0111 
0112   bool operator!=(const CaloHitContribution& other) const { return !(*this == other); }
0113   bool operator!=(const MutableCaloHitContribution& other) const { return !(*this == other); }
0114 
0115   // less comparison operator, so that objects can be e.g. stored in sets.
0116   bool operator<(const CaloHitContribution& other) const {
0117     return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other);
0118   }
0119 
0120   podio::ObjectID id() const { return getObjectID(); }
0121 
0122   const podio::ObjectID getObjectID() const;
0123 
0124   friend std::hash<CaloHitContribution>;
0125 
0126   friend void swap(CaloHitContribution& a, CaloHitContribution& b) {
0127     using std::swap;
0128     swap(a.m_obj, b.m_obj); // swap out the internal pointers
0129   }
0130 
0131 private:
0132   /// constructor from existing CaloHitContributionObj
0133   explicit CaloHitContribution(podio::utils::MaybeSharedPtr<CaloHitContributionObj> obj);
0134   CaloHitContribution(CaloHitContributionObj* obj);
0135 
0136   podio::utils::MaybeSharedPtr<CaloHitContributionObj> m_obj{new CaloHitContributionObj{}, podio::utils::MarkOwned};
0137 };
0138 
0139 std::ostream& operator<<(std::ostream& o, const CaloHitContribution& value);
0140 
0141 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0142 void to_json(nlohmann::json& j, const CaloHitContribution& value);
0143 #endif
0144 
0145 } // namespace edm4hep
0146 
0147 template <>
0148 struct std::hash<edm4hep::CaloHitContribution> {
0149   std::size_t operator()(const edm4hep::CaloHitContribution& obj) const {
0150     return std::hash<edm4hep::CaloHitContributionObj*>{}(obj.m_obj.get());
0151   }
0152 };
0153 
0154 // This is needed to avoid triggering opening every library in LD_LIBRARY_PATH
0155 // until it's fixed in ROOT. See https://github.com/root-project/root/issues/18489
0156 // and https://github.com/AIDASoft/podio/issues/770
0157 #if defined(__clang__)
0158 #pragma clang diagnostic push
0159 #pragma clang diagnostic ignored "-Wunknown-warning-option"
0160 #pragma clang diagnostic ignored "-Wdeprecated-redundant-constexpr-static-def"
0161 #pragma clang diagnostic ignored "-Wdeprecated"
0162 constexpr std::string_view edm4hep::CaloHitContribution::typeName;
0163 #pragma clang diagnostic pop
0164 #elif defined(__GNUC__)
0165 #pragma GCC diagnostic push
0166 #pragma GCC diagnostic ignored "-Wdeprecated"
0167 constexpr std::string_view edm4hep::CaloHitContribution::typeName;
0168 #pragma GCC diagnostic pop
0169 #endif
0170 
0171 #endif