ATLAS Offline Software
JetCMXData.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 namespace LVL1 {
8 
9 // Default constructor
10 JetCMXData::JetCMXData() : m_crate(0), m_module(0)
11 {
12  m_DataWords.clear();
13  m_DataWords.resize(4);
14 }
15 
16 // Construct from pre-calculated data
18  const std::vector<unsigned int>& tobWords) :
19  m_crate(crate),
20  m_module(module),
21  m_DataWords(tobWords)
22 {
23 }
24 
25 // Construct from a vector of CPMTobRoIs
27  const DataVector<JEMTobRoI>* tobs) :
28  m_crate(crate),
29  m_module(module)
30 {
31 
32  m_DataWords.clear();
33  m_DataWords.resize(4);
34 
38  std::vector<unsigned int> allTOBs(8,0);
39 
41  for ( ; itRoI != tobs->end(); ++itRoI) {
42  if ( (*itRoI)->crate() != crate || (*itRoI)->jem() != module ) continue;
43 
44  int frame = (*itRoI)->frame();
45  int lc = (*itRoI)->location();
46  int etL = (*itRoI)->energyLarge();
47  int etS = (*itRoI)->energySmall();
48 
49  // Set flag in presence map
50  m_DataWords[0] |= ( 1 << frame );
51 
52  // Store TOB data to fill backplane words later
53  unsigned int tobdata = etL + (etS<<10) + (lc<<19);
54  allTOBs[frame] = tobdata;
55  }
56 
58  int nTOB = 0;
59  for (int i = 0; i < 8; ++i) {
60  if (allTOBs[i] == 0 ) continue;
61 
62  unsigned int etL = allTOBs[i] & 0x3ff;
63  unsigned int etS = (allTOBs[i] >> 10) & 0x1ff;
64  unsigned int lc = (allTOBs[i] >> 19) & 3;
65 
66  switch (nTOB) {
67  case 0:
68  m_DataWords[0] += ( etL << 13 );
69  m_DataWords[0] += ( (etS & 7) << 8);
70  m_DataWords[1] += ( etS >> 3 );
71  m_DataWords[0] += ( lc << 11 );
72  break;
73  case 1:
74  m_DataWords[1] += ( etL << 13 );
75  m_DataWords[1] += ( (etS & 0x1f) << 6);
76  m_DataWords[2] += ( etS >> 5 );
77  m_DataWords[1] += ( lc << 11 );
78  break;
79  case 2:
80  m_DataWords[2] += ( etL << 13 );
81  m_DataWords[2] += ( (etS & 0x7f) << 4);
82  m_DataWords[3] += ( etS >> 7 );
83  m_DataWords[2] += ( lc << 11 );
84  break;
85  case 3:
86  m_DataWords[3] += ( etL << 13 );
87  m_DataWords[3] += ( etS << 2);
88  m_DataWords[3] += ( lc << 11 );
89  break;
90  }
91  nTOB++;
92 
93  } // Loop over TOB locations
94 
95  // Finally set parity bits. Will assume we used odd parity here (flip initial assignment to change)
96  for (unsigned int word = 0; word < 4; ++word) {
97  unsigned int parity = 1;
98  for (unsigned int bit = 0; bit < 24; ++bit) if ( ( (m_DataWords[word]>>bit) & 1) > 0 ) parity++;
99  parity &= 1;
100  m_DataWords[word] |= (parity<<23);
101  }
102 
103 }
104 
105 
107 {
108 }
109 
110 
115  return m_crate;
116 }
117 
120  return m_module;
121 }
122 
123 
125 unsigned int LVL1::JetCMXData::presenceMap() const {
126  unsigned int value = (m_DataWords[0] & 0xff);
127  return value;
128 }
129 
132 
133  bool overflow = false;
134 
136  if ( (m_DataWords[0] & 0xff) == 0 ) return overflow;
137 
139  int ntob = 0;
140  for (unsigned int i = 0; i < 8; ++i) {
141 
142  if ( (m_DataWords[0] & (1<<i)) > 0 ) ntob++;
143 
144  } // step through presence map
145 
146  // Set overflow flags if needed
147  if (ntob > 4) overflow = true;
148 
149  return overflow;
150 }
151 
153 std::vector<unsigned int> LVL1::JetCMXData::DataWords() const {
154  return m_DataWords;
155 }
156 
158 std::vector<unsigned int> LVL1::JetCMXData::TOBPresenceBits() const {
159 
160  std::vector<unsigned int> bits;
161 
162  int ntob = 0;
163  for (unsigned int i = 0; i < 8; ++i) {
164 
165  if ( (m_DataWords[0] & (1<<i)) > 0 ) {
166 
167  if (ntob < 4) bits.push_back(i);
168  ntob++;
169 
170  } // bit set in presence map
171 
172  } // step through presence map
173 
174  return bits;
175 }
176 
177 
179 std::vector<unsigned int> LVL1::JetCMXData::TOBWords() const {
180 
181  std::vector<unsigned int> data;
182 
184  if ( (m_DataWords[0] & 0xff) == 0 ) return data;
185 
187  unsigned int ntob = 0;
188  for (unsigned int i = 0; i < 8; ++i) {
189 
190  if ( (m_DataWords[0] & (1<<i)) > 0 ) {
191 
192  if (ntob < 4) {
193 
194  unsigned int word = 0;
195  unsigned int coord = 0;
196  unsigned int etSmall = 0;
197  unsigned int etLarge = 0;
198 
199  switch (ntob) {
200  case 0:
201  coord = (m_DataWords[0] >> 11) & 0x3;
202  etSmall = ((m_DataWords[0] >> 8) & 0x7) + ((m_DataWords[1] & 0x3f) << 3);
203  etLarge = (m_DataWords[0] >> 13) & 0x3ff;
204  break;
205  case 1:
206  coord = (m_DataWords[1] >> 11) & 0x3;
207  etSmall = ((m_DataWords[1] >> 6) & 0x1f) + ((m_DataWords[2] & 0xf) << 5);
208  etLarge = (m_DataWords[1] >> 13) & 0x3ff;
209  break;
210  case 2:
211  coord = (m_DataWords[2] >> 11) & 0x3;
212  etSmall = ((m_DataWords[2] >> 4) & 0x7f) + ((m_DataWords[3] & 0x3) << 7);
213  etLarge = (m_DataWords[2] >> 13) & 0x3ff;
214  break;
215  case 3:
216  coord = (m_DataWords[3] >> 11) & 0x3;
217  etSmall = (m_DataWords[3] >> 2) & 0x1ff;
218  etLarge = (m_DataWords[3] >> 13) & 0x3ff;
219  break;
220  }
221 
222  word = etLarge + (etSmall<<10) + (coord<<19);
223  data.push_back(word);
224  }
225  ntob++;
226 
227  } // bit set in presence map
228 
229  } // step through presence map
230 
231  return data;
232 }
233 
234 
236 std::vector<unsigned int> LVL1::JetCMXData::TopoTOBs() const {
237 
238  std::vector<unsigned int> data;
239 
241  if ( (m_DataWords[0] & 0xff) == 0 ) return data;
242 
244  unsigned int ntob = 0;
245  for (unsigned int i = 0; i < 8; ++i) {
246 
247  if ( (m_DataWords[0] & (1<<i)) > 0 ) {
248 
249  if (ntob < 4) {
250 
251  unsigned int frame = i;
252 
253  unsigned int word;
254 
255  unsigned int coord = 0;
256  unsigned int etSmall = 0;
257  unsigned int etLarge = 0;
258 
259  switch (ntob) {
260  case 0:
261  coord = (m_DataWords[0] >> 11) & 0x3;
262  etSmall = ((m_DataWords[0] >> 8) & 0x7) + ((m_DataWords[1] & 0x3f) << 3);
263  etLarge = (m_DataWords[0] >> 13) & 0x3ff;
264  break;
265  case 1:
266  coord = (m_DataWords[1] >> 11) & 0x3;
267  etSmall = ((m_DataWords[1] >> 6) & 0x1f) + ((m_DataWords[2] & 0xf) << 5);
268  etLarge = (m_DataWords[1] >> 13) & 0x3ff;
269  break;
270  case 2:
271  coord = (m_DataWords[2] >> 11) & 0x3;
272  etSmall = ((m_DataWords[2] >> 4) & 0x7f) + ((m_DataWords[3] & 0x3) << 7);
273  etLarge = (m_DataWords[2] >> 13) & 0x3ff;
274  break;
275  case 3:
276  coord = (m_DataWords[3] >> 11) & 0x3;
277  etSmall = (m_DataWords[3] >> 2) & 0x1ff;
278  etLarge = (m_DataWords[3] >> 13) & 0x3ff;
279  break;
280  }
281 
282  word = etLarge + (etSmall<<10) + (coord<<19) + (frame<<21) + (m_module<<24);
283  data.push_back(word);
284  }
285  ntob++;
286 
287  } // bit set in presence map
288 
289  } // step through presence map
290 
291  return data;
292 }
293 
294 
295 } // end namespace
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
LVL1::JetCMXData::m_DataWords
std::vector< unsigned int > m_DataWords
Definition: JetCMXData.h:52
LVL1::JetCMXData::module
int module() const
module number
Definition: JetCMXData.cxx:119
LVL1::JetCMXData::overflow
bool overflow() const
Report whether TOB overflow occurred.
Definition: JetCMXData.cxx:131
LVL1::JetCMXData::~JetCMXData
virtual ~JetCMXData()
Destructor.
Definition: JetCMXData.cxx:106
athena.value
value
Definition: athena.py:124
python.LumiCalcHtml.lc
lc
Definition: LumiCalcHtml.py:579
LVL1
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
Definition: ICMMCPHitsCnvTool.h:18
LVL1::JetCMXData::crate
int crate() const
Data accessors.
Definition: JetCMXData.cxx:114
python.PyAthena.module
module
Definition: PyAthena.py:131
lumiFormat.i
int i
Definition: lumiFormat.py:85
LVL1::JetCMXData::presenceMap
unsigned int presenceMap() const
8 bit presence map
Definition: JetCMXData.cxx:125
JetCMXData.h
LVL1::JetCMXData::TopoTOBs
std::vector< unsigned int > TopoTOBs() const
L1Topo TOB words (1bRO + 4b JEM + 3b Frame + 2b LC + 9b Small ET + 10b Large ET) for up to 4 TOBs.
Definition: JetCMXData.cxx:236
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
LVL1::JetCMXData::TOBPresenceBits
std::vector< unsigned int > TOBPresenceBits() const
Locations in Presence Map for up to 4 TOBs.
Definition: JetCMXData.cxx:158
JetVoronoiDiagramHelpers::coord
double coord
Definition: JetVoronoiDiagramHelpers.h:45
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
LVL1::JetCMXData::TOBWords
std::vector< unsigned int > TOBWords() const
Data words (2b LC + 9b Small ET + 10b Large ET) for up to 4 TOBs.
Definition: JetCMXData.cxx:179
LVL1::JetCMXData::DataWords
std::vector< unsigned int > DataWords() const
the 4 raw backplane data words
Definition: JetCMXData.cxx:153
LVL1::JetCMXData::JetCMXData
JetCMXData()
Constructors.
Definition: JetCMXData.cxx:10
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.