3#ifndef EDM4EIC_ProtoClusterCollection_H
4#define EDM4EIC_ProtoClusterCollection_H
14#include "podio/ICollectionProvider.h"
15#include "podio/CollectionBase.h"
16#include "podio/CollectionIDTable.h"
18#if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
19#include "nlohmann/json_fwd.hpp"
48 return m_index != x.m_index;
52 return m_index == x.m_index;
74 return m_index != x.m_index;
78 return m_index == x.m_index;
112 constexpr static auto typeName =
"edm4eic::ProtoClusterCollection";
119 void print(std::ostream& os=std::cout,
bool flush=true) const final;
129 template<
typename... Args>
133 std::size_t
size() const final;
136 bool empty() const final;
148 return m_isSubsetColl;
177 if (!m_isSubsetColl) {
179 [ID] (
ProtoClusterObj* obj) { obj->id = {obj->id.index, static_cast<uint32_t>(ID)}; }
186 return m_collectionID;
193 size_t getDatamodelRegistryIndex() const final;
197 return iterator(0, &m_storage.entries);
203 return iterator(m_storage.entries.size(), &m_storage.entries);
206 return const_iterator(m_storage.entries.size(), &m_storage.entries);
216 bool m_isValid{
false};
217 mutable bool m_isPrepared{
false};
218 bool m_isSubsetColl{
false};
219 uint32_t m_collectionID{0};
220 mutable std::unique_ptr<std::mutex> m_storageMtx{
nullptr};
221 mutable ProtoClusterCollectionData m_storage{};
224std::ostream&
operator<<(std::ostream& o,
const ProtoClusterCollection& v);
226template<
typename... Args>
228 if (m_isSubsetColl) {
229 throw std::logic_error(
"Cannot create new elements on a subset collection");
231 const int size = m_storage.entries.size();
232 auto obj =
new ProtoClusterObj({size, m_collectionID}, {std::forward<Args>(args)...});
233 m_storage.entries.push_back(obj);
236 obj->
m_hits =
new std::vector<edm4eic::CalorimeterHit>();
237 obj->m_weights =
new std::vector<float>();
238 m_storage.createRelations(obj);
242#if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
Definition MutableProtoCluster.h:32
Definition ProtoClusterCollectionData.h:31
ProtoClusterObjPointerContainer entries
Definition ProtoClusterCollectionData.h:36
Definition ProtoClusterCollection.h:95
ProtoClusterCollection(ProtoClusterCollection &&)=default
bool isValid() const final
Definition ProtoClusterCollection.h:189
static constexpr auto dataTypeName
Definition ProtoClusterCollection.h:114
const_iterator end() const
Definition ProtoClusterCollection.h:205
podio::SchemaVersionT getSchemaVersion() const final
schema version
Definition ProtoClusterCollection.cc:169
bool setReferences(const podio::ICollectionProvider *collectionProvider) final
Definition ProtoClusterCollection.cc:123
uint32_t getID() const final
Definition ProtoClusterCollection.h:185
bool isSubsetCollection() const final
Definition ProtoClusterCollection.h:147
static constexpr auto valueTypeName
Definition ProtoClusterCollection.h:113
~ProtoClusterCollection()
Definition ProtoClusterCollection.cc:30
ProtoClusterCollection()
Definition ProtoClusterCollection.cc:24
void prepareAfterRead() final
Definition ProtoClusterCollection.cc:108
const std::string_view getValueTypeName() const final
fully qualified type name of elements - with namespace
Definition ProtoClusterCollection.h:141
void prepareForWrite() const final
Definition ProtoClusterCollection.cc:87
MutableProtoCluster create()
Append a new object to the collection, and return this object.
Definition ProtoClusterCollection.cc:70
const std::string_view getTypeName() const final
fully qualified type name
Definition ProtoClusterCollection.h:139
const_iterator begin() const
Definition ProtoClusterCollection.h:199
ProtoClusterCollection(const ProtoClusterCollection &)=delete
std::size_t size() const final
number of elements in the collection
Definition ProtoClusterCollection.cc:51
void setID(uint32_t ID) final
Definition ProtoClusterCollection.h:175
void setSubsetCollection(bool setSubset=true) final
Definition ProtoClusterCollection.cc:59
static constexpr auto typeName
Definition ProtoClusterCollection.h:112
ProtoClusterCollection & operator=(const ProtoClusterCollection &)=delete
ProtoCluster at(std::size_t index) const
Returns the const object of given index.
Definition ProtoClusterCollection.cc:39
const std::string_view getDataTypeName() const final
fully qualified type name of stored POD elements - with namespace
Definition ProtoClusterCollection.h:143
iterator end()
Definition ProtoClusterCollection.h:202
void print(std::ostream &os=std::cout, bool flush=true) const final
Print this collection to the passed stream.
Definition ProtoClusterCollection.cc:331
void push_back(MutableProtoCluster object)
Append object to the collection.
Definition ProtoClusterCollection.cc:127
podio::CollectionWriteBuffers getBuffers() final
Get the collection buffers for this collection.
Definition ProtoClusterCollection.cc:160
void clear() final
Definition ProtoClusterCollection.cc:82
ProtoClusterCollection & operator=(ProtoClusterCollection &&)=default
bool empty() const final
Is the collection empty.
Definition ProtoClusterCollection.cc:55
Definition ProtoClusterCollection.h:40
ProtoClusterCollectionIterator(const ProtoClusterCollectionIterator &)=delete
ProtoCluster * operator->()
Definition ProtoClusterCollection.cc:275
ProtoClusterCollectionIterator(size_t index, const ProtoClusterObjPointerContainer *collection)
Definition ProtoClusterCollection.h:42
ProtoClusterCollectionIterator & operator=(const ProtoClusterCollectionIterator &)=delete
ProtoClusterCollectionIterator & operator++()
Definition ProtoClusterCollection.cc:280
ProtoCluster operator*()
Definition ProtoClusterCollection.cc:270
bool operator==(const ProtoClusterCollectionIterator &x) const
Definition ProtoClusterCollection.h:51
bool operator!=(const ProtoClusterCollectionIterator &x) const
Definition ProtoClusterCollection.h:47
Definition ProtoCluster.h:33
Definition ProtoClusterCollection.h:66
bool operator==(const ProtoClusterMutableCollectionIterator &x) const
Definition ProtoClusterCollection.h:77
MutableProtoCluster * operator->()
Definition ProtoClusterCollection.cc:292
MutableProtoCluster operator*()
Definition ProtoClusterCollection.cc:287
ProtoClusterMutableCollectionIterator & operator=(const ProtoClusterMutableCollectionIterator &)=delete
bool operator!=(const ProtoClusterMutableCollectionIterator &x) const
Definition ProtoClusterCollection.h:73
ProtoClusterMutableCollectionIterator(size_t index, const ProtoClusterObjPointerContainer *collection)
Definition ProtoClusterCollection.h:68
ProtoClusterMutableCollectionIterator & operator++()
Definition ProtoClusterCollection.cc:297
ProtoClusterMutableCollectionIterator(const ProtoClusterMutableCollectionIterator &)=delete
Definition ProtoClusterObj.h:19
std::vector< edm4eic::CalorimeterHit > * m_hits
Definition ProtoClusterObj.h:35
Definition CalorimeterHit.cc:18
std::ostream & operator<<(std::ostream &o, const CalorimeterHit &value)
Definition CalorimeterHit.cc:97
std::deque< ProtoClusterObj * > ProtoClusterObjPointerContainer
Definition ProtoClusterCollectionData.h:23
Definition CalorimeterHitCollection.h:32