35 ATH_CHECK(gRhomode!=ConversionMode::Undefined);
38 ATH_MSG_DEBUG((gRhomode==ConversionMode::Encoding ?
"Encoding" :
"Decoding") <<
" gRho ");
42 ATH_CHECK(gSJmode!=ConversionMode::Undefined);
45 ATH_MSG_DEBUG((gSJmode==ConversionMode::Encoding ?
"Encoding" :
"Decoding") <<
" gSJ ");
49 ATH_CHECK(gLJmode!=ConversionMode::Undefined);
52 ATH_MSG_DEBUG((gLJmode==ConversionMode::Encoding ?
"Encoding" :
"Decoding") <<
" gLJ ");
56 ATH_CHECK(gScalarEJwojmode!=ConversionMode::Undefined);
59 ATH_MSG_DEBUG((gScalarEJwojmode==ConversionMode::Encoding ?
"Encoding" :
"Decoding") <<
" gScalarEJwoj ");
63 ATH_CHECK(gEspressomode!=ConversionMode::Undefined);
66 ATH_MSG_DEBUG((gEspressomode==ConversionMode::Encoding ?
"Encoding" :
"Decoding") <<
" gEspresso ");
70 ATH_CHECK(gMETComponentsJwojmode!=ConversionMode::Undefined);
73 ATH_MSG_DEBUG((gMETComponentsJwojmode==ConversionMode::Encoding ?
"Encoding" :
"Decoding") <<
" gMETComponentsJwoj ");
77 ATH_CHECK(gMHTComponentsJwojmode!=ConversionMode::Undefined);
80 ATH_MSG_DEBUG((gMHTComponentsJwojmode==ConversionMode::Encoding ?
"Encoding" :
"Decoding") <<
" gMHTComponentsJwoj ");
84 ATH_CHECK(gMSTComponentsJwojmode!=ConversionMode::Undefined);
87 ATH_MSG_DEBUG((gMSTComponentsJwojmode==ConversionMode::Encoding ?
"Encoding" :
"Decoding") <<
" gMSTComponentsJwoj ");
91 ATH_CHECK(gMETComponentsNoiseCutmode!=ConversionMode::Undefined);
94 ATH_MSG_DEBUG((gMETComponentsNoiseCutmode==ConversionMode::Encoding ?
"Encoding" :
"Decoding") <<
" gMETComponentsNoiseCut ");
98 ATH_CHECK(gMETComponentsRmsmode!=ConversionMode::Undefined);
101 ATH_MSG_DEBUG((gMETComponentsRmsmode==ConversionMode::Encoding ?
"Encoding" :
"Decoding") <<
" gMETComponentsRms ");
105 ATH_CHECK(gScalarENoiseCutmode!=ConversionMode::Undefined);
108 ATH_MSG_DEBUG((gScalarENoiseCutmode==ConversionMode::Encoding ?
"Encoding" :
"Decoding") <<
" gScalarENoiseCut ");
112 ATH_CHECK(gScalarERmsmode!=ConversionMode::Undefined);
115 ATH_MSG_DEBUG((gScalarERmsmode==ConversionMode::Encoding ?
"Encoding" :
"Decoding") <<
" gScalarERms ");
149 const std::array<ConversionMode,2> modes{gSJmode,gLJmode};
150 if (std::any_of(modes.begin(),modes.end(),[&gRhomode](ConversionMode m) { return m!=gRhomode; } )) {
152 return StatusCode::FAILURE;
164 return StatusCode::SUCCESS;
203 ATH_CHECK(gRhoContainer.
record(std::make_unique<xAOD::gFexJetRoIContainer>(), std::make_unique<xAOD::gFexJetRoIAuxContainer>()));
204 ATH_MSG_DEBUG(
"Recorded gFexJetRoIContainer with key " << gRhoContainer.
key());
208 ATH_CHECK(gSJContainer.
record(std::make_unique<xAOD::gFexJetRoIContainer>(), std::make_unique<xAOD::gFexJetRoIAuxContainer>()));
209 ATH_MSG_DEBUG(
"Recorded gFexJetRoIContainer with key " << gSJContainer.
key());
213 ATH_CHECK(gLJContainer.
record(std::make_unique<xAOD::gFexJetRoIContainer>(), std::make_unique<xAOD::gFexJetRoIAuxContainer>()));
214 ATH_MSG_DEBUG(
"Recorded gFexJetRoIContainer with key " << gLJContainer.
key());
218 ATH_CHECK(gScalarEJwojContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
219 ATH_MSG_DEBUG(
"Recorded gFexJetGlobalContainer with key " << gScalarEJwojContainer.
key());
223 ATH_CHECK(gEspressoContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
224 ATH_MSG_DEBUG(
"Recorded gFexJetGlobalContainer with key " << gEspressoContainer.
key());
228 ATH_CHECK(gMETComponentsJwojContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
229 ATH_MSG_DEBUG(
"Recorded gFexJetGlobalContainer with key " << gMETComponentsJwojContainer.
key());
233 ATH_CHECK(gMHTComponentsJwojContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
234 ATH_MSG_DEBUG(
"Recorded gFexJetGlobalContainer with key " << gMHTComponentsJwojContainer.
key());
238 ATH_CHECK(gMSTComponentsJwojContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
239 ATH_MSG_DEBUG(
"Recorded gFexJetGlobalContainer with key " << gMSTComponentsJwojContainer.
key());
243 ATH_CHECK(gMETComponentsNoiseCutContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
244 ATH_MSG_DEBUG(
"Recorded gFexJetGlobalContainer with key " << gMETComponentsNoiseCutContainer.
key());
248 ATH_CHECK(gMETComponentsRmsContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
249 ATH_MSG_DEBUG(
"Recorded gFexJetGlobalContainer with key " << gMETComponentsRmsContainer.
key());
253 ATH_CHECK(gScalarENoiseCutContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
254 ATH_MSG_DEBUG(
"Recorded gFexJetGlobalContainer with key " << gScalarENoiseCutContainer.
key());
258 ATH_CHECK(gScalarERmsContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
259 ATH_MSG_DEBUG(
"Recorded gFexJetGlobalContainer with key " << gScalarERmsContainer.
key());
281 ATH_CHECK(gRhoSliceContainer.
record(std::make_unique<xAOD::gFexJetRoIContainer>(), std::make_unique<xAOD::gFexJetRoIAuxContainer>()));
282 ATH_MSG_DEBUG(
"Recorded gFexJetRoIContainer (out-of-time) with key " << gRhoSliceContainer.
key());
285 ATH_CHECK(gSJSliceContainer.
record(std::make_unique<xAOD::gFexJetRoIContainer>(), std::make_unique<xAOD::gFexJetRoIAuxContainer>()));
286 ATH_MSG_DEBUG(
"Recorded gFexJetRoIContainer (out-of-time) with key " << gSJSliceContainer.
key());
289 ATH_CHECK(gLJSliceContainer.
record(std::make_unique<xAOD::gFexJetRoIContainer>(), std::make_unique<xAOD::gFexJetRoIAuxContainer>()));
290 ATH_MSG_DEBUG(
"Recorded gFexJetRoIContainer (out-of-time) with key " << gLJSliceContainer.
key());
293 ATH_CHECK(gScalarEJwojSliceContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
294 ATH_MSG_DEBUG(
"Recorded gFexGlobalRoIContainer (out-of-time) with key " << gScalarEJwojSliceContainer.
key());
297 ATH_CHECK(gMETComponentsJwojSliceContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
298 ATH_MSG_DEBUG(
"Recorded gFexGlobalRoIContainer (out-of-time) with key " << gMETComponentsJwojSliceContainer.
key());
301 ATH_CHECK(gMHTComponentsJwojSliceContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
302 ATH_MSG_DEBUG(
"Recorded gFexGlobalRoIContainer (out-of-time) with key " << gMHTComponentsJwojSliceContainer.
key());
305 ATH_CHECK(gMSTComponentsJwojSliceContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
306 ATH_MSG_DEBUG(
"Recorded gFexGlobalRoIContainer (out-of-time) with key " << gMSTComponentsJwojSliceContainer.
key());
309 ATH_CHECK(gEspressoSliceContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
310 ATH_MSG_DEBUG(
"Recorded gFexGlobalRoIContainer (out-of-time) with key " << gEspressoSliceContainer.
key());
313 ATH_CHECK(gMETComponentsNoiseCutSliceContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
314 ATH_MSG_DEBUG(
"Recorded gFexGlobalRoIContainer (out-of-time) with key " << gMETComponentsNoiseCutSliceContainer.
key());
317 ATH_CHECK(gScalarENoiseCutSliceContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
318 ATH_MSG_DEBUG(
"Recorded gFexGlobalRoIContainer (out-of-time) with key " << gScalarENoiseCutSliceContainer.
key());
321 ATH_CHECK(gMETComponentsRmsSliceContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
322 ATH_MSG_DEBUG(
"Recorded gFexGlobalRoIContainer (out-of-time) with key " << gMETComponentsRmsSliceContainer.
key());
325 ATH_CHECK(gScalarERmsSliceContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
326 ATH_MSG_DEBUG(
"Recorded gFexGlobalRoIContainer (out-of-time) with key " << gScalarERmsSliceContainer.
key());
331 for (
const ROBF* rob : vrobf) {
335 ATH_MSG_DEBUG(
"Starting to decode " << rob->rod_ndata() <<
" ROD words from ROB 0x" << std::hex << rob->rob_source_id());
338 if(rob->rod_ndata() <= 0){
342 const auto dataArray = std::span{rob->rod_data(), rob->rod_ndata()};
347 unsigned int n_words = rob->rod_ndata();
350 for(
unsigned int iWord=0; iWord<n_words; iWord++) {
351 ATH_MSG_DEBUG(
"Raw word 0x" << std::hex << dataArray[iWord] <<
" " << std::bitset<32> (dataArray[iWord]));
358 std::vector<int> global_counter;
359 std::vector<std::array<uint32_t, 3>> JWOJ_MHT;
360 std::vector<std::array<uint32_t, 3>> JWOJ_MST;
361 std::vector<std::array<uint32_t, 3>> JWOJ_MET;
362 std::vector<std::array<uint32_t, 3>> JWOJ_SCALAR;
363 std::vector<std::array<uint32_t, 3>> GESPRESSO;
364 std::vector<std::array<uint32_t, 3>> NC_MET;
365 std::vector<std::array<uint32_t, 3>> NC_SCALAR;
366 std::vector<std::array<uint32_t, 3>> RMS_MET;
367 std::vector<std::array<uint32_t, 3>> RMS_SCALAR;
369 std::vector<uint32_t> globalSliceNumbers;
372 auto ensureSliceCapacity = [&](
size_t sliceNum) {
373 if (sliceNum >= global_counter.size()) {
374 size_t newSize = sliceNum + 1;
375 global_counter.resize(newSize, 0);
376 JWOJ_MHT.resize(newSize, {0, 0, 0});
377 JWOJ_MST.resize(newSize, {0, 0, 0});
378 JWOJ_MET.resize(newSize, {0, 0, 0});
379 JWOJ_SCALAR.resize(newSize, {0, 0, 0});
380 GESPRESSO.resize(newSize, {0, 0, 0});
381 NC_MET.resize(newSize, {0, 0, 0});
382 NC_SCALAR.resize(newSize, {0, 0, 0});
383 RMS_MET.resize(newSize, {0, 0, 0});
384 RMS_SCALAR.resize(newSize, {0, 0, 0});
389 while (
index < n_words ) {
390 const uint32_t headerWord = dataArray[
index];
398 ATH_MSG_DEBUG(
"headerWord "<< std::bitset<32> (headerWord) );
400 ATH_MSG_DEBUG(
"headerSize "<< std::bitset<2> (headerSize) );
401 ATH_MSG_DEBUG(
"errorFlags "<< std::bitset<1> (errorFlags) );
404 const uint32_t blockSize = headerSize + dataSize;
405 if ( (
index + blockSize) > n_words ) {
407 std::stringstream sdetail;
408 sdetail <<
"Remaining block size " << (n_words -
index) <<
" is too small for subblock of type " << blockType <<
" with headerSize " << headerSize <<
" and dataSize " << dataSize ;
409 std::stringstream slocation;
410 slocation <<
"0x"<< std::hex << rob->rob_source_id() << std::dec <<
" type:"<<blockType;
411 std::stringstream stitle;
412 stitle <<
"Small subblock size " ;
413 printError(slocation.str(),stitle.str(),MSG::DEBUG,sdetail.str());
424 std::stringstream sdetail;
425 sdetail <<
"L1CaloBsDecoderRun3::decodeGfexTobs: subblock type " << blockType <<
" with dataSize " << dataSize <<
" is not a multiple of " <<
gPos::WORDS_PER_SLICE <<
" words" ;
426 std::stringstream slocation;
427 slocation <<
"0x"<< std::hex << rob->rob_source_id()<< std::dec <<
" type:"<<blockType;
428 std::stringstream stitle;
429 stitle <<
"Wrong dataSize" ;
430 printError(slocation.str(),stitle.str(),MSG::DEBUG,sdetail.str());
440 bool isMet = (blockType >= 0x1 && blockType <= 0x3);
441 bool isJet = (blockType >= 0xA && blockType <= 0xC);
443 for (uint32_t sliceNumber = 0; sliceNumber < numSlices; sliceNumber++) {
446 if (sliceNumber != 0 && !multiSlice) {
451 if ( !isJet && !isMet ) {
452 std::stringstream sdetail;
453 sdetail <<
"gFexByteStreamTool::decodeGfexTobSlice: Invalid block type " << blockType ;
454 std::stringstream slocation;
455 slocation <<
"0x"<< std::hex << rob->rob_source_id();
456 std::stringstream stitle;
457 stitle <<
"Invalid block type" ;
458 printError(slocation.str(),stitle.str(),MSG::DEBUG,sdetail.str());
462 auto& targetRhoContainer = (sliceNumber == 0) ? gRhoContainer : gRhoSliceContainer;
463 auto& targetSJContainer = (sliceNumber == 0) ? gSJContainer : gSJSliceContainer;
464 auto& targetLJContainer = (sliceNumber == 0) ? gLJContainer : gLJSliceContainer;
484 targetRhoContainer->push_back(std::move(myEDM));
485 targetRhoContainer->back()->initialize(dataArray[
index+iWord],
m_gJ_scale);
486 if (sliceNumber != 0) sliceNumberDec(*targetRhoContainer->back()) = sliceNumber;
491 targetSJContainer->push_back(std::move(myEDM));
492 targetSJContainer->back()->initialize(dataArray[
index+iWord],
m_gJ_scale);
493 if (sliceNumber != 0) sliceNumberDec(*targetSJContainer->back()) = sliceNumber;
498 targetLJContainer->push_back(std::move(myEDM));
500 if (sliceNumber != 0) sliceNumberDec(*targetLJContainer->back()) = sliceNumber;
509 ensureSliceCapacity(sliceNumber);
521 global_counter[sliceNumber]++;
522 if (blockType == 0x1) {JWOJ_MHT[sliceNumber][0] = dataArray[
index+iWord];}
523 if (blockType == 0x2) {JWOJ_MHT[sliceNumber][1] = dataArray[
index+iWord];}
524 if (blockType == 0x3) {JWOJ_MHT[sliceNumber][2] = dataArray[
index+iWord];}
528 if (blockType == 0x1) {JWOJ_MST[sliceNumber][0] = dataArray[
index+iWord];}
529 if (blockType == 0x2) {JWOJ_MST[sliceNumber][1] = dataArray[
index+iWord];}
530 if (blockType == 0x3) {JWOJ_MST[sliceNumber][2] = dataArray[
index+iWord];}
534 if (blockType == 0x1) {JWOJ_MET[sliceNumber][0] = dataArray[
index+iWord];}
535 if (blockType == 0x2) {JWOJ_MET[sliceNumber][1] = dataArray[
index+iWord];}
536 if (blockType == 0x3) {JWOJ_MET[sliceNumber][2] = dataArray[
index+iWord];}
540 if (blockType == 0x1) {JWOJ_SCALAR[sliceNumber][0] = dataArray[
index+iWord];}
541 if (blockType == 0x2) {JWOJ_SCALAR[sliceNumber][1] = dataArray[
index+iWord];}
542 if (blockType == 0x3) {JWOJ_SCALAR[sliceNumber][2] = dataArray[
index+iWord];}
546 if (blockType == 0x1) {GESPRESSO[sliceNumber][0] = dataArray[
index+iWord];}
547 if (blockType == 0x2) {GESPRESSO[sliceNumber][1] = dataArray[
index+iWord];}
548 if (blockType == 0x3) {GESPRESSO[sliceNumber][2] = dataArray[
index+iWord];}
552 if (blockType == 0x1) {NC_MET[sliceNumber][0] = dataArray[
index+iWord];}
553 if (blockType == 0x2) {NC_MET[sliceNumber][1] = dataArray[
index+iWord];}
554 if (blockType == 0x3) {NC_MET[sliceNumber][2] = dataArray[
index+iWord];}
558 if (blockType == 0x1) {NC_SCALAR[sliceNumber][0] = dataArray[
index+iWord];}
559 if (blockType == 0x2) {NC_SCALAR[sliceNumber][1] = dataArray[
index+iWord];}
560 if (blockType == 0x3) {NC_SCALAR[sliceNumber][2] = dataArray[
index+iWord];}
564 if (blockType == 0x1) {RMS_MET[sliceNumber][0] = dataArray[
index+iWord];}
565 if (blockType == 0x2) {RMS_MET[sliceNumber][1] = dataArray[
index+iWord];}
566 if (blockType == 0x3) {RMS_MET[sliceNumber][2] = dataArray[
index+iWord];}
570 if (blockType == 0x1) {RMS_SCALAR[sliceNumber][0] = dataArray[
index+iWord];}
571 if (blockType == 0x2) {RMS_SCALAR[sliceNumber][1] = dataArray[
index+iWord];}
572 if (blockType == 0x3) {RMS_SCALAR[sliceNumber][2] = dataArray[
index+iWord];}
583 for (
size_t slice = 0; slice < global_counter.size(); slice++) {
584 ATH_MSG_DEBUG(
"global_counter[" << slice <<
"] is " << global_counter[slice]);
585 if (global_counter[slice] == 3) {
587 if (slice != 0 && !multiSlice) {
588 global_counter[slice] = 0;
593 auto& targetMHTContainer = (slice == 0) ? gMHTComponentsJwojContainer : gMHTComponentsJwojSliceContainer;
594 auto& targetMSTContainer = (slice == 0) ? gMSTComponentsJwojContainer : gMSTComponentsJwojSliceContainer;
595 auto& targetMETContainer = (slice == 0) ? gMETComponentsJwojContainer : gMETComponentsJwojSliceContainer;
596 auto& targetScalarContainer = (slice == 0) ? gScalarEJwojContainer : gScalarEJwojSliceContainer;
597 auto& targetEspressoContainer = (slice == 0) ? gEspressoContainer : gEspressoSliceContainer;
598 auto& targetNCMETContainer = (slice == 0) ? gMETComponentsNoiseCutContainer : gMETComponentsNoiseCutSliceContainer;
599 auto& targetNCScalarContainer = (slice == 0) ? gScalarENoiseCutContainer : gScalarENoiseCutSliceContainer;
600 auto& targetRMSMETContainer = (slice == 0) ? gMETComponentsRmsContainer : gMETComponentsRmsSliceContainer;
601 auto& targetRMSScalarContainer = (slice == 0) ? gScalarERmsContainer : gScalarERmsSliceContainer;
603 fillGlobal(JWOJ_MHT[slice], 3, targetMHTContainer, slice);
604 fillGlobal(JWOJ_MST[slice], 4, targetMSTContainer, slice);
605 int16_t scalar =
fillGlobal(JWOJ_MET[slice], 2, targetMETContainer, slice);
606 fillGlobal(JWOJ_SCALAR[slice], 1, targetScalarContainer, slice, scalar);
608 fillGlobal(GESPRESSO[slice], 1, targetEspressoContainer, slice, 0);
610 scalar =
fillGlobal(NC_MET[slice], 2, targetNCMETContainer, slice);
611 fillGlobal(NC_SCALAR[slice], 1, targetNCScalarContainer, slice, scalar);
613 scalar =
fillGlobal(RMS_MET[slice], 2, targetRMSMETContainer, slice);
614 fillGlobal(RMS_SCALAR[slice], 1, targetRMSScalarContainer, slice, scalar);
616 global_counter[slice] = 0;
622 return StatusCode::SUCCESS;