ATLAS Offline Software
Loading...
Searching...
No Matches
CaloCompactCellContainer.h
Go to the documentation of this file.
1
2
3/*
4 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
5*/
6
7#ifndef CALOEVENT_CALOCOMPACTCELLCONTAINER_H
8#define CALOEVENT_CALOCOMPACTCELLCONTAINER_H
9
25
28#include <vector>
29
31{
32
33 public:
34
40 typedef int value_type;
41
42 private:
43
50 std::vector<value_type> m_compactData;
51 public:
54 {
55 m_compactData.resize(0);
56 };
57
63 CaloCompactCellContainer(const std::vector<value_type> & theCompactData) :
64 m_compactData(theCompactData)
65 { };
66
68
77 void getCompactCellDataTime(const int & iCell, CaloCompactCell::value_type & dataTime) const;
78
79
90 CaloCompactCell getCompactCell(const int & iCell,
91 const int & nBytesPerCell) const;
92
97 inline const std::vector<value_type> & getData() const {
98 return m_compactData;
99 };
100
105 inline std::vector<value_type> & getData() {
106 return m_compactData;
107 };
108
113 const std::vector<value_type> getHeader() const;
114
119 void resize (const unsigned int & totalSize);
120
127 void setHeader(const std::vector<value_type> & theHeader);
128
135 void setCompactCell(const CaloCompactCell & theCompactCell,
136 const int & iCell, const int &headerLength);
145 void setCompactCellDataTime(CaloCompactCell::value_type &theCompactCell, const int & iCell,const int & headerLength);
146
147
156 {
157 public:
163 compact_input_iterator (std::vector<value_type>::const_iterator it);
164
165
170
171
175 std::vector<value_type>::const_iterator base() const;
176
177
178 private:
180 std::vector<value_type>::const_iterator m_it;
181
185
188 };
189
190
196
202
211 {
212 public:
219
220
226 compact_output_iterator (std::vector<value_type>::iterator it);
227
228
234
235
240
241
245 int used () const;
246
247
248 private:
250 std::vector<value_type>::iterator m_it;
251
254 };
255
256
263};
264
266 static const int nRatio = sizeof(value_type)/sizeof(CaloCompactCell::value_type);
267 int iPos = m_compactData[0] + (int)(iCell/nRatio);
268 int iMod = (iCell%nRatio)<<(8/nRatio);
270 }
271
272inline void CaloCompactCellContainer::setCompactCellDataTime(CaloCompactCell::value_type &theCompactCell, const int & iCell,const int & headerLength) {
273
274 static const int nRatio = sizeof(value_type)/sizeof(CaloCompactCell::value_type);
275
276 // the compace data for one cell
277 //CaloCompactCell::value_type cData(theCompactCell);
278 int iPos = headerLength + (int)(iCell/nRatio);
279 int iMod = (iCell%nRatio)<<(8/nRatio);
280 if ( iMod == 0 ) m_compactData[iPos] = 0;
281 m_compactData[iPos] = m_compactData[iPos] | (theCompactCell<<iMod);
282
283}
284
285
286inline
288 (std::vector<value_type>::const_iterator it)
289 : m_it (it),
290 m_word(0),
291 m_count (0)
292{
293}
294
295
296inline
299{
300 // Constants.
301 const int mask = static_cast<CaloCompactCell::value_type>(-1);
302 const int shift = 8*sizeof (CaloCompactCell::value_type);
303 const int ratio =
304 sizeof(value_type) / sizeof(CaloCompactCell::value_type);
305
306 // Fetch the next @c value_type, if needed.
307 if (m_count % ratio == 0)
308 m_word = *m_it;
309
310 // Mask off the current value.
312
313 // Bump the count.
314 if (((++m_count)%ratio) == 0) {
315 // We wrapped to a new @c value_type. Bump the underlying iterator.
316 ++m_it;
317 }
318 else {
319 // Same @c value_type --- shift the word over.
320 m_word >>= shift;
321 }
322
323 return ret;
324}
325
326
327inline
328std::vector<CaloCompactCellContainer::value_type>::const_iterator
333
334
335inline
341
342inline
347
348inline
352
353
354inline
356 (std::vector<value_type>::iterator it)
357 : m_it (it),
358 m_count (0)
359{
360}
361
362inline
365{
366 // Constants.
367 const int mask = static_cast<CaloCompactCell::value_type>(-1);
368 const int ratio =
369 sizeof(value_type) / sizeof(CaloCompactCell::value_type);
370 const int shift = 8*sizeof (CaloCompactCell::value_type) * (m_count%ratio);
371
372 // Mask the value into the current word.
373 *m_it = (*m_it & ~(mask<<shift)) | (x << shift);
374
375 // Advance the iterator.
376 if (((++m_count)%ratio) == 0)
377 ++m_it;
378}
379
380
381inline
384{
385 const int ratio =
386 sizeof(value_type) / sizeof(CaloCompactCell::value_type);
387 if (((++m_count)%ratio) == 0)
388 ++m_it;
389 return *this;
390}
391
392
393inline
395{
396 const int ratio =
397 sizeof(value_type) / sizeof(CaloCompactCell::value_type);
398 return (m_count + ratio - 1) / ratio;
399}
400
401
402inline
405{
406 return compact_output_iterator (m_compactData.begin() + headerLength);
407}
408
409
411
412#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
Simple iterator-like object for reading from the container.
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 setCompactCell(const CaloCompactCell &theCompactCell, const int &iCell, const int &headerLength)
store the compact cell with index iCell
void resize(const unsigned int &totalSize)
resize the data vector to totalSize (includes Header)
CaloCompactCell getCompactCell(const int &iCell, const int &nBytesPerCell) const
returns the compactified CaloCell data
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 setCompactCellDataTime(CaloCompactCell::value_type &theCompactCell, const int &iCell, const int &headerLength)
to speed things up ivukotic@cern.ch added this inline function to be used instead of the one above.
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)
void getCompactCellDataTime(const int &iCell, CaloCompactCell::value_type &dataTime) const
to speed things up ivukotic@cern.ch added this inline function to be used instead of the two bellow.
holds compactified CaloCell information
unsigned short value_type
value type for the compact CaloCell data