ATLAS Offline Software
Loading...
Searching...
No Matches
CaloCompactCellContainer.h
Go to the documentation of this file.
1
2
3/*
4 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
5*/
6
7#ifndef CALOEVENT_CALOCOMPACTCELLCONTAINER_H
8#define CALOEVENT_CALOCOMPACTCELLCONTAINER_H
9
25
27#include <vector>
28
29namespace CaloCompactCell {
30
31 typedef unsigned short value_type;
32
33}
34
35
37{
38
39 public:
40
46 typedef int value_type;
47
48 private:
49
56 std::vector<value_type> m_compactData;
57 public:
60 {
61 m_compactData.resize(0);
62 };
63
69 CaloCompactCellContainer(const std::vector<value_type> & theCompactData) :
70 m_compactData(theCompactData)
71 { };
72
74
75
80 inline const std::vector<value_type> & getData() const {
81 return m_compactData;
82 };
83
88 inline std::vector<value_type> & getData() {
89 return m_compactData;
90 };
91
96 const std::vector<value_type> getHeader() const;
97
102 void resize (const unsigned int & totalSize);
103
110 void setHeader(const std::vector<value_type> & theHeader);
111
118
119
128 {
129 public:
135 compact_input_iterator (std::vector<value_type>::const_iterator it);
136
137
142
143
147 std::vector<value_type>::const_iterator base() const;
148
149
150 private:
152 std::vector<value_type>::const_iterator m_it;
153
157
160 };
161
162
168
174
183 {
184 public:
191
192
198 compact_output_iterator (std::vector<value_type>::iterator it);
199
200
206
207
212
213
217 int used () const;
218
219
220 private:
222 std::vector<value_type>::iterator m_it;
223
226 };
227
228
235};
236
237
238inline
240 (std::vector<value_type>::const_iterator it)
241 : m_it (it),
242 m_word(0),
243 m_count (0)
244{
245}
246
247
248inline
251{
252 // Constants.
253 const int mask = static_cast<CaloCompactCell::value_type>(-1);
254 const int shift = 8*sizeof (CaloCompactCell::value_type);
255 const int ratio =
256 sizeof(value_type) / sizeof(CaloCompactCell::value_type);
257
258 // Fetch the next @c value_type, if needed.
259 if (m_count % ratio == 0)
260 m_word = *m_it;
261
262 // Mask off the current value.
264
265 // Bump the count.
266 if (((++m_count)%ratio) == 0) {
267 // We wrapped to a new @c value_type. Bump the underlying iterator.
268 ++m_it;
269 }
270 else {
271 // Same @c value_type --- shift the word over.
272 m_word >>= shift;
273 }
274
275 return ret;
276}
277
278
279inline
280std::vector<CaloCompactCellContainer::value_type>::const_iterator
285
286
287inline
293
294inline
299
300inline
304
305
306inline
308 (std::vector<value_type>::iterator it)
309 : m_it (it),
310 m_count (0)
311{
312}
313
314inline
317{
318 // Constants.
319 const int mask = static_cast<CaloCompactCell::value_type>(-1);
320 const int ratio =
321 sizeof(value_type) / sizeof(CaloCompactCell::value_type);
322 const int shift = 8*sizeof (CaloCompactCell::value_type) * (m_count%ratio);
323
324 // Mask the value into the current word.
325 *m_it = (*m_it & ~(mask<<shift)) | (x << shift);
326
327 // Advance the iterator.
328 if (((++m_count)%ratio) == 0)
329 ++m_it;
330}
331
332
333inline
336{
337 const int ratio =
338 sizeof(value_type) / sizeof(CaloCompactCell::value_type);
339 if (((++m_count)%ratio) == 0)
340 ++m_it;
341 return *this;
342}
343
344
345inline
347{
348 const int ratio =
349 sizeof(value_type) / sizeof(CaloCompactCell::value_type);
350 return (m_count + ratio - 1) / ratio;
351}
352
353
354inline
357{
358 return compact_output_iterator (m_compactData.begin() + headerLength);
359}
360
361
363
364#endif
macros to associate a CLID to a type
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
static unsigned int totalSize(const MultiDimArray< T, N > &ht)
#define x
std::vector< value_type >::const_iterator m_it
The iterator in the underlying container type.
int m_count
Count; used to tell how many more times we need to shift m_word.
std::vector< value_type >::const_iterator base() const
Return the underlying container iterator.
compact_input_iterator(std::vector< value_type >::const_iterator it)
Constructor.
CaloCompactCell::value_type next()
Return the current value and advance to the next one.
Simple iterator-like object for writing to the container.
int used() const
Return the number of underlying value_type words used.
compact_output_iterator & operator++()
Advance the iterator.
std::vector< value_type >::iterator m_it
The iterator in the underlying container type.
void set(CaloCompactCell::value_type x)
Set the next value, and advance the iterator.
int m_count
Count; used to tell how many more times we need to shift m_word.
container class for CaloCompactCell objects
std::vector< value_type > m_compactData
vector containing header and compact cell data.
compact_input_iterator compact_begin_input() const
Return a new compact_input_iterator pointing at the start of the data.
void resize(const unsigned int &totalSize)
resize the data vector to totalSize (includes Header)
CaloCompactCellContainer()
default Constructor.
compact_output_iterator compact_begin_output(int headerLength)
Return a new compact_output_iterator pointing at the start of the data.
compact_input_iterator compact_begin_input_from(int) const
Return a new compact_input_iterator pointing at position given as the parameter BUT from the end of t...
int value_type
value type for the internal data
void setHeader(const std::vector< value_type > &theHeader)
replaces the current header (if there was one)
CaloCompactCellContainer(const std::vector< value_type > &theCompactData)
Constructor.
std::vector< value_type > & getData()
returns the entire compact cell container (includes header)
const std::vector< value_type > getHeader() const
returns header portion of the compact cell container
const std::vector< value_type > & getData() const
returns the entire compact cell container (includes header)