Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-16 08:53:26

0001 // AUTOMATICALLY GENERATED FILE - DO NOT EDIT
0002 
0003 #ifndef EDM4EIC_ProtoCluster_H
0004 #define EDM4EIC_ProtoCluster_H
0005 
0006 #include "edm4eic/ProtoClusterObj.h"
0007 
0008 #include "edm4eic/CalorimeterHit.h"
0009 #include "podio/RelationRange.h"
0010 #include <vector>
0011 
0012 #include "podio/utilities/MaybeSharedPtr.h"
0013 #include "podio/detail/OrderKey.h"
0014 
0015 #include <ostream>
0016 #include <cstdint>
0017 
0018 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0019 #include "nlohmann/json_fwd.hpp"
0020 #endif
0021 
0022 // forward declarations
0023 namespace edm4eic {
0024 class ProtoClusterCollection;
0025 }
0026 
0027 
0028 namespace podio::detail {
0029 // Internal function used in less comparison operators of the datatypes and interface types
0030 OrderKey getOrderKey(const edm4eic::ProtoCluster& obj);
0031 };
0032 
0033 namespace edm4eic {
0034 
0035 class MutableProtoCluster;
0036 class ProtoClusterCollection;
0037 class ProtoClusterCollectionData;
0038 
0039 /** @class ProtoCluster
0040  *  Collection of hits identified by the clustering algorithm to belong together
0041  *  @author: S. Joosten
0042  */
0043 class ProtoCluster {
0044 
0045   friend class MutableProtoCluster;
0046   friend class ProtoClusterCollection;
0047   friend class edm4eic::ProtoClusterCollectionData;
0048   friend class ProtoClusterCollectionIterator;
0049   friend podio::detail::OrderKey podio::detail::getOrderKey(const ProtoCluster & obj);
0050 
0051 public:
0052   using mutable_type = MutableProtoCluster;
0053   using collection_type = ProtoClusterCollection;
0054 
0055   /// default constructor
0056   ProtoCluster();
0057 
0058 
0059   /// copy constructor
0060   ProtoCluster(const ProtoCluster& other) = default;
0061 
0062   /// copy-assignment operator
0063   ProtoCluster& operator=(ProtoCluster other) &; // Rebind this to other's internal object
0064   ProtoCluster& operator=(ProtoCluster other) && = delete; // Prevent rebinding temporary as the changes wouldn't persist
0065 
0066   /// create a mutable deep-copy of the object with identical relations
0067   /// if cloneRelations=false, the relations are not cloned and will be empty
0068   MutableProtoCluster clone(bool cloneRelations=true) const;
0069 
0070   /// destructor
0071   ~ProtoCluster() = default;
0072 
0073   /// converting constructor from mutable object
0074   ProtoCluster(const MutableProtoCluster& other);
0075 
0076   static ProtoCluster makeEmpty();
0077 
0078 public:
0079 
0080   static constexpr std::string_view typeName = "edm4eic::ProtoCluster";
0081 
0082 
0083 
0084   std::size_t hits_size() const;
0085   edm4eic::CalorimeterHit getHits(std::size_t) const;
0086   std::vector<edm4eic::CalorimeterHit>::const_iterator hits_begin() const;
0087   std::vector<edm4eic::CalorimeterHit>::const_iterator hits_end() const;
0088   podio::RelationRange<edm4eic::CalorimeterHit> getHits() const;
0089   std::size_t weights_size() const;
0090   float getWeights(std::size_t) const;
0091   std::vector<float>::const_iterator weights_begin() const;
0092   std::vector<float>::const_iterator weights_end() const;
0093   podio::RelationRange<float> getWeights() const;
0094 
0095 
0096   /// check whether the object is actually available
0097   bool isAvailable() const;
0098   /// disconnect from ProtoClusterObj instance
0099   void unlink() { m_obj = podio::utils::MaybeSharedPtr<ProtoClusterObj>{nullptr}; }
0100 
0101   bool operator==(const ProtoCluster& other) const { return m_obj == other.m_obj; }
0102   bool operator==(const MutableProtoCluster& other) const;
0103 
0104   bool operator!=(const ProtoCluster& other) const { return !(*this == other); }
0105   bool operator!=(const MutableProtoCluster& other) const { return !(*this == other); }
0106 
0107   // less comparison operator, so that objects can be e.g. stored in sets.
0108   bool operator<(const ProtoCluster& other) const { return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other); }
0109 
0110   podio::ObjectID id() const { return getObjectID(); }
0111 
0112   const podio::ObjectID getObjectID() const;
0113 
0114   friend std::hash<ProtoCluster>;
0115 
0116   friend void swap(ProtoCluster& a, ProtoCluster& b) {
0117     using std::swap;
0118     swap(a.m_obj, b.m_obj); // swap out the internal pointers
0119   }
0120 
0121 private:
0122   /// constructor from existing ProtoClusterObj
0123   explicit ProtoCluster(podio::utils::MaybeSharedPtr<ProtoClusterObj> obj);
0124   ProtoCluster(ProtoClusterObj* obj);
0125 
0126   podio::utils::MaybeSharedPtr<ProtoClusterObj> m_obj{nullptr};
0127 };
0128 
0129 std::ostream& operator<<(std::ostream& o, const ProtoCluster& value);
0130 
0131 #if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
0132 void to_json(nlohmann::json& j, const ProtoCluster& value);
0133 #endif
0134 
0135 
0136 } // namespace edm4eic
0137 
0138 
0139 
0140 template<>
0141 struct std::hash<edm4eic::ProtoCluster> {
0142   std::size_t operator()(const edm4eic::ProtoCluster& obj) const {
0143     return std::hash<edm4eic::ProtoClusterObj*>{}(obj.m_obj.get());
0144   }
0145 };
0146 
0147 
0148 // This is needed to avoid triggering opening every library in LD_LIBRARY_PATH
0149 // until it's fixed in ROOT. See https://github.com/root-project/root/issues/18489
0150 // and https://github.com/AIDASoft/podio/issues/770
0151 #if defined(__clang__)
0152 #pragma clang diagnostic push
0153 #pragma clang diagnostic ignored "-Wunknown-warning-option"
0154 #pragma clang diagnostic ignored "-Wdeprecated-redundant-constexpr-static-def"
0155 #pragma clang diagnostic ignored "-Wdeprecated"
0156 constexpr std::string_view edm4eic::ProtoCluster::typeName;
0157 #pragma clang diagnostic pop
0158 #elif defined(__GNUC__)
0159 #pragma GCC diagnostic push
0160 #pragma GCC diagnostic ignored "-Wdeprecated"
0161 constexpr std::string_view edm4eic::ProtoCluster::typeName;
0162 #pragma GCC diagnostic pop
0163 #endif
0164 
0165 #endif