ATLAS Offline Software
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 
53 const 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 
61 void CaloCompactCellContainer::resize (const unsigned int & totalSize)
62 {
63  m_compactData.resize(totalSize);
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 }
CaloCompactCellContainer.h
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
CaloCompactCellContainer::value_type
int value_type
value type for the internal data
Definition: CaloCompactCellContainer.h:40
CaloCompactCellContainer::getCompactCell
CaloCompactCell getCompactCell(const int &iCell, const int &nBytesPerCell) const
returns the compactified CaloCell data
Definition: CaloCompactCellContainer.cxx:22
CaloCompactCellContainer::setHeader
void setHeader(const std::vector< value_type > &theHeader)
replaces the current header (if there was one)
Definition: CaloCompactCellContainer.cxx:67
lumiFormat.i
int i
Definition: lumiFormat.py:85
CaloCompactCellContainer::getHeader
const std::vector< value_type > getHeader() const
returns header portion of the compact cell container
Definition: CaloCompactCellContainer.cxx:53
CaloCompactCell::value_type
unsigned short value_type
value type for the compact CaloCell data
Definition: CaloCompactCell.h:34
CaloCompactCellContainer::resize
void resize(const unsigned int &totalSize)
resize the data vector to totalSize (includes Header)
Definition: CaloCompactCellContainer.cxx:61
python.copyTCTOutput.totalSize
totalSize
Definition: copyTCTOutput.py:93
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
CaloCompactCell::getData
const std::vector< value_type > & getData() const
returns the vector of compactified CaloCell data.
Definition: CaloCompactCell.h:58
CaloCompactCellContainer::m_compactData
std::vector< value_type > m_compactData
vector containing header and compact cell data.
Definition: CaloCompactCellContainer.h:50