3#ifndef EDM4EIC_TrackerHitCollection_H
4#define EDM4EIC_TrackerHitCollection_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::TrackerHitCollection";
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;
156 TrackerHit operator[](std::
size_t index) const;
179 if (!m_isSubsetColl) {
181 [ID] (
TrackerHitObj* 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);
217 std::vector<std::uint64_t> cellID(
const size_t nElem = 0)
const;
218 std::vector<edm4hep::Vector3f> position(
const size_t nElem = 0)
const;
219 std::vector<edm4eic::CovDiag3f> positionError(
const size_t nElem = 0)
const;
220 std::vector<float> time(
const size_t nElem = 0)
const;
221 std::vector<float> timeError(
const size_t nElem = 0)
const;
222 std::vector<float> edep(
const size_t nElem = 0)
const;
223 std::vector<float> edepError(
const size_t nElem = 0)
const;
231 bool m_isValid{
false};
232 mutable bool m_isPrepared{
false};
233 bool m_isSubsetColl{
false};
234 uint32_t m_collectionID{0};
235 mutable std::unique_ptr<std::mutex> m_storageMtx{
nullptr};
236 mutable TrackerHitCollectionData m_storage{};
239std::ostream&
operator<<(std::ostream& o,
const TrackerHitCollection& v);
241template<
typename... Args>
243 if (m_isSubsetColl) {
244 throw std::logic_error(
"Cannot create new elements on a subset collection");
246 const int size = m_storage.entries.size();
247 auto obj =
new TrackerHitObj({size, m_collectionID}, {std::forward<Args>(args)...});
248 m_storage.entries.push_back(obj);
253#if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
Definition MutableTrackerHit.h:36
Definition TrackerHitCollectionData.h:31
TrackerHitObjPointerContainer entries
Definition TrackerHitCollectionData.h:36
Definition TrackerHitCollection.h:92
const std::string_view getValueTypeName() const final
fully qualified type name of elements - with namespace
Definition TrackerHitCollection.h:143
TrackerHitCollection()
Definition TrackerHitCollection.cc:23
const_iterator cbegin() const
Definition TrackerHitCollection.h:204
void print(std::ostream &os=std::cout, bool flush=true) const final
Print this collection to the passed stream.
Definition TrackerHitCollection.cc:403
bool empty() const final
Is the collection empty.
Definition TrackerHitCollection.cc:58
const_iterator end() const
Definition TrackerHitCollection.h:210
TrackerHit at(std::size_t index) const
Returns the const object of given index.
Definition TrackerHitCollection.cc:38
const_iterator begin() const
Definition TrackerHitCollection.h:201
void prepareAfterRead() final
Definition TrackerHitCollection.cc:110
const_iterator cend() const
Definition TrackerHitCollection.h:213
TrackerHitCollection & operator=(const TrackerHitCollection &)=delete
bool isSubsetCollection() const final
Definition TrackerHitCollection.h:149
std::size_t size() const final
number of elements in the collection
Definition TrackerHitCollection.cc:50
size_t size_type
Definition TrackerHitCollection.h:98
const std::string_view getTypeName() const final
fully qualified type name
Definition TrackerHitCollection.h:141
MutableTrackerHit create()
Append a new object to the collection, and return this object.
Definition TrackerHitCollection.cc:73
podio::CollectionWriteBuffers getBuffers() final
Get the collection buffers for this collection.
Definition TrackerHitCollection.cc:161
static constexpr auto dataTypeName
Definition TrackerHitCollection.h:113
static constexpr auto valueTypeName
Definition TrackerHitCollection.h:112
podio::SchemaVersionT getSchemaVersion() const final
schema version
Definition TrackerHitCollection.cc:240
uint32_t getID() const final
Definition TrackerHitCollection.h:187
TrackerHitCollection(const TrackerHitCollection &)=delete
void setSubsetCollection(bool setSubset=true) final
Definition TrackerHitCollection.cc:62
~TrackerHitCollection()
Definition TrackerHitCollection.cc:29
ptrdiff_t difference_type
Definition TrackerHitCollection.h:97
TrackerHitCollection & operator=(TrackerHitCollection &&)=default
bool setReferences(const podio::ICollectionProvider *collectionProvider) final
Definition TrackerHitCollection.cc:125
std::size_t max_size() const final
maximal number of elements in the collection
Definition TrackerHitCollection.cc:54
const std::string_view getDataTypeName() const final
fully qualified type name of stored POD elements - with namespace
Definition TrackerHitCollection.h:145
bool isValid() const final
Definition TrackerHitCollection.h:191
static constexpr auto typeName
Definition TrackerHitCollection.h:111
iterator end()
Definition TrackerHitCollection.h:207
TrackerHitCollection(TrackerHitCollection &&)=default
void clear() final
Definition TrackerHitCollection.cc:84
void prepareForWrite() const final
Definition TrackerHitCollection.cc:89
void setID(uint32_t ID) final
Definition TrackerHitCollection.h:177
void push_back(const MutableTrackerHit &object)
Append object to the collection.
Definition TrackerHitCollection.cc:129
Definition TrackerHitCollection.h:37
bool operator==(const TrackerHitCollectionIterator &x) const
Definition TrackerHitCollection.h:48
TrackerHitCollectionIterator & operator++()
Definition TrackerHitCollection.cc:353
TrackerHitCollectionIterator(size_t index, const TrackerHitObjPointerContainer *collection)
Definition TrackerHitCollection.h:39
bool operator!=(const TrackerHitCollectionIterator &x) const
Definition TrackerHitCollection.h:44
TrackerHit operator*()
Definition TrackerHitCollection.cc:343
TrackerHitCollectionIterator(const TrackerHitCollectionIterator &)=delete
TrackerHitCollectionIterator & operator=(const TrackerHitCollectionIterator &)=delete
TrackerHit * operator->()
Definition TrackerHitCollection.cc:348
Definition TrackerHit.h:38
Definition TrackerHitCollection.h:63
bool operator==(const TrackerHitMutableCollectionIterator &x) const
Definition TrackerHitCollection.h:74
TrackerHitMutableCollectionIterator & operator++()
Definition TrackerHitCollection.cc:370
TrackerHitMutableCollectionIterator & operator=(const TrackerHitMutableCollectionIterator &)=delete
TrackerHitMutableCollectionIterator(size_t index, const TrackerHitObjPointerContainer *collection)
Definition TrackerHitCollection.h:65
TrackerHitMutableCollectionIterator(const TrackerHitMutableCollectionIterator &)=delete
MutableTrackerHit * operator->()
Definition TrackerHitCollection.cc:365
bool operator!=(const TrackerHitMutableCollectionIterator &x) const
Definition TrackerHitCollection.h:70
MutableTrackerHit operator*()
Definition TrackerHitCollection.cc:360
Definition TrackerHitObj.h:21
Definition CalorimeterHit.cc:17
std::ostream & operator<<(std::ostream &o, const CalorimeterHit &value)
Definition CalorimeterHit.cc:103
std::deque< TrackerHitObj * > TrackerHitObjPointerContainer
Definition TrackerHitCollectionData.h:23
Definition CalorimeterHitCollection.h:29