File indexing completed on 2025-07-09 08:30:16
0001
0002
0003 #ifndef EDM4HEP_MutableSimCalorimeterHit_H
0004 #define EDM4HEP_MutableSimCalorimeterHit_H
0005
0006 #include "edm4hep/SimCalorimeterHitObj.h"
0007
0008 #include "edm4hep/SimCalorimeterHit.h"
0009
0010 #include "edm4hep/CaloHitContribution.h"
0011 #include "edm4hep/Vector3f.h"
0012 #include "podio/RelationRange.h"
0013 #include <cstdint>
0014 #include <vector>
0015
0016 #include "podio/utilities/MaybeSharedPtr.h"
0017
0018 #include <cstdint>
0019
0020 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0021 #include "nlohmann/json_fwd.hpp"
0022 #endif
0023
0024
0025 namespace edm4hep {
0026 class SimCalorimeterHitCollection;
0027 }
0028
0029 namespace edm4hep {
0030
0031
0032
0033
0034
0035 class MutableSimCalorimeterHit {
0036
0037 friend class SimCalorimeterHitCollection;
0038 friend class SimCalorimeterHitMutableCollectionIterator;
0039 friend class SimCalorimeterHit;
0040
0041 public:
0042 using object_type = SimCalorimeterHit;
0043 using collection_type = SimCalorimeterHitCollection;
0044
0045
0046 MutableSimCalorimeterHit();
0047
0048
0049 MutableSimCalorimeterHit(std::uint64_t cellID, float energy, edm4hep::Vector3f position);
0050
0051
0052 MutableSimCalorimeterHit(const MutableSimCalorimeterHit& other) = default;
0053
0054
0055 MutableSimCalorimeterHit& operator=(MutableSimCalorimeterHit other);
0056
0057
0058
0059 MutableSimCalorimeterHit clone(bool cloneRelations = true) const;
0060
0061
0062 ~MutableSimCalorimeterHit() = default;
0063
0064 public:
0065
0066 std::uint64_t getCellID() const;
0067
0068
0069 float getEnergy() const;
0070
0071
0072 const edm4hep::Vector3f& getPosition() const;
0073
0074
0075 void setCellID(std::uint64_t value);
0076
0077 std::uint64_t& getCellID();
0078
0079 [[deprecated("use getCellID instead")]] std::uint64_t& cellID();
0080
0081
0082 void setEnergy(float value);
0083
0084 float& getEnergy();
0085
0086 [[deprecated("use getEnergy instead")]] float& energy();
0087
0088
0089 void setPosition(edm4hep::Vector3f value);
0090
0091 edm4hep::Vector3f& getPosition();
0092
0093 [[deprecated("use getPosition instead")]] edm4hep::Vector3f& position();
0094
0095 void addToContributions(const edm4hep::CaloHitContribution&);
0096 std::size_t contributions_size() const;
0097 edm4hep::CaloHitContribution getContributions(std::size_t) const;
0098 std::vector<edm4hep::CaloHitContribution>::const_iterator contributions_begin() const;
0099 std::vector<edm4hep::CaloHitContribution>::const_iterator contributions_end() const;
0100 podio::RelationRange<edm4hep::CaloHitContribution> getContributions() const;
0101
0102
0103 bool isAvailable() const;
0104
0105 void unlink() {
0106 m_obj = podio::utils::MaybeSharedPtr<SimCalorimeterHitObj>{nullptr};
0107 }
0108
0109 bool operator==(const MutableSimCalorimeterHit& other) const {
0110 return m_obj == other.m_obj;
0111 }
0112 bool operator==(const SimCalorimeterHit& other) const;
0113
0114 bool operator!=(const MutableSimCalorimeterHit& other) const {
0115 return !(*this == other);
0116 }
0117 bool operator!=(const SimCalorimeterHit& other) const {
0118 return !(*this == other);
0119 }
0120
0121
0122 bool operator<(const MutableSimCalorimeterHit& other) const {
0123 return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other);
0124 }
0125
0126 podio::ObjectID id() const {
0127 return getObjectID();
0128 }
0129
0130 const podio::ObjectID getObjectID() const;
0131
0132 friend void swap(MutableSimCalorimeterHit& a, MutableSimCalorimeterHit& b) {
0133 using std::swap;
0134 swap(a.m_obj, b.m_obj);
0135 }
0136
0137 private:
0138
0139 explicit MutableSimCalorimeterHit(podio::utils::MaybeSharedPtr<SimCalorimeterHitObj> obj);
0140
0141 podio::utils::MaybeSharedPtr<SimCalorimeterHitObj> m_obj{nullptr};
0142 };
0143
0144 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0145 void to_json(nlohmann::json& j, const MutableSimCalorimeterHit& value);
0146 #endif
0147
0148 }
0149
0150 #endif