Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-21 10:10:37

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