EDM4eic
EIC data model
Loading...
Searching...
No Matches
TrackClusterMatchCollection.h
Go to the documentation of this file.
1// AUTOMATICALLY GENERATED FILE - DO NOT EDIT
2
3#ifndef EDM4EIC_TrackClusterMatchCollection_H
4#define EDM4EIC_TrackClusterMatchCollection_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 TrackClusterMatchCollectionIterator(size_t index, const TrackClusterMatchObjPointerContainer* collection) : m_index(index), m_object(podio::utils::MaybeSharedPtr<TrackClusterMatchObj>{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 TrackClusterMatch m_object { podio::utils::MaybeSharedPtr<TrackClusterMatchObj>{nullptr} };
81 const TrackClusterMatchObjPointerContainer* 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 TrackClusterMatchMutableCollectionIterator(size_t index, const TrackClusterMatchObjPointerContainer* collection) : m_index(index), m_object(podio::utils::MaybeSharedPtr<TrackClusterMatchObj>{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 MutableTrackClusterMatch m_object { podio::utils::MaybeSharedPtr<TrackClusterMatchObj>{nullptr} };
130 const TrackClusterMatchObjPointerContainer* m_collection{nullptr};
131};
132
133
134/**
135A Collection is identified by an ID.
136*/
137class TrackClusterMatchCollection : 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// TrackClusterMatchCollection(TrackClusterMatchVector* data, uint32_t collectionID);
158
159 constexpr static std::string_view typeName = "edm4eic::TrackClusterMatchCollection";
160 constexpr static std::string_view valueTypeName = "edm4eic::TrackClusterMatch";
161 constexpr static std::string_view dataTypeName = "edm4eic::TrackClusterMatchData";
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 TrackClusterMatchCollection* operator->() { return static_cast<TrackClusterMatchCollection*>(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 MutableTrackClusterMatch 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 TrackClusterMatch operator[](std::size_t index) const;
205 /// Returns the object of a given index
206 MutableTrackClusterMatch operator[](std::size_t index);
207 /// Returns the const object of given index
208 TrackClusterMatch at(std::size_t index) const;
209 /// Returns the object of given index
210 MutableTrackClusterMatch at(std::size_t index);
211
212
213 /// Append object to the collection
214 void push_back(const MutableTrackClusterMatch& object);
215 /// Append an object to the (subset) collection
216 void push_back(const TrackClusterMatch& 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] (TrackClusterMatchObj* 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> weight(const size_t nElem = 0) const;
286
287private:
288 // For setReferences, we need to give our own CollectionData access to our
289 // private entries. Otherwise we would need to expose a public member function
290 // that gives access to the Obj* which is definitely not what we want
292
293 bool m_isValid{false};
294 mutable bool m_isPrepared{false};
295 bool m_isSubsetColl{false};
296 uint32_t m_collectionID{0};
297 mutable std::unique_ptr<std::mutex> m_storageMtx{nullptr};
298 mutable TrackClusterMatchCollectionData m_storage{};
299};
300
301std::ostream& operator<<(std::ostream& o, const TrackClusterMatchCollection& v);
302
303template<typename... Args>
305 if (m_isSubsetColl) {
306 throw std::logic_error("Cannot create new elements on a subset collection");
307 }
308 const int size = m_storage.entries.size();
309 auto obj = new TrackClusterMatchObj({size, m_collectionID}, {std::forward<Args>(args)...});
310 m_storage.entries.push_back(obj);
311
312 return MutableTrackClusterMatch(podio::utils::MaybeSharedPtr(obj));
313}
314
315#if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
316void to_json(nlohmann::json& j, const TrackClusterMatchCollection& collection);
317#endif
318
319} // namespace edm4eic
320
321
322#endif
Definition MutableTrackClusterMatch.h:36
Definition TrackClusterMatchCollectionData.h:32
Definition TrackClusterMatchCollection.h:137
void setID(uint32_t ID) final
Definition TrackClusterMatchCollection.h:225
uint32_t getID() const final
Definition TrackClusterMatchCollection.h:235
const std::string_view getDataTypeName() const final
fully qualified type name of stored POD elements - with namespace
Definition TrackClusterMatchCollection.h:193
const_iterator end() const
Definition TrackClusterMatchCollection.h:258
podio::SchemaVersionT getSchemaVersion() const final
schema version
Definition TrackClusterMatchCollection.cc:176
void clear() final
Definition TrackClusterMatchCollection.cc:92
const_reverse_iterator rend() const
Definition TrackClusterMatchCollection.h:277
const std::string_view getValueTypeName() const final
fully qualified type name of elements - with namespace
Definition TrackClusterMatchCollection.h:191
void setSubsetCollection(bool setSubset=true) final
Definition TrackClusterMatchCollection.cc:70
TrackClusterMatch at(std::size_t index) const
Returns the const object of given index.
Definition TrackClusterMatchCollection.cc:40
const_iterator cend() const
Definition TrackClusterMatchCollection.h:261
reverse_iterator rbegin()
Definition TrackClusterMatchCollection.h:265
const_reverse_iterator crbegin() const
Definition TrackClusterMatchCollection.h:271
iterator begin()
Definition TrackClusterMatchCollection.h:246
TrackClusterMatchCollection & operator=(TrackClusterMatchCollection &&)=default
TrackClusterMatchCollection(const TrackClusterMatchCollection &)=delete
static constexpr std::string_view valueTypeName
Definition TrackClusterMatchCollection.h:160
void prepareAfterRead() final
Definition TrackClusterMatchCollection.cc:106
TrackClusterMatchCollection & operator=(const TrackClusterMatchCollection &)=delete
bool isSubsetCollection() const final
Definition TrackClusterMatchCollection.h:197
size_t size_type
Definition TrackClusterMatchCollection.h:144
TrackClusterMatchCollection()
Definition TrackClusterMatchCollection.cc:25
void prepareForWrite() const final
Definition TrackClusterMatchCollection.cc:97
void push_back(const MutableTrackClusterMatch &object)
Append object to the collection.
Definition TrackClusterMatchCollection.cc:125
TrackClusterMatch value_type
Definition TrackClusterMatchCollection.h:139
bool isValid() const final
Definition TrackClusterMatchCollection.h:239
std::reverse_iterator< iterator > reverse_iterator
Definition TrackClusterMatchCollection.h:146
TrackClusterMatchCollectionIterator const_iterator
Definition TrackClusterMatchCollection.h:141
const_iterator begin() const
Definition TrackClusterMatchCollection.h:249
TrackClusterMatchCollection(TrackClusterMatchCollection &&)=default
reverse_iterator rend()
Definition TrackClusterMatchCollection.h:274
std::size_t size() const final
number of elements in the collection
Definition TrackClusterMatchCollection.cc:52
podio::CollectionWriteBuffers getBuffers() final
Get the collection buffers for this collection.
Definition TrackClusterMatchCollection.cc:157
const_reverse_iterator crend() const
Definition TrackClusterMatchCollection.h:280
ptrdiff_t difference_type
Definition TrackClusterMatchCollection.h:143
~TrackClusterMatchCollection() override
Definition TrackClusterMatchCollection.cc:31
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition TrackClusterMatchCollection.h:145
MutableTrackClusterMatch create()
Append a new object to the collection, and return this object.
Definition TrackClusterMatchCollection.cc:81
static constexpr std::string_view dataTypeName
Definition TrackClusterMatchCollection.h:161
static constexpr std::string_view typeName
Definition TrackClusterMatchCollection.h:159
void print(std::ostream &os=std::cout, bool flush=true) const final
Print this collection to the passed stream.
Definition TrackClusterMatchCollection.cc:435
TrackClusterMatchMutableCollectionIterator iterator
Definition TrackClusterMatchCollection.h:142
bool setReferences(const podio::ICollectionProvider *collectionProvider) final
Definition TrackClusterMatchCollection.cc:121
MutableTrackClusterMatch mutable_type
Definition TrackClusterMatchCollection.h:140
std::size_t max_size() const final
maximal number of elements in the collection
Definition TrackClusterMatchCollection.cc:56
bool empty() const final
Is the collection empty.
Definition TrackClusterMatchCollection.cc:66
const_iterator cbegin() const
Definition TrackClusterMatchCollection.h:252
const std::string_view getTypeName() const final
fully qualified type name
Definition TrackClusterMatchCollection.h:189
iterator end()
Definition TrackClusterMatchCollection.h:255
friend class TrackClusterMatchCollectionData
Definition TrackClusterMatchCollection.h:291
const_reverse_iterator rbegin() const
Definition TrackClusterMatchCollection.h:268
Definition TrackClusterMatchCollection.h:36
pointer operator->()
Definition TrackClusterMatchCollection.cc:283
TrackClusterMatch value_type
Definition TrackClusterMatchCollection.h:38
TrackClusterMatchCollectionIterator & operator++()
Definition TrackClusterMatchCollection.cc:288
TrackClusterMatchCollectionIterator & operator+=(difference_type n)
Definition TrackClusterMatchCollection.cc:310
TrackClusterMatchCollectionIterator operator-(difference_type n) const
Definition TrackClusterMatchCollection.cc:330
TrackClusterMatchCollectionIterator & operator-=(difference_type n)
Definition TrackClusterMatchCollection.cc:325
TrackClusterMatchCollectionIterator & operator=(const TrackClusterMatchCollectionIterator &)=default
auto operator<=>(const TrackClusterMatchCollectionIterator &other) const
Definition TrackClusterMatchCollection.h:56
std::random_access_iterator_tag iterator_concept
Definition TrackClusterMatchCollection.h:45
std::input_iterator_tag iterator_category
Definition TrackClusterMatchCollection.h:42
TrackClusterMatchCollectionIterator operator+(difference_type n) const
Definition TrackClusterMatchCollection.cc:315
reference operator[](difference_type n) const
Definition TrackClusterMatchCollection.cc:336
TrackClusterMatch reference
Definition TrackClusterMatchCollection.h:40
TrackClusterMatchCollectionIterator & operator--()
Definition TrackClusterMatchCollection.cc:299
reference operator*() const
Definition TrackClusterMatchCollection.cc:279
TrackClusterMatchCollectionIterator(TrackClusterMatchCollectionIterator &&)=default
ptrdiff_t difference_type
Definition TrackClusterMatchCollection.h:39
bool operator==(const TrackClusterMatchCollectionIterator &x) const
Definition TrackClusterMatchCollection.h:60
TrackClusterMatchCollectionIterator(const TrackClusterMatchCollectionIterator &)=default
TrackClusterMatch * pointer
Definition TrackClusterMatchCollection.h:41
TrackClusterMatchCollectionIterator & operator=(TrackClusterMatchCollectionIterator &&)=default
TrackClusterMatchCollectionIterator(size_t index, const TrackClusterMatchObjPointerContainer *collection)
Definition TrackClusterMatchCollection.h:47
Definition TrackClusterMatch.h:44
Definition TrackClusterMatchCollection.h:85
TrackClusterMatchMutableCollectionIterator(size_t index, const TrackClusterMatchObjPointerContainer *collection)
Definition TrackClusterMatchCollection.h:96
TrackClusterMatchMutableCollectionIterator & operator-=(difference_type n)
Definition TrackClusterMatchCollection.cc:392
ptrdiff_t difference_type
Definition TrackClusterMatchCollection.h:88
std::random_access_iterator_tag iterator_concept
Definition TrackClusterMatchCollection.h:94
reference operator[](difference_type n) const
Definition TrackClusterMatchCollection.cc:403
TrackClusterMatchMutableCollectionIterator & operator++()
Definition TrackClusterMatchCollection.cc:355
TrackClusterMatchMutableCollectionIterator(TrackClusterMatchMutableCollectionIterator &&)=default
TrackClusterMatchMutableCollectionIterator & operator+=(difference_type n)
Definition TrackClusterMatchCollection.cc:377
TrackClusterMatch value_type
Definition TrackClusterMatchCollection.h:87
pointer operator->()
Definition TrackClusterMatchCollection.cc:350
MutableTrackClusterMatch reference
Definition TrackClusterMatchCollection.h:89
TrackClusterMatchMutableCollectionIterator & operator--()
Definition TrackClusterMatchCollection.cc:366
TrackClusterMatchMutableCollectionIterator(const TrackClusterMatchMutableCollectionIterator &)=default
TrackClusterMatchMutableCollectionIterator & operator=(const TrackClusterMatchMutableCollectionIterator &)=default
TrackClusterMatchMutableCollectionIterator & operator=(TrackClusterMatchMutableCollectionIterator &&)=default
bool operator==(const TrackClusterMatchMutableCollectionIterator &x) const
Definition TrackClusterMatchCollection.h:109
TrackClusterMatchMutableCollectionIterator operator-(difference_type n) const
Definition TrackClusterMatchCollection.cc:397
std::input_iterator_tag iterator_category
Definition TrackClusterMatchCollection.h:91
MutableTrackClusterMatch * pointer
Definition TrackClusterMatchCollection.h:90
auto operator<=>(const TrackClusterMatchMutableCollectionIterator &other) const
Definition TrackClusterMatchCollection.h:105
reference operator*() const
Definition TrackClusterMatchCollection.cc:346
TrackClusterMatchMutableCollectionIterator operator+(difference_type n) const
Definition TrackClusterMatchCollection.cc:382
Definition TrackClusterMatchObj.h:22
Definition CalorimeterHit.cc:17
std::ostream & operator<<(std::ostream &o, const CalorimeterHit &value)
Definition CalorimeterHit.cc:103
std::deque< TrackClusterMatchObj * > TrackClusterMatchObjPointerContainer
Definition TrackClusterMatchCollectionData.h:24
Definition CalorimeterHit.h:31