ATLAS Offline Software
Loading...
Searching...
No Matches
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
7namespace LVL1 {
8
9// Default constructor
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) :
21 m_type(type),
22 m_DataWords(tobWords)
23{
24}
25
26// Construct from a vector of CPMTobRoIs
28 const DataVector<CPMTobRoI>* tobs) :
32{
33
34 m_DataWords.clear();
35 m_DataWords.resize(4);
36
39
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
117
119
122 return m_crate;
123}
124
127 return m_module;
128}
129
132 return m_type;
133}
134
136unsigned int LVL1::CPMCMXData::presenceMap() const {
137 unsigned int value = (m_DataWords[0] & 0xffff);
138 return value;
139}
140
142std::vector<unsigned int> LVL1::CPMCMXData::DataWords() const {
143 return m_DataWords;
144}
145
146
148std::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
169std::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
230std::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
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
double coord
Type of coordination system.
Derived DataVector<T>.
Definition DataVector.h:795
DataModel_detail::const_iterator< DataVector > const_iterator
Standard const_iterator.
Definition DataVector.h:838
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
int module() const
module number
std::vector< unsigned int > DataWords() const
the 4 raw backplane data words
std::vector< unsigned int > m_DataWords
Definition CPMCMXData.h:54
int type() const
TOB type (EM/Tau)
unsigned int presenceMap() const
16 bit presence map
int crate() const
Data accessors.
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.
std::vector< unsigned int > TOBWords() const
Data words (2b LC + 5b Isol + 8b ET) for up to 5 TOBs.
virtual ~CPMCMXData()
Destructor.
std::vector< unsigned int > TOBPresenceBits() const
Locations in Presence Map for up to 5 TOBs.
bool overflow() const
Report whether TOB overflow occurred.
int m_crate
Internal data.
Definition CPMCMXData.h:51
CPMCMXData()
Constructors.
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
Extra patterns decribing particle interation process.