Back to home page

EIC code displayed by LXR

 
 

    


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