3#ifndef EICD_ProtoClusterCollection_H
4#define EICD_ProtoClusterCollection_H
14#include "podio/ICollectionProvider.h"
15#include "podio/CollectionBase.h"
16#include "podio/CollectionIDTable.h"
18#ifdef PODIO_JSON_OUTPUT
19#include "nlohmann/json.hpp"
43 return m_index != x.m_index;
65 return m_index != x.m_index;
107 template<
typename... Args>
111 size_t size() const final;
114 std::
string getTypeName() const final {
return std::string(
"eicd::ProtoClusterCollection"); }
118 std::string
getDataTypeName() const final {
return std::string(
"eicd::ProtoClusterData"); }
121 return m_isSubsetColl;
141 bool setReferences(const podio::ICollectionProvider* collectionProvider) final;
148 if (!m_isSubsetColl) {
150 [ID] (
ProtoClusterObj* obj) { obj->id = {obj->id.index, static_cast<int>(ID)}; }
157 return m_collectionID;
166 return iterator(0, &m_storage.entries);
172 return iterator(m_storage.entries.size(), &m_storage.entries);
175 return const_iterator(m_storage.entries.size(), &m_storage.entries);
185 bool m_isValid{
false};
186 mutable bool m_isPrepared{
false};
187 bool m_isSubsetColl{
false};
188 int m_collectionID{0};
189 mutable std::unique_ptr<std::mutex> m_storageMtx{std::make_unique<std::mutex>()};
190 mutable ProtoClusterCollectionData m_storage{};
193std::ostream&
operator<<(std::ostream& o,
const ProtoClusterCollection& v);
195template<
typename... Args>
197 if (m_isSubsetColl) {
198 throw std::logic_error(
"Cannot create new elements on a subset collection");
200 const int size = m_storage.entries.size();
201 auto obj =
new ProtoClusterObj({size, m_collectionID}, {std::forward<Args>(args)...});
202 m_storage.entries.push_back(obj);
205 obj->
m_hits =
new std::vector<eicd::CalorimeterHit>();
206 obj->m_weights =
new std::vector<float>();
207 m_storage.createRelations(obj);
212#ifdef PODIO_JSON_OUTPUT
Definition: MutableProtoCluster.h:29
Definition: ProtoClusterCollectionData.h:29
ProtoClusterObjPointerContainer entries
Definition: ProtoClusterCollectionData.h:34
Definition: ProtoClusterCollection.h:82
bool setReferences(const podio::ICollectionProvider *collectionProvider) final
Definition: ProtoClusterCollection.cc:107
bool isSubsetCollection() const final
Definition: ProtoClusterCollection.h:120
std::string getDataTypeName() const final
fully qualified type name of stored POD elements - with namespace
Definition: ProtoClusterCollection.h:118
ProtoCluster at(unsigned int index) const
Returns the const object of given index.
Definition: ProtoClusterCollection.cc:27
podio::CollectionBuffers getBuffers() final
Get the collection buffers for this collection.
Definition: ProtoClusterCollection.cc:137
ProtoClusterCollection()
Definition: ProtoClusterCollection.cc:15
void setID(unsigned ID) final
Definition: ProtoClusterCollection.h:146
void setSubsetCollection(bool setSubset=true) final
Definition: ProtoClusterCollection.cc:43
const_iterator end() const
Definition: ProtoClusterCollection.h:174
void push_back(ProtoCluster object)
Append object to the collection.
Definition: ProtoClusterCollection.cc:111
std::string getTypeName() const final
fully qualified type name
Definition: ProtoClusterCollection.h:114
bool isValid() const final
Definition: ProtoClusterCollection.h:160
void prepareForWrite() const final
Definition: ProtoClusterCollection.cc:71
ProtoClusterCollection & operator=(ProtoClusterCollection &&)=default
void clear() final
Definition: ProtoClusterCollection.cc:66
ProtoClusterCollection(const ProtoClusterCollection &)=delete
iterator end()
Definition: ProtoClusterCollection.h:171
std::string getValueTypeName() const final
fully qualified type name of elements - with namespace
Definition: ProtoClusterCollection.h:116
MutableProtoCluster create()
Append a new object to the collection, and return this object.
Definition: ProtoClusterCollection.cc:54
void prepareAfterRead() final
Definition: ProtoClusterCollection.cc:92
ProtoClusterCollection(ProtoClusterCollection &&)=default
unsigned getID() const final
Definition: ProtoClusterCollection.h:156
iterator begin()
Definition: ProtoClusterCollection.h:165
size_t size() const final
number of elements in the collection
Definition: ProtoClusterCollection.cc:39
const_iterator begin() const
Definition: ProtoClusterCollection.h:168
ProtoClusterCollection & operator=(const ProtoClusterCollection &)=delete
~ProtoClusterCollection()
Definition: ProtoClusterCollection.cc:18
Definition: ProtoClusterCollection.h:35
ProtoCluster * operator->()
Definition: ProtoClusterCollection.cc:156
ProtoClusterCollectionIterator & operator=(const ProtoClusterCollectionIterator &)=delete
ProtoCluster operator*()
Definition: ProtoClusterCollection.cc:151
ProtoClusterCollectionIterator(size_t index, const ProtoClusterObjPointerContainer *collection)
Definition: ProtoClusterCollection.h:37
ProtoClusterCollectionIterator(const ProtoClusterCollectionIterator &)=delete
ProtoClusterCollectionIterator & operator++()
Definition: ProtoClusterCollection.cc:161
bool operator!=(const ProtoClusterCollectionIterator &x) const
Definition: ProtoClusterCollection.h:42
Definition: ProtoCluster.h:28
Definition: ProtoClusterCollection.h:57
MutableProtoCluster operator*()
Definition: ProtoClusterCollection.cc:168
ProtoClusterMutableCollectionIterator & operator++()
Definition: ProtoClusterCollection.cc:178
ProtoClusterMutableCollectionIterator(size_t index, const ProtoClusterObjPointerContainer *collection)
Definition: ProtoClusterCollection.h:59
MutableProtoCluster * operator->()
Definition: ProtoClusterCollection.cc:173
bool operator!=(const ProtoClusterMutableCollectionIterator &x) const
Definition: ProtoClusterCollection.h:64
ProtoClusterMutableCollectionIterator(const ProtoClusterMutableCollectionIterator &)=delete
ProtoClusterMutableCollectionIterator & operator=(const ProtoClusterMutableCollectionIterator &)=delete
Definition: ProtoClusterObj.h:19
std::vector< eicd::CalorimeterHit > * m_hits
Definition: ProtoClusterObj.h:34
Definition: CalorimeterHit.cc:13
std::deque< ProtoClusterObj * > ProtoClusterObjPointerContainer
Definition: ProtoClusterCollectionData.h:21
std::ostream & operator<<(std::ostream &o, const CalorimeterHit &value)
Definition: CalorimeterHit.cc:93