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((gMETComponentsJwojmode==ConversionMode::Encoding ?
"Encoding" :
"Decoding") <<
" gMETComponentsJwoj ");
72 ATH_MSG_DEBUG((gMHTComponentsJwojmode==ConversionMode::Encoding ?
"Encoding" :
"Decoding") <<
" gMHTComponentsJwoj ");
79 ATH_MSG_DEBUG((gMSTComponentsJwojmode==ConversionMode::Encoding ?
"Encoding" :
"Decoding") <<
" gMSTComponentsJwoj ");
86 ATH_MSG_DEBUG((gMETComponentsNoiseCutmode==ConversionMode::Encoding ?
"Encoding" :
"Decoding") <<
" gMETComponentsNoiseCut ");
93 ATH_MSG_DEBUG((gMETComponentsRmsmode==ConversionMode::Encoding ?
"Encoding" :
"Decoding") <<
" gMETComponentsRms ");
100 ATH_MSG_DEBUG((gScalarENoiseCutmode==ConversionMode::Encoding ?
"Encoding" :
"Decoding") <<
" gScalarENoiseCut ");
107 ATH_MSG_DEBUG((gScalarERmsmode==ConversionMode::Encoding ?
"Encoding" :
"Decoding") <<
" gScalarERms ");
110 const std::array<ConversionMode,2> modes{gSJmode,gLJmode};
111 if (std::any_of(modes.begin(),modes.end(),[&gRhomode](ConversionMode
m) { return m!=gRhomode; } )) {
113 return StatusCode::FAILURE;
125 return StatusCode::SUCCESS;
150 return StatusCode::FAILURE;
153 return StatusCode::SUCCESS;
164 ATH_CHECK(gRhoContainer.
record(std::make_unique<xAOD::gFexJetRoIContainer>(), std::make_unique<xAOD::gFexJetRoIAuxContainer>()));
165 ATH_MSG_DEBUG(
"Recorded gFexJetRoIContainer with key " << gRhoContainer.
key());
169 ATH_CHECK(gSJContainer.
record(std::make_unique<xAOD::gFexJetRoIContainer>(), std::make_unique<xAOD::gFexJetRoIAuxContainer>()));
170 ATH_MSG_DEBUG(
"Recorded gFexJetRoIContainer with key " << gSJContainer.
key());
174 ATH_CHECK(gLJContainer.
record(std::make_unique<xAOD::gFexJetRoIContainer>(), std::make_unique<xAOD::gFexJetRoIAuxContainer>()));
175 ATH_MSG_DEBUG(
"Recorded gFexJetRoIContainer with key " << gLJContainer.
key());
179 ATH_CHECK(gScalarEJwojContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
180 ATH_MSG_DEBUG(
"Recorded gFexJetGlobalContainer with key " << gScalarEJwojContainer.
key());
184 ATH_CHECK(gMETComponentsJwojContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
185 ATH_MSG_DEBUG(
"Recorded gFexJetGlobalContainer with key " << gMETComponentsJwojContainer.
key());
189 ATH_CHECK(gMHTComponentsJwojContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
190 ATH_MSG_DEBUG(
"Recorded gFexJetGlobalContainer with key " << gMHTComponentsJwojContainer.
key());
194 ATH_CHECK(gMSTComponentsJwojContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
195 ATH_MSG_DEBUG(
"Recorded gFexJetGlobalContainer with key " << gMSTComponentsJwojContainer.
key());
199 ATH_CHECK(gMETComponentsNoiseCutContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
200 ATH_MSG_DEBUG(
"Recorded gFexJetGlobalContainer with key " << gMETComponentsNoiseCutContainer.
key());
204 ATH_CHECK(gMETComponentsRmsContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
205 ATH_MSG_DEBUG(
"Recorded gFexJetGlobalContainer with key " << gMETComponentsRmsContainer.
key());
209 ATH_CHECK(gScalarENoiseCutContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
210 ATH_MSG_DEBUG(
"Recorded gFexJetGlobalContainer with key " << gScalarENoiseCutContainer.
key());
214 ATH_CHECK(gScalarERmsContainer.
record(std::make_unique<xAOD::gFexGlobalRoIContainer>(), std::make_unique<xAOD::gFexGlobalRoIAuxContainer>()));
215 ATH_MSG_DEBUG(
"Recorded gFexJetGlobalContainer with key " << gScalarERmsContainer.
key());
219 for (
const ROBF* rob : vrobf) {
223 ATH_MSG_DEBUG(
"Starting to decode " << rob->rod_ndata() <<
" ROD words from ROB 0x" << std::hex << rob->rob_source_id());
226 if(rob->rod_ndata() <= 0){
230 const auto dataArray =
std::span{rob->rod_data(), rob->rod_ndata()};
235 unsigned int n_words = rob->rod_ndata();
238 for(
unsigned int iWord=0; iWord<
n_words; iWord++) {
239 ATH_MSG_DEBUG(
"Raw word 0x" << std::hex << dataArray[iWord] <<
" " << std::bitset<32> (dataArray[iWord]));
243 int global_counter = 0;
244 std::vector<uint32_t> JWOJ_MHT(3, 0);
245 std::vector<uint32_t> JWOJ_MST(3, 0);
246 std::vector<uint32_t> JWOJ_MET(3, 0);
247 std::vector<uint32_t> JWOJ_SCALAR(3, 0);
248 std::vector<uint32_t> NC_MET(3, 0);
249 std::vector<uint32_t> NC_SCALAR(3, 0);
250 std::vector<uint32_t> RMS_MET(3, 0);
251 std::vector<uint32_t> RMS_SCALAR(3, 0);
263 ATH_MSG_DEBUG(
"headerWord "<< std::bitset<32> (headerWord) );
265 ATH_MSG_DEBUG(
"headerSize "<< std::bitset<2> (headerSize) );
266 ATH_MSG_DEBUG(
"errorFlags "<< std::bitset<1> (errorFlags) );
272 std::stringstream sdetail;
273 sdetail <<
"Remaining block size " << (
n_words -
index) <<
" is too small for subblock of type " <<
blockType <<
" with headerSize " << headerSize <<
" and dataSize " <<
dataSize ;
274 std::stringstream slocation;
275 slocation <<
"0x"<< std::hex << rob->rob_source_id() << std::dec <<
" type:"<<
blockType;
276 std::stringstream stitle;
277 stitle <<
"Small subblock size " ;
289 std::stringstream sdetail;
291 std::stringstream slocation;
292 slocation <<
"0x"<< std::hex << rob->rob_source_id()<< std::dec <<
" type:"<<
blockType;
293 std::stringstream stitle;
294 stitle <<
"Wrong dataSize" ;
309 for (
uint32_t sliceNumber = 0; sliceNumber < numSlices; sliceNumber++) {
310 if (sliceNumber == 0){
311 if ( !isJet && !isMet ) {
313 std::stringstream sdetail;
314 sdetail <<
"gFexByteStreamTool::decodeGfexTobSlice: Invalid block type " <<
blockType ;
315 std::stringstream slocation;
316 slocation <<
"0x"<< std::hex << rob->rob_source_id();
317 std::stringstream stitle;
318 stitle <<
"Invalid block type" ;
337 gRhoContainer->
push_back(std::move(myEDM));
343 gSJContainer->
push_back(std::move(myEDM));
349 gLJContainer->
push_back(std::move(myEDM));
423 if (global_counter == 3) {
425 fillGlobal(JWOJ_MHT, 3, gMHTComponentsJwojContainer);
426 fillGlobal(JWOJ_MST, 4, gMSTComponentsJwojContainer);
428 fillGlobal(JWOJ_SCALAR, 1, gScalarEJwojContainer, scalar);
430 scalar =
fillGlobal(NC_MET, 2, gMETComponentsNoiseCutContainer);
431 fillGlobal(NC_SCALAR, 1, gScalarENoiseCutContainer, scalar);
433 scalar =
fillGlobal(RMS_MET, 2, gMETComponentsRmsContainer);
434 fillGlobal(RMS_SCALAR, 1, gScalarERmsContainer, scalar);
441 return StatusCode::SUCCESS;
458 for (
size_t fpga = 0; fpga < 3; fpga++) {
461 if (
x & 0x00080000) {
x = 0xFFFF0000 |
x; }
462 if (
y & 0x00080000) {
y = 0xFFFF0000 |
y; }
468 ATH_MSG_DEBUG(
" scalar tob, saving " << scalar <<
" in X component");
470 if( sum_y > 0x000FFF) sum_y = 0x000FFF;
471 if( sum_y < 0) sum_y = 0;
474 if (sum_x < -0x0007FF) sum_x = -0x0007FF;
475 if (sum_x > 0x0007FF) sum_x = 0x0007FF;
477 if (sum_y < -0x0007FF) sum_y = -0x0007FF;
478 if (sum_y > 0x0007FF) sum_y = 0x0007FF;
481 ATH_MSG_DEBUG(
" fillGlobal type " <<
type << std::dec <<
" sum_x " << sum_x <<
" sum_y " << sum_y);
485 METword = (sum_y & 0x00000FFF) << 0;
486 METword = METword | (sum_x & 0x00000FFF) << 12;
487 if (sum_y != 0) METword = METword | 0x00000001 << 24;
488 if (sum_x != 0) METword = METword | 0x00000001 << 25;
489 METword = METword | (
type & 0x0000001F) << 26;
494 container->
back()->setWord(METword);
495 container->
back()->setQuantityOne(sum_x);
496 container->
back()->setQuantityTwo(sum_y);
499 container->
back()->setStatusOne(1);
500 container->
back()->setStatusTwo(1);
501 container->
back()->setSaturated(0);
502 container->
back()->setGlobalType(
type);
505 int MET2 = sum_x * sum_x + sum_y * sum_y;
507 if (
MET > 0x000FFF)
MET = 0x000FFF;
517 return StatusCode::SUCCESS;
526 Monitored::Scalar(
"gfexDecoderErrorLocation",location.empty() ? std::string(
"UNKNOWN") : location),