EICd
EIC data model
ClusterLayerCollection.h
Go to the documentation of this file.
1 // AUTOMATICALLY GENERATED FILE - DO NOT EDIT
2 
3 #ifndef EICD_ClusterLayerCollection_H
4 #define EICD_ClusterLayerCollection_H
5 
6 // datamodel specific includes
8 #include "eicd/ClusterLayer.h"
9 #include "eicd/ClusterLayerObj.h"
10 
11 // podio specific includes
12 #include "podio/ICollectionProvider.h"
13 #include "podio/CollectionBase.h"
14 #include "podio/CollectionIDTable.h"
15 
16 #include <string>
17 #include <vector>
18 #include <deque>
19 #include <array>
20 #include <algorithm>
21 #include <ostream>
22 
23 namespace eic {
24 
25 
26 using ClusterLayerDataContainer = std::vector<ClusterLayerData>;
27 using ClusterLayerObjPointerContainer = std::deque<ClusterLayerObj*>;
28 
30 public:
31  ClusterLayerCollectionIterator(size_t index, const ClusterLayerObjPointerContainer* collection) : m_index(index), m_object(nullptr), m_collection(collection) {}
32 
35 
37  return m_index != x.m_index; // TODO: may not be complete
38  }
39 
43 
44 private:
45  size_t m_index;
46  ClusterLayer m_object;
47  const ClusterLayerObjPointerContainer* m_collection;
48 };
49 
50 
52 public:
53  ClusterLayerConstCollectionIterator(size_t index, const ClusterLayerObjPointerContainer* collection) : m_index(index), m_object(nullptr), m_collection(collection) {}
54 
57 
59  return m_index != x.m_index; // TODO: may not be complete
60  }
61 
65 
66 private:
67  size_t m_index;
68  ConstClusterLayer m_object;
69  const ClusterLayerObjPointerContainer* m_collection;
70 };
71 
72 
73 /**
74 A Collection is identified by an ID.
75 */
76 class ClusterLayerCollection : public podio::CollectionBase {
77 
78 public:
81 
85 // ClusterLayerCollection(ClusterLayerVector* data, int collectionID);
87 
88  void clear() override final;
89 
90  /// operator to allow pointer like calling of members a la LCIO
91  ClusterLayerCollection* operator->() { return (ClusterLayerCollection*) this; }
92 
93  /// Append a new object to the collection, and return this object.
95 
96  /// Append a new object to the collection, and return this object.
97  /// Initialized with the parameters given
98  template<typename... Args>
99  ClusterLayer create(Args&&... args);
100 
101  /// number of elements in the collection
102  size_t size() const override final;
103 
104  /// fully qualified type name of elements - with namespace
105  std::string getValueTypeName() const override { return std::string("eic::ClusterLayer"); }
106 
107  /// Returns the const object of given index
108  ConstClusterLayer operator[](unsigned int index) const;
109  /// Returns the object of a given index
110  ClusterLayer operator[](unsigned int index);
111  /// Returns the const object of given index
112  ConstClusterLayer at(unsigned int index) const;
113  /// Returns the object of given index
114  ClusterLayer at(unsigned int index);
115 
116 
117  /// Append object to the collection
118  void push_back(ConstClusterLayer object);
119 
120  void prepareForWrite() override final;
121  void prepareAfterRead() override final;
122  void setBuffer(void* address) override final;
123  bool setReferences(const podio::ICollectionProvider* collectionProvider) override final;
124 
125  podio::CollRefCollection* referenceCollections() override final { return &m_refCollections; }
126 
127  podio::VectorMembersInfo* vectorMembers() override { return &m_vecmem_info; }
128 
129  void setID(unsigned ID) override final {
130  m_collectionID = ID;
131  std::for_each(m_entries.begin(),m_entries.end(),
132  [ID] (ClusterLayerObj* obj) { obj->id = {obj->id.index, static_cast<int>(ID)}; }
133  );
134  m_isValid = true;
135  };
136 
137  unsigned getID() const override final {
138  return m_collectionID;
139  }
140 
141  bool isValid() const override final {
142  return m_isValid;
143  }
144 
145  // support for the iterator protocol
147  return iterator(0, &m_entries);
148  }
150  return const_iterator(0, &m_entries);
151  }
153  return iterator(m_entries.size(), &m_entries);
154  }
155  const_iterator end() const {
156  return const_iterator(m_entries.size(), &m_entries);
157  }
158 
159  /// returns the address of the pointer to the data buffer
160  void* getBufferAddress() override final { return (void*)&m_data; }
161 
162  /// Returns the pointer to the data buffer
163  std::vector<ClusterLayerData>* _getBuffer() { return m_data; }
164 
165  template<size_t arraysize>
166  const std::array<eic::Index, arraysize> ID() const;
167  template<size_t arraysize>
168  const std::array<eic::Index, arraysize> clusterID() const;
169  template<size_t arraysize>
170  const std::array<std::int32_t, arraysize> layer() const;
171  template<size_t arraysize>
172  const std::array<std::uint32_t, arraysize> nhits() const;
173  template<size_t arraysize>
174  const std::array<float, arraysize> energy() const;
175  template<size_t arraysize>
176  const std::array<float, arraysize> energyError() const;
177  template<size_t arraysize>
178  const std::array<float, arraysize> radius() const;
179  template<size_t arraysize>
180  const std::array<float, arraysize> skewness() const;
181  template<size_t arraysize>
182  const std::array<eic::VectorXYZ, arraysize> position() const;
183 
184 private:
185  bool m_isValid{false};
186  bool m_isReadFromFile{false};
187  int m_collectionID{0};
189 
190  // members to handle 1-to-N-relations
191 
192  // members to handle vector members
193  // members to handle streaming
194  podio::CollRefCollection m_refCollections{};
195  podio::VectorMembersInfo m_vecmem_info{};
197 };
198 
199 std::ostream& operator<<(std::ostream& o, const ClusterLayerCollection& v);
200 
201 template<typename... Args>
202 ClusterLayer ClusterLayerCollection::create(Args&&... args) {
203  const int size = m_entries.size();
204  auto obj = new ClusterLayerObj({size, m_collectionID}, {args...});
205  m_entries.push_back(obj);
206  return ClusterLayer(obj);
207 }
208 
209 template<size_t arraysize>
210 const std::array<eic::Index, arraysize> ClusterLayerCollection::ID() const {
211  std::array<eic::Index, arraysize> tmp;
212  const auto valid_size = std::min(arraysize, m_entries.size());
213  for (unsigned i = 0; i < valid_size; ++i) {
214  tmp[i] = m_entries[i]->data.ID;
215  }
216  return tmp;
217 }
218 
219 template<size_t arraysize>
220 const std::array<eic::Index, arraysize> ClusterLayerCollection::clusterID() const {
221  std::array<eic::Index, arraysize> tmp;
222  const auto valid_size = std::min(arraysize, m_entries.size());
223  for (unsigned i = 0; i < valid_size; ++i) {
224  tmp[i] = m_entries[i]->data.clusterID;
225  }
226  return tmp;
227 }
228 
229 template<size_t arraysize>
230 const std::array<std::int32_t, arraysize> ClusterLayerCollection::layer() const {
231  std::array<std::int32_t, arraysize> tmp;
232  const auto valid_size = std::min(arraysize, m_entries.size());
233  for (unsigned i = 0; i < valid_size; ++i) {
234  tmp[i] = m_entries[i]->data.layer;
235  }
236  return tmp;
237 }
238 
239 template<size_t arraysize>
240 const std::array<std::uint32_t, arraysize> ClusterLayerCollection::nhits() const {
241  std::array<std::uint32_t, arraysize> tmp;
242  const auto valid_size = std::min(arraysize, m_entries.size());
243  for (unsigned i = 0; i < valid_size; ++i) {
244  tmp[i] = m_entries[i]->data.nhits;
245  }
246  return tmp;
247 }
248 
249 template<size_t arraysize>
250 const std::array<float, arraysize> ClusterLayerCollection::energy() const {
251  std::array<float, arraysize> tmp;
252  const auto valid_size = std::min(arraysize, m_entries.size());
253  for (unsigned i = 0; i < valid_size; ++i) {
254  tmp[i] = m_entries[i]->data.energy;
255  }
256  return tmp;
257 }
258 
259 template<size_t arraysize>
260 const std::array<float, arraysize> ClusterLayerCollection::energyError() const {
261  std::array<float, arraysize> tmp;
262  const auto valid_size = std::min(arraysize, m_entries.size());
263  for (unsigned i = 0; i < valid_size; ++i) {
264  tmp[i] = m_entries[i]->data.energyError;
265  }
266  return tmp;
267 }
268 
269 template<size_t arraysize>
270 const std::array<float, arraysize> ClusterLayerCollection::radius() const {
271  std::array<float, arraysize> tmp;
272  const auto valid_size = std::min(arraysize, m_entries.size());
273  for (unsigned i = 0; i < valid_size; ++i) {
274  tmp[i] = m_entries[i]->data.radius;
275  }
276  return tmp;
277 }
278 
279 template<size_t arraysize>
280 const std::array<float, arraysize> ClusterLayerCollection::skewness() const {
281  std::array<float, arraysize> tmp;
282  const auto valid_size = std::min(arraysize, m_entries.size());
283  for (unsigned i = 0; i < valid_size; ++i) {
284  tmp[i] = m_entries[i]->data.skewness;
285  }
286  return tmp;
287 }
288 
289 template<size_t arraysize>
290 const std::array<eic::VectorXYZ, arraysize> ClusterLayerCollection::position() const {
291  std::array<eic::VectorXYZ, arraysize> tmp;
292  const auto valid_size = std::min(arraysize, m_entries.size());
293  for (unsigned i = 0; i < valid_size; ++i) {
294  tmp[i] = m_entries[i]->data.position;
295  }
296  return tmp;
297 }
298 
299 
300 } // namespace eic
301 
302 
303 #endif
ClusterLayerObj.h
eic::operator<<
std::ostream & operator<<(std::ostream &o, const ConstBasicParticle &value)
Definition: BasicParticle.cc:102
eic::ClusterLayerConstCollectionIterator::operator=
ClusterLayerConstCollectionIterator & operator=(const ClusterLayerConstCollectionIterator &)=delete
eic::ClusterLayerCollection::isValid
bool isValid() const override final
Definition: ClusterLayerCollection.h:141
eic::ClusterLayerConstCollectionIterator::operator*
ConstClusterLayer operator*()
Definition: ClusterLayerCollection.cc:123
eic::ClusterLayerCollectionIterator::ClusterLayerCollectionIterator
ClusterLayerCollectionIterator(const ClusterLayerCollectionIterator &)=delete
eic::ClusterLayerDataContainer
std::vector< ClusterLayerData > ClusterLayerDataContainer
Definition: ClusterLayerCollection.h:26
eic::ClusterLayerConstCollectionIterator::operator!=
bool operator!=(const ClusterLayerConstCollectionIterator &x) const
Definition: ClusterLayerCollection.h:58
eic::ClusterLayerConstCollectionIterator::operator++
ClusterLayerConstCollectionIterator & operator++()
Definition: ClusterLayerCollection.cc:133
eic::ClusterLayerCollection::end
const_iterator end() const
Definition: ClusterLayerCollection.h:155
eic::ClusterLayerObj
Definition: ClusterLayerObj.h:18
eic::ClusterLayerCollection::ClusterLayerCollection
ClusterLayerCollection()
Definition: ClusterLayerCollection.cc:13
eic::ClusterLayerCollectionIterator::operator*
ClusterLayer operator*()
Definition: ClusterLayerCollection.cc:106
eic::ClusterLayerCollection::setID
void setID(unsigned ID) override final
Definition: ClusterLayerCollection.h:129
eic::ClusterLayerCollection::push_back
void push_back(ConstClusterLayer object)
Append object to the collection.
Definition: ClusterLayerCollection.cc:89
eic
Definition: BasicParticle.cc:13
eic::ClusterLayerCollection::operator[]
ConstClusterLayer operator[](unsigned int index) const
Returns the const object of given index.
Definition: ClusterLayerCollection.cc:23
eic::ClusterLayerCollectionIterator::ClusterLayerCollectionIterator
ClusterLayerCollectionIterator(size_t index, const ClusterLayerObjPointerContainer *collection)
Definition: ClusterLayerCollection.h:31
eic::ClusterLayerCollectionIterator::operator->
ClusterLayer * operator->()
Definition: ClusterLayerCollection.cc:111
eic::ClusterLayerCollection
Definition: ClusterLayerCollection.h:76
eic::ClusterLayerCollection::begin
const_iterator begin() const
Definition: ClusterLayerCollection.h:149
eic::ClusterLayerCollection::setReferences
bool setReferences(const podio::ICollectionProvider *collectionProvider) override final
Definition: ClusterLayerCollection.cc:84
eic::ClusterLayerCollection::getID
unsigned getID() const override final
Definition: ClusterLayerCollection.h:137
eic::ClusterLayerCollection::vectorMembers
podio::VectorMembersInfo * vectorMembers() override
Definition: ClusterLayerCollection.h:127
eic::ClusterLayerCollection::referenceCollections
podio::CollRefCollection * referenceCollections() override final
Definition: ClusterLayerCollection.h:125
eic::ClusterLayerCollection::setBuffer
void setBuffer(void *address) override final
Definition: ClusterLayerCollection.cc:101
eic::ClusterLayerObjPointerContainer
std::deque< ClusterLayerObj * > ClusterLayerObjPointerContainer
Definition: ClusterLayerCollection.h:27
eic::ClusterLayerCollectionIterator::operator=
ClusterLayerCollectionIterator & operator=(const ClusterLayerCollectionIterator &)=delete
eic::ClusterLayerCollection::getBufferAddress
void * getBufferAddress() override final
returns the address of the pointer to the data buffer
Definition: ClusterLayerCollection.h:160
eic::ClusterLayerCollection::getValueTypeName
std::string getValueTypeName() const override
fully qualified type name of elements - with namespace
Definition: ClusterLayerCollection.h:105
eic::ClusterLayerCollectionIterator::operator!=
bool operator!=(const ClusterLayerCollectionIterator &x) const
Definition: ClusterLayerCollection.h:36
eic::ClusterLayerCollection::prepareForWrite
void prepareForWrite() override final
Definition: ClusterLayerCollection.cc:56
eic::ClusterLayerCollection::at
ConstClusterLayer at(unsigned int index) const
Returns the const object of given index.
Definition: ClusterLayerCollection.cc:27
eic::ClusterLayerCollection::clear
void clear() override final
Definition: ClusterLayerCollection.cc:50
ClusterLayerData.h
eic::ClusterLayerConstCollectionIterator::operator->
ConstClusterLayer * operator->()
Definition: ClusterLayerCollection.cc:128
eic::ClusterLayerCollection::ClusterLayerCollection
ClusterLayerCollection(const ClusterLayerCollection &)=delete
eic::ClusterLayerCollection::_getBuffer
std::vector< ClusterLayerData > * _getBuffer()
Returns the pointer to the data buffer.
Definition: ClusterLayerCollection.h:163
eic::ClusterLayerCollection::operator=
ClusterLayerCollection & operator=(const ClusterLayerCollection &)=delete
eic::ClusterLayerCollection::begin
iterator begin()
Definition: ClusterLayerCollection.h:146
eic::ClusterLayerCollection::size
size_t size() const override final
number of elements in the collection
Definition: ClusterLayerCollection.cc:39
eic::ClusterLayerCollection::prepareAfterRead
void prepareAfterRead() override final
Definition: ClusterLayerCollection.cc:69
eic::ClusterLayerCollectionIterator
Definition: ClusterLayerCollection.h:29
eic::ClusterLayerConstCollectionIterator
Definition: ClusterLayerCollection.h:51
eic::ClusterLayerConstCollectionIterator::ClusterLayerConstCollectionIterator
ClusterLayerConstCollectionIterator(const ClusterLayerConstCollectionIterator &)=delete
ClusterLayer.h
eic::ClusterLayerCollectionIterator::operator++
ClusterLayerCollectionIterator & operator++()
Definition: ClusterLayerCollection.cc:116
eic::ClusterLayer
Definition: ClusterLayer.h:23
eic::ClusterLayerCollection::ID
const std::array< eic::Index, arraysize > ID() const
Definition: ClusterLayerCollection.h:210
eic::ClusterLayerCollection::~ClusterLayerCollection
~ClusterLayerCollection()
Definition: ClusterLayerCollection.cc:18
eic::ClusterLayerConstCollectionIterator::ClusterLayerConstCollectionIterator
ClusterLayerConstCollectionIterator(size_t index, const ClusterLayerObjPointerContainer *collection)
Definition: ClusterLayerCollection.h:53
eic::ClusterLayerCollection::end
iterator end()
Definition: ClusterLayerCollection.h:152
eic::ConstClusterLayer
Definition: ClusterLayerConst.h:21
eic::ClusterLayerCollection::create
ClusterLayer create()
Append a new object to the collection, and return this object.
Definition: ClusterLayerCollection.cc:43