EDM4eic
EIC data model
Loading...
Searching...
No Matches
Cluster.h
Go to the documentation of this file.
1// AUTOMATICALLY GENERATED FILE - DO NOT EDIT
2
3#ifndef EDM4EIC_Cluster_H
4#define EDM4EIC_Cluster_H
5
7
9#include "edm4eic/Cov2f.h"
10#include "edm4eic/Cov3f.h"
11#include "edm4hep/ParticleID.h"
12#include "edm4hep/Vector3f.h"
13#include "podio/RelationRange.h"
14#include <array>
15#include <cstdint>
16#include <vector>
17
18#include "podio/utilities/MaybeSharedPtr.h"
19#include "podio/detail/OrderKey.h"
20
21#include <ostream>
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 podio::detail {
35// Internal function used in less comparison operators of the datatypes and interface types
36OrderKey getOrderKey(const edm4eic::Cluster& obj);
37};
38
39namespace edm4eic {
40
41class MutableCluster;
44
45/** @class Cluster
46 * EIC hit cluster, reworked to more closely resemble EDM4hep
47 * @author: W. Armstrong, S. Joosten, C.Peng
48 */
49class Cluster {
50
51 friend class MutableCluster;
52 friend class ClusterCollection;
55 friend podio::detail::OrderKey podio::detail::getOrderKey(const Cluster & obj);
56
57public:
60
61 /// default constructor
62 Cluster() = default;
63
64 /// Constructor initializing all members
65 Cluster(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);
66
67 /// copy constructor
68 Cluster(const Cluster& other) = default;
69
70 /// copy-assignment operator
71 Cluster& operator=(Cluster other) &; // Rebind this to other's internal object
72 Cluster& operator=(Cluster other) && = delete; // Prevent rebinding temporary as the changes wouldn't persist
73
74 /// create a mutable deep-copy of the object with identical relations
75 /// if cloneRelations=false, the relations are not cloned and will be empty
76 MutableCluster clone(bool cloneRelations=true) const;
77
78 /// destructor
79 ~Cluster() = default;
80
81 /// converting constructor from mutable object
82 Cluster(const MutableCluster& other);
83
84 static Cluster makeEmpty();
85
86public:
87
88 static constexpr std::string_view typeName = "edm4eic::Cluster";
89
90 /// Access the Flag-word that defines the type of the cluster
91 std::int32_t getType() const;
92
93 /// Access the Reconstructed energy of the cluster [GeV].
94 float getEnergy() const;
95
96 /// Access the Error on the cluster energy [GeV]
97 float getEnergyError() const;
98
99 /// Access the [ns]
100 float getTime() const;
101
102 /// Access the Error on the cluster time
103 float getTimeError() const;
104
105 /// Access the Number of hits in the cluster.
106 std::uint32_t getNhits() const;
107
108 /// Access the Global position of the cluster [mm].
109 const edm4hep::Vector3f& getPosition() const;
110
111 /// Access the Covariance matrix of the position (6 Parameters).
112 const edm4eic::Cov3f& getPositionError() const;
113
114 /// Access the Cluster radius [mm].
115 float getRadius() const;
116
117 /// Access the Cluster dispersion [mm].
118 float getDispersion() const;
119
120 /// 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].
121 const std::array<float, 3>& getPrincipalAxesLengthsXYZ() const;
122 /// 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].
123 float getPrincipalAxesLengthsXYZ(size_t i) const;
124 /// Access the Lengths along the cluster's principal axes [rad], sorted in descending order.
125 const std::array<float, 2>& getPrincipalAxesLengthsThetaPhi() const;
126 /// Access item i of the Lengths along the cluster's principal axes [rad], sorted in descending order.
127 float getPrincipalAxesLengthsThetaPhi(size_t i) const;
128 /// Access the Intrinsic cluster propagation direction polar angle [rad].
129 float getIntrinsicTheta() const;
130
131 /// 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.
132 float getIntrinsicPhi() const;
133
134 /// Access the Error on the intrinsic cluster propagation direction
136
137
138
139 std::size_t clusters_size() const;
140 edm4eic::Cluster getClusters(std::size_t) const;
141 std::vector<edm4eic::Cluster>::const_iterator clusters_begin() const;
142 std::vector<edm4eic::Cluster>::const_iterator clusters_end() const;
143 podio::RelationRange<edm4eic::Cluster> getClusters() const;
144 std::size_t hits_size() const;
145 edm4eic::CalorimeterHit getHits(std::size_t) const;
146 std::vector<edm4eic::CalorimeterHit>::const_iterator hits_begin() const;
147 std::vector<edm4eic::CalorimeterHit>::const_iterator hits_end() const;
148 podio::RelationRange<edm4eic::CalorimeterHit> getHits() const;
149 std::size_t particleIDs_size() const;
150 edm4hep::ParticleID getParticleIDs(std::size_t) const;
151 std::vector<edm4hep::ParticleID>::const_iterator particleIDs_begin() const;
152 std::vector<edm4hep::ParticleID>::const_iterator particleIDs_end() const;
153 podio::RelationRange<edm4hep::ParticleID> getParticleIDs() const;
154 std::size_t shapeParameters_size() const;
155 float getShapeParameters(std::size_t) const;
156 std::vector<float>::const_iterator shapeParameters_begin() const;
157 std::vector<float>::const_iterator shapeParameters_end() const;
158 podio::RelationRange<float> getShapeParameters() const;
159 std::size_t hitContributions_size() const;
160 float getHitContributions(std::size_t) const;
161 std::vector<float>::const_iterator hitContributions_begin() const;
162 std::vector<float>::const_iterator hitContributions_end() const;
163 podio::RelationRange<float> getHitContributions() const;
164 std::size_t subdetectorEnergies_size() const;
165 float getSubdetectorEnergies(std::size_t) const;
166 std::vector<float>::const_iterator subdetectorEnergies_begin() const;
167 std::vector<float>::const_iterator subdetectorEnergies_end() const;
168 podio::RelationRange<float> getSubdetectorEnergies() const;
169
170
171 /// check whether the object is actually available
172 bool isAvailable() const;
173 /// disconnect from ClusterObj instance
174 void unlink() { m_obj = podio::utils::MaybeSharedPtr<ClusterObj>{nullptr}; }
175
176 bool operator==(const Cluster& other) const { return m_obj == other.m_obj; }
177 bool operator==(const MutableCluster& other) const;
178
179 bool operator!=(const Cluster& other) const { return !(*this == other); }
180 bool operator!=(const MutableCluster& other) const { return !(*this == other); }
181
182 // less comparison operator, so that objects can be e.g. stored in sets.
183 bool operator<(const Cluster& other) const { return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other); }
184
185 podio::ObjectID id() const { return getObjectID(); }
186
187 const podio::ObjectID getObjectID() const;
188
189 friend std::hash<Cluster>;
190
191 friend void swap(Cluster& a, Cluster& b) {
192 using std::swap;
193 swap(a.m_obj, b.m_obj); // swap out the internal pointers
194 }
195
196private:
197 /// constructor from existing ClusterObj
198 explicit Cluster(podio::utils::MaybeSharedPtr<ClusterObj> obj);
199 Cluster(ClusterObj* obj);
200
201 podio::utils::MaybeSharedPtr<ClusterObj> m_obj{new ClusterObj{}, podio::utils::MarkOwned};
202};
203
204std::ostream& operator<<(std::ostream& o, const Cluster& value);
205
206#if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
207void to_json(nlohmann::json& j, const Cluster& value);
208#endif
209
210
211} // namespace edm4eic
212
213
214
215template<>
216struct std::hash<edm4eic::Cluster> {
217 std::size_t operator()(const edm4eic::Cluster& obj) const {
218 return std::hash<edm4eic::ClusterObj*>{}(obj.m_obj.get());
219 }
220};
221
222
223// This is needed to avoid triggering opening every library in LD_LIBRARY_PATH
224// until it's fixed in ROOT. See https://github.com/root-project/root/issues/18489
225// and https://github.com/AIDASoft/podio/issues/770
226#if defined(__clang__)
227 #pragma clang diagnostic push
228 #pragma clang diagnostic ignored "-Wunknown-warning-option"
229 #pragma clang diagnostic ignored "-Wdeprecated-redundant-constexpr-static-def"
230 #pragma clang diagnostic ignored "-Wdeprecated"
231constexpr std::string_view edm4eic::Cluster::typeName;
232 #pragma clang diagnostic pop
233#elif defined(__GNUC__)
234 #pragma GCC diagnostic push
235 #pragma GCC diagnostic ignored "-Wdeprecated"
236constexpr std::string_view edm4eic::Cluster::typeName;
237 #pragma GCC diagnostic pop
238#endif
239
240
241#endif
Definition CalorimeterHit.h:46
Definition ClusterCollectionData.h:33
Definition ClusterCollection.h:138
Definition Cluster.h:49
std::size_t particleIDs_size() const
Definition Cluster.cc:224
podio::RelationRange< float > getSubdetectorEnergies() const
Definition Cluster.cc:331
std::vector< edm4hep::ParticleID >::const_iterator particleIDs_begin() const
Definition Cluster.cc:212
bool operator<(const Cluster &other) const
Definition Cluster.h:183
std::vector< float >::const_iterator hitContributions_end() const
Definition Cluster.cc:282
bool operator==(const Cluster &other) const
Definition Cluster.h:176
std::vector< edm4eic::Cluster >::const_iterator clusters_begin() const
Definition Cluster.cc:148
podio::RelationRange< float > getShapeParameters() const
Definition Cluster.cc:267
void unlink()
disconnect from ClusterObj instance
Definition Cluster.h:174
const edm4hep::Vector3f & getPosition() const
Access the Global position of the cluster [mm].
Definition Cluster.cc:134
std::vector< float >::const_iterator shapeParameters_end() const
Definition Cluster.cc:250
friend class ClusterCollectionIterator
Definition Cluster.h:54
Cluster(const Cluster &other)=default
copy constructor
std::vector< float >::const_iterator subdetectorEnergies_begin() const
Definition Cluster.cc:308
float getEnergyError() const
Access the Error on the cluster energy [GeV].
Definition Cluster.cc:130
std::uint32_t getNhits() const
Access the Number of hits in the cluster.
Definition Cluster.cc:133
std::vector< float >::const_iterator hitContributions_begin() const
Definition Cluster.cc:276
podio::RelationRange< edm4hep::ParticleID > getParticleIDs() const
Definition Cluster.cc:235
std::vector< edm4eic::CalorimeterHit >::const_iterator hits_begin() const
Definition Cluster.cc:180
MutableCluster mutable_type
Definition Cluster.h:58
MutableCluster clone(bool cloneRelations=true) const
Definition Cluster.cc:43
friend class ClusterCollection
Definition Cluster.h:52
bool isAvailable() const
check whether the object is actually available
Definition Cluster.cc:343
float getTime() const
Access the [ns].
Definition Cluster.cc:131
podio::RelationRange< float > getHitContributions() const
Definition Cluster.cc:299
Cluster & operator=(Cluster other) &&=delete
const std::array< float, 2 > & getPrincipalAxesLengthsThetaPhi() const
Access the Lengths along the cluster's principal axes [rad], sorted in descending order.
Definition Cluster.cc:140
std::size_t hits_size() const
Definition Cluster.cc:192
float getDispersion() const
Access the Cluster dispersion [mm].
Definition Cluster.cc:137
podio::RelationRange< edm4eic::Cluster > getClusters() const
Definition Cluster.cc:171
float getRadius() const
Access the Cluster radius [mm].
Definition Cluster.cc:136
const edm4eic::Cov2f & getIntrinsicDirectionError() const
Access the Error on the intrinsic cluster propagation direction.
Definition Cluster.cc:144
std::size_t subdetectorEnergies_size() const
Definition Cluster.cc:320
podio::RelationRange< edm4eic::CalorimeterHit > getHits() const
Definition Cluster.cc:203
std::size_t hitContributions_size() const
Definition Cluster.cc:288
float getIntrinsicPhi() const
Access the Intrinsic cluster propagation direction azimuthal angle [rad]. For an XY planar detector o...
Definition Cluster.cc:143
bool operator!=(const Cluster &other) const
Definition Cluster.h:179
friend class MutableCluster
Definition Cluster.h:51
std::size_t clusters_size() const
Definition Cluster.cc:160
const edm4eic::Cov3f & getPositionError() const
Access the Covariance matrix of the position (6 Parameters).
Definition Cluster.cc:135
std::vector< float >::const_iterator shapeParameters_begin() const
Definition Cluster.cc:244
Cluster()=default
default constructor
static constexpr std::string_view typeName
Definition Cluster.h:88
static Cluster makeEmpty()
Definition Cluster.cc:124
float getIntrinsicTheta() const
Access the Intrinsic cluster propagation direction polar angle [rad].
Definition Cluster.cc:142
float getTimeError() const
Access the Error on the cluster time.
Definition Cluster.cc:132
std::vector< edm4eic::CalorimeterHit >::const_iterator hits_end() const
Definition Cluster.cc:186
podio::ObjectID id() const
Definition Cluster.h:185
~Cluster()=default
destructor
std::int32_t getType() const
Access the Flag-word that defines the type of the cluster.
Definition Cluster.cc:128
Cluster & operator=(Cluster other) &
copy-assignment operator
Definition Cluster.cc:38
const std::array< float, 3 > & getPrincipalAxesLengthsXYZ() const
Access the Lengths along the cluster's principal axes [mm], sorted in descending order (equivalent to...
Definition Cluster.cc:138
std::size_t shapeParameters_size() const
Definition Cluster.cc:256
float getEnergy() const
Access the Reconstructed energy of the cluster [GeV].
Definition Cluster.cc:129
bool operator!=(const MutableCluster &other) const
Definition Cluster.h:180
ClusterCollection collection_type
Definition Cluster.h:59
const podio::ObjectID getObjectID() const
Definition Cluster.cc:347
std::vector< edm4eic::Cluster >::const_iterator clusters_end() const
Definition Cluster.cc:154
std::vector< edm4hep::ParticleID >::const_iterator particleIDs_end() const
Definition Cluster.cc:218
friend void swap(Cluster &a, Cluster &b)
Definition Cluster.h:191
std::vector< float >::const_iterator subdetectorEnergies_end() const
Definition Cluster.cc:314
Definition ClusterObj.h:21
Definition Cov2f.h:19
Definition Cov3f.h:19
Definition MutableCluster.h:41
Definition CalorimeterHit.cc:17
std::ostream & operator<<(std::ostream &o, const CalorimeterHit &value)
Definition CalorimeterHit.cc:99
Definition CalorimeterHit.h:31
OrderKey getOrderKey(const edm4eic::CalorimeterHit &obj)
Definition CalorimeterHit.cc:146
std::size_t operator()(const edm4eic::Cluster &obj) const
Definition Cluster.h:217