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