ATLAS Offline Software
Loading...
Searching...
No Matches
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
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_DataWords(tobWords)
22{
23}
24
25// Construct from a vector of CPMTobRoIs
27 const DataVector<JEMTobRoI>* tobs) :
30{
31
32 m_DataWords.clear();
33 m_DataWords.resize(4);
34
37
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
109
110
112
115 return m_crate;
116}
117
120 return m_module;
121}
122
123
125unsigned 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
153std::vector<unsigned int> LVL1::JetCMXData::DataWords() const {
154 return m_DataWords;
155}
156
158std::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
179std::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
236std::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
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.
JetCMXData()
Constructors.
bool overflow() const
Report whether TOB overflow occurred.
int crate() const
Data accessors.
std::vector< unsigned int > TOBPresenceBits() const
Locations in Presence Map for up to 4 TOBs.
std::vector< unsigned int > m_DataWords
Definition JetCMXData.h:52
virtual ~JetCMXData()
Destructor.
unsigned int presenceMap() const
8 bit presence map
int module() const
module number
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.
std::vector< unsigned int > DataWords() const
the 4 raw backplane data words
int m_crate
Internal data.
Definition JetCMXData.h:50
std::vector< unsigned int > TOBWords() const
Data words (2b LC + 9b Small ET + 10b Large ET) for up to 4 TOBs.
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...