Back to home page

EIC code displayed by LXR

 
 

    


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

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