Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:55:36

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