EDM4eic
EIC data model
Loading...
Searching...
No Matches
MutableProtoCluster.h
Go to the documentation of this file.
1// AUTOMATICALLY GENERATED FILE - DO NOT EDIT
2
3#ifndef EDM4EIC_MutableProtoCluster_H
4#define EDM4EIC_MutableProtoCluster_H
5
7// Make the immutable class available from its mutable version but not vice versa
9
11#include "podio/RelationRange.h"
12#include <vector>
13
14#include "podio/utilities/MaybeSharedPtr.h"
15
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 edm4eic {
29
30
31/** @class MutableProtoCluster
32 * Collection of hits identified by the clustering algorithm to belong together
33 * @author: S. Joosten
34 */
36
39 friend class ProtoCluster;
40
41public:
44
45 /// default constructor
47
48
49 /// copy constructor
51
52 /// copy-assignment operator
53 MutableProtoCluster& operator=(MutableProtoCluster other) &; // Rebind this to other's internal object
54 MutableProtoCluster& operator=(MutableProtoCluster other) && = delete; // Prevent rebinding temporary as the changes wouldn't persist
55
56 /// create a mutable deep-copy of the object with identical relations
57 /// if cloneRelations=false, the relations are not cloned and will be empty
58 MutableProtoCluster clone(bool cloneRelations=true) const;
59
60 /// destructor
62
63
64public:
65
66
67
68
69
71 std::size_t hits_size() const;
72 edm4eic::CalorimeterHit getHits(std::size_t) const;
73 std::vector<edm4eic::CalorimeterHit>::const_iterator hits_begin() const;
74 std::vector<edm4eic::CalorimeterHit>::const_iterator hits_end() const;
75 podio::RelationRange<edm4eic::CalorimeterHit> getHits() const;
76 void addToWeights(const float&);
77 std::size_t weights_size() const;
78 float getWeights(std::size_t) const;
79 std::vector<float>::const_iterator weights_begin() const;
80 std::vector<float>::const_iterator weights_end() const;
81 podio::RelationRange<float> getWeights() const;
82
83
84
85 /// check whether the object is actually available
86 bool isAvailable() const;
87 /// disconnect from ProtoClusterObj instance
88 void unlink() { m_obj = podio::utils::MaybeSharedPtr<ProtoClusterObj>{nullptr}; }
89
90 bool operator==(const MutableProtoCluster& other) const { return m_obj == other.m_obj; }
91 bool operator==(const ProtoCluster& other) const;
92
93 bool operator!=(const MutableProtoCluster& other) const { return !(*this == other); }
94 bool operator!=(const ProtoCluster& other) const { return !(*this == other); }
95
96 // less comparison operator, so that objects can be e.g. stored in sets.
97 bool operator<(const MutableProtoCluster& other) const { return podio::detail::getOrderKey(*this) < podio::detail::getOrderKey(other); }
98
99 podio::ObjectID id() const { return getObjectID(); }
100
101 const podio::ObjectID getObjectID() const;
102
103 friend std::hash<MutableProtoCluster>;
104
106 using std::swap;
107 swap(a.m_obj, b.m_obj); // swap out the internal pointers
108 }
109
110private:
111 /// constructor from existing ProtoClusterObj
112 explicit MutableProtoCluster(podio::utils::MaybeSharedPtr<ProtoClusterObj> obj);
113
114 podio::utils::MaybeSharedPtr<ProtoClusterObj> m_obj{nullptr};
115};
116
117#if defined(PODIO_JSON_OUTPUT) && !defined(__CLING__)
118void to_json(nlohmann::json& j, const MutableProtoCluster& value);
119#endif
120
121
122} // namespace edm4eic
123
124
125
126template<>
127struct std::hash<edm4eic::MutableProtoCluster> {
128 std::size_t operator()(const edm4eic::MutableProtoCluster& obj) const {
129 return std::hash<edm4eic::ProtoClusterObj*>{}(obj.m_obj.get());
130 }
131};
132
133
134#endif
Definition CalorimeterHit.h:46
Definition MutableProtoCluster.h:35
friend class ProtoClusterCollection
Definition MutableProtoCluster.h:37
MutableProtoCluster clone(bool cloneRelations=true) const
Definition MutableProtoCluster.cc:27
bool operator==(const MutableProtoCluster &other) const
Definition MutableProtoCluster.h:90
friend class ProtoClusterMutableCollectionIterator
Definition MutableProtoCluster.h:38
std::size_t weights_size() const
Definition MutableProtoCluster.cc:100
MutableProtoCluster & operator=(MutableProtoCluster other) &
copy-assignment operator
Definition MutableProtoCluster.cc:22
MutableProtoCluster & operator=(MutableProtoCluster other) &&=delete
podio::ObjectID id() const
Definition MutableProtoCluster.h:99
bool operator<(const MutableProtoCluster &other) const
Definition MutableProtoCluster.h:97
void addToHits(const edm4eic::CalorimeterHit &)
Definition MutableProtoCluster.cc:47
friend void swap(MutableProtoCluster &a, MutableProtoCluster &b)
Definition MutableProtoCluster.h:105
std::vector< edm4eic::CalorimeterHit >::const_iterator hits_end() const
Definition MutableProtoCluster.cc:58
bool isAvailable() const
check whether the object is actually available
Definition MutableProtoCluster.cc:124
void addToWeights(const float &)
Definition MutableProtoCluster.cc:83
const podio::ObjectID getObjectID() const
Definition MutableProtoCluster.cc:128
bool operator!=(const MutableProtoCluster &other) const
Definition MutableProtoCluster.h:93
std::vector< float >::const_iterator weights_end() const
Definition MutableProtoCluster.cc:94
~MutableProtoCluster()=default
destructor
bool operator!=(const ProtoCluster &other) const
Definition MutableProtoCluster.h:94
friend class ProtoCluster
Definition MutableProtoCluster.h:39
podio::RelationRange< float > getWeights() const
Definition MutableProtoCluster.cc:111
std::vector< float >::const_iterator weights_begin() const
Definition MutableProtoCluster.cc:88
podio::RelationRange< edm4eic::CalorimeterHit > getHits() const
Definition MutableProtoCluster.cc:75
void unlink()
disconnect from ProtoClusterObj instance
Definition MutableProtoCluster.h:88
MutableProtoCluster()
default constructor
Definition MutableProtoCluster.cc:18
ProtoClusterCollection collection_type
Definition MutableProtoCluster.h:43
std::vector< edm4eic::CalorimeterHit >::const_iterator hits_begin() const
Definition MutableProtoCluster.cc:52
ProtoCluster object_type
Definition MutableProtoCluster.h:42
MutableProtoCluster(const MutableProtoCluster &other)=default
copy constructor
std::size_t hits_size() const
Definition MutableProtoCluster.cc:64
Definition ProtoClusterCollection.h:137
Definition ProtoCluster.h:43
Definition CalorimeterHit.cc:17
OrderKey getOrderKey(const edm4eic::CalorimeterHit &obj)
Definition CalorimeterHit.cc:150
std::size_t operator()(const edm4eic::MutableProtoCluster &obj) const
Definition MutableProtoCluster.h:128