3#ifndef EDM4EIC_ProtoClusterCollection_H
4#define EDM4EIC_ProtoClusterCollection_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"
45 return m_index != x.m_index;
49 return m_index == x.m_index;
71 return m_index != x.m_index;
75 return m_index == x.m_index;
111 constexpr static auto typeName =
"edm4eic::ProtoClusterCollection";
118 void print(std::ostream& os=std::cout,
bool flush=true) const final;
128 template<
typename... Args>
132 std::size_t
size() const final;
138 bool empty() const final;
150 return m_isSubsetColl;
179 if (!m_isSubsetColl) {
181 [ID] (
ProtoClusterObj* obj) { obj->id = {obj->id.index, static_cast<uint32_t>(ID)}; }
188 return m_collectionID;
195 size_t getDatamodelRegistryIndex() const final;
199 return iterator(0, &m_storage.entries);
208 return iterator(m_storage.entries.size(), &m_storage.entries);
211 return const_iterator(m_storage.entries.size(), &m_storage.entries);
224 bool m_isValid{
false};
225 mutable bool m_isPrepared{
false};
226 bool m_isSubsetColl{
false};
227 uint32_t m_collectionID{0};
228 mutable std::unique_ptr<std::mutex> m_storageMtx{
nullptr};
229 mutable ProtoClusterCollectionData m_storage{};
232std::ostream&
operator<<(std::ostream& o,
const ProtoClusterCollection& v);
234template<
typename... Args>
236 if (m_isSubsetColl) {
237 throw std::logic_error(
"Cannot create new elements on a subset collection");
239 const int size = m_storage.entries.size();
240 auto obj =
new ProtoClusterObj({size, m_collectionID}, {std::forward<Args>(args)...});
241 m_storage.entries.push_back(obj);
244 obj->
m_hits =
new std::vector<edm4eic::CalorimeterHit>();
245 obj->m_weights =
new std::vector<float>();
246 m_storage.createRelations(obj);
250#if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
Definition MutableProtoCluster.h:31
Definition ProtoClusterCollectionData.h:31
ProtoClusterObjPointerContainer entries
Definition ProtoClusterCollectionData.h:36
Definition ProtoClusterCollection.h:92
ProtoClusterCollection(ProtoClusterCollection &&)=default
std::size_t max_size() const final
maximal number of elements in the collection
Definition ProtoClusterCollection.cc:55
bool isValid() const final
Definition ProtoClusterCollection.h:191
static constexpr auto dataTypeName
Definition ProtoClusterCollection.h:113
void push_back(const MutableProtoCluster &object)
Append object to the collection.
Definition ProtoClusterCollection.cc:131
const_iterator end() const
Definition ProtoClusterCollection.h:210
podio::SchemaVersionT getSchemaVersion() const final
schema version
Definition ProtoClusterCollection.cc:173
bool setReferences(const podio::ICollectionProvider *collectionProvider) final
Definition ProtoClusterCollection.cc:127
uint32_t getID() const final
Definition ProtoClusterCollection.h:187
bool isSubsetCollection() const final
Definition ProtoClusterCollection.h:149
static constexpr auto valueTypeName
Definition ProtoClusterCollection.h:112
~ProtoClusterCollection()
Definition ProtoClusterCollection.cc:30
ProtoClusterCollection()
Definition ProtoClusterCollection.cc:24
void prepareAfterRead() final
Definition ProtoClusterCollection.cc:112
const std::string_view getValueTypeName() const final
fully qualified type name of elements - with namespace
Definition ProtoClusterCollection.h:143
void prepareForWrite() const final
Definition ProtoClusterCollection.cc:91
MutableProtoCluster create()
Append a new object to the collection, and return this object.
Definition ProtoClusterCollection.cc:74
const std::string_view getTypeName() const final
fully qualified type name
Definition ProtoClusterCollection.h:141
const_iterator begin() const
Definition ProtoClusterCollection.h:201
size_t size_type
Definition ProtoClusterCollection.h:98
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:177
void setSubsetCollection(bool setSubset=true) final
Definition ProtoClusterCollection.cc:63
static constexpr auto typeName
Definition ProtoClusterCollection.h:111
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:145
iterator end()
Definition ProtoClusterCollection.h:207
void print(std::ostream &os=std::cout, bool flush=true) const final
Print this collection to the passed stream.
Definition ProtoClusterCollection.cc:340
ptrdiff_t difference_type
Definition ProtoClusterCollection.h:97
podio::CollectionWriteBuffers getBuffers() final
Get the collection buffers for this collection.
Definition ProtoClusterCollection.cc:164
void clear() final
Definition ProtoClusterCollection.cc:86
ProtoClusterCollection & operator=(ProtoClusterCollection &&)=default
const_iterator cend() const
Definition ProtoClusterCollection.h:213
const_iterator cbegin() const
Definition ProtoClusterCollection.h:204
bool empty() const final
Is the collection empty.
Definition ProtoClusterCollection.cc:59
Definition ProtoClusterCollection.h:37
ProtoClusterCollectionIterator(const ProtoClusterCollectionIterator &)=delete
ProtoCluster * operator->()
Definition ProtoClusterCollection.cc:284
ProtoClusterCollectionIterator(size_t index, const ProtoClusterObjPointerContainer *collection)
Definition ProtoClusterCollection.h:39
ProtoClusterCollectionIterator & operator=(const ProtoClusterCollectionIterator &)=delete
ProtoClusterCollectionIterator & operator++()
Definition ProtoClusterCollection.cc:289
ProtoCluster operator*()
Definition ProtoClusterCollection.cc:279
bool operator==(const ProtoClusterCollectionIterator &x) const
Definition ProtoClusterCollection.h:48
bool operator!=(const ProtoClusterCollectionIterator &x) const
Definition ProtoClusterCollection.h:44
Definition ProtoCluster.h:33
Definition ProtoClusterCollection.h:63
bool operator==(const ProtoClusterMutableCollectionIterator &x) const
Definition ProtoClusterCollection.h:74
MutableProtoCluster * operator->()
Definition ProtoClusterCollection.cc:301
MutableProtoCluster operator*()
Definition ProtoClusterCollection.cc:296
ProtoClusterMutableCollectionIterator & operator=(const ProtoClusterMutableCollectionIterator &)=delete
bool operator!=(const ProtoClusterMutableCollectionIterator &x) const
Definition ProtoClusterCollection.h:70
ProtoClusterMutableCollectionIterator(size_t index, const ProtoClusterObjPointerContainer *collection)
Definition ProtoClusterCollection.h:65
ProtoClusterMutableCollectionIterator & operator++()
Definition ProtoClusterCollection.cc:306
ProtoClusterMutableCollectionIterator(const ProtoClusterMutableCollectionIterator &)=delete
Definition ProtoClusterObj.h:19
std::vector< edm4eic::CalorimeterHit > * m_hits
Definition ProtoClusterObj.h:35
Definition CalorimeterHit.cc:17
std::ostream & operator<<(std::ostream &o, const CalorimeterHit &value)
Definition CalorimeterHit.cc:103
std::deque< ProtoClusterObj * > ProtoClusterObjPointerContainer
Definition ProtoClusterCollectionData.h:23
Definition CalorimeterHitCollection.h:29