EDM4eic
EIC data model
Loading...
Searching...
No Matches
MCRecoParticleAssociationCollection.h
Go to the documentation of this file.
1// AUTOMATICALLY GENERATED FILE - DO NOT EDIT
2
3#ifndef EDM4EIC_MCRecoParticleAssociationCollection_H
4#define EDM4EIC_MCRecoParticleAssociationCollection_H
5
6// datamodel specific includes
11
12// podio specific includes
13#include "podio/ICollectionProvider.h"
14#include "podio/CollectionBase.h"
15#include "podio/detail/Pythonizations.h"
16#include "podio/utilities/TypeHelpers.h"
17
18#if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
19#include "nlohmann/json_fwd.hpp"
20#endif
21
22#include <string_view>
23#include <vector>
24#include <algorithm>
25#include <ostream>
26#include <mutex>
27#include <memory>
28#include <cstddef>
29
30namespace podio {
31 struct RelationNames;
32}
33
34namespace edm4eic {
35
36
37
39public:
41 using difference_type = ptrdiff_t;
44 using iterator_category = std::input_iterator_tag;
45 // `std::forward_iterator` is supported except that the pointers obtained with `operator->()`
46 // remain valid as long as the iterator is valid, not as long as the range is valid.
47 using iterator_concept = std::random_access_iterator_tag;
48
49 MCRecoParticleAssociationCollectionIterator(size_t index, const MCRecoParticleAssociationObjPointerContainer* collection) : m_index(index), m_object(podio::utils::MaybeSharedPtr<MCRecoParticleAssociationObj>{nullptr}), m_collection(collection) {}
51
57
58 constexpr auto operator<=>(const MCRecoParticleAssociationCollectionIterator& other) const {
59 return m_index <=> other.m_index;
60 }
61
63 return m_index == x.m_index;
64 }
65
66 reference operator*() const;
79
80private:
81 size_t m_index{0};
82 MCRecoParticleAssociation m_object { podio::utils::MaybeSharedPtr<MCRecoParticleAssociationObj>{nullptr} };
83 const MCRecoParticleAssociationObjPointerContainer* m_collection{nullptr};
84};
85
86
88public:
90 using difference_type = ptrdiff_t;
93 using iterator_category = std::input_iterator_tag;
94 // `std::forward_iterator` is supported except that the pointers obtained with `operator->()`
95 // remain valid as long as the iterator is valid, not as long as the range is valid.
96 using iterator_concept = std::random_access_iterator_tag;
97
98 MCRecoParticleAssociationMutableCollectionIterator(size_t index, const MCRecoParticleAssociationObjPointerContainer* collection) : m_index(index), m_object(podio::utils::MaybeSharedPtr<MCRecoParticleAssociationObj>{nullptr}), m_collection(collection) {}
100
106
108 return m_index <=> other.m_index;
109 }
110
112 return m_index == x.m_index;
113 }
114
115 reference operator*() const;
128
129private:
130 size_t m_index{0};
131 MutableMCRecoParticleAssociation m_object { podio::utils::MaybeSharedPtr<MCRecoParticleAssociationObj>{nullptr} };
132 const MCRecoParticleAssociationObjPointerContainer* m_collection{nullptr};
133};
134
135
136/**
137A Collection is identified by an ID.
138*/
139class MCRecoParticleAssociationCollection : public podio::CollectionBase {
140public:
145 using difference_type = ptrdiff_t;
146 using size_type = size_t;
147 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
148 using reverse_iterator = std::reverse_iterator<iterator>;
149
152 // This is a move-only type
157
159#if defined(__cpp_lib_containers_ranges)
160 template<podio::detail::RangeConvertibleTo<value_type> R>
161 MCRecoParticleAssociationCollection(std::from_range_t, R&& range);
162#endif
163
164 /// Construct a MCRecoParticleAssociation collection from a range of mutable or
165 /// immutable handles
166 template<podio::detail::RangeConvertibleTo<value_type> R>
168
169 constexpr static std::string_view typeName = "edm4eic::MCRecoParticleAssociationCollection";
170 constexpr static std::string_view valueTypeName = "edm4eic::MCRecoParticleAssociation";
171 constexpr static std::string_view dataTypeName = "edm4eic::MCRecoParticleAssociationData";
172
173 void clear() final;
174
175 /// Cppyy protocol to setup the pythonizations for this class. Not to be called directly.
176 static void __cppyy_pythonize__(PyObject* klass, const std::string& name){
177 podio::detail::pythonizations::pythonize_subscript(klass, name);
178 }
179
180 /// Print this collection to the passed stream
181 void print(std::ostream& os=std::cout, bool flush=true) const final;
182
183 /// Append a new object to the collection, and return this object.
185
186 /// Append a new object to the collection, and return this object.
187 /// Initialized with the parameters given
188 template<typename... Args>
190
191 /// number of elements in the collection
192 std::size_t size() const final;
193
194 /// maximal number of elements in the collection
195 std::size_t max_size() const final;
196
197 /// Is the collection empty
198 bool empty() const final;
199
200 /// fully qualified type name
201 const std::string_view getTypeName() const final { return typeName; }
202 /// fully qualified type name of elements - with namespace
203 const std::string_view getValueTypeName() const final { return valueTypeName; }
204 /// fully qualified type name of stored POD elements - with namespace
205 const std::string_view getDataTypeName() const final { return dataTypeName; }
206 /// schema version
207 podio::SchemaVersionT getSchemaVersion() const final;
208
209 bool isSubsetCollection() const final {
210 return m_isSubsetColl;
211 }
212
213 void setSubsetCollection(bool setSubset=true) final;
214
215 /// Returns the const object of given index
216 MCRecoParticleAssociation operator[](std::size_t index) const;
217 /// Returns the object of a given index
218 MutableMCRecoParticleAssociation operator[](std::size_t index);
219 /// Returns the const object of given index
220 MCRecoParticleAssociation at(std::size_t index) const;
221 /// Returns the object of given index
222 MutableMCRecoParticleAssociation at(std::size_t index);
223
224
225 /// Append object to the collection
227 /// Append an object to the (subset) collection
228 void push_back(const MCRecoParticleAssociation& object);
229
230 void prepareForWrite() const final;
231 void prepareAfterRead() final;
232 bool setReferences(const podio::ICollectionProvider* collectionProvider) final;
233
234 /// Get the collection buffers for this collection
235 podio::CollectionWriteBuffers getBuffers() final;
236
237 void setID(uint32_t ID) final {
238 m_collectionID = ID;
239 if (!m_isSubsetColl) {
240 std::for_each(m_storage.entries.begin(), m_storage.entries.end(),
241 [ID] (MCRecoParticleAssociationObj* obj) { obj->id = {obj->id.index, static_cast<uint32_t>(ID)}; }
242 );
243 }
244 }
245
246 uint32_t getID() const final {
247 return m_collectionID;
248 }
249
250 /// check if the collection has a valid ID
251 bool hasID() const final {
252 return getID() != static_cast<uint32_t>(podio::ObjectID::untracked) &&
253 getID() != static_cast<uint32_t>(podio::ObjectID::invalid);
254 }
255
256 [[deprecated("isValid will be removed, use hasID() if you want to check if it has an ID, otherwise assume the "
257 "collection is valid")]]
258 bool isValid() const final {
259 return hasID();
260 }
261
262 size_t getDatamodelRegistryIndex() const final;
263
264 // support for the iterator protocol
266 return iterator(0, &m_storage.entries);
267 }
269 return const_iterator(0, &m_storage.entries);
270 }
272 return begin();
273 }
275 return iterator(m_storage.entries.size(), &m_storage.entries);
276 }
278 return const_iterator(m_storage.entries.size(), &m_storage.entries);
279 }
281 return end();
282 }
283 // reverse iterators
285 return reverse_iterator(end());
286 }
291 return rbegin();
292 }
294 return reverse_iterator(begin());
295 }
300 return rend();
301 }
302
303
304 std::vector<float> weight(const size_t nElem = 0) const;
305
306private:
307 // For setReferences, we need to give our own CollectionData access to our
308 // private entries. Otherwise we would need to expose a public member function
309 // that gives access to the Obj* which is definitely not what we want
311
312 mutable bool m_isPrepared{false};
313 bool m_isSubsetColl{false};
314 uint32_t m_collectionID{static_cast<uint32_t>(podio::ObjectID::untracked)};
315 mutable std::unique_ptr<std::mutex> m_storageMtx{std::make_unique<std::mutex>()};
316 mutable MCRecoParticleAssociationCollectionData m_storage{};
317};
318
319std::ostream& operator<<(std::ostream& o, const MCRecoParticleAssociationCollection& v);
320
321template<typename... Args>
323 if (m_isSubsetColl) {
324 throw std::logic_error("Cannot create new elements on a subset collection");
325 }
326 auto obj = new MCRecoParticleAssociationObj({static_cast<int>(m_storage.entries.size()), m_collectionID}, {std::forward<Args>(args)...});
327 m_storage.entries.push_back(obj);
328
329 return MutableMCRecoParticleAssociation(podio::utils::MaybeSharedPtr(obj));
330}
331
332
333#if defined(__cpp_lib_containers_ranges)
334template<podio::detail::RangeConvertibleTo<MCRecoParticleAssociationCollection::value_type> R>
337 setSubsetCollection(podio::detail::RangeOf<R, value_type>);
338
339 for (auto&& elem : range) {
340 push_back(std::forward<decltype(elem)>(elem));
341 }
342}
343#endif
344
345template<podio::detail::RangeConvertibleTo<MCRecoParticleAssociationCollection::value_type> R>
348 if constexpr (podio::detail::RangeOf<R, value_type>) {
349 coll.setSubsetCollection();
350 }
351
352 for (auto&& elem : range) {
353 coll.push_back(std::forward<decltype(elem)>(elem));
354 }
355
356 return coll;
357}
358
359
360#if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
361void to_json(nlohmann::json& j, const MCRecoParticleAssociationCollection& collection);
362#endif
363
364} // namespace edm4eic
365
366
367// This is needed to avoid triggering opening every library in LD_LIBRARY_PATH
368// until it's fixed in ROOT. See https://github.com/root-project/root/issues/18489
369// and https://github.com/AIDASoft/podio/issues/770
370#if defined(__clang__)
371 #pragma clang diagnostic push
372 #pragma clang diagnostic ignored "-Wunknown-warning-option"
373 #pragma clang diagnostic ignored "-Wdeprecated-redundant-constexpr-static-def"
374 #pragma clang diagnostic ignored "-Wdeprecated"
378 #pragma clang diagnostic pop
379#elif defined(__GNUC__)
380 #pragma GCC diagnostic push
381 #pragma GCC diagnostic ignored "-Wdeprecated"
385 #pragma GCC diagnostic pop
386#endif
387
388
389#endif
Definition MCRecoParticleAssociationCollectionData.h:33
Definition MCRecoParticleAssociationCollection.h:139
podio::CollectionWriteBuffers getBuffers() final
Get the collection buffers for this collection.
Definition MCRecoParticleAssociationCollection.cc:153
const std::string_view getTypeName() const final
fully qualified type name
Definition MCRecoParticleAssociationCollection.h:201
const_reverse_iterator rbegin() const
Definition MCRecoParticleAssociationCollection.h:287
MCRecoParticleAssociation at(std::size_t index) const
Returns the const object of given index.
Definition MCRecoParticleAssociationCollection.cc:37
iterator end()
Definition MCRecoParticleAssociationCollection.h:274
MCRecoParticleAssociationCollection & operator=(const MCRecoParticleAssociationCollection &)=delete
MCRecoParticleAssociationCollection & operator=(MCRecoParticleAssociationCollection &&)=default
reverse_iterator rend()
Definition MCRecoParticleAssociationCollection.h:293
const_iterator cend() const
Definition MCRecoParticleAssociationCollection.h:280
const std::string_view getValueTypeName() const final
fully qualified type name of elements - with namespace
Definition MCRecoParticleAssociationCollection.h:203
const_iterator end() const
Definition MCRecoParticleAssociationCollection.h:277
~MCRecoParticleAssociationCollection() override
Definition MCRecoParticleAssociationCollection.cc:28
bool isSubsetCollection() const final
Definition MCRecoParticleAssociationCollection.h:209
bool setReferences(const podio::ICollectionProvider *collectionProvider) final
Definition MCRecoParticleAssociationCollection.cc:118
MutableMCRecoParticleAssociation mutable_type
Definition MCRecoParticleAssociationCollection.h:142
reverse_iterator rbegin()
Definition MCRecoParticleAssociationCollection.h:284
MCRecoParticleAssociationMutableCollectionIterator iterator
Definition MCRecoParticleAssociationCollection.h:144
const_reverse_iterator rend() const
Definition MCRecoParticleAssociationCollection.h:296
static constexpr std::string_view dataTypeName
Definition MCRecoParticleAssociationCollection.h:171
ptrdiff_t difference_type
Definition MCRecoParticleAssociationCollection.h:145
MCRecoParticleAssociationCollection(const MCRecoParticleAssociationCollection &)=delete
MCRecoParticleAssociationCollection(MCRecoParticleAssociationCollection &&)=default
bool isValid() const final
Definition MCRecoParticleAssociationCollection.h:258
std::reverse_iterator< iterator > reverse_iterator
Definition MCRecoParticleAssociationCollection.h:148
bool empty() const final
Is the collection empty.
Definition MCRecoParticleAssociationCollection.cc:63
std::size_t max_size() const final
maximal number of elements in the collection
Definition MCRecoParticleAssociationCollection.cc:53
void push_back(const MutableMCRecoParticleAssociation &object)
Append object to the collection.
Definition MCRecoParticleAssociationCollection.cc:122
MutableMCRecoParticleAssociation create()
Append a new object to the collection, and return this object.
Definition MCRecoParticleAssociationCollection.cc:78
static constexpr std::string_view valueTypeName
Definition MCRecoParticleAssociationCollection.h:170
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition MCRecoParticleAssociationCollection.h:147
friend class MCRecoParticleAssociationCollectionData
Definition MCRecoParticleAssociationCollection.h:310
void setSubsetCollection(bool setSubset=true) final
Definition MCRecoParticleAssociationCollection.cc:67
const std::string_view getDataTypeName() const final
fully qualified type name of stored POD elements - with namespace
Definition MCRecoParticleAssociationCollection.h:205
iterator begin()
Definition MCRecoParticleAssociationCollection.h:265
void prepareAfterRead() final
Definition MCRecoParticleAssociationCollection.cc:103
MCRecoParticleAssociation value_type
Definition MCRecoParticleAssociationCollection.h:141
const_iterator cbegin() const
Definition MCRecoParticleAssociationCollection.h:271
bool hasID() const final
check if the collection has a valid ID
Definition MCRecoParticleAssociationCollection.h:251
size_t size_type
Definition MCRecoParticleAssociationCollection.h:146
void clear() final
Definition MCRecoParticleAssociationCollection.cc:89
uint32_t getID() const final
Definition MCRecoParticleAssociationCollection.h:246
static void __cppyy_pythonize__(PyObject *klass, const std::string &name)
Cppyy protocol to setup the pythonizations for this class. Not to be called directly.
Definition MCRecoParticleAssociationCollection.h:176
void setID(uint32_t ID) final
Definition MCRecoParticleAssociationCollection.h:237
static constexpr std::string_view typeName
Definition MCRecoParticleAssociationCollection.h:169
std::size_t size() const final
number of elements in the collection
Definition MCRecoParticleAssociationCollection.cc:49
static MCRecoParticleAssociationCollection from(R &&range)
Definition MCRecoParticleAssociationCollection.h:346
podio::SchemaVersionT getSchemaVersion() const final
schema version
Definition MCRecoParticleAssociationCollection.cc:172
const_iterator begin() const
Definition MCRecoParticleAssociationCollection.h:268
MCRecoParticleAssociationCollectionIterator const_iterator
Definition MCRecoParticleAssociationCollection.h:143
void print(std::ostream &os=std::cout, bool flush=true) const final
Print this collection to the passed stream.
Definition MCRecoParticleAssociationCollection.cc:426
const_reverse_iterator crend() const
Definition MCRecoParticleAssociationCollection.h:299
const_reverse_iterator crbegin() const
Definition MCRecoParticleAssociationCollection.h:290
void prepareForWrite() const final
Definition MCRecoParticleAssociationCollection.cc:94
Definition MCRecoParticleAssociationCollection.h:38
MCRecoParticleAssociationCollectionIterator & operator--()
Definition MCRecoParticleAssociationCollection.cc:290
MCRecoParticleAssociationCollectionIterator & operator=(MCRecoParticleAssociationCollectionIterator &&)=default
pointer operator->()
Definition MCRecoParticleAssociationCollection.cc:274
MCRecoParticleAssociation reference
Definition MCRecoParticleAssociationCollection.h:42
MCRecoParticleAssociationCollectionIterator operator+(difference_type n) const
Definition MCRecoParticleAssociationCollection.cc:306
MCRecoParticleAssociationCollectionIterator(const MCRecoParticleAssociationCollectionIterator &)=default
ptrdiff_t difference_type
Definition MCRecoParticleAssociationCollection.h:41
MCRecoParticleAssociationCollectionIterator(MCRecoParticleAssociationCollectionIterator &&)=default
reference operator*() const
Definition MCRecoParticleAssociationCollection.cc:270
MCRecoParticleAssociationCollectionIterator operator-(difference_type n) const
Definition MCRecoParticleAssociationCollection.cc:321
MCRecoParticleAssociation * pointer
Definition MCRecoParticleAssociationCollection.h:43
constexpr auto operator<=>(const MCRecoParticleAssociationCollectionIterator &other) const
Definition MCRecoParticleAssociationCollection.h:58
reference operator[](difference_type n) const
Definition MCRecoParticleAssociationCollection.cc:327
std::random_access_iterator_tag iterator_concept
Definition MCRecoParticleAssociationCollection.h:47
MCRecoParticleAssociationCollectionIterator & operator+=(difference_type n)
Definition MCRecoParticleAssociationCollection.cc:301
MCRecoParticleAssociationCollectionIterator & operator=(const MCRecoParticleAssociationCollectionIterator &)=default
MCRecoParticleAssociationCollectionIterator(size_t index, const MCRecoParticleAssociationObjPointerContainer *collection)
Definition MCRecoParticleAssociationCollection.h:49
constexpr bool operator==(const MCRecoParticleAssociationCollectionIterator &x) const
Definition MCRecoParticleAssociationCollection.h:62
MCRecoParticleAssociation value_type
Definition MCRecoParticleAssociationCollection.h:40
MCRecoParticleAssociationCollectionIterator & operator++()
Definition MCRecoParticleAssociationCollection.cc:279
std::input_iterator_tag iterator_category
Definition MCRecoParticleAssociationCollection.h:44
MCRecoParticleAssociationCollectionIterator & operator-=(difference_type n)
Definition MCRecoParticleAssociationCollection.cc:316
Definition MCRecoParticleAssociation.h:48
Definition MCRecoParticleAssociationCollection.h:87
constexpr bool operator==(const MCRecoParticleAssociationMutableCollectionIterator &x) const
Definition MCRecoParticleAssociationCollection.h:111
reference operator*() const
Definition MCRecoParticleAssociationCollection.cc:337
MCRecoParticleAssociationMutableCollectionIterator & operator--()
Definition MCRecoParticleAssociationCollection.cc:357
MCRecoParticleAssociationMutableCollectionIterator & operator-=(difference_type n)
Definition MCRecoParticleAssociationCollection.cc:383
MCRecoParticleAssociationMutableCollectionIterator & operator+=(difference_type n)
Definition MCRecoParticleAssociationCollection.cc:368
MCRecoParticleAssociationMutableCollectionIterator(MCRecoParticleAssociationMutableCollectionIterator &&)=default
MutableMCRecoParticleAssociation reference
Definition MCRecoParticleAssociationCollection.h:91
std::random_access_iterator_tag iterator_concept
Definition MCRecoParticleAssociationCollection.h:96
pointer operator->()
Definition MCRecoParticleAssociationCollection.cc:341
MCRecoParticleAssociation value_type
Definition MCRecoParticleAssociationCollection.h:89
reference operator[](difference_type n) const
Definition MCRecoParticleAssociationCollection.cc:394
ptrdiff_t difference_type
Definition MCRecoParticleAssociationCollection.h:90
MCRecoParticleAssociationMutableCollectionIterator(const MCRecoParticleAssociationMutableCollectionIterator &)=default
MCRecoParticleAssociationMutableCollectionIterator & operator++()
Definition MCRecoParticleAssociationCollection.cc:346
MCRecoParticleAssociationMutableCollectionIterator & operator=(MCRecoParticleAssociationMutableCollectionIterator &&)=default
MCRecoParticleAssociationMutableCollectionIterator(size_t index, const MCRecoParticleAssociationObjPointerContainer *collection)
Definition MCRecoParticleAssociationCollection.h:98
MCRecoParticleAssociationMutableCollectionIterator operator+(difference_type n) const
Definition MCRecoParticleAssociationCollection.cc:373
constexpr auto operator<=>(const MCRecoParticleAssociationMutableCollectionIterator &other) const
Definition MCRecoParticleAssociationCollection.h:107
MCRecoParticleAssociationMutableCollectionIterator & operator=(const MCRecoParticleAssociationMutableCollectionIterator &)=default
std::input_iterator_tag iterator_category
Definition MCRecoParticleAssociationCollection.h:93
MutableMCRecoParticleAssociation * pointer
Definition MCRecoParticleAssociationCollection.h:92
MCRecoParticleAssociationMutableCollectionIterator operator-(difference_type n) const
Definition MCRecoParticleAssociationCollection.cc:388
Definition MCRecoParticleAssociationObj.h:24
Definition MutableMCRecoParticleAssociation.h:40
Definition ArrowMapper.cc:61
std::ostream & operator<<(std::ostream &o, const CalorimeterHit &value)
Definition CalorimeterHit.cc:99
std::deque< MCRecoParticleAssociationObj * > MCRecoParticleAssociationObjPointerContainer
Definition MCRecoParticleAssociationCollectionData.h:25
Definition CalorimeterHit.h:31