Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-06-03 08:33:28

0001 // AUTOMATICALLY GENERATED FILE - DO NOT EDIT
0002 
0003 #ifndef EDM4HEP_TrackMCParticleLinkCollection_H
0004 #define EDM4HEP_TrackMCParticleLinkCollection_H
0005 
0006 // datamodel specific includes
0007 #include "edm4hep/MutableTrackMCParticleLink.h"
0008 #include "edm4hep/TrackMCParticleLink.h"
0009 #include "edm4hep/TrackMCParticleLinkCollectionData.h"
0010 #include "edm4hep/TrackMCParticleLinkObj.h"
0011 
0012 // podio specific includes
0013 #include "podio/CollectionBase.h"
0014 #include "podio/ICollectionProvider.h"
0015 
0016 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0017 #include "nlohmann/json_fwd.hpp"
0018 #endif
0019 
0020 #include <algorithm>
0021 #include <cstddef>
0022 #include <memory>
0023 #include <mutex>
0024 #include <ostream>
0025 #include <string_view>
0026 #include <vector>
0027 
0028 namespace podio {
0029 struct RelationNames;
0030 }
0031 
0032 namespace edm4hep {
0033 
0034 class TrackMCParticleLinkCollectionIterator {
0035 public:
0036   TrackMCParticleLinkCollectionIterator(size_t index, const TrackMCParticleLinkObjPointerContainer* collection) :
0037       m_index(index),
0038       m_object(podio::utils::MaybeSharedPtr<TrackMCParticleLinkObj>{nullptr}),
0039       m_collection(collection) {
0040   }
0041 
0042   TrackMCParticleLinkCollectionIterator(const TrackMCParticleLinkCollectionIterator&) = delete;
0043   TrackMCParticleLinkCollectionIterator& operator=(const TrackMCParticleLinkCollectionIterator&) = delete;
0044 
0045   bool operator!=(const TrackMCParticleLinkCollectionIterator& x) const {
0046     return m_index != x.m_index; // TODO: may not be complete
0047   }
0048 
0049   bool operator==(const TrackMCParticleLinkCollectionIterator& x) const {
0050     return m_index == x.m_index; // TODO: may not be complete
0051   }
0052 
0053   TrackMCParticleLink operator*();
0054   TrackMCParticleLink* operator->();
0055   TrackMCParticleLinkCollectionIterator& operator++();
0056 
0057 private:
0058   size_t m_index;
0059   TrackMCParticleLink m_object;
0060   const TrackMCParticleLinkObjPointerContainer* m_collection;
0061 };
0062 
0063 class TrackMCParticleLinkMutableCollectionIterator {
0064 public:
0065   TrackMCParticleLinkMutableCollectionIterator(size_t index, const TrackMCParticleLinkObjPointerContainer* collection) :
0066       m_index(index),
0067       m_object(podio::utils::MaybeSharedPtr<TrackMCParticleLinkObj>{nullptr}),
0068       m_collection(collection) {
0069   }
0070 
0071   TrackMCParticleLinkMutableCollectionIterator(const TrackMCParticleLinkMutableCollectionIterator&) = delete;
0072   TrackMCParticleLinkMutableCollectionIterator& operator=(const TrackMCParticleLinkMutableCollectionIterator&) = delete;
0073 
0074   bool operator!=(const TrackMCParticleLinkMutableCollectionIterator& x) const {
0075     return m_index != x.m_index; // TODO: may not be complete
0076   }
0077 
0078   bool operator==(const TrackMCParticleLinkMutableCollectionIterator& x) const {
0079     return m_index == x.m_index; // TODO: may not be complete
0080   }
0081 
0082   MutableTrackMCParticleLink operator*();
0083   MutableTrackMCParticleLink* operator->();
0084   TrackMCParticleLinkMutableCollectionIterator& operator++();
0085 
0086 private:
0087   size_t m_index;
0088   MutableTrackMCParticleLink m_object;
0089   const TrackMCParticleLinkObjPointerContainer* m_collection;
0090 };
0091 
0092 /**
0093 A Collection is identified by an ID.
0094 */
0095 class TrackMCParticleLinkCollection : public podio::CollectionBase {
0096 public:
0097   using value_type = TrackMCParticleLink;
0098   using const_iterator = TrackMCParticleLinkCollectionIterator;
0099   using iterator = TrackMCParticleLinkMutableCollectionIterator;
0100   using difference_type = ptrdiff_t;
0101   using size_type = size_t;
0102 
0103   TrackMCParticleLinkCollection();
0104   TrackMCParticleLinkCollection(TrackMCParticleLinkCollectionData&& data, bool isSubsetColl);
0105   // This is a move-only type
0106   TrackMCParticleLinkCollection(const TrackMCParticleLinkCollection&) = delete;
0107   TrackMCParticleLinkCollection& operator=(const TrackMCParticleLinkCollection&) = delete;
0108   TrackMCParticleLinkCollection(TrackMCParticleLinkCollection&&) = default;
0109   TrackMCParticleLinkCollection& operator=(TrackMCParticleLinkCollection&&) = default;
0110 
0111   //  TrackMCParticleLinkCollection(TrackMCParticleLinkVector* data, uint32_t collectionID);
0112   ~TrackMCParticleLinkCollection() override;
0113 
0114   constexpr static auto typeName = "edm4hep::TrackMCParticleLinkCollection";
0115   constexpr static auto valueTypeName = "edm4hep::TrackMCParticleLink";
0116   constexpr static auto dataTypeName = "edm4hep::TrackMCParticleLinkData";
0117 
0118   void clear() final;
0119 
0120   /// Print this collection to the passed stream
0121   void print(std::ostream& os = std::cout, bool flush = true) const final;
0122 
0123   /// operator to allow pointer like calling of members a la LCIO
0124   TrackMCParticleLinkCollection* operator->() {
0125     return static_cast<TrackMCParticleLinkCollection*>(this);
0126   }
0127 
0128   /// Append a new object to the collection, and return this object.
0129   MutableTrackMCParticleLink create();
0130 
0131   /// Append a new object to the collection, and return this object.
0132   /// Initialized with the parameters given
0133   template <typename... Args>
0134   MutableTrackMCParticleLink create(Args&&... args);
0135 
0136   /// number of elements in the collection
0137   std::size_t size() const final;
0138 
0139   /// maximal number of elements in the collection
0140   std::size_t max_size() const final;
0141 
0142   /// Is the collection empty
0143   bool empty() const final;
0144 
0145   /// fully qualified type name
0146   const std::string_view getTypeName() const final {
0147     return typeName;
0148   }
0149   /// fully qualified type name of elements - with namespace
0150   const std::string_view getValueTypeName() const final {
0151     return valueTypeName;
0152   }
0153   /// fully qualified type name of stored POD elements - with namespace
0154   const std::string_view getDataTypeName() const final {
0155     return dataTypeName;
0156   }
0157   /// schema version
0158   podio::SchemaVersionT getSchemaVersion() const final;
0159 
0160   bool isSubsetCollection() const final {
0161     return m_isSubsetColl;
0162   }
0163 
0164   void setSubsetCollection(bool setSubset = true) final;
0165 
0166   /// Returns the const object of given index
0167   TrackMCParticleLink operator[](std::size_t index) const;
0168   /// Returns the object of a given index
0169   MutableTrackMCParticleLink operator[](std::size_t index);
0170   /// Returns the const object of given index
0171   TrackMCParticleLink at(std::size_t index) const;
0172   /// Returns the object of given index
0173   MutableTrackMCParticleLink at(std::size_t index);
0174 
0175   /// Append object to the collection
0176   void push_back(const MutableTrackMCParticleLink& object);
0177   /// Append an object to the (subset) collection
0178   void push_back(const TrackMCParticleLink& object);
0179 
0180   void prepareForWrite() const final;
0181   void prepareAfterRead() final;
0182   bool setReferences(const podio::ICollectionProvider* collectionProvider) final;
0183 
0184   /// Get the collection buffers for this collection
0185   podio::CollectionWriteBuffers getBuffers() final;
0186 
0187   void setID(uint32_t ID) final {
0188     m_collectionID = ID;
0189     if (!m_isSubsetColl) {
0190       std::for_each(m_storage.entries.begin(), m_storage.entries.end(), [ID](TrackMCParticleLinkObj* obj) {
0191         obj->id = {obj->id.index, static_cast<uint32_t>(ID)};
0192       });
0193     }
0194     m_isValid = true;
0195   }
0196 
0197   uint32_t getID() const final {
0198     return m_collectionID;
0199   }
0200 
0201   bool isValid() const final {
0202     return m_isValid;
0203   }
0204 
0205   size_t getDatamodelRegistryIndex() const final;
0206 
0207   // support for the iterator protocol
0208   iterator begin() {
0209     return iterator(0, &m_storage.entries);
0210   }
0211   const_iterator begin() const {
0212     return const_iterator(0, &m_storage.entries);
0213   }
0214   const_iterator cbegin() const {
0215     return begin();
0216   }
0217   iterator end() {
0218     return iterator(m_storage.entries.size(), &m_storage.entries);
0219   }
0220   const_iterator end() const {
0221     return const_iterator(m_storage.entries.size(), &m_storage.entries);
0222   }
0223   const_iterator cend() const {
0224     return end();
0225   }
0226 
0227   std::vector<float> weight(const size_t nElem = 0) const;
0228 
0229 private:
0230   // For setReferences, we need to give our own CollectionData access to our
0231   // private entries. Otherwise we would need to expose a public member function
0232   // that gives access to the Obj* which is definitely not what we want
0233   friend class TrackMCParticleLinkCollectionData;
0234 
0235   bool m_isValid{false};
0236   mutable bool m_isPrepared{false};
0237   bool m_isSubsetColl{false};
0238   uint32_t m_collectionID{0};
0239   mutable std::unique_ptr<std::mutex> m_storageMtx{nullptr};
0240   mutable TrackMCParticleLinkCollectionData m_storage{};
0241 };
0242 
0243 std::ostream& operator<<(std::ostream& o, const TrackMCParticleLinkCollection& v);
0244 
0245 template <typename... Args>
0246 MutableTrackMCParticleLink TrackMCParticleLinkCollection::create(Args&&... args) {
0247   if (m_isSubsetColl) {
0248     throw std::logic_error("Cannot create new elements on a subset collection");
0249   }
0250   const int size = m_storage.entries.size();
0251   auto obj = new TrackMCParticleLinkObj({size, m_collectionID}, {std::forward<Args>(args)...});
0252   m_storage.entries.push_back(obj);
0253 
0254   return MutableTrackMCParticleLink(podio::utils::MaybeSharedPtr(obj));
0255 }
0256 
0257 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0258 void to_json(nlohmann::json& j, const TrackMCParticleLinkCollection& collection);
0259 #endif
0260 
0261 } // namespace edm4hep
0262 
0263 #endif