3#ifndef EDM4EIC_RingImageCollection_H
4#define EDM4EIC_RingImageCollection_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::RingImageCollection";
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;
154 RingImage operator[](std::
size_t index) const;
177 if (!m_isSubsetColl) {
179 [ID] (
RingImageObj* 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);
209 std::vector<float> npe(
const size_t nElem = 0)
const;
210 std::vector<edm4hep::Vector3f> position(
const size_t nElem = 0)
const;
211 std::vector<edm4hep::Vector3f> positionError(
const size_t nElem = 0)
const;
212 std::vector<float> theta(
const size_t nElem = 0)
const;
213 std::vector<float> thetaError(
const size_t nElem = 0)
const;
214 std::vector<float> radius(
const size_t nElem = 0)
const;
215 std::vector<float> radiusError(
const size_t nElem = 0)
const;
223 bool m_isValid{
false};
224 mutable bool m_isPrepared{
false};
225 bool m_isSubsetColl{
false};
226 uint32_t m_collectionID{0};
227 mutable std::unique_ptr<std::mutex> m_storageMtx{
nullptr};
228 mutable RingImageCollectionData m_storage{};
231std::ostream&
operator<<(std::ostream& o,
const RingImageCollection& v);
233template<
typename... Args>
235 if (m_isSubsetColl) {
236 throw std::logic_error(
"Cannot create new elements on a subset collection");
238 const int size = m_storage.entries.size();
239 auto obj =
new RingImageObj({size, m_collectionID}, {std::forward<Args>(args)...});
240 m_storage.entries.push_back(obj);
245#if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
Definition MutableRingImage.h:30
Definition RingImageCollectionData.h:30
RingImageObjPointerContainer entries
Definition RingImageCollectionData.h:35
Definition RingImageCollection.h:95
static constexpr auto typeName
Definition RingImageCollection.h:112
uint32_t getID() const final
Definition RingImageCollection.h:185
RingImageCollection()
Definition RingImageCollection.cc:22
RingImage at(std::size_t index) const
Returns the const object of given index.
Definition RingImageCollection.cc:37
RingImageCollection(RingImageCollection &&)=default
void push_back(MutableRingImage object)
Append object to the collection.
Definition RingImageCollection.cc:124
void setID(uint32_t ID) final
Definition RingImageCollection.h:175
const_iterator begin() const
Definition RingImageCollection.h:199
~RingImageCollection()
Definition RingImageCollection.cc:28
MutableRingImage create()
Append a new object to the collection, and return this object.
Definition RingImageCollection.cc:68
std::size_t size() const final
number of elements in the collection
Definition RingImageCollection.cc:49
RingImageCollection & operator=(const RingImageCollection &)=delete
bool setReferences(const podio::ICollectionProvider *collectionProvider) final
Definition RingImageCollection.cc:120
bool empty() const final
Is the collection empty.
Definition RingImageCollection.cc:53
void print(std::ostream &os=std::cout, bool flush=true) const final
Print this collection to the passed stream.
Definition RingImageCollection.cc:391
void prepareAfterRead() final
Definition RingImageCollection.cc:105
const std::string_view getValueTypeName() const final
fully qualified type name of elements - with namespace
Definition RingImageCollection.h:141
iterator end()
Definition RingImageCollection.h:202
void clear() final
Definition RingImageCollection.cc:79
void setSubsetCollection(bool setSubset=true) final
Definition RingImageCollection.cc:57
static constexpr auto dataTypeName
Definition RingImageCollection.h:114
bool isValid() const final
Definition RingImageCollection.h:189
podio::SchemaVersionT getSchemaVersion() const final
schema version
Definition RingImageCollection.cc:235
RingImageCollection(const RingImageCollection &)=delete
bool isSubsetCollection() const final
Definition RingImageCollection.h:147
podio::CollectionWriteBuffers getBuffers() final
Get the collection buffers for this collection.
Definition RingImageCollection.cc:156
const std::string_view getDataTypeName() const final
fully qualified type name of stored POD elements - with namespace
Definition RingImageCollection.h:143
void prepareForWrite() const final
Definition RingImageCollection.cc:84
const std::string_view getTypeName() const final
fully qualified type name
Definition RingImageCollection.h:139
static constexpr auto valueTypeName
Definition RingImageCollection.h:113
RingImageCollection & operator=(RingImageCollection &&)=default
const_iterator end() const
Definition RingImageCollection.h:205
Definition RingImageCollection.h:40
bool operator!=(const RingImageCollectionIterator &x) const
Definition RingImageCollection.h:47
RingImageCollectionIterator & operator=(const RingImageCollectionIterator &)=delete
bool operator==(const RingImageCollectionIterator &x) const
Definition RingImageCollection.h:51
RingImageCollectionIterator(const RingImageCollectionIterator &)=delete
RingImageCollectionIterator(size_t index, const RingImageObjPointerContainer *collection)
Definition RingImageCollection.h:42
RingImageCollectionIterator & operator++()
Definition RingImageCollection.cc:343
RingImage operator*()
Definition RingImageCollection.cc:333
RingImage * operator->()
Definition RingImageCollection.cc:338
Definition RingImage.h:31
Definition RingImageCollection.h:66
MutableRingImage * operator->()
Definition RingImageCollection.cc:355
bool operator==(const RingImageMutableCollectionIterator &x) const
Definition RingImageCollection.h:77
RingImageMutableCollectionIterator & operator++()
Definition RingImageCollection.cc:360
bool operator!=(const RingImageMutableCollectionIterator &x) const
Definition RingImageCollection.h:73
RingImageMutableCollectionIterator(size_t index, const RingImageObjPointerContainer *collection)
Definition RingImageCollection.h:68
RingImageMutableCollectionIterator & operator=(const RingImageMutableCollectionIterator &)=delete
MutableRingImage operator*()
Definition RingImageCollection.cc:350
RingImageMutableCollectionIterator(const RingImageMutableCollectionIterator &)=delete
Definition RingImageObj.h:17
Definition CalorimeterHit.cc:18
std::ostream & operator<<(std::ostream &o, const CalorimeterHit &value)
Definition CalorimeterHit.cc:97
std::deque< RingImageObj * > RingImageObjPointerContainer
Definition RingImageCollectionData.h:22
Definition CalorimeterHitCollection.h:32