3#ifndef EDM4EIC_ReconstructedParticleCollection_H
4#define EDM4EIC_ReconstructedParticleCollection_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 ReconstructedParticle m_object { podio::utils::MaybeSharedPtr<ReconstructedParticleObj>{
nullptr} };
108 return m_index <=> other.m_index;
112 return m_index == x.m_index;
131 MutableReconstructedParticle m_object { podio::utils::MaybeSharedPtr<ReconstructedParticleObj>{
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::ReconstructedParticleCollection";
170 constexpr static std::string_view
valueTypeName =
"edm4eic::ReconstructedParticle";
171 constexpr static std::string_view
dataTypeName =
"edm4eic::ReconstructedParticleData";
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(),
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<std::int32_t> type(
const size_t nElem = 0)
const;
305 std::vector<float> energy(
const size_t nElem = 0)
const;
306 std::vector<edm4hep::Vector3f> momentum(
const size_t nElem = 0)
const;
307 std::vector<edm4hep::Vector3f> referencePoint(
const size_t nElem = 0)
const;
308 std::vector<float> charge(
const size_t nElem = 0)
const;
309 std::vector<float> mass(
const size_t nElem = 0)
const;
310 std::vector<float> goodnessOfPID(
const size_t nElem = 0)
const;
311 std::vector<edm4eic::Cov4f> covMatrix(
const size_t nElem = 0)
const;
312 std::vector<std::int32_t> PDG(
const size_t nElem = 0)
const;
320 mutable bool m_isPrepared{
false};
321 bool m_isSubsetColl{
false};
322 uint32_t m_collectionID{
static_cast<uint32_t
>(podio::ObjectID::untracked)};
323 mutable std::unique_ptr<std::mutex> m_storageMtx{std::make_unique<std::mutex>()};
327std::ostream&
operator<<(std::ostream& o,
const ReconstructedParticleCollection& v);
329template<
typename... Args>
331 if (m_isSubsetColl) {
332 throw std::logic_error(
"Cannot create new elements on a subset collection");
334 auto obj =
new ReconstructedParticleObj({
static_cast<int>(m_storage.entries.size()), m_collectionID}, {std::forward<Args>(args)...});
335 m_storage.entries.push_back(obj);
338 obj->
m_clusters =
new std::vector<edm4eic::Cluster>();
339 obj->m_tracks =
new std::vector<edm4eic::Track>();
340 obj->m_particles =
new std::vector<edm4eic::ReconstructedParticle>();
341 obj->m_particleIDs =
new std::vector<edm4hep::ParticleID>();
342 m_storage.createRelations(obj);
347#if defined(__cpp_lib_containers_ranges)
348template<podio::detail::RangeConvertibleTo<ReconstructedParticleCollection::value_type> R>
353 for (
auto&& elem : range) {
354 push_back(std::forward<
decltype(elem)>(elem));
359template<podio::detail::RangeConvertibleTo<ReconstructedParticleCollection::value_type> R>
362 if constexpr (podio::detail::RangeOf<R, value_type>) {
366 for (
auto&& elem : range) {
367 coll.
push_back(std::forward<
decltype(elem)>(elem));
374#if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
384#if defined(__clang__)
385 #pragma clang diagnostic push
386 #pragma clang diagnostic ignored "-Wunknown-warning-option"
387 #pragma clang diagnostic ignored "-Wdeprecated-redundant-constexpr-static-def"
388 #pragma clang diagnostic ignored "-Wdeprecated"
392 #pragma clang diagnostic pop
393#elif defined(__GNUC__)
394 #pragma GCC diagnostic push
395 #pragma GCC diagnostic ignored "-Wdeprecated"
399 #pragma GCC diagnostic pop
Definition MutableReconstructedParticle.h:46
Definition ReconstructedParticleCollectionData.h:35
Definition ReconstructedParticleCollection.h:139
void clear() final
Definition ReconstructedParticleCollection.cc:92
ReconstructedParticleCollection()=default
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 ReconstructedParticleCollection.h:176
void setSubsetCollection(bool setSubset=true) final
Definition ReconstructedParticleCollection.cc:69
const std::string_view getDataTypeName() const final
fully qualified type name of stored POD elements - with namespace
Definition ReconstructedParticleCollection.h:205
ReconstructedParticle at(std::size_t index) const
Returns the const object of given index.
Definition ReconstructedParticleCollection.cc:39
friend class ReconstructedParticleCollectionData
Definition ReconstructedParticleCollection.h:318
ReconstructedParticleCollectionIterator const_iterator
Definition ReconstructedParticleCollection.h:143
reverse_iterator rend()
Definition ReconstructedParticleCollection.h:293
MutableReconstructedParticle create()
Append a new object to the collection, and return this object.
Definition ReconstructedParticleCollection.cc:80
iterator end()
Definition ReconstructedParticleCollection.h:274
ptrdiff_t difference_type
Definition ReconstructedParticleCollection.h:145
const_iterator begin() const
Definition ReconstructedParticleCollection.h:268
static constexpr std::string_view dataTypeName
Definition ReconstructedParticleCollection.h:171
ReconstructedParticleCollection(ReconstructedParticleCollection &&)=default
void setID(uint32_t ID) final
Definition ReconstructedParticleCollection.h:237
bool empty() const final
Is the collection empty.
Definition ReconstructedParticleCollection.cc:65
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition ReconstructedParticleCollection.h:147
std::size_t size() const final
number of elements in the collection
Definition ReconstructedParticleCollection.cc:51
ReconstructedParticle value_type
Definition ReconstructedParticleCollection.h:141
ReconstructedParticleCollection & operator=(ReconstructedParticleCollection &&)=default
const_reverse_iterator rbegin() const
Definition ReconstructedParticleCollection.h:287
size_t size_type
Definition ReconstructedParticleCollection.h:146
void push_back(const MutableReconstructedParticle &object)
Append object to the collection.
Definition ReconstructedParticleCollection.cc:125
ReconstructedParticleCollection & operator=(const ReconstructedParticleCollection &)=delete
std::reverse_iterator< iterator > reverse_iterator
Definition ReconstructedParticleCollection.h:148
void prepareAfterRead() final
Definition ReconstructedParticleCollection.cc:106
const_iterator cend() const
Definition ReconstructedParticleCollection.h:280
bool isSubsetCollection() const final
Definition ReconstructedParticleCollection.h:209
const_iterator cbegin() const
Definition ReconstructedParticleCollection.h:271
void prepareForWrite() const final
Definition ReconstructedParticleCollection.cc:97
uint32_t getID() const final
Definition ReconstructedParticleCollection.h:246
static ReconstructedParticleCollection from(R &&range)
Definition ReconstructedParticleCollection.h:360
~ReconstructedParticleCollection() override
Definition ReconstructedParticleCollection.cc:30
ReconstructedParticleCollection(const ReconstructedParticleCollection &)=delete
podio::SchemaVersionT getSchemaVersion() const final
schema version
Definition ReconstructedParticleCollection.cc:256
const_reverse_iterator crbegin() const
Definition ReconstructedParticleCollection.h:290
bool setReferences(const podio::ICollectionProvider *collectionProvider) final
Definition ReconstructedParticleCollection.cc:121
std::size_t max_size() const final
maximal number of elements in the collection
Definition ReconstructedParticleCollection.cc:55
iterator begin()
Definition ReconstructedParticleCollection.h:265
const_reverse_iterator crend() const
Definition ReconstructedParticleCollection.h:299
podio::CollectionWriteBuffers getBuffers() final
Get the collection buffers for this collection.
Definition ReconstructedParticleCollection.cc:157
bool hasID() const final
check if the collection has a valid ID
Definition ReconstructedParticleCollection.h:251
void print(std::ostream &os=std::cout, bool flush=true) const final
Print this collection to the passed stream.
Definition ReconstructedParticleCollection.cc:538
const std::string_view getValueTypeName() const final
fully qualified type name of elements - with namespace
Definition ReconstructedParticleCollection.h:203
MutableReconstructedParticle mutable_type
Definition ReconstructedParticleCollection.h:142
static constexpr std::string_view valueTypeName
Definition ReconstructedParticleCollection.h:170
ReconstructedParticleMutableCollectionIterator iterator
Definition ReconstructedParticleCollection.h:144
const_reverse_iterator rend() const
Definition ReconstructedParticleCollection.h:296
static constexpr std::string_view typeName
Definition ReconstructedParticleCollection.h:169
bool isValid() const final
Definition ReconstructedParticleCollection.h:258
const std::string_view getTypeName() const final
fully qualified type name
Definition ReconstructedParticleCollection.h:201
reverse_iterator rbegin()
Definition ReconstructedParticleCollection.h:284
const_iterator end() const
Definition ReconstructedParticleCollection.h:277
Definition ReconstructedParticleCollection.h:38
reference operator*() const
Definition ReconstructedParticleCollection.cc:354
std::input_iterator_tag iterator_category
Definition ReconstructedParticleCollection.h:44
ReconstructedParticleCollectionIterator & operator--()
Definition ReconstructedParticleCollection.cc:374
ReconstructedParticleCollectionIterator()=default
ReconstructedParticleCollectionIterator & operator=(ReconstructedParticleCollectionIterator &&)=default
~ReconstructedParticleCollectionIterator()=default
ReconstructedParticleCollectionIterator operator+(difference_type n) const
Definition ReconstructedParticleCollection.cc:390
ReconstructedParticleCollectionIterator & operator++()
Definition ReconstructedParticleCollection.cc:363
ReconstructedParticleCollectionIterator operator-(difference_type n) const
Definition ReconstructedParticleCollection.cc:405
ReconstructedParticle * pointer
Definition ReconstructedParticleCollection.h:43
constexpr auto operator<=>(const ReconstructedParticleCollectionIterator &other) const
Definition ReconstructedParticleCollection.h:58
ReconstructedParticle value_type
Definition ReconstructedParticleCollection.h:40
ReconstructedParticleCollectionIterator(const ReconstructedParticleCollectionIterator &)=default
ReconstructedParticleCollectionIterator(size_t index, const ReconstructedParticleObjPointerContainer *collection)
Definition ReconstructedParticleCollection.h:49
reference operator[](difference_type n) const
Definition ReconstructedParticleCollection.cc:411
ReconstructedParticleCollectionIterator & operator-=(difference_type n)
Definition ReconstructedParticleCollection.cc:400
ptrdiff_t difference_type
Definition ReconstructedParticleCollection.h:41
constexpr bool operator==(const ReconstructedParticleCollectionIterator &x) const
Definition ReconstructedParticleCollection.h:62
ReconstructedParticleCollectionIterator & operator=(const ReconstructedParticleCollectionIterator &)=default
pointer operator->()
Definition ReconstructedParticleCollection.cc:358
ReconstructedParticleCollectionIterator & operator+=(difference_type n)
Definition ReconstructedParticleCollection.cc:385
std::random_access_iterator_tag iterator_concept
Definition ReconstructedParticleCollection.h:47
ReconstructedParticle reference
Definition ReconstructedParticleCollection.h:42
ReconstructedParticleCollectionIterator(ReconstructedParticleCollectionIterator &&)=default
Definition ReconstructedParticle.h:54
Definition ReconstructedParticleCollection.h:87
ReconstructedParticleMutableCollectionIterator operator+(difference_type n) const
Definition ReconstructedParticleCollection.cc:457
ReconstructedParticleMutableCollectionIterator(size_t index, const ReconstructedParticleObjPointerContainer *collection)
Definition ReconstructedParticleCollection.h:98
ReconstructedParticle value_type
Definition ReconstructedParticleCollection.h:89
ReconstructedParticleMutableCollectionIterator(const ReconstructedParticleMutableCollectionIterator &)=default
std::random_access_iterator_tag iterator_concept
Definition ReconstructedParticleCollection.h:96
MutableReconstructedParticle * pointer
Definition ReconstructedParticleCollection.h:92
ReconstructedParticleMutableCollectionIterator & operator-=(difference_type n)
Definition ReconstructedParticleCollection.cc:467
reference operator[](difference_type n) const
Definition ReconstructedParticleCollection.cc:478
ptrdiff_t difference_type
Definition ReconstructedParticleCollection.h:90
constexpr auto operator<=>(const ReconstructedParticleMutableCollectionIterator &other) const
Definition ReconstructedParticleCollection.h:107
ReconstructedParticleMutableCollectionIterator()=default
reference operator*() const
Definition ReconstructedParticleCollection.cc:421
ReconstructedParticleMutableCollectionIterator & operator+=(difference_type n)
Definition ReconstructedParticleCollection.cc:452
ReconstructedParticleMutableCollectionIterator & operator++()
Definition ReconstructedParticleCollection.cc:430
ReconstructedParticleMutableCollectionIterator & operator=(ReconstructedParticleMutableCollectionIterator &&)=default
ReconstructedParticleMutableCollectionIterator operator-(difference_type n) const
Definition ReconstructedParticleCollection.cc:472
ReconstructedParticleMutableCollectionIterator(ReconstructedParticleMutableCollectionIterator &&)=default
ReconstructedParticleMutableCollectionIterator & operator=(const ReconstructedParticleMutableCollectionIterator &)=default
~ReconstructedParticleMutableCollectionIterator()=default
MutableReconstructedParticle reference
Definition ReconstructedParticleCollection.h:91
constexpr bool operator==(const ReconstructedParticleMutableCollectionIterator &x) const
Definition ReconstructedParticleCollection.h:111
ReconstructedParticleMutableCollectionIterator & operator--()
Definition ReconstructedParticleCollection.cc:441
pointer operator->()
Definition ReconstructedParticleCollection.cc:425
std::input_iterator_tag iterator_category
Definition ReconstructedParticleCollection.h:93
Definition ReconstructedParticleObj.h:29
std::vector< edm4eic::Cluster > * m_clusters
Definition ReconstructedParticleObj.h:47
Definition ArrowMapper.cc:61
std::deque< ReconstructedParticleObj * > ReconstructedParticleObjPointerContainer
Definition ReconstructedParticleCollectionData.h:27
std::ostream & operator<<(std::ostream &o, const CalorimeterHit &value)
Definition CalorimeterHit.cc:99
Definition CalorimeterHit.h:31