ATLAS Offline Software
CaloCompactCellContainer.h
Go to the documentation of this file.
1 
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 
26 #include "AthenaKernel/CLASS_DEF.h"
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 
187  int m_count;
188  };
189 
190 
196 
202 
211  {
212  public:
219 
220 
227 
228 
234 
235 
240 
241 
245  int used () const;
246 
247 
248  private:
251 
253  int m_count;
254  };
255 
256 
263 };
264 
265 inline void CaloCompactCellContainer::getCompactCellDataTime(const int & iCell, CaloCompactCell::value_type & dataTime) const{
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 
272 inline 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 
286 inline
288  (std::vector<value_type>::const_iterator it)
289  : m_it (it),
290  m_word(0),
291  m_count (0)
292 {
293 }
294 
295 
296 inline
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 
327 inline
328 std::vector<CaloCompactCellContainer::value_type>::const_iterator
330 {
331  return m_it;
332 }
333 
334 
335 inline
338 {
339  return compact_input_iterator (m_compactData.begin() + m_compactData[0]);
340 }
341 
342 inline
345  return compact_input_iterator (m_compactData.end() - pos);
346 }
347 
348 inline
350 {
351 }
352 
353 
354 inline
357  : m_it (it),
358  m_count (0)
359 {
360 }
361 
362 inline
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 
381 inline
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 
393 inline
395 {
396  const int ratio =
397  sizeof(value_type) / sizeof(CaloCompactCell::value_type);
398  return (m_count + ratio - 1) / ratio;
399 }
400 
401 
402 inline
405 {
406  return compact_output_iterator (m_compactData.begin() + headerLength);
407 }
408 
409 
410 CLASS_DEF(CaloCompactCellContainer, 1106685019, 1)
411 
412 #endif
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
CaloCompactCellContainer::compact_output_iterator::m_it
std::vector< value_type >::iterator m_it
The iterator in the underlying container type.
Definition: CaloCompactCellContainer.h:250
CaloCompactCellContainer::setCompactCellDataTime
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.
Definition: CaloCompactCellContainer.h:272
CaloCompactCellContainer::compact_output_iterator::compact_output_iterator
compact_output_iterator()
Default constructor.
Definition: CaloCompactCellContainer.h:349
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
CaloCompactCellContainer::CaloCompactCellContainer
CaloCompactCellContainer()
default Constructor.
Definition: CaloCompactCellContainer.h:53
CaloCompactCellContainer::compact_output_iterator::used
int used() const
Return the number of underlying value_type words used.
Definition: CaloCompactCellContainer.h:394
CaloCompactCellContainer::value_type
int value_type
value type for the internal data
Definition: CaloCompactCellContainer.h:40
CaloCompactCellContainer::compact_begin_input
compact_input_iterator compact_begin_input() const
Return a new compact_input_iterator pointing at the start of the data.
Definition: CaloCompactCellContainer.h:337
skel.it
it
Definition: skel.GENtoEVGEN.py:423
CaloCompactCellContainer::getData
std::vector< value_type > & getData()
returns the entire compact cell container (includes header)
Definition: CaloCompactCellContainer.h:105
CaloCompactCell.h
CaloCompactCellContainer::getCompactCell
CaloCompactCell getCompactCell(const int &iCell, const int &nBytesPerCell) const
returns the compactified CaloCell data
Definition: CaloCompactCellContainer.cxx:22
x
#define x
python.utils.AtlRunQueryLookup.mask
string mask
Definition: AtlRunQueryLookup.py:460
CaloCompactCellContainer::compact_output_iterator::m_count
int m_count
Count; used to tell how many more times we need to shift m_word.
Definition: CaloCompactCellContainer.h:253
CaloCompactCellContainer::setHeader
void setHeader(const std::vector< value_type > &theHeader)
replaces the current header (if there was one)
Definition: CaloCompactCellContainer.cxx:67
CaloCompactCellContainer::~CaloCompactCellContainer
virtual ~CaloCompactCellContainer()
Definition: CaloCompactCellContainer.h:67
CaloCompactCellContainer::getData
const std::vector< value_type > & getData() const
returns the entire compact cell container (includes header)
Definition: CaloCompactCellContainer.h:97
CaloCompactCellContainer::compact_input_iterator::base
std::vector< value_type >::const_iterator base() const
Return the underlying container iterator.
Definition: CaloCompactCellContainer.h:329
CaloCompactCellContainer::getCompactCellDataTime
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.
Definition: CaloCompactCellContainer.h:265
CaloCompactCellContainer
container class for CaloCompactCell objects
Definition: CaloCompactCellContainer.h:31
ret
T ret(T t)
Definition: rootspy.cxx:260
CaloCompactCellContainer::compact_begin_output
compact_output_iterator compact_begin_output(int headerLength)
Return a new compact_output_iterator pointing at the start of the data.
Definition: CaloCompactCellContainer.h:404
CaloCompactCellContainer::compact_input_iterator::compact_input_iterator
compact_input_iterator(std::vector< value_type >::const_iterator it)
Constructor.
Definition: CaloCompactCellContainer.h:288
CaloCompactCellContainer::compact_input_iterator::m_it
std::vector< value_type >::const_iterator m_it
The iterator in the underlying container type.
Definition: CaloCompactCellContainer.h:180
CaloCompactCellContainer::getHeader
const std::vector< value_type > getHeader() const
returns header portion of the compact cell container
Definition: CaloCompactCellContainer.cxx:53
CaloCompactCellContainer::compact_input_iterator::next
CaloCompactCell::value_type next()
Return the current value and advance to the next one.
Definition: CaloCompactCellContainer.h:298
CaloCompactCellContainer::compact_input_iterator::m_word
value_type m_word
The current word.
Definition: CaloCompactCellContainer.h:184
CaloCompactCell::value_type
unsigned short value_type
value type for the compact CaloCell data
Definition: CaloCompactCell.h:34
CaloCompactCellContainer::compact_input_iterator
Simple iterator-like object for reading from the container.
Definition: CaloCompactCellContainer.h:156
CaloCompactCellContainer::compact_output_iterator::set
void set(CaloCompactCell::value_type x)
Set the next value, and advance the iterator.
Definition: CaloCompactCellContainer.h:364
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
CaloCompactCellContainer::resize
void resize(const unsigned int &totalSize)
resize the data vector to totalSize (includes Header)
Definition: CaloCompactCellContainer.cxx:61
CaloCompactCellContainer::compact_input_iterator::m_count
int m_count
Count; used to tell how many more times we need to shift m_word.
Definition: CaloCompactCellContainer.h:187
python.compareTCTs.ratio
ratio
Definition: compareTCTs.py:295
CLASS_DEF
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
Definition: Control/AthenaKernel/AthenaKernel/CLASS_DEF.h:64
CaloCompactCellContainer::CaloCompactCellContainer
CaloCompactCellContainer(const std::vector< value_type > &theCompactData)
Constructor.
Definition: CaloCompactCellContainer.h:63
python.copyTCTOutput.totalSize
totalSize
Definition: copyTCTOutput.py:93
CaloCompactCellContainer::compact_begin_input_from
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...
Definition: CaloCompactCellContainer.h:344
CaloCompactCell
holds compactified CaloCell information
Definition: CaloCompactCell.h:25
CaloCompactCell::WORDMASK
@ WORDMASK
Definition: CaloCompactCell.h:37
CaloCompactCellContainer::setCompactCell
void setCompactCell(const CaloCompactCell &theCompactCell, const int &iCell, const int &headerLength)
store the compact cell with index iCell
Definition: CaloCompactCellContainer.cxx:74
CaloCompactCellContainer::compact_output_iterator::operator++
compact_output_iterator & operator++()
Advance the iterator.
Definition: CaloCompactCellContainer.h:383
CLASS_DEF.h
macros to associate a CLID to a type
CaloCompactCellContainer::m_compactData
std::vector< value_type > m_compactData
vector containing header and compact cell data.
Definition: CaloCompactCellContainer.h:50
CaloCompactCellContainer::compact_output_iterator
Simple iterator-like object for writing to the container.
Definition: CaloCompactCellContainer.h:211