Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-11-15 09:35:31

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