EDM4eic
EIC data model
Loading...
Searching...
No Matches
MutableCluster.h
Go to the documentation of this file.
1// AUTOMATICALLY GENERATED FILE - DO NOT EDIT
2
3#ifndef EDM4EIC_MutableCluster_H
4#define EDM4EIC_MutableCluster_H
5
7// Make the immutable class available from its mutable version but not vice versa
8#include "edm4eic/Cluster.h"
9
11#include "edm4eic/Cov2f.h"
12#include "edm4eic/Cov3f.h"
13#include "edm4hep/ParticleID.h"
14#include "edm4hep/Vector3f.h"
15#include "podio/RelationRange.h"
16#include <array>
17#include <cstdint>
18#include <vector>
19
20#include "podio/utilities/MaybeSharedPtr.h"
21
22#include <cstdint>
23
24#if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
25#include "nlohmann/json_fwd.hpp"
26#endif
27
28// forward declarations
29namespace edm4eic {
31}
32
33
34namespace edm4eic {
35
36
37/** @class MutableCluster
38 * EIC hit cluster, reworked to more closely resemble EDM4hep
39 * @author: W. Armstrong, S. Joosten, C.Peng
40 */
42
43 friend class ClusterCollection;
45 friend class Cluster;
46
47public:
50
51 /// default constructor
52 MutableCluster() = default;
53
54 /// Constructor initializing all members
55 MutableCluster(const std::int32_t type, const float energy, const float energyError, const float time, const float timeError, const std::uint32_t nhits, const edm4hep::Vector3f& position, const edm4eic::Cov3f& positionError, const float radius, const float dispersion, const std::array<float, 3>& principalAxesLengthsXYZ, const std::array<float, 2>& principalAxesLengthsThetaPhi, const float intrinsicTheta, const float intrinsicPhi, const edm4eic::Cov2f& intrinsicDirectionError);
56
57 /// copy constructor
58 MutableCluster(const MutableCluster& other) = default;
59
60 /// copy-assignment operator
61 MutableCluster& operator=(MutableCluster other) &; // Rebind this to other's internal object
62 MutableCluster& operator=(MutableCluster other) && = delete; // Prevent rebinding temporary as the changes wouldn't persist
63
64 /// create a mutable deep-copy of the object with identical relations
65 /// if cloneRelations=false, the relations are not cloned and will be empty
66 MutableCluster clone(bool cloneRelations=true) const;
67
68 /// destructor
69 ~MutableCluster() = default;
70
71
72public:
73
74 /// Access the Flag-word that defines the type of the cluster
75 std::int32_t getType() const;
76
77 /// Access the Reconstructed energy of the cluster [GeV].
78 float getEnergy() const;
79
80 /// Access the Error on the cluster energy [GeV]
81 float getEnergyError() const;
82
83 /// Access the [ns]
84 float getTime() const;
85
86 /// Access the Error on the cluster time
87 float getTimeError() const;
88
89 /// Access the Number of hits in the cluster.
90 std::uint32_t getNhits() const;
91
92 /// Access the Global position of the cluster [mm].
93 const edm4hep::Vector3f& getPosition() const;
94
95 /// Access the Covariance matrix of the position (6 Parameters).
96 const edm4eic::Cov3f& getPositionError() const;
97
98 /// Access the Cluster radius [mm].
99 float getRadius() const;
100
101 /// Access the Cluster dispersion [mm].
102 float getDispersion() const;
103
104 /// Access the Lengths along the cluster's principal axes [mm], sorted in descending order (equivalent to sqrt of eigenvalues of the position covariance). For an XY planar detector one can expect this to be [sigma_max, sigma_min, 0].
105 const std::array<float, 3>& getPrincipalAxesLengthsXYZ() const;
106 /// Access item i of the Lengths along the cluster's principal axes [mm], sorted in descending order (equivalent to sqrt of eigenvalues of the position covariance). For an XY planar detector one can expect this to be [sigma_max, sigma_min, 0].
107 float getPrincipalAxesLengthsXYZ(size_t i) const;
108 /// Access the Lengths along the cluster's principal axes [rad], sorted in descending order.
109 const std::array<float, 2>& getPrincipalAxesLengthsThetaPhi() const;
110 /// Access item i of the Lengths along the cluster's principal axes [rad], sorted in descending order.
111 float getPrincipalAxesLengthsThetaPhi(size_t i) const;
112 /// Access the Intrinsic cluster propagation direction polar angle [rad].
113 float getIntrinsicTheta() const;
114
115 /// Access the Intrinsic cluster propagation direction azimuthal angle [rad]. For an XY planar detector one can expect this to be the tilt of "sigma_max" axis.
116 float getIntrinsicPhi() const;
117
118 /// Access the Error on the intrinsic cluster propagation direction
120
121
122
123 /// Set the Flag-word that defines the type of the cluster
124 void setType(const std::int32_t type);
125 /// Get mutable reference to Flag-word that defines the type of the cluster
126 std::int32_t& getType();
127
128 /// Set the Reconstructed energy of the cluster [GeV].
129 void setEnergy(const float energy);
130 /// Get mutable reference to Reconstructed energy of the cluster [GeV].
131 float& getEnergy();
132
133 /// Set the Error on the cluster energy [GeV]
134 void setEnergyError(const float energyError);
135 /// Get mutable reference to Error on the cluster energy [GeV]
136 float& getEnergyError();
137
138 /// Set the [ns]
139 void setTime(const float time);
140 /// Get mutable reference to [ns]
141 float& getTime();
142
143 /// Set the Error on the cluster time
144 void setTimeError(const float timeError);
145 /// Get mutable reference to Error on the cluster time
146 float& getTimeError();
147
148 /// Set the Number of hits in the cluster.
149 void setNhits(const std::uint32_t nhits);
150 /// Get mutable reference to Number of hits in the cluster.
151 std::uint32_t& getNhits();
152
153 /// Set the Global position of the cluster [mm].
154 void setPosition(const edm4hep::Vector3f& position);
155 /// Get mutable reference to Global position of the cluster [mm].
156 edm4hep::Vector3f& getPosition();
157
158 /// Set the Covariance matrix of the position (6 Parameters).
159 void setPositionError(const edm4eic::Cov3f& positionError);
160 /// Get mutable reference to Covariance matrix of the position (6 Parameters).
162
163 /// Set the Cluster radius [mm].
164 void setRadius(const float radius);
165 /// Get mutable reference to Cluster radius [mm].
166 float& getRadius();
167
168 /// Set the Cluster dispersion [mm].
169 void setDispersion(const float dispersion);
170 /// Get mutable reference to Cluster dispersion [mm].
171 float& getDispersion();
172
173 /// Set the Lengths along the cluster's principal axes [mm], sorted in descending order (equivalent to sqrt of eigenvalues of the position covariance). For an XY planar detector one can expect this to be [sigma_max, sigma_min, 0].
174 void setPrincipalAxesLengthsXYZ(const std::array<float, 3>& principalAxesLengthsXYZ);
175 void setPrincipalAxesLengthsXYZ(size_t i, float value);
176 /// Get mutable reference to Lengths along the cluster's principal axes [mm], sorted in descending order (equivalent to sqrt of eigenvalues of the position covariance). For an XY planar detector one can expect this to be [sigma_max, sigma_min, 0].
177 std::array<float, 3>& getPrincipalAxesLengthsXYZ();
178
179 /// Set the Lengths along the cluster's principal axes [rad], sorted in descending order.
180 void setPrincipalAxesLengthsThetaPhi(const std::array<float, 2>& principalAxesLengthsThetaPhi);
181 void setPrincipalAxesLengthsThetaPhi(size_t i, float value);
182 /// Get mutable reference to Lengths along the cluster's principal axes [rad], sorted in descending order.
183 std::array<float, 2>& getPrincipalAxesLengthsThetaPhi();
184
185 /// Set the Intrinsic cluster propagation direction polar angle [rad].
186 void setIntrinsicTheta(const float intrinsicTheta);
187 /// Get mutable reference to Intrinsic cluster propagation direction polar angle [rad].
188 float& getIntrinsicTheta();
189
190 /// Set the Intrinsic cluster propagation direction azimuthal angle [rad]. For an XY planar detector one can expect this to be the tilt of "sigma_max" axis.
191 void setIntrinsicPhi(const float intrinsicPhi);
192 /// Get mutable reference to Intrinsic cluster propagation direction azimuthal angle [rad]. For an XY planar detector one can expect this to be the tilt of "sigma_max" axis.
193 float& getIntrinsicPhi();
194
195 /// Set the Error on the intrinsic cluster propagation direction
196 void setIntrinsicDirectionError(const edm4eic::Cov2f& intrinsicDirectionError);
197 /// Get mutable reference to Error on the intrinsic cluster propagation direction
199
200
201
202 void addToClusters(const edm4eic::Cluster&);
203 std::size_t clusters_size() const;
204 edm4eic::Cluster getClusters(std::size_t) const;
205 std::vector<edm4eic::Cluster>::const_iterator clusters_begin() const;
206 std::vector<edm4eic::Cluster>::const_iterator clusters_end() const;
207 podio::RelationRange<edm4eic::Cluster> getClusters() const;
209 std::size_t hits_size() const;
210 edm4eic::CalorimeterHit getHits(std::size_t) const;
211 std::vector<edm4eic::CalorimeterHit>::const_iterator hits_begin() const;
212 std::vector<edm4eic::CalorimeterHit>::const_iterator hits_end() const;
213 podio::RelationRange<edm4eic::CalorimeterHit> getHits() const;
214 void addToParticleIDs(const edm4hep::ParticleID&);
215 std::size_t particleIDs_size() const;
216 edm4hep::ParticleID getParticleIDs(std::size_t) const;
217 std::vector<edm4hep::ParticleID>::const_iterator particleIDs_begin() const;
218 std::vector<edm4hep::ParticleID>::const_iterator particleIDs_end() const;
219 podio::RelationRange<edm4hep::ParticleID> getParticleIDs() const;
220 void addToShapeParameters(const float&);
221 std::size_t shapeParameters_size() const;
222 float getShapeParameters(std::size_t) const;
223 std::vector<float>::const_iterator shapeParameters_begin() const;
224 std::vector<float>::const_iterator shapeParameters_end() const;
225 podio::RelationRange<float> getShapeParameters() const;
226 void addToHitContributions(const float&);
227 std::size_t hitContributions_size() const;
228 float getHitContributions(std::size_t) const;
229 std::vector<float>::const_iterator hitContributions_begin() const;
230 std::vector<float>::const_iterator hitContributions_end() const;
231 podio::RelationRange<float> getHitContributions() const;
232 void addToSubdetectorEnergies(const float&);
233 std::size_t subdetectorEnergies_size() const;
234 float getSubdetectorEnergies(std::size_t) const;
235 std::vector<float>::const_iterator subdetectorEnergies_begin() const;
236 std::vector<float>::const_iterator subdetectorEnergies_end() const;
237 podio::RelationRange<float> getSubdetectorEnergies() const;
238
239
240
241 /// check whether the object is actually available
242 bool isAvailable() const;
243 /// disconnect from ClusterObj instance
244 void unlink() { m_obj = podio::utils::MaybeSharedPtr<ClusterObj>{nullptr}; }
245
246 constexpr bool operator==(const MutableCluster& other) const { return m_obj == other.m_obj; }
247 bool operator==(const Cluster& other) const;
248
249 constexpr bool operator!=(const MutableCluster& other) const { return !(*this == other); }
250 bool operator!=(const Cluster& other) const { return !(*this == other); }
251
252 // less comparison operator, so that objects can be e.g. stored in sets.
253 bool operator<(const MutableCluster& other) const { return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other); }
254
255 podio::ObjectID id() const { return getObjectID(); }
256
257 const podio::ObjectID getObjectID() const;
258
259 friend std::hash<MutableCluster>;
260
261 friend void swap(MutableCluster& a, MutableCluster& b) {
262 using std::swap;
263 swap(a.m_obj, b.m_obj); // swap out the internal pointers
264 }
265
266private:
267 /// constructor from existing ClusterObj
268 explicit MutableCluster(podio::utils::MaybeSharedPtr<ClusterObj> obj);
269
270 podio::utils::MaybeSharedPtr<ClusterObj> m_obj{new ClusterObj{}, podio::utils::MarkOwned};
271};
272
273#if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
274void to_json(nlohmann::json& j, const MutableCluster& value);
275#endif
276
277
278} // namespace edm4eic
279
280
281
282template<>
283struct std::hash<edm4eic::MutableCluster> {
284 std::size_t operator()(const edm4eic::MutableCluster& obj) const {
285 return std::hash<edm4eic::ClusterObj*>{}(obj.m_obj.get());
286 }
287};
288
289
290#endif
Definition CalorimeterHit.h:46
Definition ClusterCollection.h:139
Definition Cluster.h:49
Definition ClusterObj.h:21
Definition Cov2f.h:19
Definition Cov3f.h:19
Definition MutableCluster.h:41
Cluster object_type
Definition MutableCluster.h:48
const edm4hep::Vector3f & getPosition() const
Access the Global position of the cluster [mm].
Definition MutableCluster.cc:75
podio::RelationRange< float > getSubdetectorEnergies() const
Definition MutableCluster.cc:330
std::vector< edm4hep::ParticleID >::const_iterator particleIDs_begin() const
Definition MutableCluster.cc:199
friend class Cluster
Definition MutableCluster.h:45
float getTime() const
Access the [ns].
Definition MutableCluster.cc:72
void addToShapeParameters(const float &)
Definition MutableCluster.cc:230
podio::RelationRange< edm4eic::CalorimeterHit > getHits() const
Definition MutableCluster.cc:186
std::vector< edm4eic::CalorimeterHit >::const_iterator hits_end() const
Definition MutableCluster.cc:169
podio::ObjectID id() const
Definition MutableCluster.h:255
void setPosition(const edm4hep::Vector3f &position)
Set the Global position of the cluster [mm].
Definition MutableCluster.cc:100
ClusterCollection collection_type
Definition MutableCluster.h:49
std::vector< edm4eic::CalorimeterHit >::const_iterator hits_begin() const
Definition MutableCluster.cc:163
float getRadius() const
Access the Cluster radius [mm].
Definition MutableCluster.cc:77
MutableCluster()=default
default constructor
void addToParticleIDs(const edm4hep::ParticleID &)
Definition MutableCluster.cc:194
void setIntrinsicPhi(const float intrinsicPhi)
Set the Intrinsic cluster propagation direction azimuthal angle [rad]. For an XY planar detector one ...
Definition MutableCluster.cc:116
void setType(const std::int32_t type)
Set the Flag-word that defines the type of the cluster.
Definition MutableCluster.cc:88
float getTimeError() const
Access the Error on the cluster time.
Definition MutableCluster.cc:73
void unlink()
disconnect from ClusterObj instance
Definition MutableCluster.h:244
float getEnergyError() const
Access the Error on the cluster energy [GeV].
Definition MutableCluster.cc:71
bool operator!=(const Cluster &other) const
Definition MutableCluster.h:250
const edm4eic::Cov2f & getIntrinsicDirectionError() const
Access the Error on the intrinsic cluster propagation direction.
Definition MutableCluster.cc:85
bool isAvailable() const
check whether the object is actually available
Definition MutableCluster.cc:343
MutableCluster(const MutableCluster &other)=default
copy constructor
bool operator<(const MutableCluster &other) const
Definition MutableCluster.h:253
void setPrincipalAxesLengthsThetaPhi(const std::array< float, 2 > &principalAxesLengthsThetaPhi)
Set the Lengths along the cluster's principal axes [rad], sorted in descending order.
Definition MutableCluster.cc:111
std::size_t particleIDs_size() const
Definition MutableCluster.cc:211
const std::array< float, 3 > & getPrincipalAxesLengthsXYZ() const
Access the Lengths along the cluster's principal axes [mm], sorted in descending order (equivalent to...
Definition MutableCluster.cc:79
void setPositionError(const edm4eic::Cov3f &positionError)
Set the Covariance matrix of the position (6 Parameters).
Definition MutableCluster.cc:102
std::size_t hits_size() const
Definition MutableCluster.cc:175
std::vector< edm4hep::ParticleID >::const_iterator particleIDs_end() const
Definition MutableCluster.cc:205
MutableCluster & operator=(MutableCluster other) &&=delete
float getIntrinsicTheta() const
Access the Intrinsic cluster propagation direction polar angle [rad].
Definition MutableCluster.cc:83
void addToHits(const edm4eic::CalorimeterHit &)
Definition MutableCluster.cc:158
friend void swap(MutableCluster &a, MutableCluster &b)
Definition MutableCluster.h:261
podio::RelationRange< edm4hep::ParticleID > getParticleIDs() const
Definition MutableCluster.cc:222
void setTimeError(const float timeError)
Set the Error on the cluster time.
Definition MutableCluster.cc:96
MutableCluster & operator=(MutableCluster other) &
copy-assignment operator
Definition MutableCluster.cc:36
std::vector< edm4eic::Cluster >::const_iterator clusters_end() const
Definition MutableCluster.cc:133
friend class ClusterCollection
Definition MutableCluster.h:43
constexpr bool operator==(const MutableCluster &other) const
Definition MutableCluster.h:246
void setTime(const float time)
Set the [ns].
Definition MutableCluster.cc:94
const std::array< float, 2 > & getPrincipalAxesLengthsThetaPhi() const
Access the Lengths along the cluster's principal axes [rad], sorted in descending order.
Definition MutableCluster.cc:81
void setIntrinsicTheta(const float intrinsicTheta)
Set the Intrinsic cluster propagation direction polar angle [rad].
Definition MutableCluster.cc:114
std::int32_t getType() const
Access the Flag-word that defines the type of the cluster.
Definition MutableCluster.cc:69
void setPrincipalAxesLengthsXYZ(const std::array< float, 3 > &principalAxesLengthsXYZ)
Set the Lengths along the cluster's principal axes [mm], sorted in descending order (equivalent to sq...
Definition MutableCluster.cc:108
void addToSubdetectorEnergies(const float &)
Definition MutableCluster.cc:302
std::vector< float >::const_iterator hitContributions_begin() const
Definition MutableCluster.cc:271
std::vector< float >::const_iterator subdetectorEnergies_begin() const
Definition MutableCluster.cc:307
std::uint32_t getNhits() const
Access the Number of hits in the cluster.
Definition MutableCluster.cc:74
std::size_t clusters_size() const
Definition MutableCluster.cc:139
void addToHitContributions(const float &)
Definition MutableCluster.cc:266
std::size_t hitContributions_size() const
Definition MutableCluster.cc:283
~MutableCluster()=default
destructor
friend class ClusterMutableCollectionIterator
Definition MutableCluster.h:44
std::vector< edm4eic::Cluster >::const_iterator clusters_begin() const
Definition MutableCluster.cc:127
float getEnergy() const
Access the Reconstructed energy of the cluster [GeV].
Definition MutableCluster.cc:70
void setIntrinsicDirectionError(const edm4eic::Cov2f &intrinsicDirectionError)
Set the Error on the intrinsic cluster propagation direction.
Definition MutableCluster.cc:118
std::size_t shapeParameters_size() const
Definition MutableCluster.cc:247
const edm4eic::Cov3f & getPositionError() const
Access the Covariance matrix of the position (6 Parameters).
Definition MutableCluster.cc:76
MutableCluster clone(bool cloneRelations=true) const
Definition MutableCluster.cc:41
void setRadius(const float radius)
Set the Cluster radius [mm].
Definition MutableCluster.cc:104
std::vector< float >::const_iterator shapeParameters_end() const
Definition MutableCluster.cc:241
const podio::ObjectID getObjectID() const
Definition MutableCluster.cc:347
void setDispersion(const float dispersion)
Set the Cluster dispersion [mm].
Definition MutableCluster.cc:106
podio::RelationRange< edm4eic::Cluster > getClusters() const
Definition MutableCluster.cc:150
podio::RelationRange< float > getHitContributions() const
Definition MutableCluster.cc:294
constexpr bool operator!=(const MutableCluster &other) const
Definition MutableCluster.h:249
void setNhits(const std::uint32_t nhits)
Set the Number of hits in the cluster.
Definition MutableCluster.cc:98
void addToClusters(const edm4eic::Cluster &)
Definition MutableCluster.cc:122
float getIntrinsicPhi() const
Access the Intrinsic cluster propagation direction azimuthal angle [rad]. For an XY planar detector o...
Definition MutableCluster.cc:84
std::vector< float >::const_iterator subdetectorEnergies_end() const
Definition MutableCluster.cc:313
float getDispersion() const
Access the Cluster dispersion [mm].
Definition MutableCluster.cc:78
std::vector< float >::const_iterator hitContributions_end() const
Definition MutableCluster.cc:277
void setEnergy(const float energy)
Set the Reconstructed energy of the cluster [GeV].
Definition MutableCluster.cc:90
void setEnergyError(const float energyError)
Set the Error on the cluster energy [GeV].
Definition MutableCluster.cc:92
std::vector< float >::const_iterator shapeParameters_begin() const
Definition MutableCluster.cc:235
podio::RelationRange< float > getShapeParameters() const
Definition MutableCluster.cc:258
std::size_t subdetectorEnergies_size() const
Definition MutableCluster.cc:319
Definition ArrowMapper.cc:61
OrderKey getOrderKey(const edm4eic::CalorimeterHit &obj)
Definition CalorimeterHit.cc:146
std::size_t operator()(const edm4eic::MutableCluster &obj) const
Definition MutableCluster.h:284