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