14 #include "eformat/SourceIdentifier.h"
15 #include "eformat/Status.h"
25 const std::string&
name,
37 ATH_MSG_DEBUG((gRhomode==ConversionMode::Encoding ?
"Encoding" :
"Decoding") <<
" gRho ");
44 ATH_MSG_DEBUG((gSJmode==ConversionMode::Encoding ?
"Encoding" :
"Decoding") <<
" gSJ ");
51 ATH_MSG_DEBUG((gLJmode==ConversionMode::Encoding ?
"Encoding" :
"Decoding") <<
" gLJ ");
58 ATH_MSG_DEBUG((gScalarEJwojmode==ConversionMode::Encoding ?
"Encoding" :
"Decoding") <<
" gScalarEJwoj ");
65 ATH_MSG_DEBUG((gEspressomode==ConversionMode::Encoding ?
"Encoding" :
"Decoding") <<
" gEspresso ");
72 ATH_MSG_DEBUG((gMETComponentsJwojmode==ConversionMode::Encoding ?
"Encoding" :
"Decoding") <<
" gMETComponentsJwoj ");
79 ATH_MSG_DEBUG((gMHTComponentsJwojmode==ConversionMode::Encoding ?
"Encoding" :
"Decoding") <<
" gMHTComponentsJwoj ");
86 ATH_MSG_DEBUG((gMSTComponentsJwojmode==ConversionMode::Encoding ?
"Encoding" :
"Decoding") <<
" gMSTComponentsJwoj ");
93 ATH_MSG_DEBUG((gMETComponentsNoiseCutmode==ConversionMode::Encoding ?
"Encoding" :
"Decoding") <<
" gMETComponentsNoiseCut ");
100 ATH_MSG_DEBUG((gMETComponentsRmsmode==ConversionMode::Encoding ?
"Encoding" :
"Decoding") <<
" gMETComponentsRms ");
107 ATH_MSG_DEBUG((gScalarENoiseCutmode==ConversionMode::Encoding ?
"Encoding" :
"Decoding") <<
" gScalarENoiseCut ");
114 ATH_MSG_DEBUG((gScalarERmsmode==ConversionMode::Encoding ?
"Encoding" :
"Decoding") <<
" gScalarERms ");
117 const std::array<ConversionMode,2>
modes{gSJmode,gLJmode};
118 if (std::any_of(
modes.begin(),
modes.end(),[&gRhomode](ConversionMode
m) { return m!=gRhomode; } )) {
120 return StatusCode::FAILURE;
132 return StatusCode::SUCCESS;
157 return StatusCode::FAILURE;
160 return StatusCode::SUCCESS;
171 ATH_CHECK(gRhoContainer.
record(std::make_unique<xAOD::gFexJetRoIContainer>(), std::make_unique<xAOD::gFexJetRoIAuxContainer>()));
172 ATH_MSG_DEBUG(
"Recorded gFexJetRoIContainer with key " << gRhoContainer.
key());
176 ATH_CHECK(gSJContainer.
record(std::make_unique<xAOD::gFexJetRoIContainer>(), std::make_unique<xAOD::gFexJetRoIAuxContainer>()));
177 ATH_MSG_DEBUG(
"Recorded gFexJetRoIContainer with key " << gSJContainer.
key());
181 ATH_CHECK(gLJContainer.
record(std::make_unique<xAOD::gFexJetRoIContainer>(), std::make_unique<xAOD::gFexJetRoIAuxContainer>()));
182 ATH_MSG_DEBUG(
"Recorded gFexJetRoIContainer with key " << gLJContainer.
key());
186 ATH_CHECK(gScalarEJwojContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
187 ATH_MSG_DEBUG(
"Recorded gFexJetGlobalContainer with key " << gScalarEJwojContainer.
key());
191 ATH_CHECK(gEspressoContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
192 ATH_MSG_DEBUG(
"Recorded gFexJetGlobalContainer with key " << gEspressoContainer.
key());
196 ATH_CHECK(gMETComponentsJwojContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
197 ATH_MSG_DEBUG(
"Recorded gFexJetGlobalContainer with key " << gMETComponentsJwojContainer.
key());
201 ATH_CHECK(gMHTComponentsJwojContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
202 ATH_MSG_DEBUG(
"Recorded gFexJetGlobalContainer with key " << gMHTComponentsJwojContainer.
key());
206 ATH_CHECK(gMSTComponentsJwojContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
207 ATH_MSG_DEBUG(
"Recorded gFexJetGlobalContainer with key " << gMSTComponentsJwojContainer.
key());
211 ATH_CHECK(gMETComponentsNoiseCutContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
212 ATH_MSG_DEBUG(
"Recorded gFexJetGlobalContainer with key " << gMETComponentsNoiseCutContainer.
key());
216 ATH_CHECK(gMETComponentsRmsContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
217 ATH_MSG_DEBUG(
"Recorded gFexJetGlobalContainer with key " << gMETComponentsRmsContainer.
key());
221 ATH_CHECK(gScalarENoiseCutContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
222 ATH_MSG_DEBUG(
"Recorded gFexJetGlobalContainer with key " << gScalarENoiseCutContainer.
key());
226 ATH_CHECK(gScalarERmsContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
227 ATH_MSG_DEBUG(
"Recorded gFexJetGlobalContainer with key " << gScalarERmsContainer.
key());
231 for (
const ROBF* rob : vrobf) {
235 ATH_MSG_DEBUG(
"Starting to decode " << rob->rod_ndata() <<
" ROD words from ROB 0x" << std::hex << rob->rob_source_id());
238 if(rob->rod_ndata() <= 0){
242 const auto dataArray =
std::span{rob->rod_data(), rob->rod_ndata()};
247 unsigned int n_words = rob->rod_ndata();
250 for(
unsigned int iWord=0; iWord<
n_words; iWord++) {
251 ATH_MSG_DEBUG(
"Raw word 0x" << std::hex << dataArray[iWord] <<
" " << std::bitset<32> (dataArray[iWord]));
255 int global_counter = 0;
256 std::vector<uint32_t> JWOJ_MHT(3, 0);
257 std::vector<uint32_t> JWOJ_MST(3, 0);
258 std::vector<uint32_t> JWOJ_MET(3, 0);
259 std::vector<uint32_t> JWOJ_SCALAR(3, 0);
261 std::vector<uint32_t> NC_MET(3, 0);
262 std::vector<uint32_t> NC_SCALAR(3, 0);
263 std::vector<uint32_t> RMS_MET(3, 0);
264 std::vector<uint32_t> RMS_SCALAR(3, 0);
276 ATH_MSG_DEBUG(
"headerWord "<< std::bitset<32> (headerWord) );
278 ATH_MSG_DEBUG(
"headerSize "<< std::bitset<2> (headerSize) );
279 ATH_MSG_DEBUG(
"errorFlags "<< std::bitset<1> (errorFlags) );
285 std::stringstream sdetail;
286 sdetail <<
"Remaining block size " << (
n_words -
index) <<
" is too small for subblock of type " <<
blockType <<
" with headerSize " << headerSize <<
" and dataSize " <<
dataSize ;
287 std::stringstream slocation;
288 slocation <<
"0x"<< std::hex << rob->rob_source_id() << std::dec <<
" type:"<<
blockType;
289 std::stringstream stitle;
290 stitle <<
"Small subblock size " ;
302 std::stringstream sdetail;
304 std::stringstream slocation;
305 slocation <<
"0x"<< std::hex << rob->rob_source_id()<< std::dec <<
" type:"<<
blockType;
306 std::stringstream stitle;
307 stitle <<
"Wrong dataSize" ;
322 for (
uint32_t sliceNumber = 0; sliceNumber < numSlices; sliceNumber++) {
323 if (sliceNumber == 0){
324 if ( !isJet && !isMet ) {
326 std::stringstream sdetail;
327 sdetail <<
"gFexByteStreamTool::decodeGfexTobSlice: Invalid block type " <<
blockType ;
328 std::stringstream slocation;
329 slocation <<
"0x"<< std::hex << rob->rob_source_id();
330 std::stringstream stitle;
331 stitle <<
"Invalid block type" ;
350 gRhoContainer->
push_back(std::move(myEDM));
356 gSJContainer->
push_back(std::move(myEDM));
362 gLJContainer->
push_back(std::move(myEDM));
442 if (global_counter == 3) {
444 fillGlobal(JWOJ_MHT, 3, gMHTComponentsJwojContainer);
445 fillGlobal(JWOJ_MST, 4, gMSTComponentsJwojContainer);
447 fillGlobal(JWOJ_SCALAR, 1, gScalarEJwojContainer, scalar);
451 scalar =
fillGlobal(NC_MET, 2, gMETComponentsNoiseCutContainer);
452 fillGlobal(NC_SCALAR, 1, gScalarENoiseCutContainer, scalar);
454 scalar =
fillGlobal(RMS_MET, 2, gMETComponentsRmsContainer);
455 fillGlobal(RMS_SCALAR, 1, gScalarERmsContainer, scalar);
462 return StatusCode::SUCCESS;
481 for (
size_t fpga = 0; fpga < 3; fpga++) {
484 if (
x & 0x00080000) {
x = 0xFFFF0000 |
x; }
485 if (
y & 0x00080000) {
y = 0xFFFF0000 |
y; }
487 if (container.
key() ==
"L1_gScalarEJwoj" &&
y < 0)
y = 0;
493 if (container.
key() ==
"L1_gEspresso" ) {
498 ATH_MSG_DEBUG(
" scalar tob, saving " << scalar <<
" in X component");
500 if( sum_y > 0x000FFF) sum_y = 0x000FFF;
501 if( sum_y < 0) sum_y = 0;
504 if (sum_x < -0x000800) sum_x = -0x000800;
505 if (sum_x > 0x0007FF) sum_x = 0x0007FF;
507 if (sum_y < -0x000800) sum_y = -0x000800;
508 if (sum_y > 0x0007FF) sum_y = 0x0007FF;
511 ATH_MSG_DEBUG(
" fillGlobal type " <<
type << std::dec <<
" sum_x " << sum_x <<
" sum_y " << sum_y);
515 METword = (sum_y & 0x00000FFF) << 0;
516 METword = METword | (sum_x & 0x00000FFF) << 12;
517 if (sum_y != 0) METword = METword | 0x00000001 << 24;
518 if (sum_x != 0) METword = METword | 0x00000001 << 25;
519 METword = METword | (
type & 0x0000001F) << 26;
524 container->
back()->setWord(METword);
525 container->
back()->setQuantityOne(sum_x);
526 container->
back()->setQuantityTwo(sum_y);
529 container->
back()->setStatusOne(1);
530 container->
back()->setStatusTwo(1);
531 container->
back()->setSaturated(0);
532 container->
back()->setGlobalType(
type);
535 int MET2 = sum_x * sum_x + sum_y * sum_y;
537 if (
MET > 0x000FFF)
MET = 0x000FFF;
547 return StatusCode::SUCCESS;
556 Monitored::Scalar(
"gfexDecoderErrorLocation",location.empty() ? std::string(
"UNKNOWN") : location),