Back to home page

EIC code displayed by LXR

 
 

    


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

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