Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/edm4hep/GeneratorEventParametersCollection.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_GeneratorEventParametersCollection_H
0004 #define EDM4HEP_GeneratorEventParametersCollection_H
0005 
0006 // datamodel specific includes
0007 #include "edm4hep/GeneratorEventParameters.h"
0008 #include "edm4hep/GeneratorEventParametersCollectionData.h"
0009 #include "edm4hep/GeneratorEventParametersObj.h"
0010 #include "edm4hep/MutableGeneratorEventParameters.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 GeneratorEventParametersCollectionIterator {
0036 public:
0037   using value_type = GeneratorEventParameters;
0038   using difference_type = ptrdiff_t;
0039   using reference = GeneratorEventParameters;
0040   using pointer = GeneratorEventParameters*;
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   GeneratorEventParametersCollectionIterator(size_t index,
0047                                              const GeneratorEventParametersObjPointerContainer* collection)
0048       : m_index(index), m_object(podio::utils::MaybeSharedPtr<GeneratorEventParametersObj>{nullptr}),
0049         m_collection(collection) {}
0050   GeneratorEventParametersCollectionIterator() = default;
0051 
0052   GeneratorEventParametersCollectionIterator(const GeneratorEventParametersCollectionIterator&) = default;
0053   GeneratorEventParametersCollectionIterator(GeneratorEventParametersCollectionIterator&&) = default;
0054   GeneratorEventParametersCollectionIterator& operator=(const GeneratorEventParametersCollectionIterator&) = default;
0055   GeneratorEventParametersCollectionIterator& operator=(GeneratorEventParametersCollectionIterator&&) = default;
0056   ~GeneratorEventParametersCollectionIterator() = default;
0057 
0058   auto operator<=>(const GeneratorEventParametersCollectionIterator& other) const { return m_index <=> other.m_index; }
0059 
0060   bool operator==(const GeneratorEventParametersCollectionIterator& x) const { return m_index == x.m_index; }
0061 
0062   reference operator*() const;
0063   pointer operator->();
0064   GeneratorEventParametersCollectionIterator& operator++();
0065   GeneratorEventParametersCollectionIterator operator++(int);
0066   GeneratorEventParametersCollectionIterator& operator--();
0067   GeneratorEventParametersCollectionIterator operator--(int);
0068   GeneratorEventParametersCollectionIterator& operator+=(difference_type n);
0069   GeneratorEventParametersCollectionIterator operator+(difference_type n) const;
0070   friend GeneratorEventParametersCollectionIterator operator+(difference_type n,
0071                                                               const GeneratorEventParametersCollectionIterator& it);
0072   GeneratorEventParametersCollectionIterator& operator-=(difference_type n);
0073   GeneratorEventParametersCollectionIterator operator-(difference_type n) const;
0074   reference operator[](difference_type n) const;
0075   difference_type operator-(const GeneratorEventParametersCollectionIterator& other) const;
0076 
0077 private:
0078   size_t m_index{0};
0079   GeneratorEventParameters m_object{podio::utils::MaybeSharedPtr<GeneratorEventParametersObj>{nullptr}};
0080   const GeneratorEventParametersObjPointerContainer* m_collection{nullptr};
0081 };
0082 
0083 class GeneratorEventParametersMutableCollectionIterator {
0084 public:
0085   using value_type = GeneratorEventParameters;
0086   using difference_type = ptrdiff_t;
0087   using reference = MutableGeneratorEventParameters;
0088   using pointer = MutableGeneratorEventParameters*;
0089   using iterator_category = std::input_iterator_tag;
0090   // `std::forward_iterator` is supported except that the pointers obtained with `operator->()`
0091   // remain valid as long as the iterator is valid, not as long as the range is valid.
0092   using iterator_concept = std::random_access_iterator_tag;
0093 
0094   GeneratorEventParametersMutableCollectionIterator(size_t index,
0095                                                     const GeneratorEventParametersObjPointerContainer* collection)
0096       : m_index(index), m_object(podio::utils::MaybeSharedPtr<GeneratorEventParametersObj>{nullptr}),
0097         m_collection(collection) {}
0098   GeneratorEventParametersMutableCollectionIterator() = default;
0099 
0100   GeneratorEventParametersMutableCollectionIterator(const GeneratorEventParametersMutableCollectionIterator&) = default;
0101   GeneratorEventParametersMutableCollectionIterator(GeneratorEventParametersMutableCollectionIterator&&) = default;
0102   GeneratorEventParametersMutableCollectionIterator&
0103   operator=(const GeneratorEventParametersMutableCollectionIterator&) = default;
0104   GeneratorEventParametersMutableCollectionIterator&
0105   operator=(GeneratorEventParametersMutableCollectionIterator&&) = default;
0106   ~GeneratorEventParametersMutableCollectionIterator() = default;
0107 
0108   auto operator<=>(const GeneratorEventParametersMutableCollectionIterator& other) const {
0109     return m_index <=> other.m_index;
0110   }
0111 
0112   bool operator==(const GeneratorEventParametersMutableCollectionIterator& x) const { return m_index == x.m_index; }
0113 
0114   reference operator*() const;
0115   pointer operator->();
0116   GeneratorEventParametersMutableCollectionIterator& operator++();
0117   GeneratorEventParametersMutableCollectionIterator operator++(int);
0118   GeneratorEventParametersMutableCollectionIterator& operator--();
0119   GeneratorEventParametersMutableCollectionIterator operator--(int);
0120   GeneratorEventParametersMutableCollectionIterator& operator+=(difference_type n);
0121   GeneratorEventParametersMutableCollectionIterator operator+(difference_type n) const;
0122   friend GeneratorEventParametersMutableCollectionIterator
0123   operator+(difference_type n, const GeneratorEventParametersMutableCollectionIterator& it);
0124   GeneratorEventParametersMutableCollectionIterator& operator-=(difference_type n);
0125   GeneratorEventParametersMutableCollectionIterator operator-(difference_type n) const;
0126   reference operator[](difference_type n) const;
0127   difference_type operator-(const GeneratorEventParametersMutableCollectionIterator& other) const;
0128 
0129 private:
0130   size_t m_index{0};
0131   MutableGeneratorEventParameters m_object{podio::utils::MaybeSharedPtr<GeneratorEventParametersObj>{nullptr}};
0132   const GeneratorEventParametersObjPointerContainer* m_collection{nullptr};
0133 };
0134 
0135 /**
0136 A Collection is identified by an ID.
0137 */
0138 class GeneratorEventParametersCollection : public podio::CollectionBase {
0139 public:
0140   using value_type = GeneratorEventParameters;
0141   using mutable_type = MutableGeneratorEventParameters;
0142   using const_iterator = GeneratorEventParametersCollectionIterator;
0143   using iterator = GeneratorEventParametersMutableCollectionIterator;
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   GeneratorEventParametersCollection() = default;
0150   GeneratorEventParametersCollection(GeneratorEventParametersCollectionData&& data, bool isSubsetColl);
0151   // This is a move-only type
0152   GeneratorEventParametersCollection(const GeneratorEventParametersCollection&) = delete;
0153   GeneratorEventParametersCollection& operator=(const GeneratorEventParametersCollection&) = delete;
0154   GeneratorEventParametersCollection(GeneratorEventParametersCollection&&) = default;
0155   GeneratorEventParametersCollection& operator=(GeneratorEventParametersCollection&&) = default;
0156 
0157   //  GeneratorEventParametersCollection(GeneratorEventParametersVector* data, uint32_t collectionID);
0158   ~GeneratorEventParametersCollection() override;
0159 
0160   constexpr static std::string_view typeName = "edm4hep::GeneratorEventParametersCollection";
0161   constexpr static std::string_view valueTypeName = "edm4hep::GeneratorEventParameters";
0162   constexpr static std::string_view dataTypeName = "edm4hep::GeneratorEventParametersData";
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   MutableGeneratorEventParameters 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   MutableGeneratorEventParameters 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 { return m_isSubsetColl; }
0201 
0202   void setSubsetCollection(bool setSubset = true) final;
0203 
0204   /// Returns the const object of given index
0205   GeneratorEventParameters operator[](std::size_t index) const;
0206   /// Returns the object of a given index
0207   MutableGeneratorEventParameters operator[](std::size_t index);
0208   /// Returns the const object of given index
0209   GeneratorEventParameters at(std::size_t index) const;
0210   /// Returns the object of given index
0211   MutableGeneratorEventParameters at(std::size_t index);
0212 
0213   /// Append object to the collection
0214   void push_back(const MutableGeneratorEventParameters& object);
0215   /// Append an object to the (subset) collection
0216   void push_back(const GeneratorEventParameters& object);
0217 
0218   void prepareForWrite() const final;
0219   void prepareAfterRead() final;
0220   bool setReferences(const podio::ICollectionProvider* collectionProvider) final;
0221 
0222   /// Get the collection buffers for this collection
0223   podio::CollectionWriteBuffers getBuffers() final;
0224 
0225   void setID(uint32_t ID) final {
0226     m_collectionID = ID;
0227     if (!m_isSubsetColl) {
0228       std::for_each(m_storage.entries.begin(), m_storage.entries.end(),
0229                     [ID](GeneratorEventParametersObj* obj) { obj->id = {obj->id.index, static_cast<uint32_t>(ID)}; });
0230     }
0231   }
0232 
0233   uint32_t getID() const final { return m_collectionID; }
0234 
0235   /// check if the collection has a valid ID
0236   bool hasID() const final {
0237     return getID() != static_cast<uint32_t>(podio::ObjectID::untracked) &&
0238            getID() != static_cast<uint32_t>(podio::ObjectID::invalid);
0239   }
0240 
0241   [[deprecated("isValid will be removed, use hasID() if you want to check if it has an ID, otherwise assume the "
0242                "collection is valid")]] bool
0243   isValid() const final {
0244     return hasID();
0245   }
0246 
0247   size_t getDatamodelRegistryIndex() const final;
0248 
0249   // support for the iterator protocol
0250   iterator begin() { return iterator(0, &m_storage.entries); }
0251   const_iterator begin() const { return const_iterator(0, &m_storage.entries); }
0252   const_iterator cbegin() const { return begin(); }
0253   iterator end() { return iterator(m_storage.entries.size(), &m_storage.entries); }
0254   const_iterator end() const { return const_iterator(m_storage.entries.size(), &m_storage.entries); }
0255   const_iterator cend() const { return end(); }
0256   // reverse iterators
0257   reverse_iterator rbegin() { return reverse_iterator(end()); }
0258   const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); }
0259   const_reverse_iterator crbegin() const { return rbegin(); }
0260   reverse_iterator rend() { return reverse_iterator(begin()); }
0261   const_reverse_iterator rend() const { return const_reverse_iterator(begin()); }
0262   const_reverse_iterator crend() const { return rend(); }
0263 
0264   std::vector<double> sqrts(const size_t nElem = 0) const;
0265   std::vector<std::array<double, 2>> beamsPz(const size_t nElem = 0) const;
0266   std::vector<std::array<int, 2>> partonIds(const size_t nElem = 0) const;
0267   std::vector<std::array<float, 2>> beamPolarizations(const size_t nElem = 0) const;
0268 
0269 private:
0270   // For setReferences, we need to give our own CollectionData access to our
0271   // private entries. Otherwise we would need to expose a public member function
0272   // that gives access to the Obj* which is definitely not what we want
0273   friend class GeneratorEventParametersCollectionData;
0274 
0275   mutable bool m_isPrepared{false};
0276   bool m_isSubsetColl{false};
0277   uint32_t m_collectionID{static_cast<uint32_t>(podio::ObjectID::untracked)};
0278   mutable std::unique_ptr<std::mutex> m_storageMtx{std::make_unique<std::mutex>()};
0279   mutable GeneratorEventParametersCollectionData m_storage{};
0280 };
0281 
0282 std::ostream& operator<<(std::ostream& o, const GeneratorEventParametersCollection& v);
0283 
0284 template <typename... Args>
0285 MutableGeneratorEventParameters GeneratorEventParametersCollection::create(Args&&... args) {
0286   if (m_isSubsetColl) {
0287     throw std::logic_error("Cannot create new elements on a subset collection");
0288   }
0289   auto obj = new GeneratorEventParametersObj({static_cast<int>(m_storage.entries.size()), m_collectionID},
0290                                              {std::forward<Args>(args)...});
0291   m_storage.entries.push_back(obj);
0292 
0293   // Need to initialize the relation vectors manually for the {ObjectID, GeneratorEventParametersData} constructor
0294   obj->m_signalVertexParticles = new std::vector<edm4hep::MCParticle>();
0295   obj->m_crossSections = new std::vector<double>();
0296   obj->m_crossSectionErrors = new std::vector<double>();
0297   obj->m_weights = new std::vector<double>();
0298   m_storage.createRelations(obj);
0299   return MutableGeneratorEventParameters(podio::utils::MaybeSharedPtr(obj));
0300 }
0301 
0302 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0303 void to_json(nlohmann::json& j, const GeneratorEventParametersCollection& collection);
0304 #endif
0305 
0306 } // namespace edm4hep
0307 
0308 // This is needed to avoid triggering opening every library in LD_LIBRARY_PATH
0309 // until it's fixed in ROOT. See https://github.com/root-project/root/issues/18489
0310 // and https://github.com/AIDASoft/podio/issues/770
0311 #if defined(__clang__)
0312 #pragma clang diagnostic push
0313 #pragma clang diagnostic ignored "-Wunknown-warning-option"
0314 #pragma clang diagnostic ignored "-Wdeprecated-redundant-constexpr-static-def"
0315 #pragma clang diagnostic ignored "-Wdeprecated"
0316 constexpr std::string_view edm4hep::GeneratorEventParametersCollection::typeName;
0317 constexpr std::string_view edm4hep::GeneratorEventParametersCollection::valueTypeName;
0318 constexpr std::string_view edm4hep::GeneratorEventParametersCollection::dataTypeName;
0319 #pragma clang diagnostic pop
0320 #elif defined(__GNUC__)
0321 #pragma GCC diagnostic push
0322 #pragma GCC diagnostic ignored "-Wdeprecated"
0323 constexpr std::string_view edm4hep::GeneratorEventParametersCollection::typeName;
0324 constexpr std::string_view edm4hep::GeneratorEventParametersCollection::valueTypeName;
0325 constexpr std::string_view edm4hep::GeneratorEventParametersCollection::dataTypeName;
0326 #pragma GCC diagnostic pop
0327 #endif
0328 
0329 #endif