158 {
159
160
161
162
163 SG::WriteHandle<xAOD::jFexSRJetRoIContainer> jJContainer(
m_jJWriteKey, ctx);
164 ATH_CHECK(jJContainer.record(std::make_unique<xAOD::jFexSRJetRoIContainer>(), std::make_unique<xAOD::jFexSRJetRoIAuxContainer>()));
165 ATH_MSG_DEBUG(
"Recorded jFexSRJetRoIContainer with key " << jJContainer.key());
166
167
168 SG::WriteHandle<xAOD::jFexLRJetRoIContainer> jLJContainer(
m_jLJWriteKey, ctx);
169 ATH_CHECK(jLJContainer.record(std::make_unique<xAOD::jFexLRJetRoIContainer>(), std::make_unique<xAOD::jFexLRJetRoIAuxContainer>()));
170 ATH_MSG_DEBUG(
"Recorded jFexLRJetRoIContainer with key " << jLJContainer.key());
171
172
173 SG::WriteHandle<xAOD::jFexTauRoIContainer> jTauContainer(
m_jTauWriteKey, ctx);
174 ATH_CHECK(jTauContainer.record(std::make_unique<xAOD::jFexTauRoIContainer>(), std::make_unique<xAOD::jFexTauRoIAuxContainer>()));
175 ATH_MSG_DEBUG(
"Recorded jFexTauRoIContainer with key " << jTauContainer.key());
176
177
178 SG::WriteHandle<xAOD::jFexFwdElRoIContainer> jEMContainer(
m_jEMWriteKey, ctx);
179 ATH_CHECK(jEMContainer.record(std::make_unique<xAOD::jFexFwdElRoIContainer>(), std::make_unique<xAOD::jFexFwdElRoIAuxContainer>()));
180 ATH_MSG_DEBUG(
"Recorded jFexFwdElRoIContainer with key " << jEMContainer.key());
181
182
183 SG::WriteHandle<xAOD::jFexSumETRoIContainer> jTEContainer(
m_jTEWriteKey, ctx);
184 ATH_CHECK(jTEContainer.record(std::make_unique<xAOD::jFexSumETRoIContainer>(), std::make_unique<xAOD::jFexSumETRoIAuxContainer>()));
185 ATH_MSG_DEBUG(
"Recorded jFexSumETRoIContainer with key " << jTEContainer.key());
186
187
188 SG::WriteHandle<xAOD::jFexMETRoIContainer> jXEContainer(
m_jXEWriteKey, ctx);
189 ATH_CHECK(jXEContainer.record(std::make_unique<xAOD::jFexMETRoIContainer>(), std::make_unique<xAOD::jFexMETRoIAuxContainer>()));
190 ATH_MSG_DEBUG(
"Recorded jFexMETRoIContainer with key " << jXEContainer.key());
191
192
193
194
195
196 for (
const ROBF* rob : vrobf) {
197
198
199 ATH_MSG_DEBUG(
"Starting to decode " << rob->rod_ndata() <<
" ROD words from ROB 0x" << std::hex << rob->rob_source_id() << std::dec);
200
201
202 if(rob->rod_ndata() <= 0){
203 std::stringstream sdetail;
204 sdetail << "Not enough ROB words to read: "<<rob->rod_ndata() ;
205 std::stringstream slocation;
206 slocation << "0x"<< std::hex << rob->rob_source_id();
207 std::stringstream stitle;
208 stitle << "Invalid amount of ROB words" ;
209 printError(slocation.str(),stitle.str(),MSG::WARNING,sdetail.str());
210
211 continue;
212 }
213
214 const auto dataArray = std::span{rob->rod_data(), rob->rod_ndata()};
215 std::vector<uint32_t> vec_words(dataArray.begin(),dataArray.end());
216
217 std::stringstream myPrint;
218
219 myPrint << "jFEX TOB words to decode:"<< std::endl;
220 int aux = 1;
221 for (const uint32_t word : vec_words) {
222 myPrint << aux << " raw word ---> 0x"<< std::hex << word << std::dec << std::endl;
223 aux++;
224 }
226
227
228 bool READ_TOBS = true;
229
231
233 std::stringstream sdetail;
234 sdetail << "Not enough jFEX TOB words to decode (<4). Number of word to decode: "<<vec_words.size()<< ". Position within the vector: "<<trailers_pos ;
235 std::stringstream slocation;
236 slocation << "0x"<< std::hex << rob->rob_source_id();
237 std::stringstream stitle;
238 stitle << "Less than 4 trailers" ;
239 printError(slocation.str(),stitle.str(),MSG::WARNING,sdetail.str());
240
241 continue;
242 }
243
244
245 const auto [RODerror] =
RODTrailer ( vec_words.at(rob->rod_ndata()-2), vec_words.at(rob->rod_ndata()-1) );
246
247
248 if(RODerror != 0){
256
257 std::stringstream sdetail;
258 sdetail << "ROD Trailer Error bits set - 7-bits error word: 0x"<< std::hex <<RODerror << std::dec<< std::endl;
259 sdetail << "Corrective Trailer: "<< corTrailer << std::endl;
260 sdetail << "Payload CRC : "<< payloadCRC << std::endl;
261 sdetail << "Header CRC : "<< headerCRC << std::endl;
262 sdetail << "Reserved (=0) : "<< reserved << std::endl;
263 sdetail << "Length Mismatch : "<< lenerror << std::endl;
264 sdetail << "Header Mismatch : "<< headmismatch << std::endl;
265 sdetail << "Processor timeout : "<< processerror << std::endl;
266 std::stringstream slocation;
267 slocation << "ROD Error";
268
269
270 if( corTrailer ){
271 std::stringstream stitle;
272 stitle << "Corrective Trailer" ;
273 printError(slocation.str(),stitle.str(),MSG::ERROR,stitle.str() +
" - "+ sdetail.str());
274 return StatusCode::FAILURE;
275 }
276 if( payloadCRC ){
277 std::stringstream stitle;
278 stitle << "Payload CRC" ;
279 printError(slocation.str(),stitle.str(),MSG::ERROR,stitle.str() +
" - "+ sdetail.str());
280 return StatusCode::FAILURE;
281 }
282 if( headerCRC ){
283 std::stringstream stitle;
284 stitle << "Header CRC" ;
285 printError(slocation.str(),stitle.str(),MSG::ERROR,stitle.str() +
" - "+ sdetail.str());
286 return StatusCode::FAILURE;
287 }
288 if( lenerror ){
289 std::stringstream stitle;
290 stitle << "Length mismatch" ;
291 printError(slocation.str(),stitle.str(),MSG::ERROR,stitle.str() +
" - "+ sdetail.str());
292 return StatusCode::FAILURE;
293 }
294 if( headmismatch ){
295 std::stringstream stitle;
296 stitle << "Header mismatch" ;
297 printError(slocation.str(),stitle.str(),MSG::ERROR,stitle.str() +
" - "+ sdetail.str());
298 return StatusCode::FAILURE;
299 }
300 if( processerror ){
301 std::stringstream stitle;
302 stitle << "Processor Timeout" ;
303 printError(slocation.str(),stitle.str(),MSG::ERROR,stitle.str() +
" - "+ sdetail.str());
304 return StatusCode::FAILURE;
305 }
306
307 return StatusCode::FAILURE;
308 }
309
310 while(READ_TOBS){
311
313 const auto [n_xjJ, n_xjLJ, n_xjTau, n_xjEM] =
xTOBCounterTrailer( vec_words.at(trailers_pos-3) );
314 const auto [n_jJ, n_jLJ, n_jTau, n_jEM, n_jTE, n_jXE] =
TOBCounterTrailer ( vec_words.at(trailers_pos-4) );
315 unsigned int n_tobs = n_jJ + n_jLJ + n_jTau + n_jEM + n_jTE + n_jXE;
316 unsigned int n_xtobs = n_xjJ + n_xjLJ + n_xjTau + n_xjEM;
317 unsigned int total_tobs = n_tobs+n_xtobs;
318
319
320
321
322
323
324 unsigned int paddingWord = 0;
325 if(total_tobs % 2){
326 ATH_MSG_DEBUG(
"Odd number of TOBs + xTOBs:"<< total_tobs<<
", there is a padding word!");
327 paddingWord = 1;
328 }
329
330 if(error != 0){
331
338
339 std::stringstream sdetail;
340 sdetail <<
"jFEX to ROD Trailer Error bits set - 6-bits error word: 0x"<< std::hex <<
error << std::dec<< std::endl;
341 sdetail << "Corrective Trailer: "<< corTrailer << std::endl;
342 sdetail << "Safe Mode : "<< safemode << std::endl;
343 sdetail << "Protocol error : "<< proterror << std::endl;
344 sdetail << "Length Mismatch : "<< lenerror << std::endl;
345 sdetail << "Header Mismatch : "<< headmismatch << std::endl;
346 sdetail << "Processor timeout : "<< processerror << std::endl;
347 std::stringstream slocation;
348 slocation << "Error bit set";
349
350 if( corTrailer ){
351 std::stringstream stitle;
352 stitle << "Corrective Trailer" ;
353 printError(slocation.str(),stitle.str(),MSG::ERROR,sdetail.str());
354
355
356 return StatusCode::FAILURE;
357 }
358 if( safemode ){
359 std::stringstream stitle;
360 stitle << "Safe Mode" ;
361 printError(slocation.str(),stitle.str(),MSG::WARNING,sdetail.str());
362 }
363 if( proterror ){
364 std::stringstream stitle;
365 stitle << "Protocol error" ;
366 printError(slocation.str(),stitle.str(),MSG::WARNING,sdetail.str());
367 }
368 if( lenerror ){
369 std::stringstream stitle;
370 stitle << "Length mismatch" ;
371 printError(slocation.str(),stitle.str(),MSG::DEBUG,sdetail.str());
372 }
373 if( headmismatch ){
374 std::stringstream stitle;
375 stitle << "Header mismatch" ;
376 printError(slocation.str(),stitle.str(),MSG::DEBUG,sdetail.str());
377 }
378 if( processerror ){
379 std::stringstream stitle;
380 stitle << "Processor Timeout" ;
381 printError(slocation.str(),stitle.str(),MSG::DEBUG,sdetail.str());
382 }
383
384 }
385
387 std::stringstream sdetail;
388 sdetail <<
"Payload="<<
payload<<
" is different from TOBs+Trailers+padding words="<< total_tobs +
jBits::TOB_TRAILERS + paddingWord <<
" in FPGA: "<< fpga <<
" and jFEX: "<< jfex <<
". SKIPPED!" ;
389 std::stringstream slocation;
390 slocation << "jFEX "<< jfex << " FPGA "<< fpga << " in 0x"<< std::hex << rob->rob_source_id();
391 std::stringstream stitle;
392 stitle << "Wrong payload" ;
393 printError(slocation.str(),stitle.str(),MSG::WARNING,sdetail.str());
394
395
397
398 if(neg_positions < 0){
399 std::stringstream sdetail;
400 sdetail << "jFEX TOB decoder has discarded the whole event. Due to a wrong payload cannot continue decoding" ;
401 std::stringstream slocation;
402 slocation << "jFEX "<< jfex << " FPGA "<< fpga << " in 0x"<< std::hex << rob->rob_source_id();
403 std::stringstream stitle;
404 stitle << "Event discarded" ;
405
406 printError(slocation.str(),stitle.str(),MSG::DEBUG,sdetail.str());
407 break;
408 }
409
410
412
413
414 if(trailers_pos == 0) {
415 READ_TOBS = false;
416 }
417 continue;
418 }
419
420
422 std::stringstream sdetail;
424 std::stringstream slocation;
425 slocation << "jFEX "<< jfex << " FPGA "<< fpga << " in 0x"<< std::hex << rob->rob_source_id();
426 std::stringstream stitle;
427 stitle << "Event discarded" ;
428
429 printError(slocation.str(),stitle.str(),MSG::WARNING,sdetail.str());
430 break;
431 }
432
433
435
436 if(paddingWord == 1){
437 ATH_MSG_DEBUG(
"Padding word: "<< std::hex << vec_words.at(tobIndex) <<std::dec);
438 }
439
441
442
443
444 for(
unsigned int i=tobIndex;
i>tobIndex-n_xjEM;
i--) {
445 const auto [
eta,
phi ] =
getEtaPhi(jfex, fpga, vec_words.at(i-1),
"jEM xTOB");
446 jEMContainer->push_back( std::make_unique<xAOD::jFexFwdElRoI>() );
447 jEMContainer->back()->initialize(jfex, fpga, vec_words.at(i-1),0,
m_jEMRes,
eta,
phi);
448 }
449
450 tobIndex -= n_xjEM;
451
452
453 for(
unsigned int i=tobIndex;
i>tobIndex-n_xjTau;
i--) {
454 const auto [
eta,
phi ] =
getEtaPhi(jfex, fpga, vec_words.at(i-1),
"jTau xTOB");
455 jTauContainer->push_back( std::make_unique<xAOD::jFexTauRoI>() );
456 jTauContainer->back()->initialize(jfex, fpga, vec_words.at(i-1),0,
m_jTauRes,
eta,
phi);
457 }
458
459 tobIndex -= n_xjTau;
460
461
462
463
464
465
466
467
468
469
470 tobIndex -= n_xjLJ;
471
472
473 for(
unsigned int i=tobIndex;
i>tobIndex-n_xjJ;
i--) {
474 const auto [
eta,
phi ] =
getEtaPhi(jfex, fpga, vec_words.at(i-1),
"jJ xTOB");
475 jJContainer->push_back( std::make_unique<xAOD::jFexSRJetRoI>() );
476 jJContainer->back()->initialize(jfex, fpga, vec_words.at(i-1),0,
m_jJRes,
eta,
phi);
477 }
478
479 tobIndex -= n_xjJ;
480
481
482 tobIndex -= n_tobs;
483
484 }
485 else {
486
487
488
489 tobIndex -= n_xtobs;
490
491
492
494 for(
unsigned int i=tobIndex;
i>tobIndex-n_jXE;
i--) {
495 jXEContainer->push_back( std::make_unique<xAOD::jFexMETRoI>() );
496 jXEContainer->back()->initialize(jfex, fpga, vec_words.at(i-1),
m_jXERes);
497 }
498 }
499
500 tobIndex -= n_jXE;
501
502
503
505 for(
unsigned int i=tobIndex;
i>tobIndex-n_jTE;
i--) {
506 jTEContainer->push_back( std::make_unique<xAOD::jFexSumETRoI>() );
507 jTEContainer->back()->initialize(jfex, fpga, vec_words.at(i-1),
m_jTERes);
508 }
509 }
510
511 tobIndex -= n_jTE;
512
513
514 for(
unsigned int i=tobIndex;
i>tobIndex-n_jEM;
i--) {
515 const auto [
eta,
phi ] =
getEtaPhi(jfex, fpga, vec_words.at(i-1),
"jEM TOB");
516 jEMContainer->push_back( std::make_unique<xAOD::jFexFwdElRoI>() );
517 jEMContainer->back()->initialize(jfex, fpga, vec_words.at(i-1),1,
m_jEMRes,
eta,
phi);
518 }
519
520 tobIndex -= n_jEM;
521
522
523 for(
unsigned int i=tobIndex;
i>tobIndex-n_jTau;
i--) {
524 const auto [
eta,
phi ] =
getEtaPhi(jfex, fpga, vec_words.at(i-1),
"jTau TOB");
525 jTauContainer->push_back( std::make_unique<xAOD::jFexTauRoI>() );
526 jTauContainer->back()->initialize(jfex, fpga, vec_words.at(i-1),1,
m_jTauRes,
eta,
phi);
527 }
528
529 tobIndex -= n_jTau;
530
531
532 for(
unsigned int i=tobIndex;
i>tobIndex-n_jLJ;
i--) {
533 const auto [
eta,
phi ] =
getEtaPhi(jfex, fpga, vec_words.at(i-1),
"jLJ TOB");
534 jLJContainer->push_back( std::make_unique<xAOD::jFexLRJetRoI>() );
535 jLJContainer->back()->initialize(jfex, fpga, vec_words.at(i-1),1,
m_jLJRes,
eta,
phi);
536 }
537
538 tobIndex -= n_jLJ;
539
540
541 for(
unsigned int i=tobIndex;
i>tobIndex-n_jJ;
i--) {
542 const auto [
eta,
phi ] =
getEtaPhi(jfex, fpga, vec_words.at(i-1),
"jJ TOB");
543 jJContainer->push_back( std::make_unique<xAOD::jFexSRJetRoI>() );
544 jJContainer->back()->initialize(jfex, fpga, vec_words.at(i-1),1,
m_jJRes,
eta,
phi);
545 }
546
547 tobIndex -= n_jJ;
548 }
549
551
552 if(trailers_pos != tobIndex){
553 std::stringstream sdetail;
554 sdetail << "Something went wrong decoding jFEX BS data. Trailer position: " << trailers_pos << " should match the TOB index position:" << tobIndex ;
555 std::stringstream slocation;
556 slocation << "jFEX "<< jfex << " FPGA "<< fpga << " in 0x"<< std::hex << rob->rob_source_id();
557 std::stringstream stitle;
558 stitle << "Wrong amount of words" ;
559
560 printError(slocation.str(),stitle.str(),MSG::ERROR,sdetail.str());
561
562 return StatusCode::FAILURE;
563 }
564
565
566 if(trailers_pos == 0){
567 READ_TOBS = false;
568 }
569 }
570 }
571
572 return StatusCode::SUCCESS;
573}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment ROBF
static constexpr uint32_t ERROR_SAFE_MODE
static constexpr uint32_t ERROR_HEADER_MISMATCH
static constexpr uint32_t ROD_WORDS
Number of jFEX to ROD trailer words.
static constexpr uint32_t ROD_TRAILER_1b
Masking words.
static constexpr uint32_t TOB_TRAILERS
static constexpr uint32_t FPGA_U1
static constexpr uint32_t ROD_ERROR_LENGTH_MISMATCH
static constexpr uint32_t ROD_ERROR_HEADER_CRC
static constexpr uint32_t ERROR_CORR_TRAILER
static constexpr uint32_t jFEX2ROD_WORDS
static constexpr uint32_t ROD_ERROR_HEADER_MISMATCH
static constexpr uint32_t ROD_ERROR_PAYLOAD_CRC
static constexpr uint32_t ERROR_PROC_TIMEOUT
static constexpr uint32_t ERROR_PROTOCOL_ERROR
static constexpr uint32_t ROD_ERROR_RESERVED
static constexpr uint32_t ROD_ERROR_CORR_TRAILER
static constexpr uint32_t ROD_ERROR_PROC_TIMEOUT
static constexpr uint32_t ERROR_LENGTH_MISMATCH
static constexpr uint32_t FPGA_U4