ATLAS Offline Software
Loading...
Searching...
No Matches
CaloCompactCellContainer.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
5//-----------------------------------------------------------------------
6// File and Version Information:
7// $Id: CaloCompactCellContainer.cxx,v 1.2 2004-08-05 22:15:01 menke Exp $
8//
9// Description: see CaloCompactCellContainer.h
10//
11// Environment:
12// Software developed for the ATLAS Detector at the CERN LHC
13//
14// Author List:
15// Sven Menke
16//
17//-----------------------------------------------------------------------
18
20
22( const int & iCell,
23 const int & nBytesPerCell) const
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}
52
53const std::vector<CaloCompactCellContainer::value_type> CaloCompactCellContainer::getHeader() const
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}
60
62{
64}
65
67(const std::vector<CaloCompactCellContainer::value_type> & theHeader)
68{
69 for(unsigned int i=0;i<theHeader.size();i++)
70 m_compactData[i] = theHeader[i];
71}
72
74(const CaloCompactCell &theCompactCell,
75 const int & iCell,
76 const int & headerLength) {
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}
static unsigned int totalSize(const MultiDimArray< T, N > &ht)
std::vector< value_type > m_compactData
vector containing header and compact cell 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
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)
const std::vector< value_type > getHeader() const
returns header portion of the compact cell container
holds compactified CaloCell information
unsigned short value_type
value type for the compact CaloCell data
const std::vector< value_type > & getData() const
returns the vector of compactified CaloCell data.