ATLAS Offline Software
CPMCMXData.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 CPMCMXData::CPMCMXData() : m_crate(0), m_module(0), m_type(0)
11 {
12  m_DataWords.clear();
13  m_DataWords.resize(4);
14 }
15 
16 // Construct from pre-calculated data
17 CPMCMXData::CPMCMXData(int crate, int module, int type,
18  const std::vector<unsigned int>& tobWords) :
19  m_crate(crate),
20  m_module(module),
21  m_type(type),
22  m_DataWords(tobWords)
23 {
24 }
25 
26 // Construct from a vector of CPMTobRoIs
27 CPMCMXData::CPMCMXData(int crate, int module, int type,
28  const DataVector<CPMTobRoI>* tobs) :
29  m_crate(crate),
30  m_module(module),
31  m_type(type)
32 {
33 
34  m_DataWords.clear();
35  m_DataWords.resize(4);
36 
40  std::vector<unsigned int> allTOBs(16,0);
41 
43  for ( ; itRoI != tobs->end(); ++itRoI) {
44  if ( (*itRoI)->crate() != crate || (*itRoI)->cpm() != module || (*itRoI)->type() != type ) continue;
45 
46  int chip = (*itRoI)->chip();
47  int chipCoord = (*itRoI)->location();
48  int et = (*itRoI)->energy();
49  int isol = (*itRoI)->isolation();
50 
51  int side = (chipCoord >> 2);
52  int lc = chipCoord & 3;
53 
54  // Set flag in presence map
55  unsigned int presence = 2*chip + side;
56  m_DataWords[0] |= ( 1 << presence );
57 
58  // Store TOB data to fill backplane words later
59  unsigned int tobdata = et + (isol<<8) + (lc<<13);
60  allTOBs[presence] = tobdata;
61  }
62 
64  int nTOB = 0;
65  for (int i = 0; i < 16; ++i) {
66  if (allTOBs[i] == 0 ) continue;
67 
68  unsigned int et = allTOBs[i] & 0xff;
69  unsigned int isol = (allTOBs[i] >> 8) & 0x1f;
70  unsigned int lc = (allTOBs[i] >> 13) & 3;
71 
72  switch (nTOB) {
73  case 0:
74  m_DataWords[1] += et;
75  m_DataWords[0] += (isol<<18);
76  m_DataWords[0] += (lc<<16);
77  break;
78  case 1:
79  m_DataWords[1] += (et<<8);
80  m_DataWords[1] += (isol<<18);
81  m_DataWords[1] += (lc<<16);
82  break;
83  case 2:
84  m_DataWords[2] += et;
85  m_DataWords[2] += (isol<<18);
86  m_DataWords[2] += (lc<<16);
87  break;
88  case 3:
89  m_DataWords[2] += (et<<8);
90  m_DataWords[3] += (isol<<10);
91  m_DataWords[3] += (lc<<8);
92  break;
93  case 4:
94  m_DataWords[3] += et;
95  m_DataWords[3] += (isol<<18);
96  m_DataWords[3] += (lc<<16);
97  break;
98  }
99  nTOB++;
100 
101  } // Loop over TOB locations
102 
103  // Finally set parity bits. Will assume we used odd parity here (flip initial assignment to change)
104  for (unsigned int word = 0; word < 4; ++word) {
105  unsigned int parity = 1;
106  for (unsigned int bit = 0; bit < 24; ++bit) if ( ( (m_DataWords[word]>>bit) & 1) > 0 ) parity++;
107  parity &= 1;
108  m_DataWords[word] |= (parity<<23);
109  }
110 
111 }
112 
113 
115 {
116 }
117 
122  return m_crate;
123 }
124 
127  return m_module;
128 }
129 
132  return m_type;
133 }
134 
136 unsigned int LVL1::CPMCMXData::presenceMap() const {
137  unsigned int value = (m_DataWords[0] & 0xffff);
138  return value;
139 }
140 
142 std::vector<unsigned int> LVL1::CPMCMXData::DataWords() const {
143  return m_DataWords;
144 }
145 
146 
148 std::vector<unsigned int> LVL1::CPMCMXData::TOBPresenceBits() const {
149 
150  std::vector<unsigned int> bits;
151 
152  int ntob = 0;
153  for (unsigned int i = 0; i < 16; ++i) {
154 
155  if ( (m_DataWords[0] & (1<<i)) > 0 ) {
156 
157  if (ntob < 5) bits.push_back(i);
158  ntob++;
159 
160  } // bit set in presence map
161 
162  } // step through presence map
163 
164  return bits;
165 }
166 
167 
169 std::vector<unsigned int> LVL1::CPMCMXData::TOBWords() const {
170 
171  std::vector<unsigned int> data;
172 
174  if ( (m_DataWords[0] & 0xffff) == 0 ) return data;
175 
177  unsigned int ntob = 0;
178  for (unsigned int i = 0; i < 16; ++i) {
179 
180  if ( (m_DataWords[0] & (1<<i)) > 0 ) {
181 
182  if (ntob < 5) {
183 
184  unsigned int word = 0;
185  unsigned int coord = 0;
186  unsigned int isol = 0;
187  unsigned int et = 0;
188 
189  switch (ntob) {
190  case 0:
191  coord = (m_DataWords[0] >> 16) & 3;
192  isol = (m_DataWords[0] >> 18) & 0x1f;
193  et = m_DataWords[1] & 0xff;
194  break;
195  case 1:
196  coord = (m_DataWords[1] >> 16) & 3;
197  isol = (m_DataWords[1] >> 18) & 0x1f;
198  et = (m_DataWords[1] >> 8) & 0xff;
199  break;
200  case 2:
201  coord = (m_DataWords[2] >> 16) & 3;
202  isol = (m_DataWords[2] >> 18) & 0x1f;
203  et = m_DataWords[2] & 0xff;
204  break;
205  case 3:
206  coord = (m_DataWords[3] >> 8) & 3;
207  isol = (m_DataWords[3] >> 10) & 0x1f;
208  et = (m_DataWords[2] >> 8) & 0xff;
209  break;
210  case 4:
211  coord = (m_DataWords[3] >> 16) & 3;
212  isol = (m_DataWords[3] >> 18) & 0x1f;
213  et = m_DataWords[3] & 0xff;
214  break;
215  }
216  word = et + (isol<<8) + (coord<<13);
217  data.push_back(word);
218  }
219  ntob++;
220 
221  } // bit set in presence map
222 
223  } // step through presence map
224 
225  return data;
226 }
227 
228 
230 std::vector<unsigned int> LVL1::CPMCMXData::TopoTOBs() const {
231 
232  std::vector<unsigned int> data;
233 
235  if ( (m_DataWords[0] & 0xffff) == 0 ) return data;
236 
238  unsigned int ntob = 0;
239  for (unsigned int i = 0; i < 16; ++i) {
240 
241  if ( (m_DataWords[0] & (1<<i)) > 0 ) {
242 
243  if (ntob < 5) {
244 
245  unsigned int chip = i/2;
246  unsigned int rl = (i&1) << 2;
247 
248  unsigned int word;
249 
250  unsigned int coord = 0;
251  unsigned int isol = 0;
252  unsigned int et = 0;
253 
254  switch (ntob) {
255  case 0:
256  coord = ((m_DataWords[0] >> 16) & 3) + rl;
257  isol = (m_DataWords[0] >> 18) & 0x1f;
258  et = m_DataWords[1] & 0xff;
259  break;
260  case 1:
261  coord = ((m_DataWords[1] >> 16) & 3) + rl;
262  isol = (m_DataWords[1] >> 18) & 0x1f;
263  et = (m_DataWords[1] >> 8) & 0xff;
264  break;
265  case 2:
266  coord = ((m_DataWords[2] >> 16) & 3) + rl;
267  isol = (m_DataWords[2] >> 18) & 0x1f;
268  et = m_DataWords[2] & 0xff;
269  break;
270  case 3:
271  coord = ((m_DataWords[3] >> 8) & 3) + rl;
272  isol = (m_DataWords[3] >> 10) & 0x1f;
273  et = (m_DataWords[2] >> 8) & 0xff;
274  break;
275  case 4:
276  coord = ((m_DataWords[3] >> 16) & 3) + rl;
277  isol = (m_DataWords[3] >> 18) & 0x1f;
278  et = m_DataWords[3] & 0xff;
279  break;
280  }
281  word = et + (isol<<8) + (coord<<13) + (chip<<16) + (m_module<<19);
282  data.push_back(word);
283  }
284  ntob++;
285 
286  } // bit set in presence map
287 
288  } // step through presence map
289 
290  return data;
291 }
292 
293 
296 
297  bool overflow = false;
298 
300  if ( (m_DataWords[0] & 0xffff) == 0 ) return overflow;
301 
303  int ntob = 0;
304  for (unsigned int i = 0; i < 16; ++i) {
305 
306  if ( (m_DataWords[0] & (1<<i)) > 0 ) ntob++;
307 
308  } // step through presence map
309 
310  // Set overflow flags if needed
311  if (ntob > 5) overflow = true;
312 
313  return overflow;
314 }
315 
316 
317 } // end namespace
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
et
Extra patterns decribing particle interation process.
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
LVL1::CPMCMXData::type
int type() const
TOB type (EM/Tau)
Definition: CPMCMXData.cxx:131
xAOD::et
et
Definition: TrigEMCluster_v1.cxx:25
LVL1::CPMCMXData::overflow
bool overflow() const
Report whether TOB overflow occurred.
Definition: CPMCMXData.cxx:295
LVL1::CPMCMXData::m_DataWords
std::vector< unsigned int > m_DataWords
Definition: CPMCMXData.h:54
athena.value
value
Definition: athena.py:122
LVL1::CPMCMXData::module
int module() const
module number
Definition: CPMCMXData.cxx:126
python.LumiCalcHtml.lc
lc
Definition: LumiCalcHtml.py:579
LVL1
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
Definition: ICMMCPHitsCnvTool.h:18
TRT::Hit::side
@ side
Definition: HitInfo.h:83
LVL1::CPMCMXData::presenceMap
unsigned int presenceMap() const
16 bit presence map
Definition: CPMCMXData.cxx:136
m_type
TokenType m_type
the type
Definition: TProperty.cxx:44
python.PyAthena.module
module
Definition: PyAthena.py:134
LVL1::CPMCMXData::crate
int crate() const
Data accessors.
Definition: CPMCMXData.cxx:121
lumiFormat.i
int i
Definition: lumiFormat.py:92
CPMCMXData.h
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
LVL1::CPMCMXData::~CPMCMXData
virtual ~CPMCMXData()
Destructor.
Definition: CPMCMXData.cxx:114
LVL1::CPMCMXData::TOBWords
std::vector< unsigned int > TOBWords() const
Data words (2b LC + 5b Isol + 8b ET) for up to 5 TOBs.
Definition: CPMCMXData.cxx:169
LVL1::CPMCMXData::DataWords
std::vector< unsigned int > DataWords() const
the 4 raw backplane data words
Definition: CPMCMXData.cxx:142
LVL1::CPMCMXData::TOBPresenceBits
std::vector< unsigned int > TOBPresenceBits() const
Locations in Presence Map for up to 5 TOBs.
Definition: CPMCMXData.cxx:148
JetVoronoiDiagramHelpers::coord
double coord
Definition: JetVoronoiDiagramHelpers.h:45
PlotCalibFromCool.rl
rl
Definition: PlotCalibFromCool.py:529
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
LVL1::CPMCMXData::TopoTOBs
std::vector< unsigned int > TopoTOBs() const
L1Topo TOB words (1bRO + 4b CPM + 3b Chip + 3b LC + 5b Isol + 8b ET) for up to 5 TOBs.
Definition: CPMCMXData.cxx:230
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
LVL1::CPMCMXData::CPMCMXData
CPMCMXData()
Constructors.
Definition: CPMCMXData.cxx:10
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.