Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/edm4hep/SimTrackerHitCollection.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_SimTrackerHitCollection_H
0004 #define EDM4HEP_SimTrackerHitCollection_H
0005 
0006 // datamodel specific includes
0007 #include "edm4hep/MutableSimTrackerHit.h"
0008 #include "edm4hep/SimTrackerHit.h"
0009 #include "edm4hep/SimTrackerHitCollectionData.h"
0010 #include "edm4hep/SimTrackerHitObj.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 SimTrackerHitCollectionIterator {
0036 public:
0037   using value_type = SimTrackerHit;
0038   using difference_type = ptrdiff_t;
0039   using reference = SimTrackerHit;
0040   using pointer = SimTrackerHit*;
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   SimTrackerHitCollectionIterator(size_t index, const SimTrackerHitObjPointerContainer* collection)
0047       : m_index(index), m_object(podio::utils::MaybeSharedPtr<SimTrackerHitObj>{nullptr}), m_collection(collection) {}
0048   SimTrackerHitCollectionIterator() = default;
0049 
0050   SimTrackerHitCollectionIterator(const SimTrackerHitCollectionIterator&) = default;
0051   SimTrackerHitCollectionIterator(SimTrackerHitCollectionIterator&&) = default;
0052   SimTrackerHitCollectionIterator& operator=(const SimTrackerHitCollectionIterator&) = default;
0053   SimTrackerHitCollectionIterator& operator=(SimTrackerHitCollectionIterator&&) = default;
0054   ~SimTrackerHitCollectionIterator() = default;
0055 
0056   auto operator<=>(const SimTrackerHitCollectionIterator& other) const { return m_index <=> other.m_index; }
0057 
0058   bool operator==(const SimTrackerHitCollectionIterator& x) const { return m_index == x.m_index; }
0059 
0060   reference operator*() const;
0061   pointer operator->();
0062   SimTrackerHitCollectionIterator& operator++();
0063   SimTrackerHitCollectionIterator operator++(int);
0064   SimTrackerHitCollectionIterator& operator--();
0065   SimTrackerHitCollectionIterator operator--(int);
0066   SimTrackerHitCollectionIterator& operator+=(difference_type n);
0067   SimTrackerHitCollectionIterator operator+(difference_type n) const;
0068   friend SimTrackerHitCollectionIterator operator+(difference_type n, const SimTrackerHitCollectionIterator& it);
0069   SimTrackerHitCollectionIterator& operator-=(difference_type n);
0070   SimTrackerHitCollectionIterator operator-(difference_type n) const;
0071   reference operator[](difference_type n) const;
0072   difference_type operator-(const SimTrackerHitCollectionIterator& other) const;
0073 
0074 private:
0075   size_t m_index{0};
0076   SimTrackerHit m_object{podio::utils::MaybeSharedPtr<SimTrackerHitObj>{nullptr}};
0077   const SimTrackerHitObjPointerContainer* m_collection{nullptr};
0078 };
0079 
0080 class SimTrackerHitMutableCollectionIterator {
0081 public:
0082   using value_type = SimTrackerHit;
0083   using difference_type = ptrdiff_t;
0084   using reference = MutableSimTrackerHit;
0085   using pointer = MutableSimTrackerHit*;
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   SimTrackerHitMutableCollectionIterator(size_t index, const SimTrackerHitObjPointerContainer* collection)
0092       : m_index(index), m_object(podio::utils::MaybeSharedPtr<SimTrackerHitObj>{nullptr}), m_collection(collection) {}
0093   SimTrackerHitMutableCollectionIterator() = default;
0094 
0095   SimTrackerHitMutableCollectionIterator(const SimTrackerHitMutableCollectionIterator&) = default;
0096   SimTrackerHitMutableCollectionIterator(SimTrackerHitMutableCollectionIterator&&) = default;
0097   SimTrackerHitMutableCollectionIterator& operator=(const SimTrackerHitMutableCollectionIterator&) = default;
0098   SimTrackerHitMutableCollectionIterator& operator=(SimTrackerHitMutableCollectionIterator&&) = default;
0099   ~SimTrackerHitMutableCollectionIterator() = default;
0100 
0101   auto operator<=>(const SimTrackerHitMutableCollectionIterator& other) const { return m_index <=> other.m_index; }
0102 
0103   bool operator==(const SimTrackerHitMutableCollectionIterator& x) const { return m_index == x.m_index; }
0104 
0105   reference operator*() const;
0106   pointer operator->();
0107   SimTrackerHitMutableCollectionIterator& operator++();
0108   SimTrackerHitMutableCollectionIterator operator++(int);
0109   SimTrackerHitMutableCollectionIterator& operator--();
0110   SimTrackerHitMutableCollectionIterator operator--(int);
0111   SimTrackerHitMutableCollectionIterator& operator+=(difference_type n);
0112   SimTrackerHitMutableCollectionIterator operator+(difference_type n) const;
0113   friend SimTrackerHitMutableCollectionIterator operator+(difference_type n,
0114                                                           const SimTrackerHitMutableCollectionIterator& it);
0115   SimTrackerHitMutableCollectionIterator& operator-=(difference_type n);
0116   SimTrackerHitMutableCollectionIterator operator-(difference_type n) const;
0117   reference operator[](difference_type n) const;
0118   difference_type operator-(const SimTrackerHitMutableCollectionIterator& other) const;
0119 
0120 private:
0121   size_t m_index{0};
0122   MutableSimTrackerHit m_object{podio::utils::MaybeSharedPtr<SimTrackerHitObj>{nullptr}};
0123   const SimTrackerHitObjPointerContainer* m_collection{nullptr};
0124 };
0125 
0126 /**
0127 A Collection is identified by an ID.
0128 */
0129 class SimTrackerHitCollection : public podio::CollectionBase {
0130 public:
0131   using value_type = SimTrackerHit;
0132   using mutable_type = MutableSimTrackerHit;
0133   using const_iterator = SimTrackerHitCollectionIterator;
0134   using iterator = SimTrackerHitMutableCollectionIterator;
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   SimTrackerHitCollection() = default;
0141   SimTrackerHitCollection(SimTrackerHitCollectionData&& data, bool isSubsetColl);
0142   // This is a move-only type
0143   SimTrackerHitCollection(const SimTrackerHitCollection&) = delete;
0144   SimTrackerHitCollection& operator=(const SimTrackerHitCollection&) = delete;
0145   SimTrackerHitCollection(SimTrackerHitCollection&&) = default;
0146   SimTrackerHitCollection& operator=(SimTrackerHitCollection&&) = default;
0147 
0148   //  SimTrackerHitCollection(SimTrackerHitVector* data, uint32_t collectionID);
0149   ~SimTrackerHitCollection() override;
0150 
0151   constexpr static std::string_view typeName = "edm4hep::SimTrackerHitCollection";
0152   constexpr static std::string_view valueTypeName = "edm4hep::SimTrackerHit";
0153   constexpr static std::string_view dataTypeName = "edm4hep::SimTrackerHitData";
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   MutableSimTrackerHit 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   MutableSimTrackerHit 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   SimTrackerHit operator[](std::size_t index) const;
0197   /// Returns the object of a given index
0198   MutableSimTrackerHit operator[](std::size_t index);
0199   /// Returns the const object of given index
0200   SimTrackerHit at(std::size_t index) const;
0201   /// Returns the object of given index
0202   MutableSimTrackerHit at(std::size_t index);
0203 
0204   /// Append object to the collection
0205   void push_back(const MutableSimTrackerHit& object);
0206   /// Append an object to the (subset) collection
0207   void push_back(const SimTrackerHit& 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](SimTrackerHitObj* 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<float> eDep(const size_t nElem = 0) const;
0257   std::vector<float> time(const size_t nElem = 0) const;
0258   std::vector<float> pathLength(const size_t nElem = 0) const;
0259   std::vector<std::int32_t> quality(const size_t nElem = 0) const;
0260   std::vector<edm4hep::Vector3d> position(const size_t nElem = 0) const;
0261   std::vector<edm4hep::Vector3f> momentum(const size_t nElem = 0) const;
0262 
0263 private:
0264   // For setReferences, we need to give our own CollectionData access to our
0265   // private entries. Otherwise we would need to expose a public member function
0266   // that gives access to the Obj* which is definitely not what we want
0267   friend class SimTrackerHitCollectionData;
0268 
0269   mutable bool m_isPrepared{false};
0270   bool m_isSubsetColl{false};
0271   uint32_t m_collectionID{static_cast<uint32_t>(podio::ObjectID::untracked)};
0272   mutable std::unique_ptr<std::mutex> m_storageMtx{std::make_unique<std::mutex>()};
0273   mutable SimTrackerHitCollectionData m_storage{};
0274 };
0275 
0276 std::ostream& operator<<(std::ostream& o, const SimTrackerHitCollection& v);
0277 
0278 template <typename... Args>
0279 MutableSimTrackerHit SimTrackerHitCollection::create(Args&&... args) {
0280   if (m_isSubsetColl) {
0281     throw std::logic_error("Cannot create new elements on a subset collection");
0282   }
0283   auto obj =
0284       new SimTrackerHitObj({static_cast<int>(m_storage.entries.size()), m_collectionID}, {std::forward<Args>(args)...});
0285   m_storage.entries.push_back(obj);
0286 
0287   return MutableSimTrackerHit(podio::utils::MaybeSharedPtr(obj));
0288 }
0289 
0290 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0291 void to_json(nlohmann::json& j, const SimTrackerHitCollection& collection);
0292 #endif
0293 
0294 } // namespace edm4hep
0295 
0296 // This is needed to avoid triggering opening every library in LD_LIBRARY_PATH
0297 // until it's fixed in ROOT. See https://github.com/root-project/root/issues/18489
0298 // and https://github.com/AIDASoft/podio/issues/770
0299 #if defined(__clang__)
0300 #pragma clang diagnostic push
0301 #pragma clang diagnostic ignored "-Wunknown-warning-option"
0302 #pragma clang diagnostic ignored "-Wdeprecated-redundant-constexpr-static-def"
0303 #pragma clang diagnostic ignored "-Wdeprecated"
0304 constexpr std::string_view edm4hep::SimTrackerHitCollection::typeName;
0305 constexpr std::string_view edm4hep::SimTrackerHitCollection::valueTypeName;
0306 constexpr std::string_view edm4hep::SimTrackerHitCollection::dataTypeName;
0307 #pragma clang diagnostic pop
0308 #elif defined(__GNUC__)
0309 #pragma GCC diagnostic push
0310 #pragma GCC diagnostic ignored "-Wdeprecated"
0311 constexpr std::string_view edm4hep::SimTrackerHitCollection::typeName;
0312 constexpr std::string_view edm4hep::SimTrackerHitCollection::valueTypeName;
0313 constexpr std::string_view edm4hep::SimTrackerHitCollection::dataTypeName;
0314 #pragma GCC diagnostic pop
0315 #endif
0316 
0317 #endif