Back to home page

EIC code displayed by LXR

 
 

    


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