Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-04 08:12:05

0001 // AUTOMATICALLY GENERATED FILE - DO NOT EDIT
0002 
0003 #ifndef ACTSPODIOEDM_TrackerHitLocalCollection_H
0004 #define ACTSPODIOEDM_TrackerHitLocalCollection_H
0005 
0006 // datamodel specific includes
0007 #include "ActsPodioEdm/MutableTrackerHitLocal.h"
0008 #include "ActsPodioEdm/TrackerHitLocal.h"
0009 #include "ActsPodioEdm/TrackerHitLocalCollectionData.h"
0010 #include "ActsPodioEdm/TrackerHitLocalObj.h"
0011 
0012 // podio specific includes
0013 #include "podio/CollectionBase.h"
0014 #include "podio/ICollectionProvider.h"
0015 #include "podio/detail/Pythonizations.h"
0016 
0017 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0018 #include "nlohmann/json_fwd.hpp"
0019 #endif
0020 
0021 #include <algorithm>
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 ActsPodioEdm {
0034 
0035 class TrackerHitLocalCollectionIterator {
0036  public:
0037   using value_type = TrackerHitLocal;
0038   using difference_type = ptrdiff_t;
0039   using reference = TrackerHitLocal;
0040   using pointer = TrackerHitLocal*;
0041   using iterator_category = std::input_iterator_tag;
0042   // `std::forward_iterator` is supported except that the pointers obtained with
0043   // `operator->()` remain valid as long as the iterator is valid, not as long
0044   // as the range is valid.
0045   using iterator_concept = std::random_access_iterator_tag;
0046 
0047   TrackerHitLocalCollectionIterator(
0048       size_t index, const TrackerHitLocalObjPointerContainer* collection)
0049       : m_index(index),
0050         m_object(podio::utils::MaybeSharedPtr<TrackerHitLocalObj>{nullptr}),
0051         m_collection(collection) {}
0052   TrackerHitLocalCollectionIterator() = default;
0053 
0054   TrackerHitLocalCollectionIterator(const TrackerHitLocalCollectionIterator&) =
0055       default;
0056   TrackerHitLocalCollectionIterator(TrackerHitLocalCollectionIterator&&) =
0057       default;
0058   TrackerHitLocalCollectionIterator& operator=(
0059       const TrackerHitLocalCollectionIterator&) = default;
0060   TrackerHitLocalCollectionIterator& operator=(
0061       TrackerHitLocalCollectionIterator&&) = default;
0062   ~TrackerHitLocalCollectionIterator() = default;
0063 
0064   auto operator<=>(const TrackerHitLocalCollectionIterator& other) const {
0065     return m_index <=> other.m_index;
0066   }
0067 
0068   bool operator==(const TrackerHitLocalCollectionIterator& x) const {
0069     return m_index == x.m_index;
0070   }
0071 
0072   reference operator*() const;
0073   pointer operator->();
0074   TrackerHitLocalCollectionIterator& operator++();
0075   TrackerHitLocalCollectionIterator operator++(int);
0076   TrackerHitLocalCollectionIterator& operator--();
0077   TrackerHitLocalCollectionIterator operator--(int);
0078   TrackerHitLocalCollectionIterator& operator+=(difference_type n);
0079   TrackerHitLocalCollectionIterator operator+(difference_type n) const;
0080   friend TrackerHitLocalCollectionIterator operator+(
0081       difference_type n, const TrackerHitLocalCollectionIterator& it);
0082   TrackerHitLocalCollectionIterator& operator-=(difference_type n);
0083   TrackerHitLocalCollectionIterator operator-(difference_type n) const;
0084   reference operator[](difference_type n) const;
0085   difference_type operator-(
0086       const TrackerHitLocalCollectionIterator& other) const;
0087 
0088  private:
0089   size_t m_index{0};
0090   TrackerHitLocal m_object{
0091       podio::utils::MaybeSharedPtr<TrackerHitLocalObj>{nullptr}};
0092   const TrackerHitLocalObjPointerContainer* m_collection{nullptr};
0093 };
0094 
0095 class TrackerHitLocalMutableCollectionIterator {
0096  public:
0097   using value_type = TrackerHitLocal;
0098   using difference_type = ptrdiff_t;
0099   using reference = MutableTrackerHitLocal;
0100   using pointer = MutableTrackerHitLocal*;
0101   using iterator_category = std::input_iterator_tag;
0102   // `std::forward_iterator` is supported except that the pointers obtained with
0103   // `operator->()` remain valid as long as the iterator is valid, not as long
0104   // as the range is valid.
0105   using iterator_concept = std::random_access_iterator_tag;
0106 
0107   TrackerHitLocalMutableCollectionIterator(
0108       size_t index, const TrackerHitLocalObjPointerContainer* collection)
0109       : m_index(index),
0110         m_object(podio::utils::MaybeSharedPtr<TrackerHitLocalObj>{nullptr}),
0111         m_collection(collection) {}
0112   TrackerHitLocalMutableCollectionIterator() = default;
0113 
0114   TrackerHitLocalMutableCollectionIterator(
0115       const TrackerHitLocalMutableCollectionIterator&) = default;
0116   TrackerHitLocalMutableCollectionIterator(
0117       TrackerHitLocalMutableCollectionIterator&&) = default;
0118   TrackerHitLocalMutableCollectionIterator& operator=(
0119       const TrackerHitLocalMutableCollectionIterator&) = default;
0120   TrackerHitLocalMutableCollectionIterator& operator=(
0121       TrackerHitLocalMutableCollectionIterator&&) = default;
0122   ~TrackerHitLocalMutableCollectionIterator() = default;
0123 
0124   auto operator<=>(
0125       const TrackerHitLocalMutableCollectionIterator& other) const {
0126     return m_index <=> other.m_index;
0127   }
0128 
0129   bool operator==(const TrackerHitLocalMutableCollectionIterator& x) const {
0130     return m_index == x.m_index;
0131   }
0132 
0133   reference operator*() const;
0134   pointer operator->();
0135   TrackerHitLocalMutableCollectionIterator& operator++();
0136   TrackerHitLocalMutableCollectionIterator operator++(int);
0137   TrackerHitLocalMutableCollectionIterator& operator--();
0138   TrackerHitLocalMutableCollectionIterator operator--(int);
0139   TrackerHitLocalMutableCollectionIterator& operator+=(difference_type n);
0140   TrackerHitLocalMutableCollectionIterator operator+(difference_type n) const;
0141   friend TrackerHitLocalMutableCollectionIterator operator+(
0142       difference_type n, const TrackerHitLocalMutableCollectionIterator& it);
0143   TrackerHitLocalMutableCollectionIterator& operator-=(difference_type n);
0144   TrackerHitLocalMutableCollectionIterator operator-(difference_type n) const;
0145   reference operator[](difference_type n) const;
0146   difference_type operator-(
0147       const TrackerHitLocalMutableCollectionIterator& other) const;
0148 
0149  private:
0150   size_t m_index{0};
0151   MutableTrackerHitLocal m_object{
0152       podio::utils::MaybeSharedPtr<TrackerHitLocalObj>{nullptr}};
0153   const TrackerHitLocalObjPointerContainer* m_collection{nullptr};
0154 };
0155 
0156 /**
0157 A Collection is identified by an ID.
0158 */
0159 class TrackerHitLocalCollection : public podio::CollectionBase {
0160  public:
0161   using value_type = TrackerHitLocal;
0162   using mutable_type = MutableTrackerHitLocal;
0163   using const_iterator = TrackerHitLocalCollectionIterator;
0164   using iterator = TrackerHitLocalMutableCollectionIterator;
0165   using difference_type = ptrdiff_t;
0166   using size_type = size_t;
0167   using const_reverse_iterator = std::reverse_iterator<const_iterator>;
0168   using reverse_iterator = std::reverse_iterator<iterator>;
0169 
0170   TrackerHitLocalCollection() = default;
0171   TrackerHitLocalCollection(TrackerHitLocalCollectionData&& data,
0172                             bool isSubsetColl);
0173   // This is a move-only type
0174   TrackerHitLocalCollection(const TrackerHitLocalCollection&) = delete;
0175   TrackerHitLocalCollection& operator=(const TrackerHitLocalCollection&) =
0176       delete;
0177   TrackerHitLocalCollection(TrackerHitLocalCollection&&) = default;
0178   TrackerHitLocalCollection& operator=(TrackerHitLocalCollection&&) = default;
0179 
0180   //  TrackerHitLocalCollection(TrackerHitLocalVector* data, uint32_t
0181   //  collectionID);
0182   ~TrackerHitLocalCollection() override;
0183 
0184   constexpr static std::string_view typeName =
0185       "ActsPodioEdm::TrackerHitLocalCollection";
0186   constexpr static std::string_view valueTypeName =
0187       "ActsPodioEdm::TrackerHitLocal";
0188   constexpr static std::string_view dataTypeName =
0189       "ActsPodioEdm::TrackerHitLocalData";
0190 
0191   void clear() final;
0192 
0193   /// Cppyy protocol to setup the pythonizations for this class. Not to be
0194   /// called directly.
0195   static void __cppyy_pythonize__(PyObject* klass, const std::string& name) {
0196     podio::detail::pythonizations::pythonize_subscript(klass, name);
0197   }
0198 
0199   /// Print this collection to the passed stream
0200   void print(std::ostream& os = std::cout, bool flush = true) const final;
0201 
0202   /// Append a new object to the collection, and return this object.
0203   MutableTrackerHitLocal create();
0204 
0205   /// Append a new object to the collection, and return this object.
0206   /// Initialized with the parameters given
0207   template <typename... Args>
0208   MutableTrackerHitLocal create(Args&&... args);
0209 
0210   /// number of elements in the collection
0211   std::size_t size() const final;
0212 
0213   /// maximal number of elements in the collection
0214   std::size_t max_size() const final;
0215 
0216   /// Is the collection empty
0217   bool empty() const final;
0218 
0219   /// fully qualified type name
0220   const std::string_view getTypeName() const final { return typeName; }
0221   /// fully qualified type name of elements - with namespace
0222   const std::string_view getValueTypeName() const final {
0223     return valueTypeName;
0224   }
0225   /// fully qualified type name of stored POD elements - with namespace
0226   const std::string_view getDataTypeName() const final { return dataTypeName; }
0227   /// schema version
0228   podio::SchemaVersionT getSchemaVersion() const final;
0229 
0230   bool isSubsetCollection() const final { return m_isSubsetColl; }
0231 
0232   void setSubsetCollection(bool setSubset = true) final;
0233 
0234   /// Returns the const object of given index
0235   TrackerHitLocal operator[](std::size_t index) const;
0236   /// Returns the object of a given index
0237   MutableTrackerHitLocal operator[](std::size_t index);
0238   /// Returns the const object of given index
0239   TrackerHitLocal at(std::size_t index) const;
0240   /// Returns the object of given index
0241   MutableTrackerHitLocal at(std::size_t index);
0242 
0243   /// Append object to the collection
0244   void push_back(const MutableTrackerHitLocal& object);
0245   /// Append an object to the (subset) collection
0246   void push_back(const TrackerHitLocal& object);
0247 
0248   void prepareForWrite() const final;
0249   void prepareAfterRead() final;
0250   bool setReferences(
0251       const podio::ICollectionProvider* collectionProvider) final;
0252 
0253   /// Get the collection buffers for this collection
0254   podio::CollectionWriteBuffers getBuffers() final;
0255 
0256   void setID(uint32_t ID) final {
0257     m_collectionID = ID;
0258     if (!m_isSubsetColl) {
0259       std::for_each(m_storage.entries.begin(), m_storage.entries.end(),
0260                     [ID](TrackerHitLocalObj* obj) {
0261                       obj->id = {obj->id.index, static_cast<uint32_t>(ID)};
0262                     });
0263     }
0264   }
0265 
0266   uint32_t getID() const final { return m_collectionID; }
0267 
0268   /// check if the collection has a valid ID
0269   bool hasID() const final {
0270     return getID() != static_cast<uint32_t>(podio::ObjectID::untracked) &&
0271            getID() != static_cast<uint32_t>(podio::ObjectID::invalid);
0272   }
0273 
0274   [[deprecated(
0275       "isValid will be removed, use hasID() if you want to check if it has an "
0276       "ID, otherwise assume the "
0277       "collection is valid")]]
0278   bool isValid() const final {
0279     return hasID();
0280   }
0281 
0282   size_t getDatamodelRegistryIndex() const final;
0283 
0284   // support for the iterator protocol
0285   iterator begin() { return iterator(0, &m_storage.entries); }
0286   const_iterator begin() const { return const_iterator(0, &m_storage.entries); }
0287   const_iterator cbegin() const { return begin(); }
0288   iterator end() {
0289     return iterator(m_storage.entries.size(), &m_storage.entries);
0290   }
0291   const_iterator end() const {
0292     return const_iterator(m_storage.entries.size(), &m_storage.entries);
0293   }
0294   const_iterator cend() const { return end(); }
0295   // reverse iterators
0296   reverse_iterator rbegin() { return reverse_iterator(end()); }
0297   const_reverse_iterator rbegin() const {
0298     return const_reverse_iterator(end());
0299   }
0300   const_reverse_iterator crbegin() const { return rbegin(); }
0301   reverse_iterator rend() { return reverse_iterator(begin()); }
0302   const_reverse_iterator rend() const {
0303     return const_reverse_iterator(begin());
0304   }
0305   const_reverse_iterator crend() const { return rend(); }
0306 
0307   std::vector<std::uint64_t> cellID(const size_t nElem = 0) const;
0308   std::vector<std::int32_t> type(const size_t nElem = 0) const;
0309   std::vector<std::int32_t> quality(const size_t nElem = 0) const;
0310   std::vector<float> time(const size_t nElem = 0) const;
0311   std::vector<float> eDep(const size_t nElem = 0) const;
0312   std::vector<float> eDepError(const size_t nElem = 0) const;
0313   std::vector<edm4hep::Vector3d> position(const size_t nElem = 0) const;
0314 
0315  private:
0316   // For setReferences, we need to give our own CollectionData access to our
0317   // private entries. Otherwise we would need to expose a public member function
0318   // that gives access to the Obj* which is definitely not what we want
0319   friend class TrackerHitLocalCollectionData;
0320 
0321   mutable bool m_isPrepared{false};
0322   bool m_isSubsetColl{false};
0323   uint32_t m_collectionID{static_cast<uint32_t>(podio::ObjectID::untracked)};
0324   mutable std::unique_ptr<std::mutex> m_storageMtx{
0325       std::make_unique<std::mutex>()};
0326   mutable TrackerHitLocalCollectionData m_storage{};
0327 };
0328 
0329 std::ostream& operator<<(std::ostream& o, const TrackerHitLocalCollection& v);
0330 
0331 template <typename... Args>
0332 MutableTrackerHitLocal TrackerHitLocalCollection::create(Args&&... args) {
0333   if (m_isSubsetColl) {
0334     throw std::logic_error("Cannot create new elements on a subset collection");
0335   }
0336   auto obj = new TrackerHitLocalObj(
0337       {static_cast<int>(m_storage.entries.size()), m_collectionID},
0338       {std::forward<Args>(args)...});
0339   m_storage.entries.push_back(obj);
0340 
0341   // Need to initialize the relation vectors manually for the {ObjectID,
0342   // TrackerHitLocalData} constructor
0343   obj->m_measurement = new std::vector<float>();
0344   obj->m_covariance = new std::vector<float>();
0345   m_storage.createRelations(obj);
0346   return MutableTrackerHitLocal(podio::utils::MaybeSharedPtr(obj));
0347 }
0348 
0349 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0350 void to_json(nlohmann::json& j, const TrackerHitLocalCollection& collection);
0351 #endif
0352 
0353 }  // namespace ActsPodioEdm
0354 
0355 // This is needed to avoid triggering opening every library in LD_LIBRARY_PATH
0356 // until it's fixed in ROOT. See
0357 // https://github.com/root-project/root/issues/18489 and
0358 // https://github.com/AIDASoft/podio/issues/770
0359 #if defined(__clang__)
0360 #pragma clang diagnostic push
0361 #pragma clang diagnostic ignored "-Wunknown-warning-option"
0362 #pragma clang diagnostic ignored "-Wdeprecated-redundant-constexpr-static-def"
0363 #pragma clang diagnostic ignored "-Wdeprecated"
0364 constexpr std::string_view ActsPodioEdm::TrackerHitLocalCollection::typeName;
0365 constexpr std::string_view
0366     ActsPodioEdm::TrackerHitLocalCollection::valueTypeName;
0367 constexpr std::string_view
0368     ActsPodioEdm::TrackerHitLocalCollection::dataTypeName;
0369 #pragma clang diagnostic pop
0370 #elif defined(__GNUC__)
0371 #pragma GCC diagnostic push
0372 #pragma GCC diagnostic ignored "-Wdeprecated"
0373 constexpr std::string_view ActsPodioEdm::TrackerHitLocalCollection::typeName;
0374 constexpr std::string_view
0375     ActsPodioEdm::TrackerHitLocalCollection::valueTypeName;
0376 constexpr std::string_view
0377     ActsPodioEdm::TrackerHitLocalCollection::dataTypeName;
0378 #pragma GCC diagnostic pop
0379 #endif
0380 
0381 #endif