3#ifndef EDM4EIC_TrackSegmentCollection_H
4#define EDM4EIC_TrackSegmentCollection_H
13#include "podio/ICollectionProvider.h"
14#include "podio/CollectionBase.h"
15#include "podio/detail/Pythonizations.h"
16#include "podio/utilities/TypeHelpers.h"
18#if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
19#include "nlohmann/json_fwd.hpp"
59 return m_index <=> other.m_index;
63 return m_index == x.m_index;
82 TrackSegment m_object { podio::utils::MaybeSharedPtr<TrackSegmentObj>{
nullptr} };
108 return m_index <=> other.m_index;
112 return m_index == x.m_index;
131 MutableTrackSegment m_object { podio::utils::MaybeSharedPtr<TrackSegmentObj>{
nullptr} };
159#if defined(__cpp_lib_containers_ranges)
160 template<podio::detail::RangeConvertibleTo<value_type> R>
166 template<podio::detail::RangeConvertibleTo<value_type> R>
169 constexpr static std::string_view
typeName =
"edm4eic::TrackSegmentCollection";
171 constexpr static std::string_view
dataTypeName =
"edm4eic::TrackSegmentData";
177 podio::detail::pythonizations::pythonize_subscript(klass, name);
181 void print(std::ostream& os=std::cout,
bool flush=
true) const final;
188 template<typename... Args>
192 std::
size_t size() const final;
198 bool empty() const final;
210 return m_isSubsetColl;
239 if (!m_isSubsetColl) {
240 std::for_each(m_storage.entries.begin(), m_storage.entries.end(),
241 [ID] (
TrackSegmentObj* obj) { obj->id = {obj->id.index, static_cast<uint32_t>(ID)}; }
247 return m_collectionID;
252 return getID() !=
static_cast<uint32_t
>(podio::ObjectID::untracked) &&
253 getID() !=
static_cast<uint32_t
>(podio::ObjectID::invalid);
256 [[deprecated(
"isValid will be removed, use hasID() if you want to check if it has an ID, otherwise assume the "
257 "collection is valid")]]
262 size_t getDatamodelRegistryIndex() const final;
266 return iterator(0, &m_storage.entries);
275 return iterator(m_storage.entries.size(), &m_storage.entries);
278 return const_iterator(m_storage.entries.size(), &m_storage.entries);
304 std::vector<float> length(
const size_t nElem = 0)
const;
305 std::vector<float> lengthError(
const size_t nElem = 0)
const;
313 mutable bool m_isPrepared{
false};
314 bool m_isSubsetColl{
false};
315 uint32_t m_collectionID{
static_cast<uint32_t
>(podio::ObjectID::untracked)};
316 mutable std::unique_ptr<std::mutex> m_storageMtx{std::make_unique<std::mutex>()};
320std::ostream&
operator<<(std::ostream& o,
const TrackSegmentCollection& v);
322template<
typename... Args>
324 if (m_isSubsetColl) {
325 throw std::logic_error(
"Cannot create new elements on a subset collection");
327 auto obj =
new TrackSegmentObj({
static_cast<int>(m_storage.entries.size()), m_collectionID}, {std::forward<Args>(args)...});
328 m_storage.entries.push_back(obj);
331 obj->
m_points =
new std::vector<edm4eic::TrackPoint>();
332 m_storage.createRelations(obj);
337#if defined(__cpp_lib_containers_ranges)
338template<podio::detail::RangeConvertibleTo<TrackSegmentCollection::value_type> R>
343 for (
auto&& elem : range) {
344 push_back(std::forward<
decltype(elem)>(elem));
349template<podio::detail::RangeConvertibleTo<TrackSegmentCollection::value_type> R>
352 if constexpr (podio::detail::RangeOf<R, value_type>) {
356 for (
auto&& elem : range) {
357 coll.
push_back(std::forward<
decltype(elem)>(elem));
364#if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
374#if defined(__clang__)
375 #pragma clang diagnostic push
376 #pragma clang diagnostic ignored "-Wunknown-warning-option"
377 #pragma clang diagnostic ignored "-Wdeprecated-redundant-constexpr-static-def"
378 #pragma clang diagnostic ignored "-Wdeprecated"
382 #pragma clang diagnostic pop
383#elif defined(__GNUC__)
384 #pragma GCC diagnostic push
385 #pragma GCC diagnostic ignored "-Wdeprecated"
389 #pragma GCC diagnostic pop
Definition MutableTrackSegment.h:37
Definition TrackSegmentCollectionData.h:32
Definition TrackSegmentCollection.h:139
static void __cppyy_pythonize__(PyObject *klass, const std::string &name)
Cppyy protocol to setup the pythonizations for this class. Not to be called directly.
Definition TrackSegmentCollection.h:176
void push_back(const MutableTrackSegment &object)
Append object to the collection.
Definition TrackSegmentCollection.cc:123
reverse_iterator rend()
Definition TrackSegmentCollection.h:293
std::size_t size() const final
number of elements in the collection
Definition TrackSegmentCollection.cc:49
const_iterator begin() const
Definition TrackSegmentCollection.h:268
TrackSegmentCollection & operator=(TrackSegmentCollection &&)=default
reverse_iterator rbegin()
Definition TrackSegmentCollection.h:284
const std::string_view getTypeName() const final
fully qualified type name
Definition TrackSegmentCollection.h:201
const_iterator cbegin() const
Definition TrackSegmentCollection.h:271
const_reverse_iterator crbegin() const
Definition TrackSegmentCollection.h:290
const_reverse_iterator crend() const
Definition TrackSegmentCollection.h:299
void clear() final
Definition TrackSegmentCollection.cc:90
iterator end()
Definition TrackSegmentCollection.h:274
static constexpr std::string_view valueTypeName
Definition TrackSegmentCollection.h:170
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition TrackSegmentCollection.h:147
~TrackSegmentCollection() override
Definition TrackSegmentCollection.cc:28
bool hasID() const final
check if the collection has a valid ID
Definition TrackSegmentCollection.h:251
void setID(uint32_t ID) final
Definition TrackSegmentCollection.h:237
TrackSegment at(std::size_t index) const
Returns the const object of given index.
Definition TrackSegmentCollection.cc:37
TrackSegmentMutableCollectionIterator iterator
Definition TrackSegmentCollection.h:144
const_iterator cend() const
Definition TrackSegmentCollection.h:280
static constexpr std::string_view typeName
Definition TrackSegmentCollection.h:169
TrackSegmentCollection(const TrackSegmentCollection &)=delete
TrackSegmentCollection(TrackSegmentCollection &&)=default
void print(std::ostream &os=std::cout, bool flush=true) const final
Print this collection to the passed stream.
Definition TrackSegmentCollection.cc:444
bool isValid() const final
Definition TrackSegmentCollection.h:258
void setSubsetCollection(bool setSubset=true) final
Definition TrackSegmentCollection.cc:67
MutableTrackSegment mutable_type
Definition TrackSegmentCollection.h:142
void prepareForWrite() const final
Definition TrackSegmentCollection.cc:95
const_iterator end() const
Definition TrackSegmentCollection.h:277
const_reverse_iterator rend() const
Definition TrackSegmentCollection.h:296
podio::CollectionWriteBuffers getBuffers() final
Get the collection buffers for this collection.
Definition TrackSegmentCollection.cc:155
static TrackSegmentCollection from(R &&range)
Definition TrackSegmentCollection.h:350
iterator begin()
Definition TrackSegmentCollection.h:265
const std::string_view getDataTypeName() const final
fully qualified type name of stored POD elements - with namespace
Definition TrackSegmentCollection.h:205
bool empty() const final
Is the collection empty.
Definition TrackSegmentCollection.cc:63
bool isSubsetCollection() const final
Definition TrackSegmentCollection.h:209
std::size_t max_size() const final
maximal number of elements in the collection
Definition TrackSegmentCollection.cc:53
MutableTrackSegment create()
Append a new object to the collection, and return this object.
Definition TrackSegmentCollection.cc:78
TrackSegment value_type
Definition TrackSegmentCollection.h:141
TrackSegmentCollection & operator=(const TrackSegmentCollection &)=delete
size_t size_type
Definition TrackSegmentCollection.h:146
friend class TrackSegmentCollectionData
Definition TrackSegmentCollection.h:311
bool setReferences(const podio::ICollectionProvider *collectionProvider) final
Definition TrackSegmentCollection.cc:119
void prepareAfterRead() final
Definition TrackSegmentCollection.cc:104
TrackSegmentCollection()=default
const std::string_view getValueTypeName() const final
fully qualified type name of elements - with namespace
Definition TrackSegmentCollection.h:203
std::reverse_iterator< iterator > reverse_iterator
Definition TrackSegmentCollection.h:148
static constexpr std::string_view dataTypeName
Definition TrackSegmentCollection.h:171
const_reverse_iterator rbegin() const
Definition TrackSegmentCollection.h:287
ptrdiff_t difference_type
Definition TrackSegmentCollection.h:145
TrackSegmentCollectionIterator const_iterator
Definition TrackSegmentCollection.h:143
podio::SchemaVersionT getSchemaVersion() const final
schema version
Definition TrackSegmentCollection.cc:184
uint32_t getID() const final
Definition TrackSegmentCollection.h:246
Definition TrackSegmentCollection.h:38
ptrdiff_t difference_type
Definition TrackSegmentCollection.h:41
TrackSegment * pointer
Definition TrackSegmentCollection.h:43
TrackSegmentCollectionIterator operator+(difference_type n) const
Definition TrackSegmentCollection.cc:320
TrackSegmentCollectionIterator & operator--()
Definition TrackSegmentCollection.cc:304
~TrackSegmentCollectionIterator()=default
TrackSegmentCollectionIterator operator-(difference_type n) const
Definition TrackSegmentCollection.cc:335
TrackSegmentCollectionIterator & operator=(TrackSegmentCollectionIterator &&)=default
TrackSegmentCollectionIterator(const TrackSegmentCollectionIterator &)=default
constexpr bool operator==(const TrackSegmentCollectionIterator &x) const
Definition TrackSegmentCollection.h:62
TrackSegmentCollectionIterator(size_t index, const TrackSegmentObjPointerContainer *collection)
Definition TrackSegmentCollection.h:49
std::input_iterator_tag iterator_category
Definition TrackSegmentCollection.h:44
TrackSegmentCollectionIterator & operator-=(difference_type n)
Definition TrackSegmentCollection.cc:330
TrackSegment reference
Definition TrackSegmentCollection.h:42
reference operator[](difference_type n) const
Definition TrackSegmentCollection.cc:341
TrackSegmentCollectionIterator & operator++()
Definition TrackSegmentCollection.cc:293
pointer operator->()
Definition TrackSegmentCollection.cc:288
TrackSegmentCollectionIterator & operator+=(difference_type n)
Definition TrackSegmentCollection.cc:315
TrackSegmentCollectionIterator & operator=(const TrackSegmentCollectionIterator &)=default
std::random_access_iterator_tag iterator_concept
Definition TrackSegmentCollection.h:47
TrackSegmentCollectionIterator(TrackSegmentCollectionIterator &&)=default
reference operator*() const
Definition TrackSegmentCollection.cc:284
TrackSegmentCollectionIterator()=default
constexpr auto operator<=>(const TrackSegmentCollectionIterator &other) const
Definition TrackSegmentCollection.h:58
TrackSegment value_type
Definition TrackSegmentCollection.h:40
Definition TrackSegment.h:45
Definition TrackSegmentCollection.h:87
std::input_iterator_tag iterator_category
Definition TrackSegmentCollection.h:93
TrackSegmentMutableCollectionIterator operator-(difference_type n) const
Definition TrackSegmentCollection.cc:402
TrackSegmentMutableCollectionIterator(TrackSegmentMutableCollectionIterator &&)=default
TrackSegmentMutableCollectionIterator()=default
MutableTrackSegment reference
Definition TrackSegmentCollection.h:91
TrackSegmentMutableCollectionIterator(size_t index, const TrackSegmentObjPointerContainer *collection)
Definition TrackSegmentCollection.h:98
pointer operator->()
Definition TrackSegmentCollection.cc:355
TrackSegment value_type
Definition TrackSegmentCollection.h:89
~TrackSegmentMutableCollectionIterator()=default
TrackSegmentMutableCollectionIterator(const TrackSegmentMutableCollectionIterator &)=default
ptrdiff_t difference_type
Definition TrackSegmentCollection.h:90
MutableTrackSegment * pointer
Definition TrackSegmentCollection.h:92
constexpr auto operator<=>(const TrackSegmentMutableCollectionIterator &other) const
Definition TrackSegmentCollection.h:107
reference operator*() const
Definition TrackSegmentCollection.cc:351
constexpr bool operator==(const TrackSegmentMutableCollectionIterator &x) const
Definition TrackSegmentCollection.h:111
TrackSegmentMutableCollectionIterator & operator++()
Definition TrackSegmentCollection.cc:360
TrackSegmentMutableCollectionIterator & operator=(const TrackSegmentMutableCollectionIterator &)=default
std::random_access_iterator_tag iterator_concept
Definition TrackSegmentCollection.h:96
TrackSegmentMutableCollectionIterator operator+(difference_type n) const
Definition TrackSegmentCollection.cc:387
TrackSegmentMutableCollectionIterator & operator=(TrackSegmentMutableCollectionIterator &&)=default
TrackSegmentMutableCollectionIterator & operator--()
Definition TrackSegmentCollection.cc:371
TrackSegmentMutableCollectionIterator & operator-=(difference_type n)
Definition TrackSegmentCollection.cc:397
TrackSegmentMutableCollectionIterator & operator+=(difference_type n)
Definition TrackSegmentCollection.cc:382
reference operator[](difference_type n) const
Definition TrackSegmentCollection.cc:408
Definition TrackSegmentObj.h:24
std::vector< edm4eic::TrackPoint > * m_points
Definition TrackSegmentObj.h:41
Definition ArrowMapper.cc:61
std::deque< TrackSegmentObj * > TrackSegmentObjPointerContainer
Definition TrackSegmentCollectionData.h:24
std::ostream & operator<<(std::ostream &o, const CalorimeterHit &value)
Definition CalorimeterHit.cc:99
Definition CalorimeterHit.h:31