File indexing completed on 2026-09-01 09:08:21
0001
0002
0003 #ifndef EDM4HEP_MutableCaloHitContribution_H
0004 #define EDM4HEP_MutableCaloHitContribution_H
0005
0006 #include "edm4hep/CaloHitContributionObj.h"
0007
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
0022 namespace edm4hep {
0023 class CaloHitContributionCollection;
0024 class MCParticle;
0025 class MutableMCParticle;
0026 }
0027
0028 namespace edm4hep {
0029
0030
0031
0032
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
0045 MutableCaloHitContribution() = default;
0046
0047
0048 MutableCaloHitContribution(const std::int32_t PDG, const float energy, const float time,
0049 const edm4hep::Vector3f& stepPosition, const float stepLength);
0050
0051
0052 MutableCaloHitContribution(const MutableCaloHitContribution& other) = default;
0053
0054
0055 MutableCaloHitContribution& operator=(MutableCaloHitContribution other) &;
0056 MutableCaloHitContribution& operator=(MutableCaloHitContribution other) && =
0057 delete;
0058
0059
0060
0061 MutableCaloHitContribution clone(bool cloneRelations = true) const;
0062
0063
0064 ~MutableCaloHitContribution() = default;
0065
0066 public:
0067
0068 std::int32_t getPDG() const;
0069
0070
0071 float getEnergy() const;
0072
0073
0074 float getTime() const;
0075
0076
0077 const edm4hep::Vector3f& getStepPosition() const;
0078
0079
0080 float getStepLength() const;
0081
0082
0083
0084 const edm4hep::MCParticle getParticle() const;
0085
0086
0087 void setPDG(const std::int32_t PDG);
0088
0089 std::int32_t& getPDG();
0090
0091
0092 void setEnergy(const float energy);
0093
0094 float& getEnergy();
0095
0096
0097 void setTime(const float time);
0098
0099 float& getTime();
0100
0101
0102 void setStepPosition(const edm4hep::Vector3f& stepPosition);
0103
0104 edm4hep::Vector3f& getStepPosition();
0105
0106
0107 void setStepLength(const float stepLength);
0108
0109 float& getStepLength();
0110
0111
0112
0113 void setParticle(const edm4hep::MCParticle& value);
0114
0115
0116 bool isAvailable() const;
0117
0118 void unlink() { m_obj = podio::utils::MaybeSharedPtr<CaloHitContributionObj>{nullptr}; }
0119
0120 constexpr bool operator==(const MutableCaloHitContribution& other) const { return m_obj == other.m_obj; }
0121 bool operator==(const CaloHitContribution& other) const;
0122
0123 constexpr bool operator!=(const MutableCaloHitContribution& other) const { return !(*this == other); }
0124 bool operator!=(const CaloHitContribution& other) const { return !(*this == other); }
0125
0126
0127 bool operator<(const MutableCaloHitContribution& other) const {
0128 return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other);
0129 }
0130
0131 podio::ObjectID id() const { return getObjectID(); }
0132
0133 const podio::ObjectID getObjectID() const;
0134
0135 friend std::hash<MutableCaloHitContribution>;
0136
0137 friend void swap(MutableCaloHitContribution& a, MutableCaloHitContribution& b) {
0138 using std::swap;
0139 swap(a.m_obj, b.m_obj);
0140 }
0141
0142 private:
0143
0144 explicit MutableCaloHitContribution(podio::utils::MaybeSharedPtr<CaloHitContributionObj> obj);
0145
0146 podio::utils::MaybeSharedPtr<CaloHitContributionObj> m_obj{new CaloHitContributionObj{}, podio::utils::MarkOwned};
0147 };
0148
0149 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0150 void to_json(nlohmann::json& j, const MutableCaloHitContribution& value);
0151 #endif
0152
0153 }
0154
0155 template <>
0156 struct std::hash<edm4hep::MutableCaloHitContribution> {
0157 std::size_t operator()(const edm4hep::MutableCaloHitContribution& obj) const {
0158 return std::hash<edm4hep::CaloHitContributionObj*>{}(obj.m_obj.get());
0159 }
0160 };
0161
0162 #endif