Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/edm4hep/TrackerHit3DCollection.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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