EDM4eic
EIC data model
Loading...
Searching...
No Matches
CherenkovParticleIDCollection.h
Go to the documentation of this file.
1// AUTOMATICALLY GENERATED FILE - DO NOT EDIT
2
3#ifndef EDM4EIC_CherenkovParticleIDCollection_H
4#define EDM4EIC_CherenkovParticleIDCollection_H
5
6// datamodel specific includes
11
12// podio specific includes
13#include "podio/ICollectionProvider.h"
14#include "podio/CollectionBase.h"
15
16#if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
17#include "nlohmann/json_fwd.hpp"
18#endif
19
20#include <string_view>
21#include <vector>
22#include <algorithm>
23#include <ostream>
24#include <mutex>
25#include <memory>
26#include <cstddef>
27
28namespace podio {
29 struct RelationNames;
30}
31
32namespace edm4eic {
33
34
35
37public:
39 using difference_type = ptrdiff_t;
42 using iterator_category = std::input_iterator_tag;
43 // `std::forward_iterator` is supported except that the pointers obtained with `operator->()`
44 // remain valid as long as the iterator is valid, not as long as the range is valid.
45 using iterator_concept = std::random_access_iterator_tag;
46
47 CherenkovParticleIDCollectionIterator(size_t index, const CherenkovParticleIDObjPointerContainer* collection) : m_index(index), m_object(podio::utils::MaybeSharedPtr<CherenkovParticleIDObj>{nullptr}), m_collection(collection) {}
49
55
57 return m_index <=> other.m_index;
58 }
59
61 return m_index == x.m_index;
62 }
63
64 reference operator*() const;
77
78private:
79 size_t m_index{0};
80 CherenkovParticleID m_object { podio::utils::MaybeSharedPtr<CherenkovParticleIDObj>{nullptr} };
81 const CherenkovParticleIDObjPointerContainer* m_collection{nullptr};
82};
83
84
86public:
88 using difference_type = ptrdiff_t;
91 using iterator_category = std::input_iterator_tag;
92 // `std::forward_iterator` is supported except that the pointers obtained with `operator->()`
93 // remain valid as long as the iterator is valid, not as long as the range is valid.
94 using iterator_concept = std::random_access_iterator_tag;
95
96 CherenkovParticleIDMutableCollectionIterator(size_t index, const CherenkovParticleIDObjPointerContainer* collection) : m_index(index), m_object(podio::utils::MaybeSharedPtr<CherenkovParticleIDObj>{nullptr}), m_collection(collection) {}
98
104
106 return m_index <=> other.m_index;
107 }
108
110 return m_index == x.m_index;
111 }
112
113 reference operator*() const;
126
127private:
128 size_t m_index{0};
129 MutableCherenkovParticleID m_object { podio::utils::MaybeSharedPtr<CherenkovParticleIDObj>{nullptr} };
130 const CherenkovParticleIDObjPointerContainer* m_collection{nullptr};
131};
132
133
134/**
135A Collection is identified by an ID.
136*/
137class CherenkovParticleIDCollection : public podio::CollectionBase {
138public:
143 using difference_type = ptrdiff_t;
144 using size_type = size_t;
145 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
146 using reverse_iterator = std::reverse_iterator<iterator>;
147
150 // This is a move-only type
155
156// CherenkovParticleIDCollection(CherenkovParticleIDVector* data, uint32_t collectionID);
158
159 constexpr static std::string_view typeName = "edm4eic::CherenkovParticleIDCollection";
160 constexpr static std::string_view valueTypeName = "edm4eic::CherenkovParticleID";
161 constexpr static std::string_view dataTypeName = "edm4eic::CherenkovParticleIDData";
162
163 void clear() final;
164
165 /// Print this collection to the passed stream
166 void print(std::ostream& os=std::cout, bool flush=true) const final;
167
168 /// operator to allow pointer like calling of members a la LCIO
169 CherenkovParticleIDCollection* operator->() { return static_cast<CherenkovParticleIDCollection*>(this); }
170
171 /// Append a new object to the collection, and return this object.
173
174 /// Append a new object to the collection, and return this object.
175 /// Initialized with the parameters given
176 template<typename... Args>
177 MutableCherenkovParticleID create(Args&&... args);
178
179 /// number of elements in the collection
180 std::size_t size() const final;
181
182 /// maximal number of elements in the collection
183 std::size_t max_size() const final;
184
185 /// Is the collection empty
186 bool empty() const final;
187
188 /// fully qualified type name
189 const std::string_view getTypeName() const final { return typeName; }
190 /// fully qualified type name of elements - with namespace
191 const std::string_view getValueTypeName() const final { return valueTypeName; }
192 /// fully qualified type name of stored POD elements - with namespace
193 const std::string_view getDataTypeName() const final { return dataTypeName; }
194 /// schema version
195 podio::SchemaVersionT getSchemaVersion() const final;
196
197 bool isSubsetCollection() const final {
198 return m_isSubsetColl;
199 }
200
201 void setSubsetCollection(bool setSubset=true) final;
202
203 /// Returns the const object of given index
204 CherenkovParticleID operator[](std::size_t index) const;
205 /// Returns the object of a given index
206 MutableCherenkovParticleID operator[](std::size_t index);
207 /// Returns the const object of given index
208 CherenkovParticleID at(std::size_t index) const;
209 /// Returns the object of given index
210 MutableCherenkovParticleID at(std::size_t index);
211
212
213 /// Append object to the collection
214 void push_back(const MutableCherenkovParticleID& object);
215 /// Append an object to the (subset) collection
216 void push_back(const CherenkovParticleID& object);
217
218 void prepareForWrite() const final;
219 void prepareAfterRead() final;
220 bool setReferences(const podio::ICollectionProvider* collectionProvider) final;
221
222 /// Get the collection buffers for this collection
223 podio::CollectionWriteBuffers getBuffers() final;
224
225 void setID(uint32_t ID) final {
226 m_collectionID = ID;
227 if (!m_isSubsetColl) {
228 std::for_each(m_storage.entries.begin(), m_storage.entries.end(),
229 [ID] (CherenkovParticleIDObj* obj) { obj->id = {obj->id.index, static_cast<uint32_t>(ID)}; }
230 );
231 }
232 m_isValid = true;
233 }
234
235 uint32_t getID() const final {
236 return m_collectionID;
237 }
238
239 bool isValid() const final {
240 return m_isValid;
241 }
242
243 size_t getDatamodelRegistryIndex() const final;
244
245 // support for the iterator protocol
247 return iterator(0, &m_storage.entries);
248 }
250 return const_iterator(0, &m_storage.entries);
251 }
253 return begin();
254 }
256 return iterator(m_storage.entries.size(), &m_storage.entries);
257 }
259 return const_iterator(m_storage.entries.size(), &m_storage.entries);
260 }
262 return end();
263 }
264 // reverse iterators
266 return reverse_iterator(end());
267 }
272 return rbegin();
273 }
275 return reverse_iterator(begin());
276 }
281 return rend();
282 }
283
284
285 std::vector<float> npe(const size_t nElem = 0) const;
286 std::vector<float> refractiveIndex(const size_t nElem = 0) const;
287 std::vector<float> photonEnergy(const size_t nElem = 0) const;
288
289private:
290 // For setReferences, we need to give our own CollectionData access to our
291 // private entries. Otherwise we would need to expose a public member function
292 // that gives access to the Obj* which is definitely not what we want
294
295 bool m_isValid{false};
296 mutable bool m_isPrepared{false};
297 bool m_isSubsetColl{false};
298 uint32_t m_collectionID{0};
299 mutable std::unique_ptr<std::mutex> m_storageMtx{nullptr};
300 mutable CherenkovParticleIDCollectionData m_storage{};
301};
302
303std::ostream& operator<<(std::ostream& o, const CherenkovParticleIDCollection& v);
304
305template<typename... Args>
307 if (m_isSubsetColl) {
308 throw std::logic_error("Cannot create new elements on a subset collection");
309 }
310 const int size = m_storage.entries.size();
311 auto obj = new CherenkovParticleIDObj({size, m_collectionID}, {std::forward<Args>(args)...});
312 m_storage.entries.push_back(obj);
313
314 // Need to initialize the relation vectors manually for the {ObjectID, CherenkovParticleIDData} constructor
315 obj->m_rawHitAssociations = new std::vector<edm4eic::MCRecoTrackerHitAssociation>();
316 obj->m_hypotheses = new std::vector<edm4eic::CherenkovParticleIDHypothesis>();
317 obj->m_thetaPhiPhotons = new std::vector<edm4hep::Vector2f>();
318 m_storage.createRelations(obj);
319 return MutableCherenkovParticleID(podio::utils::MaybeSharedPtr(obj));
320}
321
322#if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
323void to_json(nlohmann::json& j, const CherenkovParticleIDCollection& collection);
324#endif
325
326} // namespace edm4eic
327
328
329#endif
Definition CherenkovParticleIDCollectionData.h:32
Definition CherenkovParticleIDCollection.h:137
void push_back(const MutableCherenkovParticleID &object)
Append object to the collection.
Definition CherenkovParticleIDCollection.cc:127
const_reverse_iterator crbegin() const
Definition CherenkovParticleIDCollection.h:271
const_reverse_iterator rend() const
Definition CherenkovParticleIDCollection.h:277
static constexpr std::string_view valueTypeName
Definition CherenkovParticleIDCollection.h:160
reverse_iterator rend()
Definition CherenkovParticleIDCollection.h:274
void clear() final
Definition CherenkovParticleIDCollection.cc:94
std::reverse_iterator< iterator > reverse_iterator
Definition CherenkovParticleIDCollection.h:146
CherenkovParticleIDCollection()
Definition CherenkovParticleIDCollection.cc:26
const_iterator begin() const
Definition CherenkovParticleIDCollection.h:249
const_iterator end() const
Definition CherenkovParticleIDCollection.h:258
bool isValid() const final
Definition CherenkovParticleIDCollection.h:239
CherenkovParticleIDCollection & operator=(CherenkovParticleIDCollection &&)=default
void prepareForWrite() const final
Definition CherenkovParticleIDCollection.cc:99
void setID(uint32_t ID) final
Definition CherenkovParticleIDCollection.h:225
uint32_t getID() const final
Definition CherenkovParticleIDCollection.h:235
podio::CollectionWriteBuffers getBuffers() final
Get the collection buffers for this collection.
Definition CherenkovParticleIDCollection.cc:160
const_reverse_iterator rbegin() const
Definition CherenkovParticleIDCollection.h:268
const_iterator cbegin() const
Definition CherenkovParticleIDCollection.h:252
const_reverse_iterator crend() const
Definition CherenkovParticleIDCollection.h:280
void setSubsetCollection(bool setSubset=true) final
Definition CherenkovParticleIDCollection.cc:71
std::size_t size() const final
number of elements in the collection
Definition CherenkovParticleIDCollection.cc:53
CherenkovParticleID value_type
Definition CherenkovParticleIDCollection.h:139
void print(std::ostream &os=std::cout, bool flush=true) const final
Print this collection to the passed stream.
Definition CherenkovParticleIDCollection.cc:479
bool setReferences(const podio::ICollectionProvider *collectionProvider) final
Definition CherenkovParticleIDCollection.cc:123
CherenkovParticleIDMutableCollectionIterator iterator
Definition CherenkovParticleIDCollection.h:142
const std::string_view getDataTypeName() const final
fully qualified type name of stored POD elements - with namespace
Definition CherenkovParticleIDCollection.h:193
static constexpr std::string_view dataTypeName
Definition CherenkovParticleIDCollection.h:161
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition CherenkovParticleIDCollection.h:145
const std::string_view getValueTypeName() const final
fully qualified type name of elements - with namespace
Definition CherenkovParticleIDCollection.h:191
const std::string_view getTypeName() const final
fully qualified type name
Definition CherenkovParticleIDCollection.h:189
MutableCherenkovParticleID create()
Append a new object to the collection, and return this object.
Definition CherenkovParticleIDCollection.cc:82
std::size_t max_size() const final
maximal number of elements in the collection
Definition CherenkovParticleIDCollection.cc:57
CherenkovParticleIDCollection(CherenkovParticleIDCollection &&)=default
CherenkovParticleID at(std::size_t index) const
Returns the const object of given index.
Definition CherenkovParticleIDCollection.cc:41
~CherenkovParticleIDCollection() override
Definition CherenkovParticleIDCollection.cc:32
void prepareAfterRead() final
Definition CherenkovParticleIDCollection.cc:108
CherenkovParticleIDCollection(const CherenkovParticleIDCollection &)=delete
iterator begin()
Definition CherenkovParticleIDCollection.h:246
static constexpr std::string_view typeName
Definition CherenkovParticleIDCollection.h:159
const_iterator cend() const
Definition CherenkovParticleIDCollection.h:261
size_t size_type
Definition CherenkovParticleIDCollection.h:144
ptrdiff_t difference_type
Definition CherenkovParticleIDCollection.h:143
bool isSubsetCollection() const final
Definition CherenkovParticleIDCollection.h:197
CherenkovParticleIDCollectionIterator const_iterator
Definition CherenkovParticleIDCollection.h:141
podio::SchemaVersionT getSchemaVersion() const final
schema version
Definition CherenkovParticleIDCollection.cc:199
iterator end()
Definition CherenkovParticleIDCollection.h:255
MutableCherenkovParticleID mutable_type
Definition CherenkovParticleIDCollection.h:140
CherenkovParticleIDCollection & operator=(const CherenkovParticleIDCollection &)=delete
bool empty() const final
Is the collection empty.
Definition CherenkovParticleIDCollection.cc:67
friend class CherenkovParticleIDCollectionData
Definition CherenkovParticleIDCollection.h:293
reverse_iterator rbegin()
Definition CherenkovParticleIDCollection.h:265
Definition CherenkovParticleIDCollection.h:36
ptrdiff_t difference_type
Definition CherenkovParticleIDCollection.h:39
CherenkovParticleIDCollectionIterator operator+(difference_type n) const
Definition CherenkovParticleIDCollection.cc:344
CherenkovParticleID reference
Definition CherenkovParticleIDCollection.h:40
CherenkovParticleIDCollectionIterator & operator+=(difference_type n)
Definition CherenkovParticleIDCollection.cc:339
CherenkovParticleIDCollectionIterator & operator-=(difference_type n)
Definition CherenkovParticleIDCollection.cc:354
CherenkovParticleIDCollectionIterator(const CherenkovParticleIDCollectionIterator &)=default
bool operator==(const CherenkovParticleIDCollectionIterator &x) const
Definition CherenkovParticleIDCollection.h:60
CherenkovParticleID value_type
Definition CherenkovParticleIDCollection.h:38
CherenkovParticleIDCollectionIterator(CherenkovParticleIDCollectionIterator &&)=default
auto operator<=>(const CherenkovParticleIDCollectionIterator &other) const
Definition CherenkovParticleIDCollection.h:56
pointer operator->()
Definition CherenkovParticleIDCollection.cc:312
CherenkovParticleIDCollectionIterator(size_t index, const CherenkovParticleIDObjPointerContainer *collection)
Definition CherenkovParticleIDCollection.h:47
reference operator[](difference_type n) const
Definition CherenkovParticleIDCollection.cc:365
CherenkovParticleIDCollectionIterator & operator++()
Definition CherenkovParticleIDCollection.cc:317
CherenkovParticleIDCollectionIterator & operator=(CherenkovParticleIDCollectionIterator &&)=default
CherenkovParticleIDCollectionIterator & operator--()
Definition CherenkovParticleIDCollection.cc:328
CherenkovParticleIDCollectionIterator operator-(difference_type n) const
Definition CherenkovParticleIDCollection.cc:359
reference operator*() const
Definition CherenkovParticleIDCollection.cc:308
std::random_access_iterator_tag iterator_concept
Definition CherenkovParticleIDCollection.h:45
std::input_iterator_tag iterator_category
Definition CherenkovParticleIDCollection.h:42
CherenkovParticleID * pointer
Definition CherenkovParticleIDCollection.h:41
CherenkovParticleIDCollectionIterator & operator=(const CherenkovParticleIDCollectionIterator &)=default
Definition CherenkovParticleID.h:46
Definition CherenkovParticleIDCollection.h:85
CherenkovParticleIDMutableCollectionIterator & operator++()
Definition CherenkovParticleIDCollection.cc:384
CherenkovParticleID value_type
Definition CherenkovParticleIDCollection.h:87
MutableCherenkovParticleID * pointer
Definition CherenkovParticleIDCollection.h:90
std::random_access_iterator_tag iterator_concept
Definition CherenkovParticleIDCollection.h:94
CherenkovParticleIDMutableCollectionIterator & operator=(CherenkovParticleIDMutableCollectionIterator &&)=default
CherenkovParticleIDMutableCollectionIterator(const CherenkovParticleIDMutableCollectionIterator &)=default
bool operator==(const CherenkovParticleIDMutableCollectionIterator &x) const
Definition CherenkovParticleIDCollection.h:109
CherenkovParticleIDMutableCollectionIterator operator+(difference_type n) const
Definition CherenkovParticleIDCollection.cc:411
CherenkovParticleIDMutableCollectionIterator(size_t index, const CherenkovParticleIDObjPointerContainer *collection)
Definition CherenkovParticleIDCollection.h:96
pointer operator->()
Definition CherenkovParticleIDCollection.cc:379
CherenkovParticleIDMutableCollectionIterator & operator--()
Definition CherenkovParticleIDCollection.cc:395
MutableCherenkovParticleID reference
Definition CherenkovParticleIDCollection.h:89
reference operator*() const
Definition CherenkovParticleIDCollection.cc:375
reference operator[](difference_type n) const
Definition CherenkovParticleIDCollection.cc:432
ptrdiff_t difference_type
Definition CherenkovParticleIDCollection.h:88
CherenkovParticleIDMutableCollectionIterator & operator+=(difference_type n)
Definition CherenkovParticleIDCollection.cc:406
CherenkovParticleIDMutableCollectionIterator operator-(difference_type n) const
Definition CherenkovParticleIDCollection.cc:426
CherenkovParticleIDMutableCollectionIterator & operator-=(difference_type n)
Definition CherenkovParticleIDCollection.cc:421
CherenkovParticleIDMutableCollectionIterator(CherenkovParticleIDMutableCollectionIterator &&)=default
auto operator<=>(const CherenkovParticleIDMutableCollectionIterator &other) const
Definition CherenkovParticleIDCollection.h:105
std::input_iterator_tag iterator_category
Definition CherenkovParticleIDCollection.h:91
CherenkovParticleIDMutableCollectionIterator & operator=(const CherenkovParticleIDMutableCollectionIterator &)=default
Definition CherenkovParticleIDObj.h:26
std::vector< edm4eic::MCRecoTrackerHitAssociation > * m_rawHitAssociations
Definition CherenkovParticleIDObj.h:43
Definition MutableCherenkovParticleID.h:38
Definition CalorimeterHit.cc:17
std::ostream & operator<<(std::ostream &o, const CalorimeterHit &value)
Definition CalorimeterHit.cc:103
std::deque< CherenkovParticleIDObj * > CherenkovParticleIDObjPointerContainer
Definition CherenkovParticleIDCollectionData.h:24
Definition CalorimeterHit.h:31