Decode the FPGA output based on the type.
user shouldn't call this function directly They should call the following user-level functions
24{
25 using namespace FPGADataFormatUtilities;
26
28
29 std::vector<uint64_t> header_words;
30 std::vector<uint64_t> footer_words;
31 std::vector<uint64_t> ghits_words;
32 std::vector<uint64_t> gtracks_words;
33 std::vector<uint64_t> slices_words;
34 std::vector<uint64_t> pixel_edm_words;
35 std::vector<uint64_t> strip_edm_words;
36
38
39
40 for (const auto &word : bytestream)
41 {
43 switch (state)
44 {
46 {
48 {
49 ATH_MSG_ERROR(
"The first word is not the event hearder! Something is wrong");
51 break;
52 }
53
54 header_words.push_back(word);
55 if (header_words.size() == 3)
56 {
60
61
62
63
64 switch (blockType)
65 {
67 {
69 if(pcAux == nullptr)
70 {
71 ATH_MSG_ERROR(
"The PixelClusterAuxInput is not provided to decode function! Something is wrong");
73 break;
74 }
75 break;
76 }
78 {
80 if(scAux == nullptr)
81 {
82 ATH_MSG_ERROR(
"The StripClusterAuxInput is not provided to decode function! Something is wrong");
84 break;
85 }
86 break;
87 }
89 {
91 break;
92 }
94 {
96 break;
97 }
98 default:
99 {
100 ATH_MSG_ERROR(
"The blockType is not recognized! Something is wrong");
102 break;
103 }
104 }
105
106
107 if (msgLvl(MSG::DEBUG))
108 {
118 }
119 break;
120 }
121 break;
122 }
124 {
125
127 {
128 auto module = get_bitfields_M_HDR_w1(word);
129
130
131 if (msgLvl(MSG::DEBUG))
132 {
138 }
139
140
141
142 switch (blockType)
143 {
145 {
147 break;
148 }
150 {
152 break;
153 }
154 default:
155 {
156 ATH_MSG_ERROR(
"The blockType is not recognized! Something is wrong");
158 break;
159 }
160 }
161 }
162
164 {
166 gtracks_words.push_back(word);
167 break;
168 }
170 {
172 footer_words.push_back(word);
173 break;
174 }
175 else
176 {
177 ATH_MSG_ERROR(
"The word after the last cluster is not a module header or event footer! Something is wrong");
179 break;
180 }
181 break;
182 }
184 {
185 ghits_words.push_back(word);
186 if (ghits_words.size() == 2)
187 {
197 ATH_MSG_DEBUG(
"\tlastofslice: " << Ghit_w1.lastofslice/GHITZ_W1_LASTOFSLICE_mf);
198 ATH_MSG_DEBUG(
"\tspare: " << Ghit_w1.spare/GHITZ_W1_SPARE_mf);
200 ATH_MSG_DEBUG(
"\tcluster1: " << Ghit_w2.cluster1/GHITZ_W2_CLUSTER1_mf);
201 ATH_MSG_DEBUG(
"\tcluster2: " << Ghit_w2.cluster2/GHITZ_W2_CLUSTER2_mf);
203 ATH_MSG_DEBUG(
"\tspare: " << Ghit_w2.spare/GHITZ_W2_SPARE_mf);
204 ghits_words.clear();
205 if (Ghit_w1.last == 1)
206 {
208 break;
209 }
210 break;
211 }
212 break;
213 }
215 {
216 pixel_edm_words.push_back(word);
217
218 if (pixel_edm_words.size() == 10)
219 {
220
221
222
223
224
225
227
228
229
234
235 unsigned short current_rdo_size = 0;
236 if (rdo_w1 != 0)
237 {
238 pcAux->
rdoList.push_back(rdo_w1);
239 current_rdo_size++;
240 }
241 if (rdo_w2 != 0)
242 {
243 pcAux->
rdoList.push_back(rdo_w2);
244 current_rdo_size++;
245 }
246 if (rdo_w3 != 0)
247 {
248 pcAux->
rdoList.push_back(rdo_w3);
249 current_rdo_size++;
250 }
251 if (rdo_w4 != 0)
252 {
253 pcAux->
rdoList.push_back(rdo_w4);
254 current_rdo_size++;
255 }
256
262
265
268
270
273
274
277
278
280 {
284 }
285 pixel_edm_words.clear();
286
287
288 if (msgLvl(MSG::DEBUG))
289 {
304 }
305 break;
306 }
307
308 break;
309 }
311 {
312 strip_edm_words.push_back(word);
313
314 if (strip_edm_words.size() == 9 and scAux)
315 {
317
319
322
326
328
329
334
335 unsigned short current_rdo_size = 0;
336 if (rdo_w1 != 0)
337 {
338 scAux->rdoList.push_back(rdo_w1);
339 current_rdo_size++;
340 }
341 if (rdo_w2 != 0)
342 {
343 scAux->rdoList.push_back(rdo_w2);
344 current_rdo_size++;
345 }
346 if (rdo_w3 != 0)
347 {
348 scAux->rdoList.push_back(rdo_w3);
349 current_rdo_size++;
350 }
351 if (rdo_w4 != 0)
352 {
353 scAux->rdoList.push_back(rdo_w4);
354 current_rdo_size++;
355 }
356
359
360
362 {
366 }
367 strip_edm_words.clear();
368
369
370 if (msgLvl(MSG::DEBUG))
371 {
375 ATH_MSG_DEBUG(
"\tlocalPosition_x: " << scAux->localPosition.back());
376 ATH_MSG_DEBUG(
"\tlocalCovariance_xx: " << scAux->localCovariance.back());
377 ATH_MSG_DEBUG(
"\tglobalPosition_x: " << scAux->globalPosition.at(scAux->globalPosition.size() - 3));
378 ATH_MSG_DEBUG(
"\tglobalPosition_y: " << scAux->globalPosition.at(scAux->globalPosition.size() - 2));
379 ATH_MSG_DEBUG(
"\tglobalPosition_z: " << scAux->globalPosition.back());
380 ATH_MSG_DEBUG(
"\tchannelsInPhi: " << scAux->channelsInPhi.back());
382 }
383 break;
384 }
385 break;
386 }
388 {
389 footer_words.push_back(word);
390 if (footer_words.size() == 3)
391 {
392
396
397
405
406
407 header_words.clear();
408 footer_words.clear();
410
411
412
414 break;
415 }
416 break;
417 }
419 {
420 gtracks_words.push_back(word);
421 if (gtracks_words.size() == 3)
422 {
427 ATH_MSG_DEBUG(
"\tflag: 0x" << std::hex << gtrack_w1.
flag/GTRACK_HDR_W1_FLAG_mf << std::dec);
443 gtracks_words.clear();
445 break;
446 }
447 break;
448 }
450 {
451 slices_words.push_back(word);
453
455 ATH_MSG_DEBUG(
"\tflag: 0x" << std::hex << slice_w1.
flag/GTRACK_HDR_W1_FLAG_mf << std::dec);
460 slices_words.clear();
462 break;
463 }
465 {
466 ATH_MSG_ERROR(
"FSM is in an error state! Something is wrong");
467 break;
468 }
469 default:
470 ATH_MSG_ERROR(
"FSM is not in a valid state! Something is wrong");
471 break;
472 }
473 }
474
475 return StatusCode::SUCCESS;
476}