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
17#if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
18#include "nlohmann/json_fwd.hpp"
19#endif
20
21#include <string_view>
22#include <vector>
23#include <algorithm>
24#include <ostream>
25#include <mutex>
26#include <memory>
27#include <cstddef>
28
29namespace podio {
30 struct RelationNames;
31}
32
33namespace edm4eic {
34
35
36
38public:
40 using difference_type = ptrdiff_t;
43 using iterator_category = std::input_iterator_tag;
44 // `std::forward_iterator` is supported except that the pointers obtained with `operator->()`
45 // remain valid as long as the iterator is valid, not as long as the range is valid.
46 using iterator_concept = std::random_access_iterator_tag;
47
48 TrackSeedCollectionIterator(size_t index, const TrackSeedObjPointerContainer* collection) : m_index(index), m_object(podio::utils::MaybeSharedPtr<TrackSeedObj>{nullptr}), m_collection(collection) {}
50
56
57 auto operator<=>(const TrackSeedCollectionIterator& other) const {
58 return m_index <=> other.m_index;
59 }
60
62 return m_index == x.m_index;
63 }
64
65 reference operator*() const;
78
79private:
80 size_t m_index{0};
81 TrackSeed m_object { podio::utils::MaybeSharedPtr<TrackSeedObj>{nullptr} };
82 const TrackSeedObjPointerContainer* m_collection{nullptr};
83};
84
85
87public:
89 using difference_type = ptrdiff_t;
92 using iterator_category = std::input_iterator_tag;
93 // `std::forward_iterator` is supported except that the pointers obtained with `operator->()`
94 // remain valid as long as the iterator is valid, not as long as the range is valid.
95 using iterator_concept = std::random_access_iterator_tag;
96
97 TrackSeedMutableCollectionIterator(size_t index, const TrackSeedObjPointerContainer* collection) : m_index(index), m_object(podio::utils::MaybeSharedPtr<TrackSeedObj>{nullptr}), m_collection(collection) {}
99
105
107 return m_index <=> other.m_index;
108 }
109
111 return m_index == x.m_index;
112 }
113
114 reference operator*() const;
127
128private:
129 size_t m_index{0};
130 MutableTrackSeed m_object { podio::utils::MaybeSharedPtr<TrackSeedObj>{nullptr} };
131 const TrackSeedObjPointerContainer* m_collection{nullptr};
132};
133
134
135/**
136A Collection is identified by an ID.
137*/
138class TrackSeedCollection : public podio::CollectionBase {
139public:
144 using difference_type = ptrdiff_t;
145 using size_type = size_t;
146 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
147 using reverse_iterator = std::reverse_iterator<iterator>;
148
150 TrackSeedCollection(TrackSeedCollectionData&& data, bool isSubsetColl);
151 // This is a move-only type
156
157// TrackSeedCollection(TrackSeedVector* data, uint32_t collectionID);
158 ~TrackSeedCollection() override;
159
160 constexpr static std::string_view typeName = "edm4eic::TrackSeedCollection";
161 constexpr static std::string_view valueTypeName = "edm4eic::TrackSeed";
162 constexpr static std::string_view dataTypeName = "edm4eic::TrackSeedData";
163
164 void clear() final;
165
166 /// Cppyy protocol to setup the pythonizations for this class. Not to be called directly.
167 static void __cppyy_pythonize__(PyObject* klass, const std::string& name){
168 podio::detail::pythonizations::pythonize_subscript(klass, name);
169 }
170
171 /// Print this collection to the passed stream
172 void print(std::ostream& os=std::cout, bool flush=true) const final;
173
174 /// Append a new object to the collection, and return this object.
176
177 /// Append a new object to the collection, and return this object.
178 /// Initialized with the parameters given
179 template<typename... Args>
180 MutableTrackSeed create(Args&&... args);
181
182 /// number of elements in the collection
183 std::size_t size() const final;
184
185 /// maximal number of elements in the collection
186 std::size_t max_size() const final;
187
188 /// Is the collection empty
189 bool empty() const final;
190
191 /// fully qualified type name
192 const std::string_view getTypeName() const final { return typeName; }
193 /// fully qualified type name of elements - with namespace
194 const std::string_view getValueTypeName() const final { return valueTypeName; }
195 /// fully qualified type name of stored POD elements - with namespace
196 const std::string_view getDataTypeName() const final { return dataTypeName; }
197 /// schema version
198 podio::SchemaVersionT getSchemaVersion() const final;
199
200 bool isSubsetCollection() const final {
201 return m_isSubsetColl;
202 }
203
204 void setSubsetCollection(bool setSubset=true) final;
205
206 /// Returns the const object of given index
207 TrackSeed operator[](std::size_t index) const;
208 /// Returns the object of a given index
209 MutableTrackSeed operator[](std::size_t index);
210 /// Returns the const object of given index
211 TrackSeed at(std::size_t index) const;
212 /// Returns the object of given index
213 MutableTrackSeed at(std::size_t index);
214
215
216 /// Append object to the collection
217 void push_back(const MutableTrackSeed& object);
218 /// Append an object to the (subset) collection
219 void push_back(const TrackSeed& object);
220
221 void prepareForWrite() const final;
222 void prepareAfterRead() final;
223 bool setReferences(const podio::ICollectionProvider* collectionProvider) final;
224
225 /// Get the collection buffers for this collection
226 podio::CollectionWriteBuffers getBuffers() final;
227
228 void setID(uint32_t ID) final {
229 m_collectionID = ID;
230 if (!m_isSubsetColl) {
231 std::for_each(m_storage.entries.begin(), m_storage.entries.end(),
232 [ID] (TrackSeedObj* obj) { obj->id = {obj->id.index, static_cast<uint32_t>(ID)}; }
233 );
234 }
235 }
236
237 uint32_t getID() const final {
238 return m_collectionID;
239 }
240
241 /// check if the collection has a valid ID
242 bool hasID() const final {
243 return getID() != static_cast<uint32_t>(podio::ObjectID::untracked) &&
244 getID() != static_cast<uint32_t>(podio::ObjectID::invalid);
245 }
246
247 [[deprecated("isValid will be removed, use hasID() if you want to check if it has an ID, otherwise assume the "
248 "collection is valid")]]
249 bool isValid() const final {
250 return hasID();
251 }
252
253 size_t getDatamodelRegistryIndex() const final;
254
255 // support for the iterator protocol
257 return iterator(0, &m_storage.entries);
258 }
260 return const_iterator(0, &m_storage.entries);
261 }
263 return begin();
264 }
266 return iterator(m_storage.entries.size(), &m_storage.entries);
267 }
269 return const_iterator(m_storage.entries.size(), &m_storage.entries);
270 }
272 return end();
273 }
274 // reverse iterators
276 return reverse_iterator(end());
277 }
282 return rbegin();
283 }
285 return reverse_iterator(begin());
286 }
291 return rend();
292 }
293
294
295 std::vector<edm4hep::Vector3f> perigee(const size_t nElem = 0) const;
296
297private:
298 // For setReferences, we need to give our own CollectionData access to our
299 // private entries. Otherwise we would need to expose a public member function
300 // that gives access to the Obj* which is definitely not what we want
302
303 mutable bool m_isPrepared{false};
304 bool m_isSubsetColl{false};
305 uint32_t m_collectionID{static_cast<uint32_t>(podio::ObjectID::untracked)};
306 mutable std::unique_ptr<std::mutex> m_storageMtx{std::make_unique<std::mutex>()};
307 mutable TrackSeedCollectionData m_storage{};
308};
309
310std::ostream& operator<<(std::ostream& o, const TrackSeedCollection& v);
311
312template<typename... Args>
314 if (m_isSubsetColl) {
315 throw std::logic_error("Cannot create new elements on a subset collection");
316 }
317 auto obj = new TrackSeedObj({static_cast<int>(m_storage.entries.size()), m_collectionID}, {std::forward<Args>(args)...});
318 m_storage.entries.push_back(obj);
319
320 // Need to initialize the relation vectors manually for the {ObjectID, TrackSeedData} constructor
321 obj->m_hits = new std::vector<edm4eic::TrackerHit>();
322 m_storage.createRelations(obj);
323 return MutableTrackSeed(podio::utils::MaybeSharedPtr(obj));
324}
325
326#if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
327void to_json(nlohmann::json& j, const TrackSeedCollection& collection);
328#endif
329
330} // namespace edm4eic
331
332
333// This is needed to avoid triggering opening every library in LD_LIBRARY_PATH
334// until it's fixed in ROOT. See https://github.com/root-project/root/issues/18489
335// and https://github.com/AIDASoft/podio/issues/770
336#if defined(__clang__)
337 #pragma clang diagnostic push
338 #pragma clang diagnostic ignored "-Wunknown-warning-option"
339 #pragma clang diagnostic ignored "-Wdeprecated-redundant-constexpr-static-def"
340 #pragma clang diagnostic ignored "-Wdeprecated"
341constexpr std::string_view edm4eic::TrackSeedCollection::typeName;
342constexpr std::string_view edm4eic::TrackSeedCollection::valueTypeName;
343constexpr std::string_view edm4eic::TrackSeedCollection::dataTypeName;
344 #pragma clang diagnostic pop
345#elif defined(__GNUC__)
346 #pragma GCC diagnostic push
347 #pragma GCC diagnostic ignored "-Wdeprecated"
348constexpr std::string_view edm4eic::TrackSeedCollection::typeName;
349constexpr std::string_view edm4eic::TrackSeedCollection::valueTypeName;
350constexpr std::string_view edm4eic::TrackSeedCollection::dataTypeName;
351 #pragma GCC diagnostic pop
352#endif
353
354
355#endif
Definition MutableTrackSeed.h:38
Definition TrackSeedCollectionData.h:33
Definition TrackSeedCollection.h:138
TrackSeedCollection(TrackSeedCollection &&)=default
podio::CollectionWriteBuffers getBuffers() final
Get the collection buffers for this collection.
Definition TrackSeedCollection.cc:155
iterator end()
Definition TrackSeedCollection.h:265
const_iterator begin() const
Definition TrackSeedCollection.h:259
static constexpr std::string_view typeName
Definition TrackSeedCollection.h:160
TrackSeed value_type
Definition TrackSeedCollection.h:140
const_reverse_iterator rend() const
Definition TrackSeedCollection.h:287
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)
Cppyy protocol to setup the pythonizations for this class. Not to be called directly.
Definition TrackSeedCollection.h:167
ptrdiff_t difference_type
Definition TrackSeedCollection.h:144
std::size_t size() const final
number of elements in the collection
Definition TrackSeedCollection.cc:49
const_iterator cbegin() const
Definition TrackSeedCollection.h:262
bool hasID() const final
check if the collection has a valid ID
Definition TrackSeedCollection.h:242
reverse_iterator rend()
Definition TrackSeedCollection.h:284
podio::SchemaVersionT getSchemaVersion() const final
schema version
Definition TrackSeedCollection.cc:174
bool setReferences(const podio::ICollectionProvider *collectionProvider) final
Definition TrackSeedCollection.cc:119
TrackSeedCollectionIterator const_iterator
Definition TrackSeedCollection.h:142
const_iterator cend() const
Definition TrackSeedCollection.h:271
const_iterator end() const
Definition TrackSeedCollection.h:268
TrackSeedCollection(const TrackSeedCollection &)=delete
bool isSubsetCollection() const final
Definition TrackSeedCollection.h:200
reverse_iterator rbegin()
Definition TrackSeedCollection.h:275
void print(std::ostream &os=std::cout, bool flush=true) const final
Print this collection to the passed stream.
Definition TrackSeedCollection.cc:435
void setSubsetCollection(bool setSubset=true) final
Definition TrackSeedCollection.cc:67
const_reverse_iterator crend() const
Definition TrackSeedCollection.h:290
const std::string_view getTypeName() const final
fully qualified type name
Definition TrackSeedCollection.h:192
MutableTrackSeed mutable_type
Definition TrackSeedCollection.h:141
void push_back(const MutableTrackSeed &object)
Append object to the collection.
Definition TrackSeedCollection.cc:123
bool isValid() const final
Definition TrackSeedCollection.h:249
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:194
static constexpr std::string_view dataTypeName
Definition TrackSeedCollection.h:162
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition TrackSeedCollection.h:146
void setID(uint32_t ID) final
Definition TrackSeedCollection.h:228
bool empty() const final
Is the collection empty.
Definition TrackSeedCollection.cc:63
iterator begin()
Definition TrackSeedCollection.h:256
void clear() final
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:278
MutableTrackSeed create()
Append a new object to the collection, and return this object.
Definition TrackSeedCollection.cc:78
static constexpr std::string_view valueTypeName
Definition TrackSeedCollection.h:161
friend class TrackSeedCollectionData
Definition TrackSeedCollection.h:301
size_t size_type
Definition TrackSeedCollection.h:145
const std::string_view getDataTypeName() const final
fully qualified type name of stored POD elements - with namespace
Definition TrackSeedCollection.h:196
const_reverse_iterator crbegin() const
Definition TrackSeedCollection.h:281
TrackSeedCollection & operator=(const TrackSeedCollection &)=delete
TrackSeedMutableCollectionIterator iterator
Definition TrackSeedCollection.h:143
~TrackSeedCollection() override
Definition TrackSeedCollection.cc:28
std::reverse_iterator< iterator > reverse_iterator
Definition TrackSeedCollection.h:147
void prepareAfterRead() final
Definition TrackSeedCollection.cc:104
uint32_t getID() const final
Definition TrackSeedCollection.h:237
Definition TrackSeedCollection.h:37
TrackSeedCollectionIterator(size_t index, const TrackSeedObjPointerContainer *collection)
Definition TrackSeedCollection.h:48
reference operator*() const
Definition TrackSeedCollection.cc:276
TrackSeedCollectionIterator & operator--()
Definition TrackSeedCollection.cc:296
ptrdiff_t difference_type
Definition TrackSeedCollection.h:40
std::input_iterator_tag iterator_category
Definition TrackSeedCollection.h:43
auto operator<=>(const TrackSeedCollectionIterator &other) const
Definition TrackSeedCollection.h:57
TrackSeedCollectionIterator(TrackSeedCollectionIterator &&)=default
pointer operator->()
Definition TrackSeedCollection.cc:280
TrackSeedCollectionIterator & operator++()
Definition TrackSeedCollection.cc:285
TrackSeedCollectionIterator operator+(difference_type n) const
Definition TrackSeedCollection.cc:312
TrackSeed reference
Definition TrackSeedCollection.h:41
TrackSeedCollectionIterator & operator=(const TrackSeedCollectionIterator &)=default
TrackSeedCollectionIterator & operator+=(difference_type n)
Definition TrackSeedCollection.cc:307
TrackSeedCollectionIterator & operator-=(difference_type n)
Definition TrackSeedCollection.cc:322
std::random_access_iterator_tag iterator_concept
Definition TrackSeedCollection.h:46
TrackSeedCollectionIterator & operator=(TrackSeedCollectionIterator &&)=default
TrackSeed * pointer
Definition TrackSeedCollection.h:42
TrackSeed value_type
Definition TrackSeedCollection.h:39
bool operator==(const TrackSeedCollectionIterator &x) const
Definition TrackSeedCollection.h:61
TrackSeedCollectionIterator operator-(difference_type n) const
Definition TrackSeedCollection.cc:327
TrackSeedCollectionIterator(const TrackSeedCollectionIterator &)=default
reference operator[](difference_type n) const
Definition TrackSeedCollection.cc:333
Definition TrackSeed.h:46
Definition TrackSeedCollection.h:86
MutableTrackSeed * pointer
Definition TrackSeedCollection.h:91
TrackSeedMutableCollectionIterator operator-(difference_type n) const
Definition TrackSeedCollection.cc:394
TrackSeedMutableCollectionIterator & operator++()
Definition TrackSeedCollection.cc:352
auto operator<=>(const TrackSeedMutableCollectionIterator &other) const
Definition TrackSeedCollection.h:106
TrackSeedMutableCollectionIterator & operator--()
Definition TrackSeedCollection.cc:363
std::random_access_iterator_tag iterator_concept
Definition TrackSeedCollection.h:95
TrackSeedMutableCollectionIterator operator+(difference_type n) const
Definition TrackSeedCollection.cc:379
TrackSeedMutableCollectionIterator(TrackSeedMutableCollectionIterator &&)=default
MutableTrackSeed reference
Definition TrackSeedCollection.h:90
std::input_iterator_tag iterator_category
Definition TrackSeedCollection.h:92
pointer operator->()
Definition TrackSeedCollection.cc:347
TrackSeedMutableCollectionIterator & operator+=(difference_type n)
Definition TrackSeedCollection.cc:374
reference operator*() const
Definition TrackSeedCollection.cc:343
TrackSeedMutableCollectionIterator(const TrackSeedMutableCollectionIterator &)=default
TrackSeedMutableCollectionIterator & operator=(TrackSeedMutableCollectionIterator &&)=default
TrackSeed value_type
Definition TrackSeedCollection.h:88
TrackSeedMutableCollectionIterator & operator-=(difference_type n)
Definition TrackSeedCollection.cc:389
TrackSeedMutableCollectionIterator(size_t index, const TrackSeedObjPointerContainer *collection)
Definition TrackSeedCollection.h:97
bool operator==(const TrackSeedMutableCollectionIterator &x) const
Definition TrackSeedCollection.h:110
TrackSeedMutableCollectionIterator & operator=(const TrackSeedMutableCollectionIterator &)=default
ptrdiff_t difference_type
Definition TrackSeedCollection.h:89
reference operator[](difference_type n) const
Definition TrackSeedCollection.cc:400
Definition TrackSeedObj.h:24
std::vector< edm4eic::TrackerHit > * m_hits
Definition TrackSeedObj.h:41
Definition CalorimeterHit.cc:17
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