Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 08:54:59

0001 // AUTOMATICALLY GENERATED FILE - DO NOT EDIT
0002 
0003 #ifndef EDM4EIC_MCRecoCalorimeterHitAssociationCollection_H
0004 #define EDM4EIC_MCRecoCalorimeterHitAssociationCollection_H
0005 
0006 // datamodel specific includes
0007 #include "edm4eic/MCRecoCalorimeterHitAssociation.h"
0008 #include "edm4eic/MutableMCRecoCalorimeterHitAssociation.h"
0009 #include "edm4eic/MCRecoCalorimeterHitAssociationObj.h"
0010 #include "edm4eic/MCRecoCalorimeterHitAssociationCollectionData.h"
0011 
0012 // podio specific includes
0013 #include "podio/ICollectionProvider.h"
0014 #include "podio/CollectionBase.h"
0015 
0016 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0017 #include "nlohmann/json_fwd.hpp"
0018 #endif
0019 
0020 #include <string_view>
0021 #include <vector>
0022 #include <algorithm>
0023 #include <ostream>
0024 #include <mutex>
0025 #include <memory>
0026 #include <cstddef>
0027 
0028 namespace podio {
0029   struct RelationNames;
0030 }
0031 
0032 namespace edm4eic {
0033 
0034 
0035 
0036 class MCRecoCalorimeterHitAssociationCollectionIterator {
0037 public:
0038   using value_type = MCRecoCalorimeterHitAssociation;
0039   using difference_type = ptrdiff_t;
0040   using reference = MCRecoCalorimeterHitAssociation;
0041   using pointer = MCRecoCalorimeterHitAssociation*;
0042   using iterator_category = std::input_iterator_tag;
0043   // `std::forward_iterator` is supported except that the pointers obtained with `operator->()`
0044   // remain valid as long as the iterator is valid, not as long as the range is valid.
0045   using iterator_concept = std::random_access_iterator_tag;
0046 
0047   MCRecoCalorimeterHitAssociationCollectionIterator(size_t index, const MCRecoCalorimeterHitAssociationObjPointerContainer* collection) : m_index(index), m_object(podio::utils::MaybeSharedPtr<MCRecoCalorimeterHitAssociationObj>{nullptr}), m_collection(collection) {}
0048   MCRecoCalorimeterHitAssociationCollectionIterator() = default;
0049 
0050   MCRecoCalorimeterHitAssociationCollectionIterator(const MCRecoCalorimeterHitAssociationCollectionIterator&) = default;
0051   MCRecoCalorimeterHitAssociationCollectionIterator(MCRecoCalorimeterHitAssociationCollectionIterator&&) = default;
0052   MCRecoCalorimeterHitAssociationCollectionIterator& operator=(const MCRecoCalorimeterHitAssociationCollectionIterator&) = default;
0053   MCRecoCalorimeterHitAssociationCollectionIterator& operator=(MCRecoCalorimeterHitAssociationCollectionIterator&&) = default;
0054   ~MCRecoCalorimeterHitAssociationCollectionIterator() = default;
0055 
0056   auto operator<=>(const MCRecoCalorimeterHitAssociationCollectionIterator& other) const {
0057     return m_index <=> other.m_index;
0058   }
0059 
0060   bool operator==(const MCRecoCalorimeterHitAssociationCollectionIterator& x) const {
0061     return m_index ==  x.m_index;
0062   }
0063 
0064   reference operator*() const;
0065   pointer operator->();
0066   MCRecoCalorimeterHitAssociationCollectionIterator& operator++();
0067   MCRecoCalorimeterHitAssociationCollectionIterator operator++(int);
0068   MCRecoCalorimeterHitAssociationCollectionIterator& operator--();
0069   MCRecoCalorimeterHitAssociationCollectionIterator operator--(int);
0070   MCRecoCalorimeterHitAssociationCollectionIterator& operator+=(difference_type n);
0071   MCRecoCalorimeterHitAssociationCollectionIterator operator+(difference_type n) const;
0072   friend MCRecoCalorimeterHitAssociationCollectionIterator operator+(difference_type n, const MCRecoCalorimeterHitAssociationCollectionIterator& it);
0073   MCRecoCalorimeterHitAssociationCollectionIterator& operator-=(difference_type n);
0074   MCRecoCalorimeterHitAssociationCollectionIterator operator-(difference_type n) const;
0075   reference operator[](difference_type n) const;
0076   difference_type operator-(const MCRecoCalorimeterHitAssociationCollectionIterator& other) const;
0077 
0078 private:
0079   size_t m_index{0};
0080   MCRecoCalorimeterHitAssociation m_object { podio::utils::MaybeSharedPtr<MCRecoCalorimeterHitAssociationObj>{nullptr} };
0081   const MCRecoCalorimeterHitAssociationObjPointerContainer* m_collection{nullptr};
0082 };
0083 
0084 
0085 class MCRecoCalorimeterHitAssociationMutableCollectionIterator {
0086 public:
0087   using value_type = MCRecoCalorimeterHitAssociation;
0088   using difference_type = ptrdiff_t;
0089   using reference = MutableMCRecoCalorimeterHitAssociation;
0090   using pointer = MutableMCRecoCalorimeterHitAssociation*;
0091   using iterator_category = std::input_iterator_tag;
0092   // `std::forward_iterator` is supported except that the pointers obtained with `operator->()`
0093   // remain valid as long as the iterator is valid, not as long as the range is valid.
0094   using iterator_concept = std::random_access_iterator_tag;
0095 
0096   MCRecoCalorimeterHitAssociationMutableCollectionIterator(size_t index, const MCRecoCalorimeterHitAssociationObjPointerContainer* collection) : m_index(index), m_object(podio::utils::MaybeSharedPtr<MCRecoCalorimeterHitAssociationObj>{nullptr}), m_collection(collection) {}
0097   MCRecoCalorimeterHitAssociationMutableCollectionIterator() = default;
0098 
0099   MCRecoCalorimeterHitAssociationMutableCollectionIterator(const MCRecoCalorimeterHitAssociationMutableCollectionIterator&) = default;
0100   MCRecoCalorimeterHitAssociationMutableCollectionIterator(MCRecoCalorimeterHitAssociationMutableCollectionIterator&&) = default;
0101   MCRecoCalorimeterHitAssociationMutableCollectionIterator& operator=(const MCRecoCalorimeterHitAssociationMutableCollectionIterator&) = default;
0102   MCRecoCalorimeterHitAssociationMutableCollectionIterator& operator=(MCRecoCalorimeterHitAssociationMutableCollectionIterator&&) = default;
0103   ~MCRecoCalorimeterHitAssociationMutableCollectionIterator() = default;
0104 
0105   auto operator<=>(const MCRecoCalorimeterHitAssociationMutableCollectionIterator& other) const {
0106     return m_index <=> other.m_index;
0107   }
0108 
0109   bool operator==(const MCRecoCalorimeterHitAssociationMutableCollectionIterator& x) const {
0110     return m_index ==  x.m_index;
0111   }
0112 
0113   reference operator*() const;
0114   pointer operator->();
0115   MCRecoCalorimeterHitAssociationMutableCollectionIterator& operator++();
0116   MCRecoCalorimeterHitAssociationMutableCollectionIterator operator++(int);
0117   MCRecoCalorimeterHitAssociationMutableCollectionIterator& operator--();
0118   MCRecoCalorimeterHitAssociationMutableCollectionIterator operator--(int);
0119   MCRecoCalorimeterHitAssociationMutableCollectionIterator& operator+=(difference_type n);
0120   MCRecoCalorimeterHitAssociationMutableCollectionIterator operator+(difference_type n) const;
0121   friend MCRecoCalorimeterHitAssociationMutableCollectionIterator operator+(difference_type n, const MCRecoCalorimeterHitAssociationMutableCollectionIterator& it);
0122   MCRecoCalorimeterHitAssociationMutableCollectionIterator& operator-=(difference_type n);
0123   MCRecoCalorimeterHitAssociationMutableCollectionIterator operator-(difference_type n) const;
0124   reference operator[](difference_type n) const;
0125   difference_type operator-(const MCRecoCalorimeterHitAssociationMutableCollectionIterator& other) const;
0126 
0127 private:
0128   size_t m_index{0};
0129   MutableMCRecoCalorimeterHitAssociation m_object { podio::utils::MaybeSharedPtr<MCRecoCalorimeterHitAssociationObj>{nullptr} };
0130   const MCRecoCalorimeterHitAssociationObjPointerContainer* m_collection{nullptr};
0131 };
0132 
0133 
0134 /**
0135 A Collection is identified by an ID.
0136 */
0137 class MCRecoCalorimeterHitAssociationCollection : public podio::CollectionBase {
0138 public:
0139   using value_type = MCRecoCalorimeterHitAssociation;
0140   using mutable_type = MutableMCRecoCalorimeterHitAssociation;
0141   using const_iterator = MCRecoCalorimeterHitAssociationCollectionIterator;
0142   using iterator = MCRecoCalorimeterHitAssociationMutableCollectionIterator;
0143   using difference_type = ptrdiff_t;
0144   using size_type = size_t;
0145   using const_reverse_iterator = std::reverse_iterator<const_iterator>;
0146   using reverse_iterator = std::reverse_iterator<iterator>;
0147 
0148   MCRecoCalorimeterHitAssociationCollection();
0149   MCRecoCalorimeterHitAssociationCollection(MCRecoCalorimeterHitAssociationCollectionData&& data, bool isSubsetColl);
0150   // This is a move-only type
0151   MCRecoCalorimeterHitAssociationCollection(const MCRecoCalorimeterHitAssociationCollection& ) = delete;
0152   MCRecoCalorimeterHitAssociationCollection& operator=(const MCRecoCalorimeterHitAssociationCollection& ) = delete;
0153   MCRecoCalorimeterHitAssociationCollection(MCRecoCalorimeterHitAssociationCollection&&) = default;
0154   MCRecoCalorimeterHitAssociationCollection& operator=(MCRecoCalorimeterHitAssociationCollection&&) = default;
0155 
0156 //  MCRecoCalorimeterHitAssociationCollection(MCRecoCalorimeterHitAssociationVector* data, uint32_t collectionID);
0157   ~MCRecoCalorimeterHitAssociationCollection() override;
0158 
0159   constexpr static std::string_view typeName = "edm4eic::MCRecoCalorimeterHitAssociationCollection";
0160   constexpr static std::string_view valueTypeName = "edm4eic::MCRecoCalorimeterHitAssociation";
0161   constexpr static std::string_view dataTypeName = "edm4eic::MCRecoCalorimeterHitAssociationData";
0162 
0163   void clear() final;
0164 
0165   /// Print this collection to the passed stream
0166   void print(std::ostream& os=std::cout, bool flush=true) const final;
0167 
0168   /// operator to allow pointer like calling of members a la LCIO
0169   MCRecoCalorimeterHitAssociationCollection* operator->() { return static_cast<MCRecoCalorimeterHitAssociationCollection*>(this); }
0170 
0171   /// Append a new object to the collection, and return this object.
0172   MutableMCRecoCalorimeterHitAssociation create();
0173 
0174   /// Append a new object to the collection, and return this object.
0175   /// Initialized with the parameters given
0176   template<typename... Args>
0177   MutableMCRecoCalorimeterHitAssociation create(Args&&... args);
0178 
0179   /// number of elements in the collection
0180   std::size_t size() const final;
0181 
0182   /// maximal number of elements in the collection
0183   std::size_t max_size() const final;
0184 
0185   /// Is the collection empty
0186   bool empty() const final;
0187 
0188   /// fully qualified type name
0189   const std::string_view getTypeName() const final { return typeName; }
0190   /// fully qualified type name of elements - with namespace
0191   const std::string_view getValueTypeName() const final { return valueTypeName; }
0192   /// fully qualified type name of stored POD elements - with namespace
0193   const std::string_view getDataTypeName() const final { return dataTypeName; }
0194   /// schema version
0195   podio::SchemaVersionT getSchemaVersion() const final;
0196 
0197   bool isSubsetCollection() const final {
0198     return m_isSubsetColl;
0199   }
0200 
0201   void setSubsetCollection(bool setSubset=true) final;
0202 
0203   /// Returns the const object of given index
0204   MCRecoCalorimeterHitAssociation operator[](std::size_t index) const;
0205   /// Returns the object of a given index
0206   MutableMCRecoCalorimeterHitAssociation operator[](std::size_t index);
0207   /// Returns the const object of given index
0208   MCRecoCalorimeterHitAssociation at(std::size_t index) const;
0209   /// Returns the object of given index
0210   MutableMCRecoCalorimeterHitAssociation at(std::size_t index);
0211 
0212 
0213   /// Append object to the collection
0214   void push_back(const MutableMCRecoCalorimeterHitAssociation& object);
0215   /// Append an object to the (subset) collection
0216   void push_back(const MCRecoCalorimeterHitAssociation& object);
0217 
0218   void prepareForWrite() const final;
0219   void prepareAfterRead() final;
0220   bool setReferences(const podio::ICollectionProvider* collectionProvider) final;
0221 
0222   /// Get the collection buffers for this collection
0223   podio::CollectionWriteBuffers getBuffers() final;
0224 
0225   void setID(uint32_t ID) final {
0226     m_collectionID = ID;
0227     if (!m_isSubsetColl) {
0228       std::for_each(m_storage.entries.begin(), m_storage.entries.end(),
0229                   [ID] (MCRecoCalorimeterHitAssociationObj* obj) { obj->id = {obj->id.index, static_cast<uint32_t>(ID)}; }
0230       );
0231     }
0232     m_isValid = true;
0233   }
0234 
0235   uint32_t getID() const final {
0236     return m_collectionID;
0237   }
0238 
0239   bool isValid() const final {
0240     return m_isValid;
0241   }
0242 
0243   size_t getDatamodelRegistryIndex() const final;
0244 
0245   // support for the iterator protocol
0246   iterator begin() {
0247     return iterator(0, &m_storage.entries);
0248   }
0249   const_iterator begin() const {
0250     return const_iterator(0, &m_storage.entries);
0251   }
0252   const_iterator cbegin() const {
0253     return begin();
0254   }
0255   iterator end() {
0256     return iterator(m_storage.entries.size(), &m_storage.entries);
0257   }
0258   const_iterator end() const {
0259     return const_iterator(m_storage.entries.size(), &m_storage.entries);
0260   }
0261   const_iterator cend() const {
0262     return end();
0263   }
0264   // reverse iterators
0265   reverse_iterator rbegin() {
0266     return reverse_iterator(end());
0267   }
0268   const_reverse_iterator rbegin() const {
0269     return const_reverse_iterator(end());
0270   }
0271   const_reverse_iterator crbegin() const {
0272     return rbegin();
0273   }
0274   reverse_iterator rend() {
0275     return reverse_iterator(begin());
0276   }
0277   const_reverse_iterator rend() const {
0278     return const_reverse_iterator(begin());
0279   }
0280   const_reverse_iterator crend() const {
0281     return rend();
0282   }
0283 
0284 
0285   std::vector<float> weight(const size_t nElem = 0) const;
0286 
0287 private:
0288   // For setReferences, we need to give our own CollectionData access to our
0289   // private entries. Otherwise we would need to expose a public member function
0290   // that gives access to the Obj* which is definitely not what we want
0291   friend class MCRecoCalorimeterHitAssociationCollectionData;
0292 
0293   bool m_isValid{false};
0294   mutable bool m_isPrepared{false};
0295   bool m_isSubsetColl{false};
0296   uint32_t m_collectionID{0};
0297   mutable std::unique_ptr<std::mutex> m_storageMtx{nullptr};
0298   mutable MCRecoCalorimeterHitAssociationCollectionData m_storage{};
0299 };
0300 
0301 std::ostream& operator<<(std::ostream& o, const MCRecoCalorimeterHitAssociationCollection& v);
0302 
0303 template<typename... Args>
0304 MutableMCRecoCalorimeterHitAssociation MCRecoCalorimeterHitAssociationCollection::create(Args&&... args) {
0305   if (m_isSubsetColl) {
0306     throw std::logic_error("Cannot create new elements on a subset collection");
0307   }
0308   const int size = m_storage.entries.size();
0309   auto obj = new MCRecoCalorimeterHitAssociationObj({size, m_collectionID}, {std::forward<Args>(args)...});
0310   m_storage.entries.push_back(obj);
0311 
0312   return MutableMCRecoCalorimeterHitAssociation(podio::utils::MaybeSharedPtr(obj));
0313 }
0314 
0315 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0316 void to_json(nlohmann::json& j, const MCRecoCalorimeterHitAssociationCollection& collection);
0317 #endif
0318 
0319 } // namespace edm4eic
0320 
0321 
0322 #endif