219 ATH_CHECK(gRhoContainer.
record(std::make_unique<xAOD::gFexJetRoIContainer>(), std::make_unique<xAOD::gFexJetRoIAuxContainer>()));
220 ATH_MSG_DEBUG(
"Recorded gFexJetRoIContainer with key " << gRhoContainer.
key());
221 ATH_CHECK(gSJContainer.
record(std::make_unique<xAOD::gFexJetRoIContainer>(), std::make_unique<xAOD::gFexJetRoIAuxContainer>()));
222 ATH_MSG_DEBUG(
"Recorded gFexJetRoIContainer with key " << gSJContainer.
key());
223 ATH_CHECK(gLJContainer.
record(std::make_unique<xAOD::gFexJetRoIContainer>(), std::make_unique<xAOD::gFexJetRoIAuxContainer>()));
224 ATH_MSG_DEBUG(
"Recorded gFexJetRoIContainer with key " << gLJContainer.
key());
225 ATH_CHECK(gScalarEJwojContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
226 ATH_MSG_DEBUG(
"Recorded gFexJetGlobalContainer with key " << gScalarEJwojContainer.
key());
227 ATH_CHECK(gMETComponentsJwojContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
228 ATH_MSG_DEBUG(
"Recorded gFexJetGlobalContainer with key " << gMETComponentsJwojContainer.
key());
229 ATH_CHECK(gMHTComponentsJwojContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
230 ATH_MSG_DEBUG(
"Recorded gFexJetGlobalContainer with key " << gMHTComponentsJwojContainer.
key());
231 ATH_CHECK(gMSTComponentsJwojContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
232 ATH_MSG_DEBUG(
"Recorded gFexJetGlobalContainer with key " << gMSTComponentsJwojContainer.
key());
233 ATH_CHECK(gMETComponentsNoiseCutContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
234 ATH_MSG_DEBUG(
"Recorded gFexJetGlobalContainer with key " << gMETComponentsNoiseCutContainer.
key());
235 ATH_CHECK(gMETComponentsRmsContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
236 ATH_MSG_DEBUG(
"Recorded gFexJetGlobalContainer with key " << gMETComponentsRmsContainer.
key());
237 ATH_CHECK(gScalarENoiseCutContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
238 ATH_MSG_DEBUG(
"Recorded gFexJetGlobalContainer with key " << gScalarENoiseCutContainer.
key());
239 ATH_CHECK(gScalarERmsContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
240 ATH_MSG_DEBUG(
"Recorded gFexJetGlobalContainer with key " << gScalarERmsContainer.
key());
245 ATH_CHECK(gEspressoContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
246 ATH_MSG_DEBUG(
"Recorded gFexJetGlobalContainer with key " << gEspressoContainer.
key());
250 ATH_CHECK(gRistrettoContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
251 ATH_MSG_DEBUG(
"Recorded gFexJetGlobalContainer with key " << gRistrettoContainer.
key());
274 ATH_CHECK(gRhoSliceContainer.
record(std::make_unique<xAOD::gFexJetRoIContainer>(), std::make_unique<xAOD::gFexJetRoIAuxContainer>()));
275 ATH_MSG_DEBUG(
"Recorded gFexJetRoIContainer (out-of-time) with key " << gRhoSliceContainer.
key());
278 ATH_CHECK(gSJSliceContainer.
record(std::make_unique<xAOD::gFexJetRoIContainer>(), std::make_unique<xAOD::gFexJetRoIAuxContainer>()));
279 ATH_MSG_DEBUG(
"Recorded gFexJetRoIContainer (out-of-time) with key " << gSJSliceContainer.
key());
282 ATH_CHECK(gLJSliceContainer.
record(std::make_unique<xAOD::gFexJetRoIContainer>(), std::make_unique<xAOD::gFexJetRoIAuxContainer>()));
283 ATH_MSG_DEBUG(
"Recorded gFexJetRoIContainer (out-of-time) with key " << gLJSliceContainer.
key());
286 ATH_CHECK(gScalarEJwojSliceContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
287 ATH_MSG_DEBUG(
"Recorded gFexGlobalRoIContainer (out-of-time) with key " << gScalarEJwojSliceContainer.
key());
290 ATH_CHECK(gMETComponentsJwojSliceContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
291 ATH_MSG_DEBUG(
"Recorded gFexGlobalRoIContainer (out-of-time) with key " << gMETComponentsJwojSliceContainer.
key());
294 ATH_CHECK(gMHTComponentsJwojSliceContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
295 ATH_MSG_DEBUG(
"Recorded gFexGlobalRoIContainer (out-of-time) with key " << gMHTComponentsJwojSliceContainer.
key());
298 ATH_CHECK(gMSTComponentsJwojSliceContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
299 ATH_MSG_DEBUG(
"Recorded gFexGlobalRoIContainer (out-of-time) with key " << gMSTComponentsJwojSliceContainer.
key());
302 ATH_CHECK(gEspressoSliceContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
303 ATH_MSG_DEBUG(
"Recorded gFexGlobalRoIContainer (out-of-time) with key " << gEspressoSliceContainer.
key());
306 ATH_CHECK(gRistrettoSliceContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
307 ATH_MSG_DEBUG(
"Recorded gFexGlobalRoIContainer (out-of-time) with key " << gRistrettoSliceContainer.
key());
310 ATH_CHECK(gMETComponentsNoiseCutSliceContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
311 ATH_MSG_DEBUG(
"Recorded gFexGlobalRoIContainer (out-of-time) with key " << gMETComponentsNoiseCutSliceContainer.
key());
314 ATH_CHECK(gScalarENoiseCutSliceContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
315 ATH_MSG_DEBUG(
"Recorded gFexGlobalRoIContainer (out-of-time) with key " << gScalarENoiseCutSliceContainer.
key());
318 ATH_CHECK(gMETComponentsRmsSliceContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
319 ATH_MSG_DEBUG(
"Recorded gFexGlobalRoIContainer (out-of-time) with key " << gMETComponentsRmsSliceContainer.
key());
322 ATH_CHECK(gScalarERmsSliceContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
323 ATH_MSG_DEBUG(
"Recorded gFexGlobalRoIContainer (out-of-time) with key " << gScalarERmsSliceContainer.
key());
328 for (
const ROBF* rob : vrobf) {
332 ATH_MSG_DEBUG(
"Starting to decode " << rob->rod_ndata() <<
" ROD words from ROB 0x" << std::hex << rob->rob_source_id());
335 if(rob->rod_ndata() <= 0){
339 const auto dataArray = std::span{rob->rod_data(), rob->rod_ndata()};
344 unsigned int n_words = rob->rod_ndata();
348 constexpr unsigned int ROD_TRAILER_WORDS = 2;
349 if (n_words >= ROD_TRAILER_WORDS) n_words -= ROD_TRAILER_WORDS;
352 for(
unsigned int iWord=0; iWord<n_words; iWord++) {
353 ATH_MSG_DEBUG(
"Raw word 0x" << std::hex << dataArray[iWord] <<
" " << std::bitset<32> (dataArray[iWord]));
360 std::vector<int> global_counter;
361 std::vector<std::array<uint32_t, 3>> JWOJ_MHT;
362 std::vector<std::array<uint32_t, 3>> JWOJ_MST;
363 std::vector<std::array<uint32_t, 3>> JWOJ_MET;
364 std::vector<std::array<uint32_t, 3>> JWOJ_SCALAR;
365 std::vector<std::array<uint32_t, 3>> GESPRESSO;
366 std::vector<std::array<uint32_t, 3>> GRISTRETTO;
367 std::vector<std::array<uint32_t, 3>> NC_MET;
368 std::vector<std::array<uint32_t, 3>> NC_SCALAR;
369 std::vector<std::array<uint32_t, 3>> RMS_MET;
370 std::vector<std::array<uint32_t, 3>> RMS_SCALAR;
372 std::vector<uint32_t> globalSliceNumbers;
375 auto ensureSliceCapacity = [&](
size_t sliceNum) {
376 if (sliceNum >= global_counter.size()) {
377 size_t newSize = sliceNum + 1;
378 global_counter.resize(newSize, 0);
379 JWOJ_MHT.resize(newSize, {0, 0, 0});
380 JWOJ_MST.resize(newSize, {0, 0, 0});
381 JWOJ_MET.resize(newSize, {0, 0, 0});
382 JWOJ_SCALAR.resize(newSize, {0, 0, 0});
383 GESPRESSO.resize(newSize, {0, 0, 0});
384 GRISTRETTO.resize(newSize, {0, 0, 0});
385 NC_MET.resize(newSize, {0, 0, 0});
386 NC_SCALAR.resize(newSize, {0, 0, 0});
387 RMS_MET.resize(newSize, {0, 0, 0});
388 RMS_SCALAR.resize(newSize, {0, 0, 0});
393 while (
index < n_words ) {
394 const uint32_t headerWord = dataArray[
index];
402 ATH_MSG_DEBUG(
"headerWord "<< std::bitset<32> (headerWord) );
404 ATH_MSG_DEBUG(
"headerSize "<< std::bitset<2> (headerSize) );
405 ATH_MSG_DEBUG(
"errorFlags "<< std::bitset<1> (errorFlags) );
408 const uint32_t blockSize = headerSize + dataSize;
409 if ( (
index + blockSize) > n_words ) {
411 std::stringstream sdetail;
412 sdetail <<
"Remaining block size " << (n_words -
index) <<
" is too small for subblock of type " << blockType <<
" with headerSize " << headerSize <<
" and dataSize " << dataSize ;
413 std::stringstream slocation;
414 slocation <<
"0x"<< std::hex << rob->rob_source_id() << std::dec <<
" type:"<<blockType;
415 std::stringstream stitle;
416 stitle <<
"Small subblock size " ;
417 printError(slocation.str(),stitle.str(),MSG::DEBUG,sdetail.str());
428 std::stringstream sdetail;
429 sdetail <<
"L1CaloBsDecoderRun3::decodeGfexTobs: subblock type " << blockType <<
" with dataSize " << dataSize <<
" is not a multiple of " <<
gPos::WORDS_PER_SLICE <<
" words" ;
430 std::stringstream slocation;
431 slocation <<
"0x"<< std::hex << rob->rob_source_id()<< std::dec <<
" type:"<<blockType;
432 std::stringstream stitle;
433 stitle <<
"Wrong dataSize" ;
434 printError(slocation.str(),stitle.str(),MSG::DEBUG,sdetail.str());
444 bool isMet = (blockType >= 0x1 && blockType <= 0x3);
445 bool isJet = (blockType >= 0xA && blockType <= 0xC);
447 for (uint32_t sliceNumber = 0; sliceNumber < numSlices; sliceNumber++) {
450 if (sliceNumber != 0 && !multiSlice) {
455 if ( !isJet && !isMet ) {
456 std::stringstream sdetail;
457 sdetail <<
"gFexByteStreamTool::decodeGfexTobSlice: Invalid block type " << blockType ;
458 std::stringstream slocation;
459 slocation <<
"0x"<< std::hex << rob->rob_source_id();
460 std::stringstream stitle;
461 stitle <<
"Invalid block type" ;
462 printError(slocation.str(),stitle.str(),MSG::DEBUG,sdetail.str());
466 auto& targetRhoContainer = (sliceNumber == 0) ? gRhoContainer : gRhoSliceContainer;
467 auto& targetSJContainer = (sliceNumber == 0) ? gSJContainer : gSJSliceContainer;
468 auto& targetLJContainer = (sliceNumber == 0) ? gLJContainer : gLJSliceContainer;
473 if (isJet && (sliceNumber != 0 || decodeStdTOBs)) {
484 static const SG::AuxElement::Decorator<uint32_t> sliceNumberDec(
"sliceNumber");
489 targetRhoContainer->push_back(std::move(myEDM));
490 targetRhoContainer->back()->initialize(dataArray[
index+iWord],
m_gJ_scale);
491 if (sliceNumber != 0) sliceNumberDec(*targetRhoContainer->back()) = sliceNumber;
496 targetSJContainer->push_back(std::move(myEDM));
497 targetSJContainer->back()->initialize(dataArray[
index+iWord],
m_gJ_scale);
498 if (sliceNumber != 0) sliceNumberDec(*targetSJContainer->back()) = sliceNumber;
503 targetLJContainer->push_back(std::move(myEDM));
505 if (sliceNumber != 0) sliceNumberDec(*targetLJContainer->back()) = sliceNumber;
514 ensureSliceCapacity(sliceNumber);
526 global_counter[sliceNumber]++;
527 if (blockType == 0x1) {JWOJ_MHT[sliceNumber][0] = dataArray[
index+iWord];}
528 if (blockType == 0x2) {JWOJ_MHT[sliceNumber][1] = dataArray[
index+iWord];}
529 if (blockType == 0x3) {JWOJ_MHT[sliceNumber][2] = dataArray[
index+iWord];}
533 if (blockType == 0x1) {JWOJ_MST[sliceNumber][0] = dataArray[
index+iWord];}
534 if (blockType == 0x2) {JWOJ_MST[sliceNumber][1] = dataArray[
index+iWord];}
535 if (blockType == 0x3) {JWOJ_MST[sliceNumber][2] = dataArray[
index+iWord];}
539 if (blockType == 0x1) {JWOJ_MET[sliceNumber][0] = dataArray[
index+iWord];}
540 if (blockType == 0x2) {JWOJ_MET[sliceNumber][1] = dataArray[
index+iWord];}
541 if (blockType == 0x3) {JWOJ_MET[sliceNumber][2] = dataArray[
index+iWord];}
545 if (blockType == 0x1) {JWOJ_SCALAR[sliceNumber][0] = dataArray[
index+iWord];}
546 if (blockType == 0x2) {JWOJ_SCALAR[sliceNumber][1] = dataArray[
index+iWord];}
547 if (blockType == 0x3) {JWOJ_SCALAR[sliceNumber][2] = dataArray[
index+iWord];}
551 if (blockType == 0x1) {GESPRESSO[sliceNumber][0] = dataArray[
index+iWord];}
552 if (blockType == 0x2) {GESPRESSO[sliceNumber][1] = dataArray[
index+iWord];}
553 if (blockType == 0x3) {GESPRESSO[sliceNumber][2] = dataArray[
index+iWord];}
557 if (blockType == 0x1) {GRISTRETTO[sliceNumber][0] = dataArray[
index+iWord];}
558 if (blockType == 0x2) {GRISTRETTO[sliceNumber][1] = dataArray[
index+iWord];}
559 if (blockType == 0x3) {GRISTRETTO[sliceNumber][2] = dataArray[
index+iWord];}
563 if (blockType == 0x1) {NC_MET[sliceNumber][0] = dataArray[
index+iWord];}
564 if (blockType == 0x2) {NC_MET[sliceNumber][1] = dataArray[
index+iWord];}
565 if (blockType == 0x3) {NC_MET[sliceNumber][2] = dataArray[
index+iWord];}
569 if (blockType == 0x1) {NC_SCALAR[sliceNumber][0] = dataArray[
index+iWord];}
570 if (blockType == 0x2) {NC_SCALAR[sliceNumber][1] = dataArray[
index+iWord];}
571 if (blockType == 0x3) {NC_SCALAR[sliceNumber][2] = dataArray[
index+iWord];}
575 if (blockType == 0x1) {RMS_MET[sliceNumber][0] = dataArray[
index+iWord];}
576 if (blockType == 0x2) {RMS_MET[sliceNumber][1] = dataArray[
index+iWord];}
577 if (blockType == 0x3) {RMS_MET[sliceNumber][2] = dataArray[
index+iWord];}
581 if (blockType == 0x1) {RMS_SCALAR[sliceNumber][0] = dataArray[
index+iWord];}
582 if (blockType == 0x2) {RMS_SCALAR[sliceNumber][1] = dataArray[
index+iWord];}
583 if (blockType == 0x3) {RMS_SCALAR[sliceNumber][2] = dataArray[
index+iWord];}
594 for (
size_t slice = 0; slice < global_counter.size(); slice++) {
595 ATH_MSG_DEBUG(
"global_counter[" << slice <<
"] is " << global_counter[slice]);
596 if (global_counter[slice] == 3) {
598 if (slice != 0 && !multiSlice) {
599 global_counter[slice] = 0;
604 if (slice == 0 && !decodeStdTOBs) {
606 fillGlobal(GESPRESSO[slice], 1, gEspressoContainer, slice, 0);
607 fillGlobal(GRISTRETTO[slice], 1, gRistrettoContainer, slice, 0);
609 auto& targetMHTContainer = (slice == 0) ? gMHTComponentsJwojContainer : gMHTComponentsJwojSliceContainer;
610 auto& targetMSTContainer = (slice == 0) ? gMSTComponentsJwojContainer : gMSTComponentsJwojSliceContainer;
611 auto& targetMETContainer = (slice == 0) ? gMETComponentsJwojContainer : gMETComponentsJwojSliceContainer;
612 auto& targetScalarContainer = (slice == 0) ? gScalarEJwojContainer : gScalarEJwojSliceContainer;
613 auto& targetEspressoContainer = (slice == 0) ? gEspressoContainer : gEspressoSliceContainer;
614 auto& targetRistrettoContainer = (slice == 0) ? gRistrettoContainer : gRistrettoSliceContainer;
615 auto& targetNCMETContainer = (slice == 0) ? gMETComponentsNoiseCutContainer : gMETComponentsNoiseCutSliceContainer;
616 auto& targetNCScalarContainer = (slice == 0) ? gScalarENoiseCutContainer : gScalarENoiseCutSliceContainer;
617 auto& targetRMSMETContainer = (slice == 0) ? gMETComponentsRmsContainer : gMETComponentsRmsSliceContainer;
618 auto& targetRMSScalarContainer = (slice == 0) ? gScalarERmsContainer : gScalarERmsSliceContainer;
620 fillGlobal(JWOJ_MHT[slice], 3, targetMHTContainer, slice);
621 fillGlobal(JWOJ_MST[slice], 4, targetMSTContainer, slice);
622 int16_t scalar =
fillGlobal(JWOJ_MET[slice], 2, targetMETContainer, slice);
623 fillGlobal(JWOJ_SCALAR[slice], 1, targetScalarContainer, slice, scalar);
625 fillGlobal(GESPRESSO[slice], 1, targetEspressoContainer, slice, 0);
627 fillGlobal(GRISTRETTO[slice], 1, targetRistrettoContainer, slice, 0);
629 scalar =
fillGlobal(NC_MET[slice], 2, targetNCMETContainer, slice);
630 fillGlobal(NC_SCALAR[slice], 1, targetNCScalarContainer, slice, scalar);
632 scalar =
fillGlobal(RMS_MET[slice], 2, targetRMSMETContainer, slice);
633 fillGlobal(RMS_SCALAR[slice], 1, targetRMSScalarContainer, slice, scalar);
636 global_counter[slice] = 0;
642 return StatusCode::SUCCESS;