3#ifndef EDM4EIC_VertexCollection_H
4#define EDM4EIC_VertexCollection_H
13#include "podio/ICollectionProvider.h"
14#include "podio/CollectionBase.h"
16#if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
17#include "nlohmann/json_fwd.hpp"
57 return m_index <=> other.m_index;
61 return m_index == x.m_index;
80 Vertex m_object { podio::utils::MaybeSharedPtr<VertexObj>{
nullptr} };
106 return m_index <=> other.m_index;
110 return m_index == x.m_index;
129 MutableVertex m_object { podio::utils::MaybeSharedPtr<VertexObj>{
nullptr} };
159 constexpr static std::string_view
typeName =
"edm4eic::VertexCollection";
161 constexpr static std::string_view
dataTypeName =
"edm4eic::VertexData";
166 void print(std::ostream& os=std::cout,
bool flush=true) const final;
176 template<
typename... Args>
180 std::size_t
size() const final;
186 bool empty() const final;
198 return m_isSubsetColl;
204 Vertex operator[](std::
size_t index) const;
227 if (!m_isSubsetColl) {
228 std::for_each(m_storage.entries.begin(), m_storage.entries.end(),
229 [ID] (
VertexObj* obj) { obj->id = {obj->id.index, static_cast<uint32_t>(ID)}; }
236 return m_collectionID;
243 size_t getDatamodelRegistryIndex() const final;
247 return iterator(0, &m_storage.entries);
256 return iterator(m_storage.entries.size(), &m_storage.entries);
259 return const_iterator(m_storage.entries.size(), &m_storage.entries);
285 std::vector<std::int32_t> type(
const size_t nElem = 0)
const;
286 std::vector<float> chi2(
const size_t nElem = 0)
const;
287 std::vector<int> ndf(
const size_t nElem = 0)
const;
288 std::vector<edm4hep::Vector4f> position(
const size_t nElem = 0)
const;
289 std::vector<edm4eic::Cov4f> positionError(
const size_t nElem = 0)
const;
297 bool m_isValid{
false};
298 mutable bool m_isPrepared{
false};
299 bool m_isSubsetColl{
false};
300 uint32_t m_collectionID{0};
301 mutable std::unique_ptr<std::mutex> m_storageMtx{
nullptr};
305std::ostream&
operator<<(std::ostream& o,
const VertexCollection& v);
307template<
typename... Args>
309 if (m_isSubsetColl) {
310 throw std::logic_error(
"Cannot create new elements on a subset collection");
312 const int size = m_storage.entries.size();
313 auto obj =
new VertexObj({
size, m_collectionID}, {std::forward<Args>(args)...});
314 m_storage.entries.push_back(obj);
318 m_storage.createRelations(obj);
322#if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
Definition MutableVertex.h:38
Definition VertexCollectionData.h:31
Definition VertexCollection.h:137
static constexpr std::string_view valueTypeName
Definition VertexCollection.h:160
const_iterator cbegin() const
Definition VertexCollection.h:252
MutableVertex create()
Append a new object to the collection, and return this object.
Definition VertexCollection.cc:80
void push_back(const MutableVertex &object)
Append object to the collection.
Definition VertexCollection.cc:125
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition VertexCollection.h:145
VertexCollection(VertexCollection &&)=default
podio::CollectionWriteBuffers getBuffers() final
Get the collection buffers for this collection.
Definition VertexCollection.cc:158
size_t size_type
Definition VertexCollection.h:144
Vertex at(std::size_t index) const
Returns the const object of given index.
Definition VertexCollection.cc:39
std::size_t max_size() const final
maximal number of elements in the collection
Definition VertexCollection.cc:55
VertexCollection & operator=(const VertexCollection &)=delete
VertexCollectionIterator const_iterator
Definition VertexCollection.h:141
bool isValid() const final
Definition VertexCollection.h:239
void clear() final
Definition VertexCollection.cc:92
VertexCollection & operator=(VertexCollection &&)=default
VertexCollection()
Definition VertexCollection.cc:24
const std::string_view getValueTypeName() const final
fully qualified type name of elements - with namespace
Definition VertexCollection.h:191
const_reverse_iterator crbegin() const
Definition VertexCollection.h:271
~VertexCollection() override
Definition VertexCollection.cc:30
void prepareForWrite() const final
Definition VertexCollection.cc:97
static constexpr std::string_view dataTypeName
Definition VertexCollection.h:161
uint32_t getID() const final
Definition VertexCollection.h:235
reverse_iterator rend()
Definition VertexCollection.h:274
bool setReferences(const podio::ICollectionProvider *collectionProvider) final
Definition VertexCollection.cc:121
const_reverse_iterator rend() const
Definition VertexCollection.h:277
static constexpr std::string_view typeName
Definition VertexCollection.h:159
bool isSubsetCollection() const final
Definition VertexCollection.h:197
VertexCollection(const VertexCollection &)=delete
MutableVertex mutable_type
Definition VertexCollection.h:140
Vertex value_type
Definition VertexCollection.h:139
bool empty() const final
Is the collection empty.
Definition VertexCollection.cc:65
VertexMutableCollectionIterator iterator
Definition VertexCollection.h:142
void print(std::ostream &os=std::cout, bool flush=true) const final
Print this collection to the passed stream.
Definition VertexCollection.cc:481
const_iterator begin() const
Definition VertexCollection.h:249
const std::string_view getDataTypeName() const final
fully qualified type name of stored POD elements - with namespace
Definition VertexCollection.h:193
podio::SchemaVersionT getSchemaVersion() const final
schema version
Definition VertexCollection.cc:217
const std::string_view getTypeName() const final
fully qualified type name
Definition VertexCollection.h:189
void prepareAfterRead() final
Definition VertexCollection.cc:106
iterator end()
Definition VertexCollection.h:255
const_iterator end() const
Definition VertexCollection.h:258
ptrdiff_t difference_type
Definition VertexCollection.h:143
void setID(uint32_t ID) final
Definition VertexCollection.h:225
friend class VertexCollectionData
Definition VertexCollection.h:295
iterator begin()
Definition VertexCollection.h:246
const_iterator cend() const
Definition VertexCollection.h:261
const_reverse_iterator crend() const
Definition VertexCollection.h:280
reverse_iterator rbegin()
Definition VertexCollection.h:265
void setSubsetCollection(bool setSubset=true) final
Definition VertexCollection.cc:69
const_reverse_iterator rbegin() const
Definition VertexCollection.h:268
std::size_t size() const final
number of elements in the collection
Definition VertexCollection.cc:51
std::reverse_iterator< iterator > reverse_iterator
Definition VertexCollection.h:146
Definition VertexCollection.h:36
VertexCollectionIterator()=default
auto operator<=>(const VertexCollectionIterator &other) const
Definition VertexCollection.h:56
VertexCollectionIterator & operator--()
Definition VertexCollection.cc:340
std::random_access_iterator_tag iterator_concept
Definition VertexCollection.h:45
VertexCollectionIterator(VertexCollectionIterator &&)=default
VertexCollectionIterator operator-(difference_type n) const
Definition VertexCollection.cc:371
bool operator==(const VertexCollectionIterator &x) const
Definition VertexCollection.h:60
VertexCollectionIterator & operator=(const VertexCollectionIterator &)=default
std::input_iterator_tag iterator_category
Definition VertexCollection.h:42
~VertexCollectionIterator()=default
pointer operator->()
Definition VertexCollection.cc:324
Vertex reference
Definition VertexCollection.h:40
reference operator*() const
Definition VertexCollection.cc:320
VertexCollectionIterator & operator=(VertexCollectionIterator &&)=default
Vertex * pointer
Definition VertexCollection.h:41
VertexCollectionIterator & operator++()
Definition VertexCollection.cc:329
VertexCollectionIterator(const VertexCollectionIterator &)=default
VertexCollectionIterator operator+(difference_type n) const
Definition VertexCollection.cc:356
VertexCollectionIterator & operator+=(difference_type n)
Definition VertexCollection.cc:351
Vertex value_type
Definition VertexCollection.h:38
ptrdiff_t difference_type
Definition VertexCollection.h:39
VertexCollectionIterator & operator-=(difference_type n)
Definition VertexCollection.cc:366
reference operator[](difference_type n) const
Definition VertexCollection.cc:377
VertexCollectionIterator(size_t index, const VertexObjPointerContainer *collection)
Definition VertexCollection.h:47
Definition VertexCollection.h:85
bool operator==(const VertexMutableCollectionIterator &x) const
Definition VertexCollection.h:109
VertexMutableCollectionIterator & operator++()
Definition VertexCollection.cc:396
reference operator[](difference_type n) const
Definition VertexCollection.cc:444
VertexMutableCollectionIterator(VertexMutableCollectionIterator &&)=default
std::input_iterator_tag iterator_category
Definition VertexCollection.h:91
VertexMutableCollectionIterator operator-(difference_type n) const
Definition VertexCollection.cc:438
VertexMutableCollectionIterator & operator=(const VertexMutableCollectionIterator &)=default
VertexMutableCollectionIterator & operator+=(difference_type n)
Definition VertexCollection.cc:418
MutableVertex * pointer
Definition VertexCollection.h:90
reference operator*() const
Definition VertexCollection.cc:387
VertexMutableCollectionIterator & operator--()
Definition VertexCollection.cc:407
VertexMutableCollectionIterator & operator=(VertexMutableCollectionIterator &&)=default
VertexMutableCollectionIterator operator+(difference_type n) const
Definition VertexCollection.cc:423
std::random_access_iterator_tag iterator_concept
Definition VertexCollection.h:94
VertexMutableCollectionIterator(const VertexMutableCollectionIterator &)=default
Vertex value_type
Definition VertexCollection.h:87
ptrdiff_t difference_type
Definition VertexCollection.h:88
VertexMutableCollectionIterator()=default
MutableVertex reference
Definition VertexCollection.h:89
pointer operator->()
Definition VertexCollection.cc:391
~VertexMutableCollectionIterator()=default
auto operator<=>(const VertexMutableCollectionIterator &other) const
Definition VertexCollection.h:105
VertexMutableCollectionIterator(size_t index, const VertexObjPointerContainer *collection)
Definition VertexCollection.h:96
VertexMutableCollectionIterator & operator-=(difference_type n)
Definition VertexCollection.cc:433
Definition VertexObj.h:20
std::vector< edm4eic::ReconstructedParticle > * m_associatedParticles
Definition VertexObj.h:36
Definition CalorimeterHit.cc:17
std::ostream & operator<<(std::ostream &o, const CalorimeterHit &value)
Definition CalorimeterHit.cc:103
std::deque< VertexObj * > VertexObjPointerContainer
Definition VertexCollectionData.h:23
Definition CalorimeterHit.h:31