Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-08 08:22:28

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