EDM4eic
EIC data model
Loading...
Searching...
No Matches
ProtoCluster.h
Go to the documentation of this file.
1// AUTOMATICALLY GENERATED FILE - DO NOT EDIT
2
3#ifndef EDM4EIC_ProtoCluster_H
4#define EDM4EIC_ProtoCluster_H
5
7
9#include "podio/RelationRange.h"
10#include <vector>
11
12#include "podio/utilities/MaybeSharedPtr.h"
13#include "podio/detail/OrderKey.h"
14
15#include <ostream>
16#include <cstdint>
17
18#if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
19#include "nlohmann/json_fwd.hpp"
20#endif
21
22// forward declarations
23namespace edm4eic {
25}
26
27
28namespace podio::detail {
29// Internal function used in less comparison operators of the datatypes and interface types
30OrderKey getOrderKey(const edm4eic::ProtoCluster& obj);
31};
32
33namespace edm4eic {
34
38
39/** @class ProtoCluster
40 * Collection of hits identified by the clustering algorithm to belong together
41 * @author: S. Joosten
42 */
44
45 friend class MutableProtoCluster;
49 friend podio::detail::OrderKey podio::detail::getOrderKey(const ProtoCluster & obj);
50
51public:
54
55 /// default constructor
57
58
59 /// copy constructor
60 ProtoCluster(const ProtoCluster& other) = default;
61
62 /// copy-assignment operator
63 ProtoCluster& operator=(ProtoCluster other) &; // Rebind this to other's internal object
64 ProtoCluster& operator=(ProtoCluster other) && = delete; // Prevent rebinding temporary as the changes wouldn't persist
65
66 /// create a mutable deep-copy of the object with identical relations
67 /// if cloneRelations=false, the relations are not cloned and will be empty
68 MutableProtoCluster clone(bool cloneRelations=true) const;
69
70 /// destructor
71 ~ProtoCluster() = default;
72
73 /// converting constructor from mutable object
75
76 static ProtoCluster makeEmpty();
77
78public:
79
80 static constexpr std::string_view typeName = "edm4eic::ProtoCluster";
81
82
83
84 std::size_t hits_size() const;
85 edm4eic::CalorimeterHit getHits(std::size_t) const;
86 std::vector<edm4eic::CalorimeterHit>::const_iterator hits_begin() const;
87 std::vector<edm4eic::CalorimeterHit>::const_iterator hits_end() const;
88 podio::RelationRange<edm4eic::CalorimeterHit> getHits() const;
89 std::size_t weights_size() const;
90 float getWeights(std::size_t) const;
91 std::vector<float>::const_iterator weights_begin() const;
92 std::vector<float>::const_iterator weights_end() const;
93 podio::RelationRange<float> getWeights() const;
94
95
96 /// check whether the object is actually available
97 bool isAvailable() const;
98 /// disconnect from ProtoClusterObj instance
99 void unlink() { m_obj = podio::utils::MaybeSharedPtr<ProtoClusterObj>{nullptr}; }
100
101 bool operator==(const ProtoCluster& other) const { return m_obj == other.m_obj; }
102 bool operator==(const MutableProtoCluster& other) const;
103
104 bool operator!=(const ProtoCluster& other) const { return !(*this == other); }
105 bool operator!=(const MutableProtoCluster& other) const { return !(*this == other); }
106
107 // less comparison operator, so that objects can be e.g. stored in sets.
108 bool operator<(const ProtoCluster& other) const { return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other); }
109
110 podio::ObjectID id() const { return getObjectID(); }
111
112 const podio::ObjectID getObjectID() const;
113
114 friend std::hash<ProtoCluster>;
115
116 friend void swap(ProtoCluster& a, ProtoCluster& b) {
117 using std::swap;
118 swap(a.m_obj, b.m_obj); // swap out the internal pointers
119 }
120
121private:
122 /// constructor from existing ProtoClusterObj
123 explicit ProtoCluster(podio::utils::MaybeSharedPtr<ProtoClusterObj> obj);
125
126 podio::utils::MaybeSharedPtr<ProtoClusterObj> m_obj{nullptr};
127};
128
129std::ostream& operator<<(std::ostream& o, const ProtoCluster& value);
130
131#if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
132void to_json(nlohmann::json& j, const ProtoCluster& value);
133#endif
134
135
136} // namespace edm4eic
137
138
139
140template<>
141struct std::hash<edm4eic::ProtoCluster> {
142 std::size_t operator()(const edm4eic::ProtoCluster& obj) const {
143 return std::hash<edm4eic::ProtoClusterObj*>{}(obj.m_obj.get());
144 }
145};
146
147
148// This is needed to avoid triggering opening every library in LD_LIBRARY_PATH
149// until it's fixed in ROOT. See https://github.com/root-project/root/issues/18489
150// and https://github.com/AIDASoft/podio/issues/770
151#if defined(__clang__)
152#pragma clang diagnostic push
153#pragma clang diagnostic ignored "-Wunknown-warning-option"
154#pragma clang diagnostic ignored "-Wdeprecated-redundant-constexpr-static-def"
155#pragma clang diagnostic ignored "-Wdeprecated"
156constexpr std::string_view edm4eic::ProtoCluster::typeName;
157#pragma clang diagnostic pop
158#elif defined(__GNUC__)
159#pragma GCC diagnostic push
160#pragma GCC diagnostic ignored "-Wdeprecated"
161constexpr std::string_view edm4eic::ProtoCluster::typeName;
162#pragma GCC diagnostic pop
163#endif
164
165#endif
Definition CalorimeterHit.h:46
Definition MutableProtoCluster.h:35
Definition ProtoClusterCollectionData.h:31
Definition ProtoClusterCollection.h:137
Definition ProtoCluster.h:43
const podio::ObjectID getObjectID() const
Definition ProtoCluster.cc:144
friend class ProtoClusterCollection
Definition ProtoCluster.h:46
friend class MutableProtoCluster
Definition ProtoCluster.h:45
ProtoCluster & operator=(ProtoCluster other) &&=delete
bool operator==(const ProtoCluster &other) const
Definition ProtoCluster.h:101
ProtoCluster & operator=(ProtoCluster other) &
copy-assignment operator
Definition ProtoCluster.cc:24
bool operator<(const ProtoCluster &other) const
Definition ProtoCluster.h:108
std::vector< float >::const_iterator weights_begin() const
Definition ProtoCluster.cc:105
podio::RelationRange< edm4eic::CalorimeterHit > getHits() const
Definition ProtoCluster.cc:96
friend void swap(ProtoCluster &a, ProtoCluster &b)
Definition ProtoCluster.h:116
ProtoCluster(const ProtoCluster &other)=default
copy constructor
bool isAvailable() const
check whether the object is actually available
Definition ProtoCluster.cc:140
std::size_t weights_size() const
Definition ProtoCluster.cc:117
bool operator!=(const MutableProtoCluster &other) const
Definition ProtoCluster.h:105
ProtoClusterCollection collection_type
Definition ProtoCluster.h:53
friend class ProtoClusterCollectionIterator
Definition ProtoCluster.h:48
podio::ObjectID id() const
Definition ProtoCluster.h:110
ProtoCluster()
default constructor
Definition ProtoCluster.cc:20
static constexpr std::string_view typeName
Definition ProtoCluster.h:80
MutableProtoCluster clone(bool cloneRelations=true) const
Definition ProtoCluster.cc:29
std::size_t hits_size() const
Definition ProtoCluster.cc:85
MutableProtoCluster mutable_type
Definition ProtoCluster.h:52
std::vector< float >::const_iterator weights_end() const
Definition ProtoCluster.cc:111
std::vector< edm4eic::CalorimeterHit >::const_iterator hits_begin() const
Definition ProtoCluster.cc:73
std::vector< edm4eic::CalorimeterHit >::const_iterator hits_end() const
Definition ProtoCluster.cc:79
~ProtoCluster()=default
destructor
bool operator!=(const ProtoCluster &other) const
Definition ProtoCluster.h:104
static ProtoCluster makeEmpty()
Definition ProtoCluster.cc:66
void unlink()
disconnect from ProtoClusterObj instance
Definition ProtoCluster.h:99
podio::RelationRange< float > getWeights() const
Definition ProtoCluster.cc:128
Definition ProtoClusterObj.h:20
Definition CalorimeterHit.cc:17
std::ostream & operator<<(std::ostream &o, const CalorimeterHit &value)
Definition CalorimeterHit.cc:103
Definition CalorimeterHit.h:31
OrderKey getOrderKey(const edm4eic::CalorimeterHit &obj)
Definition CalorimeterHit.cc:150
std::size_t operator()(const edm4eic::ProtoCluster &obj) const
Definition ProtoCluster.h:142