ATLAS Offline Software
Loading...
Searching...
No Matches
CaloCompactCellContainer Class Reference

container class for CaloCompactCell objects More...

#include <CaloCompactCellContainer.h>

Collaboration diagram for CaloCompactCellContainer:

Classes

class  compact_input_iterator
 Simple iterator-like object for reading from the container. More...
class  compact_output_iterator
 Simple iterator-like object for writing to the container. More...

Public Types

typedef int value_type
 value type for the internal data

Public Member Functions

 CaloCompactCellContainer ()
 default Constructor.
 CaloCompactCellContainer (const std::vector< value_type > &theCompactData)
 Constructor.
virtual ~CaloCompactCellContainer ()
void getCompactCellDataTime (const int &iCell, CaloCompactCell::value_type &dataTime) const
 to speed things up ivuko.nosp@m.tic@.nosp@m.cern..nosp@m.ch added this inline function to be used instead of the two bellow.
CaloCompactCell getCompactCell (const int &iCell, const int &nBytesPerCell) const
 returns the compactified CaloCell data
const std::vector< value_type > & getData () const
 returns the entire compact cell container (includes header)
std::vector< value_type > & getData ()
 returns the entire compact cell container (includes header)
const std::vector< value_typegetHeader () const
 returns header portion of the compact cell container
void resize (const unsigned int &totalSize)
 resize the data vector to totalSize (includes Header)
void setHeader (const std::vector< value_type > &theHeader)
 replaces the current header (if there was one)
void setCompactCell (const CaloCompactCell &theCompactCell, const int &iCell, const int &headerLength)
 store the compact cell with index iCell
void setCompactCellDataTime (CaloCompactCell::value_type &theCompactCell, const int &iCell, const int &headerLength)
 to speed things up ivuko.nosp@m.tic@.nosp@m.cern..nosp@m.ch added this inline function to be used instead of the one above.
compact_input_iterator compact_begin_input () const
 Return a new compact_input_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 the data.
compact_output_iterator compact_begin_output (int headerLength)
 Return a new compact_output_iterator pointing at the start of the data.

Private Attributes

std::vector< value_typem_compactData
 vector containing header and compact cell data.

Detailed Description

container class for CaloCompactCell objects

Version
$Id: CaloCompactCellContainer.h,v 1.7 2008-11-20 21:35:56 ssnyder Exp $
Author
Sven Menke menke.nosp@m.@mpp.nosp@m.mu.mp.nosp@m.g.de
Date
03-August-2004

Container class to contain compactified CaloCell objects from a complete CaloCellContainer. The completeness is required in the sense that for every Calorimeter present in the CaloCellContainer all possible cells have to be filled. This allows for not storing the Identifier for the cells. The compact cells (and instances of this class) are produced by the CaloCompactCellTool in CaloTools.

Definition at line 30 of file CaloCompactCellContainer.h.

Member Typedef Documentation

◆ value_type

value type for the internal data

The internal data format has a length of 32bit. Therefore this type must have the length of 32 bits.

Definition at line 40 of file CaloCompactCellContainer.h.

Constructor & Destructor Documentation

◆ CaloCompactCellContainer() [1/2]

CaloCompactCellContainer::CaloCompactCellContainer ( )
inline

default Constructor.

Definition at line 53 of file CaloCompactCellContainer.h.

54 {
55 m_compactData.resize(0);
56 };
std::vector< value_type > m_compactData
vector containing header and compact cell data.

◆ CaloCompactCellContainer() [2/2]

CaloCompactCellContainer::CaloCompactCellContainer ( const std::vector< value_type > & theCompactData)
inline

Constructor.

Parameters
theCompactDataThe vector holding the header and CaloCompactCell data

Definition at line 63 of file CaloCompactCellContainer.h.

63 :
64 m_compactData(theCompactData)
65 { };

◆ ~CaloCompactCellContainer()

virtual CaloCompactCellContainer::~CaloCompactCellContainer ( )
inlinevirtual

Definition at line 67 of file CaloCompactCellContainer.h.

67{ };

Member Function Documentation

◆ compact_begin_input()

CaloCompactCellContainer::compact_input_iterator CaloCompactCellContainer::compact_begin_input ( ) const
inline

Return a new compact_input_iterator pointing at the start of the data.

Definition at line 337 of file CaloCompactCellContainer.h.

338{
340}
Simple iterator-like object for reading from the container.

◆ compact_begin_input_from()

CaloCompactCellContainer::compact_input_iterator CaloCompactCellContainer::compact_begin_input_from ( int pos) const
inline

Return a new compact_input_iterator pointing at position given as the parameter BUT from the end of the data.

Definition at line 344 of file CaloCompactCellContainer.h.

344 {
345 return compact_input_iterator (m_compactData.end() - pos);
346}

◆ compact_begin_output()

CaloCompactCellContainer::compact_output_iterator CaloCompactCellContainer::compact_begin_output ( int headerLength)
inline

Return a new compact_output_iterator pointing at the start of the data.

Parameters
headerLengthThe length of the header in front of the data.

Definition at line 404 of file CaloCompactCellContainer.h.

405{
406 return compact_output_iterator (m_compactData.begin() + headerLength);
407}
Simple iterator-like object for writing to the container.

◆ getCompactCell()

CaloCompactCell CaloCompactCellContainer::getCompactCell ( const int & iCell,
const int & nBytesPerCell ) const

returns the compactified CaloCell data

Parameters
iCellthe index of the cell in the CaloCompactCellContainer
nBytesPerCellthe size of each CaloCompactCell in bytes
Returns
a CaloCompactCell

returns the compactified CaloCell information in form of a CaloCompactCell which is needed to restore the original CaloCell object.

Definition at line 21 of file CaloCompactCellContainer.cxx.

24{
25 // the size of value_type must be an integral multiple
26 // of the size of CaloCompactCell::value_type
27 const int nRatio = sizeof(value_type)/sizeof(CaloCompactCell::value_type);
28
29 // the number of words (in terms of the CaloCompactCell::value_type)
30 // needed to store one compact cell
31 const int nWords = nBytesPerCell/sizeof(CaloCompactCell::value_type);
32
33 // the compace data for one cell
34 std::vector<CaloCompactCell::value_type> cData(nWords);
35
36 for (int iWord=0;iWord<nWords;iWord++) {
37 // the vector element to use for this cell
38 int iPos = m_compactData[0] + (int)((iCell*nWords+iWord)/nRatio);
39
40 // the relative position inside the vector element to use for this cell
41 int iMod = ((iCell*nWords+iWord)%nRatio)<<(8/nRatio);
42
43 // shift the current vector element down and project out 16 bits
44 cData[iWord] = (CaloCompactCell::value_type) (((m_compactData[iPos])>>iMod)
46
47 }
48
49 CaloCompactCell cCell(cData);
50 return cCell;
51}
int value_type
value type for the internal data
unsigned short value_type
value type for the compact CaloCell data

◆ getCompactCellDataTime()

void CaloCompactCellContainer::getCompactCellDataTime ( const int & iCell,
CaloCompactCell::value_type & dataTime ) const
inline

to speed things up ivuko.nosp@m.tic@.nosp@m.cern..nosp@m.ch added this inline function to be used instead of the two bellow.

It uses no vectors since it takes time to make them. nwords and a loop over them is removed since nwords is always=1 as nBytesPerCell is = sizeof(CaloCompactCell::value_type) Its inlined and calculation is simplifed

Definition at line 265 of file CaloCompactCellContainer.h.

265 {
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 }

◆ getData() [1/2]

std::vector< value_type > & CaloCompactCellContainer::getData ( )
inline

returns the entire compact cell container (includes header)

Returns
a reference to the vector holding the compact data

Definition at line 105 of file CaloCompactCellContainer.h.

105 {
106 return m_compactData;
107 };

◆ getData() [2/2]

const std::vector< value_type > & CaloCompactCellContainer::getData ( ) const
inline

returns the entire compact cell container (includes header)

Returns
a const reference to the vector holding the compact data

Definition at line 97 of file CaloCompactCellContainer.h.

97 {
98 return m_compactData;
99 };

◆ getHeader()

const std::vector< CaloCompactCellContainer::value_type > CaloCompactCellContainer::getHeader ( ) const

returns header portion of the compact cell container

Returns
a const vector holding the header data

Definition at line 53 of file CaloCompactCellContainer.cxx.

54{
55 std::vector<value_type> theHeader(m_compactData[0]);
56 for(int i=0;i<m_compactData[0];i++)
57 theHeader[i] = m_compactData[i];
58 return theHeader;
59}

◆ resize()

void CaloCompactCellContainer::resize ( const unsigned int & totalSize)

resize the data vector to totalSize (includes Header)

Parameters
totalSizethe total size in unites of value_type

Definition at line 61 of file CaloCompactCellContainer.cxx.

62{
64}
static unsigned int totalSize(const MultiDimArray< T, N > &ht)

◆ setCompactCell()

void CaloCompactCellContainer::setCompactCell ( const CaloCompactCell & theCompactCell,
const int & iCell,
const int & headerLength )

store the compact cell with index iCell

Parameters
theCompactCellthe compact CaloCell data
iCellthe index in the CaloCompactCellContainer
headerLengththe space reserved for the header information

Definition at line 73 of file CaloCompactCellContainer.cxx.

76 {
77
78 // the size of value_type must be an integral multiple
79 // of the size of CaloCompactCell::value_type
80 const int nRatio = sizeof(value_type)/sizeof(CaloCompactCell::value_type);
81
82 // the compace data for one cell
83 std::vector<CaloCompactCell::value_type> cData(theCompactCell.getData());
84
85 // the number of words (in terms of the CaloCompactCell::value_type)
86 // needed to store one compact cell
87 const int nWords = cData.size();
88
89 for (int iWord=0;iWord<nWords;iWord++) {
90 // the vector element to use for this cell
91 int iPos = headerLength + (int)((iCell*nWords+iWord)/nRatio);
92
93 // the relative position inside the vector element to use for this cell
94 int iMod = ((iCell*nWords+iWord)%nRatio)<<(8/nRatio);
95
96 if ( iMod == 0 )
97 m_compactData[iPos] = 0;
98 // shift the 16 bits to the correct position and put them into the
99 // current vector element
100 m_compactData[iPos] = m_compactData[iPos] | (cData[iWord]<<iMod);
101 }
102}
const std::vector< value_type > & getData() const
returns the vector of compactified CaloCell data.

◆ setCompactCellDataTime()

void CaloCompactCellContainer::setCompactCellDataTime ( CaloCompactCell::value_type & theCompactCell,
const int & iCell,
const int & headerLength )
inline

to speed things up ivuko.nosp@m.tic@.nosp@m.cern..nosp@m.ch added this inline function to be used instead of the one above.

It uses no vectors since it takes time to make them. nwords and a loop over them is removed since nwords is always=1 as nBytesPerCell is = sizeof(CaloCompactCell::value_type) Its inlined and calculation is simplifed

Definition at line 272 of file CaloCompactCellContainer.h.

272 {
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}

◆ setHeader()

void CaloCompactCellContainer::setHeader ( const std::vector< value_type > & theHeader)

replaces the current header (if there was one)

Parameters
theHeaderthe new header

used by the compactifier tool on creation of the container

Definition at line 66 of file CaloCompactCellContainer.cxx.

68{
69 for(unsigned int i=0;i<theHeader.size();i++)
70 m_compactData[i] = theHeader[i];
71}

Member Data Documentation

◆ m_compactData

std::vector<value_type> CaloCompactCellContainer::m_compactData
private

vector containing header and compact cell data.

the first int in the vector must contain the header length (in number of 32bit ints) including the first int

Definition at line 50 of file CaloCompactCellContainer.h.


The documentation for this class was generated from the following files: