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());
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());
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());
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());
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());
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());
196 for (
const ROBF* rob : vrobf) {
199 ATH_MSG_DEBUG(
"Starting to decode " << rob->rod_ndata() <<
" ROD words from ROB 0x" << std::hex << rob->rob_source_id() << std::dec);
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());
214 const auto dataArray = std::span{rob->rod_data(), rob->rod_ndata()};
215 std::vector<uint32_t> vec_words(dataArray.begin(),dataArray.end());
217 std::stringstream myPrint;
219 myPrint <<
"jFEX TOB words to decode:"<< std::endl;
221 for (
const uint32_t word : vec_words) {
222 myPrint <<
aux <<
" raw word ---> 0x"<< std::hex << word << std::dec << std::endl;
228 bool READ_TOBS =
true;
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());
245 const auto [RODerror] =
RODTrailer ( vec_words.at(rob->rod_ndata()-2), vec_words.at(rob->rod_ndata()-1) );
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";
271 std::stringstream stitle;
272 stitle <<
"Corrective Trailer" ;
273 printError(slocation.str(),stitle.str(),MSG::ERROR,stitle.str() +
" - "+ sdetail.str());
274 return StatusCode::FAILURE;
277 std::stringstream stitle;
278 stitle <<
"Payload CRC" ;
279 printError(slocation.str(),stitle.str(),MSG::ERROR,stitle.str() +
" - "+ sdetail.str());
280 return StatusCode::FAILURE;
283 std::stringstream stitle;
284 stitle <<
"Header CRC" ;
285 printError(slocation.str(),stitle.str(),MSG::ERROR,stitle.str() +
" - "+ sdetail.str());
286 return StatusCode::FAILURE;
289 std::stringstream stitle;
290 stitle <<
"Length mismatch" ;
291 printError(slocation.str(),stitle.str(),MSG::ERROR,stitle.str() +
" - "+ sdetail.str());
292 return StatusCode::FAILURE;
295 std::stringstream stitle;
296 stitle <<
"Header mismatch" ;
297 printError(slocation.str(),stitle.str(),MSG::ERROR,stitle.str() +
" - "+ sdetail.str());
298 return StatusCode::FAILURE;
301 std::stringstream stitle;
302 stitle <<
"Processor Timeout" ;
303 printError(slocation.str(),stitle.str(),MSG::ERROR,stitle.str() +
" - "+ sdetail.str());
304 return StatusCode::FAILURE;
307 return StatusCode::FAILURE;
312 const auto [payload, fpga, jfex,
error] =
jFEXtoRODTrailer ( vec_words.at(trailers_pos-2), vec_words.at(trailers_pos-1) );
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;
324 unsigned int paddingWord = 0;
326 ATH_MSG_DEBUG(
"Odd number of TOBs + xTOBs:"<< total_tobs<<
", there is a padding word!");
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";
351 std::stringstream stitle;
352 stitle <<
"Corrective Trailer" ;
353 printError(slocation.str(),stitle.str(),MSG::ERROR,sdetail.str());
356 return StatusCode::FAILURE;
359 std::stringstream stitle;
360 stitle <<
"Safe Mode" ;
361 printError(slocation.str(),stitle.str(),MSG::WARNING,sdetail.str());
364 std::stringstream stitle;
365 stitle <<
"Protocol error" ;
366 printError(slocation.str(),stitle.str(),MSG::WARNING,sdetail.str());
369 std::stringstream stitle;
370 stitle <<
"Length mismatch" ;
371 printError(slocation.str(),stitle.str(),MSG::DEBUG,sdetail.str());
374 std::stringstream stitle;
375 stitle <<
"Header mismatch" ;
376 printError(slocation.str(),stitle.str(),MSG::DEBUG,sdetail.str());
379 std::stringstream stitle;
380 stitle <<
"Processor Timeout" ;
381 printError(slocation.str(),stitle.str(),MSG::DEBUG,sdetail.str());
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());
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" ;
406 printError(slocation.str(),stitle.str(),MSG::DEBUG,sdetail.str());
414 if(trailers_pos == 0) {
422 std::stringstream sdetail;
423 sdetail <<
"Payload: "<< payload<<
" is lower than the expected size (at least" <<
jBits::TOB_TRAILERS <<
"trailers)" ;
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" ;
429 printError(slocation.str(),stitle.str(),MSG::WARNING,sdetail.str());
436 if(paddingWord == 1){
437 ATH_MSG_DEBUG(
"Padding word: "<< std::hex << vec_words.at(tobIndex) <<std::dec);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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" ;
560 printError(slocation.str(),stitle.str(),MSG::ERROR,sdetail.str());
562 return StatusCode::FAILURE;
566 if(trailers_pos == 0){
572 return StatusCode::SUCCESS;