Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-06-03 08:33:27

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 
0016 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0017 #include "nlohmann/json_fwd.hpp"
0018 #endif
0019 
0020 #include <algorithm>
0021 #include <cstddef>
0022 #include <memory>
0023 #include <mutex>
0024 #include <ostream>
0025 #include <string_view>
0026 #include <vector>
0027 
0028 namespace podio {
0029 struct RelationNames;
0030 }
0031 
0032 namespace edm4hep {
0033 
0034 class TrackerHit3DCollectionIterator {
0035 public:
0036   TrackerHit3DCollectionIterator(size_t index, const TrackerHit3DObjPointerContainer* collection) :
0037       m_index(index), m_object(podio::utils::MaybeSharedPtr<TrackerHit3DObj>{nullptr}), m_collection(collection) {
0038   }
0039 
0040   TrackerHit3DCollectionIterator(const TrackerHit3DCollectionIterator&) = delete;
0041   TrackerHit3DCollectionIterator& operator=(const TrackerHit3DCollectionIterator&) = delete;
0042 
0043   bool operator!=(const TrackerHit3DCollectionIterator& x) const {
0044     return m_index != x.m_index; // TODO: may not be complete
0045   }
0046 
0047   bool operator==(const TrackerHit3DCollectionIterator& x) const {
0048     return m_index == x.m_index; // TODO: may not be complete
0049   }
0050 
0051   TrackerHit3D operator*();
0052   TrackerHit3D* operator->();
0053   TrackerHit3DCollectionIterator& operator++();
0054 
0055 private:
0056   size_t m_index;
0057   TrackerHit3D m_object;
0058   const TrackerHit3DObjPointerContainer* m_collection;
0059 };
0060 
0061 class TrackerHit3DMutableCollectionIterator {
0062 public:
0063   TrackerHit3DMutableCollectionIterator(size_t index, const TrackerHit3DObjPointerContainer* collection) :
0064       m_index(index), m_object(podio::utils::MaybeSharedPtr<TrackerHit3DObj>{nullptr}), m_collection(collection) {
0065   }
0066 
0067   TrackerHit3DMutableCollectionIterator(const TrackerHit3DMutableCollectionIterator&) = delete;
0068   TrackerHit3DMutableCollectionIterator& operator=(const TrackerHit3DMutableCollectionIterator&) = delete;
0069 
0070   bool operator!=(const TrackerHit3DMutableCollectionIterator& x) const {
0071     return m_index != x.m_index; // TODO: may not be complete
0072   }
0073 
0074   bool operator==(const TrackerHit3DMutableCollectionIterator& x) const {
0075     return m_index == x.m_index; // TODO: may not be complete
0076   }
0077 
0078   MutableTrackerHit3D operator*();
0079   MutableTrackerHit3D* operator->();
0080   TrackerHit3DMutableCollectionIterator& operator++();
0081 
0082 private:
0083   size_t m_index;
0084   MutableTrackerHit3D m_object;
0085   const TrackerHit3DObjPointerContainer* m_collection;
0086 };
0087 
0088 /**
0089 A Collection is identified by an ID.
0090 */
0091 class TrackerHit3DCollection : public podio::CollectionBase {
0092 public:
0093   using value_type = TrackerHit3D;
0094   using const_iterator = TrackerHit3DCollectionIterator;
0095   using iterator = TrackerHit3DMutableCollectionIterator;
0096   using difference_type = ptrdiff_t;
0097   using size_type = size_t;
0098 
0099   TrackerHit3DCollection();
0100   TrackerHit3DCollection(TrackerHit3DCollectionData&& data, bool isSubsetColl);
0101   // This is a move-only type
0102   TrackerHit3DCollection(const TrackerHit3DCollection&) = delete;
0103   TrackerHit3DCollection& operator=(const TrackerHit3DCollection&) = delete;
0104   TrackerHit3DCollection(TrackerHit3DCollection&&) = default;
0105   TrackerHit3DCollection& operator=(TrackerHit3DCollection&&) = default;
0106 
0107   //  TrackerHit3DCollection(TrackerHit3DVector* data, uint32_t collectionID);
0108   ~TrackerHit3DCollection() override;
0109 
0110   constexpr static auto typeName = "edm4hep::TrackerHit3DCollection";
0111   constexpr static auto valueTypeName = "edm4hep::TrackerHit3D";
0112   constexpr static auto dataTypeName = "edm4hep::TrackerHit3DData";
0113 
0114   void clear() final;
0115 
0116   /// Print this collection to the passed stream
0117   void print(std::ostream& os = std::cout, bool flush = true) const final;
0118 
0119   /// operator to allow pointer like calling of members a la LCIO
0120   TrackerHit3DCollection* operator->() {
0121     return static_cast<TrackerHit3DCollection*>(this);
0122   }
0123 
0124   /// Append a new object to the collection, and return this object.
0125   MutableTrackerHit3D create();
0126 
0127   /// Append a new object to the collection, and return this object.
0128   /// Initialized with the parameters given
0129   template <typename... Args>
0130   MutableTrackerHit3D create(Args&&... args);
0131 
0132   /// number of elements in the collection
0133   std::size_t size() const final;
0134 
0135   /// maximal number of elements in the collection
0136   std::size_t max_size() const final;
0137 
0138   /// Is the collection empty
0139   bool empty() const final;
0140 
0141   /// fully qualified type name
0142   const std::string_view getTypeName() const final {
0143     return typeName;
0144   }
0145   /// fully qualified type name of elements - with namespace
0146   const std::string_view getValueTypeName() const final {
0147     return valueTypeName;
0148   }
0149   /// fully qualified type name of stored POD elements - with namespace
0150   const std::string_view getDataTypeName() const final {
0151     return dataTypeName;
0152   }
0153   /// schema version
0154   podio::SchemaVersionT getSchemaVersion() const final;
0155 
0156   bool isSubsetCollection() const final {
0157     return m_isSubsetColl;
0158   }
0159 
0160   void setSubsetCollection(bool setSubset = true) final;
0161 
0162   /// Returns the const object of given index
0163   TrackerHit3D operator[](std::size_t index) const;
0164   /// Returns the object of a given index
0165   MutableTrackerHit3D operator[](std::size_t index);
0166   /// Returns the const object of given index
0167   TrackerHit3D at(std::size_t index) const;
0168   /// Returns the object of given index
0169   MutableTrackerHit3D at(std::size_t index);
0170 
0171   /// Append object to the collection
0172   void push_back(const MutableTrackerHit3D& object);
0173   /// Append an object to the (subset) collection
0174   void push_back(const TrackerHit3D& object);
0175 
0176   void prepareForWrite() const final;
0177   void prepareAfterRead() final;
0178   bool setReferences(const podio::ICollectionProvider* collectionProvider) final;
0179 
0180   /// Get the collection buffers for this collection
0181   podio::CollectionWriteBuffers getBuffers() final;
0182 
0183   void setID(uint32_t ID) final {
0184     m_collectionID = ID;
0185     if (!m_isSubsetColl) {
0186       std::for_each(m_storage.entries.begin(), m_storage.entries.end(), [ID](TrackerHit3DObj* obj) {
0187         obj->id = {obj->id.index, static_cast<uint32_t>(ID)};
0188       });
0189     }
0190     m_isValid = true;
0191   }
0192 
0193   uint32_t getID() const final {
0194     return m_collectionID;
0195   }
0196 
0197   bool isValid() const final {
0198     return m_isValid;
0199   }
0200 
0201   size_t getDatamodelRegistryIndex() const final;
0202 
0203   // support for the iterator protocol
0204   iterator begin() {
0205     return iterator(0, &m_storage.entries);
0206   }
0207   const_iterator begin() const {
0208     return const_iterator(0, &m_storage.entries);
0209   }
0210   const_iterator cbegin() const {
0211     return begin();
0212   }
0213   iterator end() {
0214     return iterator(m_storage.entries.size(), &m_storage.entries);
0215   }
0216   const_iterator end() const {
0217     return const_iterator(m_storage.entries.size(), &m_storage.entries);
0218   }
0219   const_iterator cend() const {
0220     return end();
0221   }
0222 
0223   std::vector<std::uint64_t> cellID(const size_t nElem = 0) const;
0224   std::vector<std::int32_t> type(const size_t nElem = 0) const;
0225   std::vector<std::int32_t> quality(const size_t nElem = 0) const;
0226   std::vector<float> time(const size_t nElem = 0) const;
0227   std::vector<float> eDep(const size_t nElem = 0) const;
0228   std::vector<float> eDepError(const size_t nElem = 0) const;
0229   std::vector<edm4hep::Vector3d> position(const size_t nElem = 0) const;
0230   std::vector<edm4hep::CovMatrix3f> covMatrix(const size_t nElem = 0) const;
0231 
0232 private:
0233   // For setReferences, we need to give our own CollectionData access to our
0234   // private entries. Otherwise we would need to expose a public member function
0235   // that gives access to the Obj* which is definitely not what we want
0236   friend class TrackerHit3DCollectionData;
0237 
0238   bool m_isValid{false};
0239   mutable bool m_isPrepared{false};
0240   bool m_isSubsetColl{false};
0241   uint32_t m_collectionID{0};
0242   mutable std::unique_ptr<std::mutex> m_storageMtx{nullptr};
0243   mutable TrackerHit3DCollectionData m_storage{};
0244 };
0245 
0246 std::ostream& operator<<(std::ostream& o, const TrackerHit3DCollection& v);
0247 
0248 template <typename... Args>
0249 MutableTrackerHit3D TrackerHit3DCollection::create(Args&&... args) {
0250   if (m_isSubsetColl) {
0251     throw std::logic_error("Cannot create new elements on a subset collection");
0252   }
0253   const int size = m_storage.entries.size();
0254   auto obj = new TrackerHit3DObj({size, m_collectionID}, {std::forward<Args>(args)...});
0255   m_storage.entries.push_back(obj);
0256 
0257   return MutableTrackerHit3D(podio::utils::MaybeSharedPtr(obj));
0258 }
0259 
0260 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0261 void to_json(nlohmann::json& j, const TrackerHit3DCollection& collection);
0262 #endif
0263 
0264 } // namespace edm4hep
0265 
0266 #endif