File indexing completed on 2024-11-15 09:35:41
0001
0002
0003 #ifndef EDM4HEP_MutableCluster_H
0004 #define EDM4HEP_MutableCluster_H
0005
0006 #include "edm4hep/ClusterObj.h"
0007
0008 #include "edm4hep/Cluster.h"
0009
0010 #include "edm4hep/CalorimeterHit.h"
0011 #include "edm4hep/ParticleID.h"
0012 #include "edm4hep/Vector3f.h"
0013 #include "podio/RelationRange.h"
0014 #include <array>
0015 #include <cstdint>
0016 #include <vector>
0017
0018 #include "podio/utilities/MaybeSharedPtr.h"
0019
0020 #include <cstddef>
0021 #include <ostream>
0022
0023 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0024 #include "nlohmann/json_fwd.hpp"
0025 #endif
0026
0027 namespace edm4hep {
0028
0029
0030
0031
0032
0033 class MutableCluster {
0034
0035 friend class ClusterCollection;
0036 friend class ClusterMutableCollectionIterator;
0037 friend class Cluster;
0038
0039 public:
0040 using object_type = Cluster;
0041 using collection_type = ClusterCollection;
0042
0043
0044 MutableCluster();
0045
0046
0047 MutableCluster(std::int32_t type, float energy, float energyError, edm4hep::Vector3f position,
0048 std::array<float, 6> positionError, float iTheta, float phi, edm4hep::Vector3f directionError);
0049
0050
0051 MutableCluster(const MutableCluster& other) = default;
0052
0053
0054 MutableCluster& operator=(MutableCluster other);
0055
0056
0057 MutableCluster clone() const;
0058
0059
0060 ~MutableCluster() = default;
0061
0062
0063 operator Cluster() const;
0064
0065 public:
0066
0067 std::int32_t getType() const;
0068
0069
0070 float getEnergy() const;
0071
0072
0073 float getEnergyError() const;
0074
0075
0076 const edm4hep::Vector3f& getPosition() const;
0077
0078
0079 const std::array<float, 6>& getPositionError() const;
0080
0081 float getPositionError(size_t i) const;
0082
0083
0084 float getITheta() const;
0085
0086
0087
0088 float getPhi() const;
0089
0090
0091 const edm4hep::Vector3f& getDirectionError() const;
0092
0093
0094 void setType(std::int32_t value);
0095
0096
0097 void setEnergy(float value);
0098
0099
0100 void setEnergyError(float value);
0101
0102
0103 void setPosition(edm4hep::Vector3f value);
0104
0105 edm4hep::Vector3f& position();
0106
0107
0108 void setPositionError(std::array<float, 6> value);
0109 void setPositionError(size_t i, float value);
0110
0111 std::array<float, 6>& positionError();
0112
0113
0114
0115 void setITheta(float value);
0116
0117
0118
0119 void setPhi(float value);
0120
0121
0122 void setDirectionError(edm4hep::Vector3f value);
0123
0124 edm4hep::Vector3f& directionError();
0125
0126 void addToClusters(edm4hep::Cluster);
0127 std::size_t clusters_size() const;
0128 edm4hep::Cluster getClusters(std::size_t) const;
0129 std::vector<edm4hep::Cluster>::const_iterator clusters_begin() const;
0130 std::vector<edm4hep::Cluster>::const_iterator clusters_end() const;
0131 podio::RelationRange<edm4hep::Cluster> getClusters() const;
0132 void addToHits(edm4hep::CalorimeterHit);
0133 std::size_t hits_size() const;
0134 edm4hep::CalorimeterHit getHits(std::size_t) const;
0135 std::vector<edm4hep::CalorimeterHit>::const_iterator hits_begin() const;
0136 std::vector<edm4hep::CalorimeterHit>::const_iterator hits_end() const;
0137 podio::RelationRange<edm4hep::CalorimeterHit> getHits() const;
0138 void addToParticleIDs(edm4hep::ParticleID);
0139 std::size_t particleIDs_size() const;
0140 edm4hep::ParticleID getParticleIDs(std::size_t) const;
0141 std::vector<edm4hep::ParticleID>::const_iterator particleIDs_begin() const;
0142 std::vector<edm4hep::ParticleID>::const_iterator particleIDs_end() const;
0143 podio::RelationRange<edm4hep::ParticleID> getParticleIDs() const;
0144 void addToShapeParameters(float);
0145 std::size_t shapeParameters_size() const;
0146 float getShapeParameters(std::size_t) const;
0147 std::vector<float>::const_iterator shapeParameters_begin() const;
0148 std::vector<float>::const_iterator shapeParameters_end() const;
0149 podio::RelationRange<float> getShapeParameters() const;
0150 void addToSubdetectorEnergies(float);
0151 std::size_t subdetectorEnergies_size() const;
0152 float getSubdetectorEnergies(std::size_t) const;
0153 std::vector<float>::const_iterator subdetectorEnergies_begin() const;
0154 std::vector<float>::const_iterator subdetectorEnergies_end() const;
0155 podio::RelationRange<float> getSubdetectorEnergies() const;
0156
0157
0158 bool isAvailable() const;
0159
0160 void unlink() {
0161 m_obj = podio::utils::MaybeSharedPtr<ClusterObj>{nullptr};
0162 }
0163
0164 bool operator==(const MutableCluster& other) const {
0165 return m_obj == other.m_obj;
0166 }
0167 bool operator==(const Cluster& other) const;
0168
0169
0170 bool operator<(const MutableCluster& other) const {
0171 return m_obj < other.m_obj;
0172 }
0173
0174 podio::ObjectID id() const {
0175 return getObjectID();
0176 }
0177
0178 const podio::ObjectID getObjectID() const;
0179
0180 friend void swap(MutableCluster& a, MutableCluster& b) {
0181 using std::swap;
0182 swap(a.m_obj, b.m_obj);
0183 }
0184
0185 private:
0186
0187 explicit MutableCluster(podio::utils::MaybeSharedPtr<ClusterObj> obj);
0188
0189 podio::utils::MaybeSharedPtr<ClusterObj> m_obj{nullptr};
0190 };
0191
0192 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0193 void to_json(nlohmann::json& j, const MutableCluster& value);
0194 #endif
0195
0196 }
0197
0198 #endif