197 {
198
199
200
201
202 SG::WriteHandle<xAOD::gFexJetRoIContainer> gRhoContainer(
m_gFexRhoWriteKey, ctx);
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());
205
206
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());
210
211
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());
215
216
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());
220
221
222 SG::WriteHandle<xAOD::gFexGlobalRoIContainer> gEspressoContainer(
m_gEspressoWriteKey, ctx);
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());
225
226
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());
230
231
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());
235
236
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());
240
241
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());
245
246
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());
250
251
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());
255
256
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());
260
261
263
264
265 SG::WriteHandle<xAOD::gFexJetRoIContainer> gRhoSliceContainer;
266 SG::WriteHandle<xAOD::gFexJetRoIContainer> gSJSliceContainer;
267 SG::WriteHandle<xAOD::gFexJetRoIContainer> gLJSliceContainer;
268
269 SG::WriteHandle<xAOD::gFexGlobalRoIContainer> gScalarEJwojSliceContainer;
270 SG::WriteHandle<xAOD::gFexGlobalRoIContainer> gMETComponentsJwojSliceContainer;
271 SG::WriteHandle<xAOD::gFexGlobalRoIContainer> gMHTComponentsJwojSliceContainer;
272 SG::WriteHandle<xAOD::gFexGlobalRoIContainer> gMSTComponentsJwojSliceContainer;
273 SG::WriteHandle<xAOD::gFexGlobalRoIContainer> gEspressoSliceContainer;
274 SG::WriteHandle<xAOD::gFexGlobalRoIContainer> gMETComponentsNoiseCutSliceContainer;
275 SG::WriteHandle<xAOD::gFexGlobalRoIContainer> gScalarENoiseCutSliceContainer;
276 SG::WriteHandle<xAOD::gFexGlobalRoIContainer> gMETComponentsRmsSliceContainer;
277 SG::WriteHandle<xAOD::gFexGlobalRoIContainer> gScalarERmsSliceContainer;
278
279 if (multiSlice) {
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());
283
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());
287
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());
291
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());
295
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());
299
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());
303
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());
307
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());
311
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());
315
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());
319
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());
323
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());
327 }
328
329
330
331 for (
const ROBF* rob : vrobf) {
332
333
334
335 ATH_MSG_DEBUG(
"Starting to decode " << rob->rod_ndata() <<
" ROD words from ROB 0x" << std::hex << rob->rob_source_id());
336
337
338 if(rob->rod_ndata() <= 0){
339 continue;
340 }
341
342 const auto dataArray = std::span{rob->rod_data(), rob->rod_ndata()};
343
344
345
346
347 unsigned int n_words = rob->rod_ndata();
348
349
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]));
352 }
353
354
355
356
357
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;
368
369 std::vector<uint32_t> globalSliceNumbers;
370
371
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});
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});
385 }
386 };
387
389 while ( index < n_words ) {
395
397 ATH_MSG_DEBUG(
"word "<< std::bitset<32> (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) );
403
405 if ( (index + blockSize) > n_words ) {
406
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());
414
415 }
416
418
421
423
424 std::stringstream sdetail;
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());
431
432
434 continue;
435
436 }
437
438
439
442
443 for (uint32_t sliceNumber = 0; sliceNumber < numSlices; sliceNumber++) {
444
445
446 if (sliceNumber != 0 && !multiSlice) {
448 continue;
449 }
450
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());
459 }
460
461
462 auto& targetRhoContainer = (sliceNumber == 0) ? gRhoContainer : gRhoSliceContainer;
463 auto& targetSJContainer = (sliceNumber == 0) ? gSJContainer : gSJSliceContainer;
464 auto& targetLJContainer = (sliceNumber == 0) ? gLJContainer : gLJSliceContainer;
465
467
468 if (isJet) {
469
471 continue;
472 }
473
475 continue;
476 }
477
478
480
481
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;
487 }
488
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;
494 }
495
498 targetLJContainer->push_back(std::move(myEDM));
499 targetLJContainer->back()->initialize(dataArray[index+iWord],
m_gLJ_scale);
500 if (sliceNumber != 0) sliceNumberDec(*targetLJContainer->back()) = sliceNumber;
501 }
502
503 }
504
505
506
507 if (isMet){
508
509 ensureSliceCapacity(sliceNumber);
510
511
513 continue;
514 }
515
517 continue;
518 }
519
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];}
525 }
526
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];}
531 }
532
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];}
537 }
538
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];}
543 }
544
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];}
549 }
550
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];}
555 }
556
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];}
561 }
562
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];}
567 }
568
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];}
573 }
574
575 }
576
577 }
578
580 }
581
582
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) {
586
587 if (slice != 0 && !multiSlice) {
588 global_counter[
slice] = 0;
589 continue;
590 }
591
592
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;
602
603 fillGlobal(JWOJ_MHT[slice], 3, targetMHTContainer, slice);
604 fillGlobal(JWOJ_MST[slice], 4, targetMSTContainer, slice);
606 fillGlobal(JWOJ_SCALAR[slice], 1, targetScalarContainer, slice, scalar);
607
608 fillGlobal(GESPRESSO[slice], 1, targetEspressoContainer, slice, 0);
609
610 scalar =
fillGlobal(NC_MET[slice], 2, targetNCMETContainer, slice);
611 fillGlobal(NC_SCALAR[slice], 1, targetNCScalarContainer, slice, scalar);
612
613 scalar =
fillGlobal(RMS_MET[slice], 2, targetRMSMETContainer, slice);
614 fillGlobal(RMS_SCALAR[slice], 1, targetRMSScalarContainer, slice, scalar);
615
616 global_counter[
slice] = 0;
617 }
618 }
619
620 }
621 }
622 return StatusCode::SUCCESS;
623}
#define ATH_CHECK
Evaluate an expression and check for errors.
OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment ROBF
SG::Decorator< T, ALLOC > Decorator
virtual const std::string & key() const override final
Return the StoreGate ID for the referenced object.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
L1Topo::BlockTypes blockType(const uint32_t word, uint32_t offset=28, uint32_t size=0x0f)
Function to return the block type of a data word from L1Topo.
constexpr unsigned int WORDS_PER_SLICE
constexpr std::array< unsigned int, 4 > GBLOCK_POSITION
constexpr unsigned int BLOCK_TYPE_BIT
constexpr std::array< unsigned int, 2 > GJET_POSITION
constexpr unsigned int DATA_SIZE_MASK
constexpr unsigned int JWOJ_MHT_POSITION
constexpr unsigned int GESPRESSO_POSITION
constexpr unsigned int RMS_MET_POSITION
constexpr unsigned int NC_SCALAR_POSITION
constexpr std::array< unsigned int, 4 > GLOBAL_UNUSED_POSITION
constexpr unsigned int BLOCK_TYPE_MASK
constexpr unsigned int ERROR_FLAG_BIT
constexpr std::array< unsigned int, 2 > TRAILER_POSITION
constexpr unsigned int HEADER_SIZE_MASK
constexpr unsigned int NC_MET_POSITION
constexpr unsigned int HEADER_SIZE_BIT
constexpr unsigned int ERROR_FLAG_MASK
constexpr std::array< unsigned int, 5 > JET_UNUSED_POSITION
constexpr unsigned int GRHO_POSITION
constexpr unsigned int JWOJ_SCALAR_POSITION
constexpr unsigned int JWOJ_MST_POSITION
constexpr unsigned int RMS_SCALAR_POSITION
constexpr unsigned int JWOJ_MET_POSITION
constexpr std::size_t n_words
size_t dataSize(TDA::PayloadIterator start)
Size in bytes of the buffer that is needed to decode next fragment data content.
gFexJetRoI_v1 gFexJetRoI
Define the latest version of the gFexJetRoI class.
setScaleOne setStatusOne setSaturated int16_t