3#ifndef EICD_TrackSegmentCollection_H
4#define EICD_TrackSegmentCollection_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::TrackSegmentCollection"); }
118 std::string
getDataTypeName() const final {
return std::string(
"eicd::TrackSegmentData"); }
121 return m_isSubsetColl;
141 bool setReferences(const podio::ICollectionProvider* collectionProvider) final;
148 if (!m_isSubsetColl) {
150 [ID] (
TrackSegmentObj* 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);
178 template<
size_t arraysize>
179 const std::array<float, arraysize> length()
const;
180 template<
size_t arraysize>
181 const std::array<float, arraysize> lengthError()
const;
189 bool m_isValid{
false};
190 mutable bool m_isPrepared{
false};
191 bool m_isSubsetColl{
false};
192 int m_collectionID{0};
193 mutable std::unique_ptr<std::mutex> m_storageMtx{std::make_unique<std::mutex>()};
194 mutable TrackSegmentCollectionData m_storage{};
197std::ostream&
operator<<(std::ostream& o,
const TrackSegmentCollection& v);
199template<
typename... Args>
201 if (m_isSubsetColl) {
202 throw std::logic_error(
"Cannot create new elements on a subset collection");
204 const int size = m_storage.entries.size();
205 auto obj =
new TrackSegmentObj({size, m_collectionID}, {std::forward<Args>(args)...});
206 m_storage.entries.push_back(obj);
209 obj->
m_points =
new std::vector<eicd::TrackPoint>();
210 m_storage.createRelations(obj);
214template<
size_t arraysize>
215const std::array<float, arraysize> TrackSegmentCollection::length()
const {
216 std::array<float, arraysize> tmp{};
217 const auto valid_size = std::min(arraysize, m_storage.entries.size());
218 for (
unsigned i = 0; i < valid_size; ++i) {
219 tmp[i] = m_storage.entries[i]->data.length;
224template<
size_t arraysize>
225const std::array<float, arraysize> TrackSegmentCollection::lengthError()
const {
226 std::array<float, arraysize> tmp{};
227 const auto valid_size = std::min(arraysize, m_storage.entries.size());
228 for (
unsigned i = 0; i < valid_size; ++i) {
229 tmp[i] = m_storage.entries[i]->data.lengthError;
235#ifdef PODIO_JSON_OUTPUT
Definition: MutableTrackSegment.h:34
Definition: TrackSegmentCollectionData.h:29
TrackSegmentObjPointerContainer entries
Definition: TrackSegmentCollectionData.h:34
Definition: TrackSegmentCollection.h:82
std::string getTypeName() const final
fully qualified type name
Definition: TrackSegmentCollection.h:114
TrackSegmentCollection()
Definition: TrackSegmentCollection.cc:15
TrackSegmentCollection & operator=(TrackSegmentCollection &&)=default
unsigned getID() const final
Definition: TrackSegmentCollection.h:156
TrackSegment at(unsigned int index) const
Returns the const object of given index.
Definition: TrackSegmentCollection.cc:27
podio::CollectionBuffers getBuffers() final
Get the collection buffers for this collection.
Definition: TrackSegmentCollection.cc:137
iterator begin()
Definition: TrackSegmentCollection.h:165
~TrackSegmentCollection()
Definition: TrackSegmentCollection.cc:18
TrackSegmentCollection(TrackSegmentCollection &&)=default
MutableTrackSegment create()
Append a new object to the collection, and return this object.
Definition: TrackSegmentCollection.cc:54
void push_back(TrackSegment object)
Append object to the collection.
Definition: TrackSegmentCollection.cc:111
bool isValid() const final
Definition: TrackSegmentCollection.h:160
const_iterator end() const
Definition: TrackSegmentCollection.h:174
size_t size() const final
number of elements in the collection
Definition: TrackSegmentCollection.cc:39
void clear() final
Definition: TrackSegmentCollection.cc:66
iterator end()
Definition: TrackSegmentCollection.h:171
void prepareForWrite() const final
Definition: TrackSegmentCollection.cc:71
bool isSubsetCollection() const final
Definition: TrackSegmentCollection.h:120
void prepareAfterRead() final
Definition: TrackSegmentCollection.cc:92
void setSubsetCollection(bool setSubset=true) final
Definition: TrackSegmentCollection.cc:43
const_iterator begin() const
Definition: TrackSegmentCollection.h:168
void setID(unsigned ID) final
Definition: TrackSegmentCollection.h:146
bool setReferences(const podio::ICollectionProvider *collectionProvider) final
Definition: TrackSegmentCollection.cc:107
std::string getValueTypeName() const final
fully qualified type name of elements - with namespace
Definition: TrackSegmentCollection.h:116
TrackSegmentCollection & operator=(const TrackSegmentCollection &)=delete
std::string getDataTypeName() const final
fully qualified type name of stored POD elements - with namespace
Definition: TrackSegmentCollection.h:118
TrackSegmentCollection(const TrackSegmentCollection &)=delete
Definition: TrackSegmentCollection.h:35
TrackSegmentCollectionIterator & operator=(const TrackSegmentCollectionIterator &)=delete
TrackSegmentCollectionIterator(const TrackSegmentCollectionIterator &)=delete
TrackSegment operator*()
Definition: TrackSegmentCollection.cc:151
bool operator!=(const TrackSegmentCollectionIterator &x) const
Definition: TrackSegmentCollection.h:42
TrackSegment * operator->()
Definition: TrackSegmentCollection.cc:156
TrackSegmentCollectionIterator(size_t index, const TrackSegmentObjPointerContainer *collection)
Definition: TrackSegmentCollection.h:37
TrackSegmentCollectionIterator & operator++()
Definition: TrackSegmentCollection.cc:161
Definition: TrackSegment.h:33
Definition: TrackSegmentCollection.h:57
TrackSegmentMutableCollectionIterator(size_t index, const TrackSegmentObjPointerContainer *collection)
Definition: TrackSegmentCollection.h:59
TrackSegmentMutableCollectionIterator & operator++()
Definition: TrackSegmentCollection.cc:178
TrackSegmentMutableCollectionIterator & operator=(const TrackSegmentMutableCollectionIterator &)=delete
TrackSegmentMutableCollectionIterator(const TrackSegmentMutableCollectionIterator &)=delete
bool operator!=(const TrackSegmentMutableCollectionIterator &x) const
Definition: TrackSegmentCollection.h:64
MutableTrackSegment operator*()
Definition: TrackSegmentCollection.cc:168
MutableTrackSegment * operator->()
Definition: TrackSegmentCollection.cc:173
Definition: TrackSegmentObj.h:23
std::vector< eicd::TrackPoint > * m_points
Definition: TrackSegmentObj.h:39
Definition: CalorimeterHit.cc:13
std::ostream & operator<<(std::ostream &o, const CalorimeterHit &value)
Definition: CalorimeterHit.cc:93
std::deque< TrackSegmentObj * > TrackSegmentObjPointerContainer
Definition: TrackSegmentCollectionData.h:21