ATLAS Offline Software
Loading...
Searching...
No Matches
jFexRoiByteStreamTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5//***************************************************************************
6// jFexRoiByteStreamTool - This tool decodes Run3 jFEX RoI data!
7// -------------------
8// begin : 01 01 2022
9// email : Sergi.Rodriguez@cern.ch
10// ***************************************************************************/
11
13#include "jFexBits.h"
14#include "eformat/SourceIdentifier.h"
15#include "eformat/Status.h"
16
17#include <fstream>
18#include <span>
19
22
23namespace jBits = LVL1::jFEXBits;
24
25struct color {
26 std::string RED ="\033[1;31m";
27 std::string ORANGE ="\033[1;38;5;208m";
28 std::string YELLOW ="\033[1;33m";
29 std::string GREEN ="\033[1;32m";
30 std::string BLUE ="\033[1;34m";
31 std::string PURPLE ="\033[1;35m";
32 std::string END ="\033[0m";
33 std::string B_BLUE ="\033[1;44m";
34 std::string B_PURPLE ="\033[1;45m";
35 std::string B_ORANGE ="\033[1;48;5;208;30m";
36 std::string B_GRAY ="\033[1;100m";
37 std::string B_RED ="\033[1;41m";
38 std::string B_GREEN ="\033[1;42m";
39} const C;
40
41namespace {
42 // Per-(jfex,fpga) bucket of TOB / xTOB raw words for encoder serialisation.
43 // jXE / jTE only have non-empty vectors when fpga is U1 or U4 (firmware constraint).
44 struct FpgaBlock {
45 std::vector<uint32_t> jJ, jLJ, jTau, jEM;
46 std::vector<uint32_t> xjJ, xjLJ, xjTau, xjEM;
47 std::vector<uint32_t> jTE, jXE;
48 void addTob(const xAOD::jFexSRJetRoI& t) { (t.isTOB() ? jJ : xjJ ).push_back(t.tobWord()); }
49 void addTob(const xAOD::jFexLRJetRoI& t) { (t.isTOB() ? jLJ : xjLJ ).push_back(t.tobWord()); }
50 void addTob(const xAOD::jFexTauRoI& t) { (t.isTOB() ? jTau : xjTau).push_back(t.tobWord()); }
51 void addTob(const xAOD::jFexFwdElRoI& t) { (t.isTOB() ? jEM : xjEM ).push_back(t.tobWord()); }
52 void addTob(const xAOD::jFexSumETRoI& t) { jTE.push_back(t.tobWord()); }
53 void addTob(const xAOD::jFexMETRoI& t) { jXE.push_back(t.tobWord()); }
54 };
55
56 // (jfex, fpga) -> bucket. std::map sorts by < so iteration order is deterministic.
57 using FragmentMap = std::map<std::pair<uint32_t,uint32_t>, FpgaBlock>;
58
59 template<typename T>
60 void bucketContainer(const xAOD::TrigComposite& l1, FragmentMap& blocks) {
61 using ContT = DataVector<T>;
62 for (const std::string& name : l1.getObjectNames<ContT>()) {
63 auto link = l1.objectLink<ContT>(name);
64 if (!link.isValid()) continue;
65 const ContT* c = link.getStorableObjectPointer();
66 if (!c) continue;
67 for (const T* tob : *c) {
68 blocks[{tob->jFexNumber(), tob->fpgaNumber()}].addTob(*tob);
69 }
70 }
71 }
72}
73
75 const std::string& name,
76 const IInterface* parent)
77 : base_class(type, name, parent) {}
78
80 // Decoder write keys (BS->xAOD); each one is initialised only if configured.
83 ATH_CHECK(m_jTauWriteKey.initialize(!m_jTauWriteKey.empty()));
87
88 ATH_CHECK(m_l1MenuKey.initialize());
89
90
91 //Reading from CVMFS TOB mapping
93
94 // Initialize monitoring tool if not empty
95 if (!m_monTool.empty()) {
96 ATH_CHECK(m_monTool.retrieve());
97 ATH_MSG_INFO("Logging errors to " << m_monTool.name() << " monitoring tool");
98 m_UseMonitoring = true;
99 }
100
101 return StatusCode::SUCCESS;
102}
103
105
106 // Retrieve the L1 menu configuration
108 ATH_CHECK(l1Menu.isValid());
109
110 try {
111 const auto& thrExtraInfo = l1Menu->thrExtraInfo();
112 const TrigConf::L1ThrExtraInfo_jTAU & thr_jTAU = thrExtraInfo.jTAU();
113 const TrigConf::L1ThrExtraInfo_jJ & thr_jJ = thrExtraInfo.jJ();
114 const TrigConf::L1ThrExtraInfo_jLJ & thr_jLJ = thrExtraInfo.jLJ();
115 const TrigConf::L1ThrExtraInfo_jEM & thr_jEM = thrExtraInfo.jEM();
116 const TrigConf::L1ThrExtraInfo_jTE & thr_jTE = thrExtraInfo.jTE();
117 const TrigConf::L1ThrExtraInfo_jXE & thr_jXE = thrExtraInfo.jXE();
118
119 ATH_CHECK(thr_jTAU.isValid());
120 ATH_CHECK(thr_jJ.isValid() );
121 ATH_CHECK(thr_jLJ.isValid() );
122 ATH_CHECK(thr_jEM.isValid() );
123 ATH_CHECK(thr_jTE.isValid() );
124 ATH_CHECK(thr_jXE.isValid() );
125
126 m_jTauRes = thr_jTAU.resolutionMeV();
127 m_jJRes = thr_jJ.resolutionMeV();
128 m_jLJRes = thr_jLJ.resolutionMeV();
129 m_jEMRes = thr_jEM.resolutionMeV();
130 m_jXERes = thr_jXE.resolutionMeV();
131 m_jTERes = thr_jTE.resolutionMeV();
132
133 } catch (const std::exception& e) {
134 ATH_MSG_ERROR("Exception reading L1Menu: " << e.what());
135 return StatusCode::FAILURE;
136 }
137
138 return StatusCode::SUCCESS;
139
140}
141
142
143// BS->xAOD conversion
144StatusCode jFexRoiByteStreamTool::convertFromBS(const std::vector<const ROBF*>& vrobf, const EventContext& ctx) const {
145
146 //WriteHandle for jFEX EDMs
147
148 //---SRJet EDM
150 ATH_CHECK(jJContainer.record(std::make_unique<xAOD::jFexSRJetRoIContainer>(), std::make_unique<xAOD::jFexSRJetRoIAuxContainer>()));
151 ATH_MSG_DEBUG("Recorded jFexSRJetRoIContainer with key " << jJContainer.key());
152
153 //---LRJet EDM
155 ATH_CHECK(jLJContainer.record(std::make_unique<xAOD::jFexLRJetRoIContainer>(), std::make_unique<xAOD::jFexLRJetRoIAuxContainer>()));
156 ATH_MSG_DEBUG("Recorded jFexLRJetRoIContainer with key " << jLJContainer.key());
157
158 //---Tau EDM
160 ATH_CHECK(jTauContainer.record(std::make_unique<xAOD::jFexTauRoIContainer>(), std::make_unique<xAOD::jFexTauRoIAuxContainer>()));
161 ATH_MSG_DEBUG("Recorded jFexTauRoIContainer with key " << jTauContainer.key());
162
163 //---EM EDM
165 ATH_CHECK(jEMContainer.record(std::make_unique<xAOD::jFexFwdElRoIContainer>(), std::make_unique<xAOD::jFexFwdElRoIAuxContainer>()));
166 ATH_MSG_DEBUG("Recorded jFexFwdElRoIContainer with key " << jEMContainer.key());
167
168 //---SumET EDM
170 ATH_CHECK(jTEContainer.record(std::make_unique<xAOD::jFexSumETRoIContainer>(), std::make_unique<xAOD::jFexSumETRoIAuxContainer>()));
171 ATH_MSG_DEBUG("Recorded jFexSumETRoIContainer with key " << jTEContainer.key());
172
173 //---MET EDM
175 ATH_CHECK(jXEContainer.record(std::make_unique<xAOD::jFexMETRoIContainer>(), std::make_unique<xAOD::jFexMETRoIAuxContainer>()));
176 ATH_MSG_DEBUG("Recorded jFexMETRoIContainer with key " << jXEContainer.key());
177
178
179
180
181 // Iterate over ROBFragments to decode
182 for (const ROBF* rob : vrobf) {
183 // Iterate over ROD words and decode
184
185 ATH_MSG_DEBUG("Starting to decode " << rob->rod_ndata() << " ROD words from ROB 0x" << std::hex << rob->rob_source_id() << std::dec);
186
187 //There is no data to decode.. not even the ROD trailers
188 if(rob->rod_ndata() <= 0){
189 std::stringstream sdetail;
190 sdetail << "Not enough ROB words to read: "<<rob->rod_ndata() ;
191 std::stringstream slocation;
192 slocation << "0x"<< std::hex << rob->rob_source_id();
193 std::stringstream stitle;
194 stitle << "Invalid amount of ROB words" ;
195 printError(slocation.str(),stitle.str(),MSG::WARNING,sdetail.str());
196
197 continue;
198 }
199
200 const auto dataArray = std::span{rob->rod_data(), rob->rod_ndata()};
201 std::vector<uint32_t> vec_words(dataArray.begin(),dataArray.end());
202
203 std::stringstream myPrint;
204
205 myPrint << "jFEX TOB words to decode:"<< std::endl;
206 int aux = 1;
207 for (const uint32_t word : vec_words) {
208 myPrint << aux << " raw word ---> 0x"<< std::hex << word << std::dec << std::endl;
209 aux++;
210 }
211 ATH_MSG_DEBUG(myPrint.str());
212
213 // Starting to loop over the different jFEX blocks
214 bool READ_TOBS = true;
215 // jFEX to ROD trailer position after the ROD trailer
216 unsigned int trailers_pos = rob->rod_ndata() - jBits::ROD_WORDS;
217
218 if(vec_words.size() < (jBits::ROD_WORDS+jBits::jFEX2ROD_WORDS) || trailers_pos < (jBits::ROD_WORDS+jBits::jFEX2ROD_WORDS) ){
219 std::stringstream sdetail;
220 sdetail << "Not enough jFEX TOB words to decode (<4). Number of word to decode: "<<vec_words.size()<< ". Position within the vector: "<<trailers_pos ;
221 std::stringstream slocation;
222 slocation << "0x"<< std::hex << rob->rob_source_id();
223 std::stringstream stitle;
224 stitle << "Less than 4 trailers" ;
225 printError(slocation.str(),stitle.str(),MSG::WARNING,sdetail.str());
226
227 continue;
228 }
229
230 //check ROD error
231 const auto [RODerror] = RODTrailer ( vec_words.at(rob->rod_ndata()-2), vec_words.at(rob->rod_ndata()-1) );
232
233 // if ROD errors return gracefully
234 if(RODerror != 0){
235 bool corTrailer = ((RODerror >> jBits::ROD_ERROR_CORR_TRAILER ) & jBits::ROD_TRAILER_1b);
236 bool payloadCRC = ((RODerror >> jBits::ROD_ERROR_PAYLOAD_CRC ) & jBits::ROD_TRAILER_1b);
237 bool headerCRC = ((RODerror >> jBits::ROD_ERROR_HEADER_CRC ) & jBits::ROD_TRAILER_1b);
238 bool reserved = ((RODerror >> jBits::ROD_ERROR_RESERVED ) & jBits::ROD_TRAILER_1b);
239 bool lenerror = ((RODerror >> jBits::ROD_ERROR_LENGTH_MISMATCH ) & jBits::ROD_TRAILER_1b);
240 bool headmismatch = ((RODerror >> jBits::ROD_ERROR_HEADER_MISMATCH ) & jBits::ROD_TRAILER_1b);
241 bool processerror = ((RODerror >> jBits::ROD_ERROR_PROC_TIMEOUT ) & jBits::ROD_TRAILER_1b);
242
243 std::stringstream sdetail;
244 sdetail << "ROD Trailer Error bits set - 7-bits error word: 0x"<< std::hex <<RODerror << std::dec<< std::endl;
245 sdetail << "Corrective Trailer: "<< corTrailer << std::endl;
246 sdetail << "Payload CRC : "<< payloadCRC << std::endl;
247 sdetail << "Header CRC : "<< headerCRC << std::endl;
248 sdetail << "Reserved (=0) : "<< reserved << std::endl;
249 sdetail << "Length Mismatch : "<< lenerror << std::endl;
250 sdetail << "Header Mismatch : "<< headmismatch << std::endl;
251 sdetail << "Processor timeout : "<< processerror << std::endl;
252 std::stringstream slocation;
253 slocation << "ROD Error";
254
255 //Returning Status code failure, it needs to go to debug stream
256 if( corTrailer ){
257 std::stringstream stitle;
258 stitle << "Corrective Trailer" ;
259 printError(slocation.str(),stitle.str(),MSG::ERROR,stitle.str() + " - "+ sdetail.str());
260 return StatusCode::FAILURE;
261 }
262 if( payloadCRC ){
263 std::stringstream stitle;
264 stitle << "Payload CRC" ;
265 printError(slocation.str(),stitle.str(),MSG::ERROR,stitle.str() + " - "+ sdetail.str());
266 return StatusCode::FAILURE;
267 }
268 if( headerCRC ){
269 std::stringstream stitle;
270 stitle << "Header CRC" ;
271 printError(slocation.str(),stitle.str(),MSG::ERROR,stitle.str() + " - "+ sdetail.str());
272 return StatusCode::FAILURE;
273 }
274 if( lenerror ){
275 std::stringstream stitle;
276 stitle << "Length mismatch" ;
277 printError(slocation.str(),stitle.str(),MSG::ERROR,stitle.str() + " - "+ sdetail.str());
278 return StatusCode::FAILURE;
279 }
280 if( headmismatch ){
281 std::stringstream stitle;
282 stitle << "Header mismatch" ;
283 printError(slocation.str(),stitle.str(),MSG::ERROR,stitle.str() + " - "+ sdetail.str());
284 return StatusCode::FAILURE;
285 }
286 if( processerror ){
287 std::stringstream stitle;
288 stitle << "Processor Timeout" ;
289 printError(slocation.str(),stitle.str(),MSG::ERROR,stitle.str() + " - "+ sdetail.str());
290 return StatusCode::FAILURE;
291 }
292
293 return StatusCode::FAILURE;
294 }
295
296 while(READ_TOBS){
297
298 const auto [payload, fpga, jfex, error] = jFEXtoRODTrailer ( vec_words.at(trailers_pos-2), vec_words.at(trailers_pos-1) );
299 const auto [n_xjJ, n_xjLJ, n_xjTau, n_xjEM] = xTOBCounterTrailer( vec_words.at(trailers_pos-3) );
300 const auto [n_jJ, n_jLJ, n_jTau, n_jEM, n_jTE, n_jXE] = TOBCounterTrailer ( vec_words.at(trailers_pos-4) );
301 unsigned int n_tobs = n_jJ + n_jLJ + n_jTau + n_jEM + n_jTE + n_jXE;
302 unsigned int n_xtobs = n_xjJ + n_xjLJ + n_xjTau + n_xjEM;
303 unsigned int total_tobs = n_tobs+n_xtobs;
304 //printf("----------> trailer_pos:%3d payload:%3d N.Words:%3d fpga:%3d jfex:%3d\n",trailers_pos,payload,total_tobs+jBits::TOB_TRAILERS,fpga,jfex);
305 //printf(" TOBs(0x%08x): jJ:%3d jLJ:%3d jTau:%3d jEM:%3d jTE:%3d jXE:%3d\n",vec_words.at(trailers_pos-4),n_jJ,n_jLJ,n_jTau,n_jEM,n_jTE,n_jXE);
306 //printf("xTOBs(0x%08x): xjJ:%3d xjLJ:%3d xjTau:%3d xjEM:%3d\n",vec_words.at(trailers_pos-3),n_xjJ,n_xjLJ,n_xjTau,n_xjEM);
307
308 // First we need to check if there is a padding word.
309 //Padding wordis when there is an even number in the payload, but odd number of xTOB and TOB.. need to check and remove the extra word.
310 unsigned int paddingWord = 0;
311 if(total_tobs % 2){
312 ATH_MSG_DEBUG("Odd number of TOBs + xTOBs:"<< total_tobs<<", there is a padding word!");
313 paddingWord = 1;
314 }
315
316 if(error != 0){
317
318 bool corTrailer = ((error >> jBits::ERROR_CORR_TRAILER ) & jBits::ROD_TRAILER_1b);
319 bool safemode = ((error >> jBits::ERROR_SAFE_MODE ) & jBits::ROD_TRAILER_1b);
322 bool headmismatch = ((error >> jBits::ERROR_HEADER_MISMATCH ) & jBits::ROD_TRAILER_1b);
323 bool processerror = ((error >> jBits::ERROR_PROC_TIMEOUT ) & jBits::ROD_TRAILER_1b);
324
325 std::stringstream sdetail;
326 sdetail << "jFEX to ROD Trailer Error bits set - 6-bits error word: 0x"<< std::hex <<error << std::dec<< std::endl;
327 sdetail << "Corrective Trailer: "<< corTrailer << std::endl;
328 sdetail << "Safe Mode : "<< safemode << std::endl;
329 sdetail << "Protocol error : "<< proterror << std::endl;
330 sdetail << "Length Mismatch : "<< lenerror << std::endl;
331 sdetail << "Header Mismatch : "<< headmismatch << std::endl;
332 sdetail << "Processor timeout : "<< processerror << std::endl;
333 std::stringstream slocation;
334 slocation << "Error bit set";
335
336 if( corTrailer ){
337 std::stringstream stitle;
338 stitle << "Corrective Trailer" ;
339 printError(slocation.str(),stitle.str(),MSG::ERROR,sdetail.str());
340
341 //Returning Status code failure needs to go to debug stream
342 return StatusCode::FAILURE;
343 }
344 if( safemode ){
345 std::stringstream stitle;
346 stitle << "Safe Mode" ;
347 printError(slocation.str(),stitle.str(),MSG::WARNING,sdetail.str());
348 }
349 if( proterror ){
350 std::stringstream stitle;
351 stitle << "Protocol error" ;
352 printError(slocation.str(),stitle.str(),MSG::WARNING,sdetail.str());
353 }
354 if( lenerror ){
355 std::stringstream stitle;
356 stitle << "Length mismatch" ;
357 printError(slocation.str(),stitle.str(),MSG::DEBUG,sdetail.str());
358 }
359 if( headmismatch ){
360 std::stringstream stitle;
361 stitle << "Header mismatch" ;
362 printError(slocation.str(),stitle.str(),MSG::DEBUG,sdetail.str());
363 }
364 if( processerror ){
365 std::stringstream stitle;
366 stitle << "Processor Timeout" ;
367 printError(slocation.str(),stitle.str(),MSG::DEBUG,sdetail.str());
368 }
369
370 }
371
372 if(payload != (total_tobs + jBits::TOB_TRAILERS + paddingWord)){
373 std::stringstream sdetail;
374 sdetail << "Payload="<< payload<<" is different from TOBs+Trailers+padding words="<< total_tobs + jBits::TOB_TRAILERS + paddingWord <<" in FPGA: "<< fpga << " and jFEX: "<< jfex <<". SKIPPED!" ;
375 std::stringstream slocation;
376 slocation << "jFEX "<< jfex << " FPGA "<< fpga << " in 0x"<< std::hex << rob->rob_source_id();
377 std::stringstream stitle;
378 stitle << "Wrong payload" ;
379 printError(slocation.str(),stitle.str(),MSG::WARNING,sdetail.str());
380
381 //Checking if we can continue decoding data for the rest of FPGAs. No negative positions
382 int neg_positions = trailers_pos - (payload + jBits::TOB_TRAILERS);
383 //If negative, whole event must be discarded!
384 if(neg_positions < 0){
385 std::stringstream sdetail;
386 sdetail << "jFEX TOB decoder has discarded the whole event. Due to a wrong payload cannot continue decoding" ;
387 std::stringstream slocation;
388 slocation << "jFEX "<< jfex << " FPGA "<< fpga << " in 0x"<< std::hex << rob->rob_source_id();
389 std::stringstream stitle;
390 stitle << "Event discarded" ;
391
392 printError(slocation.str(),stitle.str(),MSG::DEBUG,sdetail.str());
393 break;
394 }
395
396 //Jumping to next FPGA
397 trailers_pos -= (payload+jBits::TOB_TRAILERS);
398
399 //Is it 0? then we finish the loop, next event
400 if(trailers_pos == 0) {
401 READ_TOBS = false;
402 }
403 continue;
404 }
405
406 //The minimum number for the payload should be 2 (The TOB/xTOB counters). If lower send an error message
407 if(payload < jBits::TOB_TRAILERS){
408 std::stringstream sdetail;
409 sdetail << "Payload: "<< payload<<" is lower than the expected size (at least" << jBits::TOB_TRAILERS << "trailers)" ;
410 std::stringstream slocation;
411 slocation << "jFEX "<< jfex << " FPGA "<< fpga << " in 0x"<< std::hex << rob->rob_source_id();
412 std::stringstream stitle;
413 stitle << "Event discarded" ;
414
415 printError(slocation.str(),stitle.str(),MSG::WARNING,sdetail.str());
416 break;
417 }
418
419 //removing jFEX to ROD, TOB and xTOB Trailers from trailers_pos (4 positions), possible padding word added on the data to get even number of 32bit words
420 unsigned int tobIndex = trailers_pos - (jBits::jFEX2ROD_WORDS + jBits::TOB_TRAILERS + paddingWord);
421
422 if(paddingWord == 1){
423 ATH_MSG_DEBUG("Padding word: "<< std::hex << vec_words.at(tobIndex) <<std::dec);
424 }
425
427 /************************************************** DECODING xTOBS **************************************************/
428
429 //saving xjEM into the EDM container
430 for(unsigned int i=tobIndex; i>tobIndex-n_xjEM; i--) {
431 const auto [eta, phi ] = getEtaPhi(jfex, fpga, vec_words.at(i-1),"jEM xTOB");
432 jEMContainer->push_back( std::make_unique<xAOD::jFexFwdElRoI>() );
433 jEMContainer->back()->initialize(jfex, fpga, vec_words.at(i-1),0, m_jEMRes, eta, phi);
434 }
435 //removing xjEM counter from TOBs
436 tobIndex -= n_xjEM;
437
438 //saving xjTau into the EDM container
439 for(unsigned int i=tobIndex; i>tobIndex-n_xjTau; i--) {
440 const auto [eta, phi ] = getEtaPhi(jfex, fpga, vec_words.at(i-1),"jTau xTOB");
441 jTauContainer->push_back( std::make_unique<xAOD::jFexTauRoI>() );
442 jTauContainer->back()->initialize(jfex, fpga, vec_words.at(i-1),0, m_jTauRes, eta, phi);
443 }
444 //removing xjTau counter from TOBs
445 tobIndex -= n_xjTau;
446
447 //saving xjLJ into the EDM container
448 /* Aug 2025 - commented out so that we no longer fill jLJ collections. May be resurrected for run4
449 * so am leaving this code commented
450 for(unsigned int i=tobIndex; i>tobIndex-n_xjLJ; i--) {
451 const auto [eta, phi ] = getEtaPhi(jfex, fpga, vec_words.at(i-1),"jLJ xTOB");
452 jLJContainer->push_back( std::make_unique<xAOD::jFexLRJetRoI>() );
453 jLJContainer->back()->initialize(jfex, fpga, vec_words.at(i-1),0, m_jLJRes, eta, phi);
454 } */
455 //removing xjLJ counter from TOBs
456 tobIndex -= n_xjLJ;
457
458 //saving xjJ into the EDM container
459 for(unsigned int i=tobIndex; i>tobIndex-n_xjJ; i--) {
460 const auto [eta, phi ] = getEtaPhi(jfex, fpga, vec_words.at(i-1),"jJ xTOB");
461 jJContainer->push_back( std::make_unique<xAOD::jFexSRJetRoI>() );
462 jJContainer->back()->initialize(jfex, fpga, vec_words.at(i-1),0, m_jJRes, eta, phi);
463 }
464 //removing xjJ counter from TOBs
465 tobIndex -= n_xjJ;
466
467 // skipping TOBs to jump to the next set of data
468 tobIndex -= n_tobs;
469
470 }
471 else {
472 /************************************************** DECODING TOBS **************************************************/
473
474 // skipping extended-TOBs
475 tobIndex -= n_xtobs;
476
477 //saving jXE into the EDM container
478 //Only FPGA U1 and U4 are sent to L1Topo, it cover the full phi
479 if(fpga == jBits::FPGA_U1 || fpga == jBits::FPGA_U4 ){
480 for(unsigned int i=tobIndex; i>tobIndex-n_jXE; i--) {
481 jXEContainer->push_back( std::make_unique<xAOD::jFexMETRoI>() );
482 jXEContainer->back()->initialize(jfex, fpga, vec_words.at(i-1), m_jXERes);
483 }
484 }
485 //removing jXE counter from TOBs
486 tobIndex -= n_jXE;
487
488 //saving jTE into the EDM container
489 //Only FPGA U1 and U4 are sent to L1Topo, it cover the full phi
490 if(fpga == jBits::FPGA_U1 || fpga == jBits::FPGA_U4 ) {
491 for(unsigned int i=tobIndex; i>tobIndex-n_jTE; i--) {
492 jTEContainer->push_back( std::make_unique<xAOD::jFexSumETRoI>() );
493 jTEContainer->back()->initialize(jfex, fpga, vec_words.at(i-1), m_jTERes);
494 }
495 }
496 //removing jTE counter from TOBs
497 tobIndex -= n_jTE;
498
499 //saving jEM into the EDM container
500 for(unsigned int i=tobIndex; i>tobIndex-n_jEM; i--) {
501 const auto [eta, phi ] = getEtaPhi(jfex, fpga, vec_words.at(i-1),"jEM TOB");
502 jEMContainer->push_back( std::make_unique<xAOD::jFexFwdElRoI>() );
503 jEMContainer->back()->initialize(jfex, fpga, vec_words.at(i-1),1, m_jEMRes, eta, phi);
504 }
505 //removing jEM counter from TOBs
506 tobIndex -= n_jEM;
507
508 //saving jTau into the EDM container
509 for(unsigned int i=tobIndex; i>tobIndex-n_jTau; i--) {
510 const auto [eta, phi ] = getEtaPhi(jfex, fpga, vec_words.at(i-1),"jTau TOB");
511 jTauContainer->push_back( std::make_unique<xAOD::jFexTauRoI>() );
512 jTauContainer->back()->initialize(jfex, fpga, vec_words.at(i-1),1, m_jTauRes, eta, phi);
513 }
514 //removing jTau counter from TOBs
515 tobIndex -= n_jTau;
516
517 //saving jLJ into the EDM container
518 for(unsigned int i=tobIndex; i>tobIndex-n_jLJ; i--) {
519 const auto [eta, phi ] = getEtaPhi(jfex, fpga, vec_words.at(i-1),"jLJ TOB");
520 jLJContainer->push_back( std::make_unique<xAOD::jFexLRJetRoI>() );
521 jLJContainer->back()->initialize(jfex, fpga, vec_words.at(i-1),1, m_jLJRes, eta, phi);
522 }
523 //removing jLJ counter from TOBs
524 tobIndex -= n_jLJ;
525
526 //saving jJ into the EDM container
527 for(unsigned int i=tobIndex; i>tobIndex-n_jJ; i--) {
528 const auto [eta, phi ] = getEtaPhi(jfex, fpga, vec_words.at(i-1),"jJ TOB");
529 jJContainer->push_back( std::make_unique<xAOD::jFexSRJetRoI>() );
530 jJContainer->back()->initialize(jfex, fpga, vec_words.at(i-1),1, m_jJRes, eta, phi);
531 }
532 //removing jJ counter from TOBs
533 tobIndex -= n_jJ;
534 }
535 //moving trailer position index to the next jFEX data block
536 trailers_pos -= (payload + jBits::jFEX2ROD_WORDS);
537
538 if(trailers_pos != tobIndex){
539 std::stringstream sdetail;
540 sdetail << "Something went wrong decoding jFEX BS data. Trailer position: " << trailers_pos << " should match the TOB index position:" << tobIndex ;
541 std::stringstream slocation;
542 slocation << "jFEX "<< jfex << " FPGA "<< fpga << " in 0x"<< std::hex << rob->rob_source_id();
543 std::stringstream stitle;
544 stitle << "Wrong amount of words" ;
545
546 printError(slocation.str(),stitle.str(),MSG::ERROR,sdetail.str());
547
548 return StatusCode::FAILURE;
549 }
550
551
552 if(trailers_pos == 0){
553 READ_TOBS = false;
554 }
555 }
556 }
557
558 return StatusCode::SUCCESS;
559}
560
561
562// Unpack number of TOBs in Trailer "TOB,XTOB Counter Trailer"
563std::array<uint32_t,6> jFexRoiByteStreamTool::TOBCounterTrailer (uint32_t word) const {
564
565 uint32_t jJ = ((word >> jBits::jJ_TOB_COUNTS ) & jBits::TOB_COUNTS_6b);
566 uint32_t jLJ = ((word >> jBits::jLJ_TOB_COUNTS ) & jBits::TOB_COUNTS_6b);
567 uint32_t jTau = ((word >> jBits::jTau_TOB_COUNTS) & jBits::TOB_COUNTS_6b);
568 uint32_t jEM = ((word >> jBits::jEM_TOB_COUNTS ) & jBits::TOB_COUNTS_6b);
569 uint32_t jTE = ((word >> jBits::jTE_TOB_COUNTS ) & jBits::TOB_COUNTS_1b);
570 uint32_t jXE = ((word >> jBits::jXE_TOB_COUNTS ) & jBits::TOB_COUNTS_1b);
571 //uint32_t TSM = ((word ) & jBits::TOB_COUNTS_1b); // Trigger Safe Mode. Not used for now, maybe is needed in the future
572
573 std::stringstream sdetail;
574 sdetail << "TOB Counter Trailer. Word: 0x"<< std::hex <<word << std::dec << std::endl;
575 sdetail << "jJ Item : "<< jJ << std::endl;
576 sdetail << "jLJ Item : "<< jLJ << std::endl;
577 sdetail << "jTau Item : "<< jTau << std::endl;
578 sdetail << "jEM Item : "<< jEM << std::endl;
579 sdetail << "jTE Item : "<< jTE << std::endl;
580 sdetail << "jXE Item : "<< jXE << std::endl;
581 ATH_MSG_DEBUG(sdetail.str());
582
583 return {jJ,jLJ,jTau,jEM,jTE,jXE};
584
585}
586
587// Unpack number of xTOBs in Trailer "TOB,XTOB Counter Trailer"
588std::array<uint32_t,4> jFexRoiByteStreamTool::xTOBCounterTrailer (uint32_t word) const {
589
590 uint32_t xjJ = ((word >> jBits::jJ_TOB_COUNTS ) & jBits::TOB_COUNTS_6b);
591 uint32_t xjLJ = ((word >> jBits::jLJ_TOB_COUNTS ) & jBits::TOB_COUNTS_6b);
592 uint32_t xjTau = ((word >> jBits::jTau_TOB_COUNTS) & jBits::TOB_COUNTS_6b);
593 uint32_t xjEM = ((word >> jBits::jEM_TOB_COUNTS ) & jBits::TOB_COUNTS_6b);
594
595 std::stringstream sdetail;
596 sdetail << "xTOB Counter Trailer. Word: 0x"<< std::hex <<word << std::dec << std::endl;
597 sdetail << "xjJ Item : "<< xjJ << std::endl;
598 sdetail << "xjLJ Item : "<< xjLJ << std::endl;
599 sdetail << "xjTau Item : "<< xjTau << std::endl;
600 sdetail << "xjEM Item : "<< xjEM << std::endl;
601 ATH_MSG_DEBUG(sdetail.str());
602
603 return {xjJ,xjLJ,xjTau,xjEM};
604
605}
606
607// Unpack jFEX to ROD Trailer
608std::array<uint32_t,4> jFexRoiByteStreamTool::jFEXtoRODTrailer (uint32_t word0, uint32_t word1) const {
609
610 uint32_t payload = ((word0 >> jBits::PAYLOAD_ROD_TRAILER ) & jBits::ROD_TRAILER_16b);
611 uint32_t fpga = ((word0 >> jBits::FPGA_ROD_TRAILER ) & jBits::ROD_TRAILER_2b );
612 uint32_t jfex = ((word0 >> jBits::jFEX_ROD_TRAILER ) & jBits::ROD_TRAILER_4b );
613 uint32_t ROslice = ((word0 >> jBits::RO_ROD_TRAILER ) & jBits::ROD_TRAILER_4b );
614 uint32_t TSN = ((word0 >> jBits::TSN_ROD_TRAILER ) & jBits::ROD_TRAILER_4b );
615
616 uint32_t error = ((word1 >> jBits::ERROR_ROD_TRAILER ) & jBits::ROD_TRAILER_6b );
617 uint32_t CRC = ((word1 >> jBits::CRC_ROD_TRAILER ) & jBits::ROD_TRAILER_20b);
618
619
620 std::stringstream sdetail;
621 sdetail << "jFEX to ROD Trailer. Word0: 0x"<< std::hex <<word0 << " and Word1: 0x"<< word1 << std::endl;
622 sdetail << "Payload (from word0): "<< payload << std::endl;
623 sdetail << "FPGA (from word0): "<< fpga << std::endl;
624 sdetail << "jFEX (from word0): "<< jfex << std::endl;
625 sdetail << "RO slice (from word0): "<< ROslice << std::endl;
626 sdetail << "TSN (from word0): "<< TSN << std::endl;
627 sdetail << "Error (from word1): "<< error << std::endl;
628 sdetail << "CRC (from word1): "<< CRC << std::dec << std::endl;
629
630 ATH_MSG_DEBUG(sdetail.str());
631
632 return {payload, fpga, jfex, error};
633
634}
635
636// Unpack ROD Trailer
637std::array<uint32_t,1> jFexRoiByteStreamTool::RODTrailer (uint32_t /*word0*/, uint32_t word1) const {
638
639 uint32_t error = ((word1 >> jBits::ERROR_ROD_TRAILER ) & jBits::ROD_TRAILER_7b );
640
641 //return an array since we can implement more features in the future
642 return {error};
643
644}
645
646
647// Pack TOB counts into "TOB Counter Trailer" (inverse of TOBCounterTrailer)
648uint32_t jFexRoiByteStreamTool::buildTOBCounterTrailer(uint32_t n_jJ, uint32_t n_jLJ, uint32_t n_jTau,
649 uint32_t n_jEM, uint32_t has_jTE, uint32_t has_jXE) const {
650 uint32_t word = 0;
651 word |= (n_jJ & jBits::TOB_COUNTS_6b) << jBits::jJ_TOB_COUNTS;
652 word |= (n_jLJ & jBits::TOB_COUNTS_6b) << jBits::jLJ_TOB_COUNTS;
653 word |= (n_jTau & jBits::TOB_COUNTS_6b) << jBits::jTau_TOB_COUNTS;
654 word |= (n_jEM & jBits::TOB_COUNTS_6b) << jBits::jEM_TOB_COUNTS;
655 word |= (has_jTE & jBits::TOB_COUNTS_1b) << jBits::jTE_TOB_COUNTS;
656 word |= (has_jXE & jBits::TOB_COUNTS_1b) << jBits::jXE_TOB_COUNTS;
657 return word;
658}
659
660
661// Pack xTOB counts into "xTOB Counter Trailer" (inverse of xTOBCounterTrailer)
662uint32_t jFexRoiByteStreamTool::buildxTOBCounterTrailer(uint32_t n_xjJ, uint32_t n_xjLJ,
663 uint32_t n_xjTau, uint32_t n_xjEM) const {
664 uint32_t word = 0;
665 word |= (n_xjJ & jBits::TOB_COUNTS_6b) << jBits::jJ_TOB_COUNTS;
666 word |= (n_xjLJ & jBits::TOB_COUNTS_6b) << jBits::jLJ_TOB_COUNTS;
667 word |= (n_xjTau & jBits::TOB_COUNTS_6b) << jBits::jTau_TOB_COUNTS;
668 word |= (n_xjEM & jBits::TOB_COUNTS_6b) << jBits::jEM_TOB_COUNTS;
669 return word;
670}
671
672
673// Pack jFEX-to-ROD trailer (inverse of jFEXtoRODTrailer).
674// ROslice / TSN (in word0) and error / CRC (in word1) are left at 0; round-trip
675// decoder does not use them for histogram comparison.
676std::array<uint32_t,2> jFexRoiByteStreamTool::buildjFEXtoRODTrailer(uint32_t payload, uint32_t fpga,
677 uint32_t jfex) const {
678 uint32_t word0 = 0;
682 uint32_t word1 = 0;
683 return {word0, word1};
684}
685
686
687// Unpack jFEX to ROD Header
688void jFexRoiByteStreamTool::jFEXtoRODHeader (uint32_t /*word0*/, uint32_t /*word1*/) const {
689
690 //std::cout << "jFEXtoRODHeader: word0 0x" << std::hex << word0 << std::dec << std::endl;
691 //std::cout << "jFEXtoRODHeader: word1 0x" << std::hex << word1 << std::dec << std::endl;
692
693 //std::cout << "\tWord0 : " << std::bitset<32>(word0) << std::endl;
694 //std::cout << "\tWord1 : " << std::bitset<32>(word1) << std::endl;
695
696
697 //std::cout << "\tWord0 L1Calo: " << ((word0 >> jBits::L1CALO_STREAM_ID_ROD_HEADER ) & jBits::ROD_HEADER_8b ) << std::endl;
698 //std::cout << "\t\t L1Calo SLOT: " << ((word0 >> (jBits::L1CALO_STREAM_ID_ROD_HEADER + jBits::L1CALO_STREAM_ID_SLOT_ROD_HEADER) ) & 4 ) << std::endl;
699 //std::cout << "\t\t L1Calo FPGA: " << ((word0 >> (jBits::L1CALO_STREAM_ID_ROD_HEADER + jBits::L1CALO_STREAM_ID_FPGA_ROD_HEADER) ) & 2 ) << std::endl;
700 //std::cout << "\t\t L1Calo INFO: " << ((word0 >> (jBits::L1CALO_STREAM_ID_ROD_HEADER + jBits::L1CALO_STREAM_ID_INFO_ROD_HEADER) ) & 2 ) << std::endl;
701 //std::cout << "\tWord0 BCN : " << ((word0 >> jBits::BCN_ROD_HEADER ) & jBits::ROD_HEADER_12b ) << std::endl;
702 //std::cout << "\tWord0 CRC : " << ((word0 >> jBits::CRC_ROD_HEADER ) & jBits::ROD_HEADER_9b ) << std::endl;
703 //std::cout << "\tWord0 Vers : " << ((word0 >> jBits::VERS_ROD_HEADER ) & jBits::ROD_HEADER_3b ) << std::endl;
704
705 //std::cout << "\tWord1 L1ID : " << ((word1 >> jBits::L1ID_ROD_HEADER ) & jBits::ROD_HEADER_24b ) << std::endl;
706 //std::cout << "\tWord1 ECRID : " << ((word1 >> jBits::ECRID_ROD_HEADER ) & jBits::ROD_HEADER_8b ) << std::endl;
707
708
709
710}
711
712
713StatusCode jFexRoiByteStreamTool::ReadfromFile(const std::string & fileName){
714
715 std::string myline;
716
717 //openning file with ifstream
718 std::ifstream myfile(fileName);
719
720 if ( !myfile.is_open() ){
721 ATH_MSG_ERROR("Could not open file:" << fileName);
722 return StatusCode::FAILURE;
723 }
724
725 //loading the mapping information
726 while ( std::getline (myfile, myline) ) {
727
728 //removing the header of the file (it is just information!)
729 if(myline[0] == '#') continue;
730
731 //Splitting myline in different substrings
732 std::stringstream oneLine(myline);
733
734 //reading elements
735 std::vector<float> elements;
736 std::string element;
737 while(std::getline(oneLine, element, ' '))
738 {
739 elements.push_back(std::stof(element));
740 }
741
742 // It should have 6 elements
743 // ordered as: jfex fpga localEta localPhi eta phi
744 if(elements.size() != 6){
745 ATH_MSG_ERROR("Unexpected number of elemennts (6 expected) in file: "<< fileName);
746 myfile.close();
747 return StatusCode::FAILURE;
748 }
749 // building array of < eta, phi >
750 std::array<float,2> aux_arr{ {elements.at(4),elements.at(5)} };
751
752 //filling the map with the hash given by mapIndex()
753 m_TobPos_map[ mapIndex(elements.at(0),elements.at(1),elements.at(2),elements.at(3)) ] = aux_arr;
754
755 }
756 myfile.close();
757
758 return StatusCode::SUCCESS;
759}
760
761constexpr unsigned int jFexRoiByteStreamTool::mapIndex(unsigned int jfex, unsigned int fpga, unsigned int iEta, unsigned int iPhi) {
762 // values from hardware: jfex=[0,5] 4 bits, fpga=[0,3] 4 bits, ieta=[0,24] 8 bits, iphi=[0,15] 4 bits
763 return (jfex << 16) | (fpga << 12) | (iEta << 4) | iPhi;
764}
765
766std::array<uint8_t,2> jFexRoiByteStreamTool::unpackLocalCoords (uint32_t word) const{
767
768 uint8_t iEta = (word >> s_etaBit) & s_etaMask;
769 uint8_t iPhi = (word >> s_phiBit) & s_phiMask;
770
771 return {iEta, iPhi};
772
773}
774
775std::array<float,2> jFexRoiByteStreamTool::getEtaPhi (unsigned int jfex, unsigned int fpga, uint32_t word, const char* obj = "") const{
776
777 const auto [iEta, iPhi] = unpackLocalCoords(word);
778 unsigned int index = mapIndex(jfex, fpga, iEta, iPhi);
779
780 auto it = m_TobPos_map.find(index);
781 if(it == m_TobPos_map.end()){
782 //This should be a WARNING.. masked until jFEX firmware bug is fixed
783 ATH_MSG_DEBUG("No index found for "<< obj <<" word, jFex:"<<jfex << " Fpga:"<<fpga<< " iEta:"<<+iEta<< " iPhi:"<<+iPhi<< " for 32-bit word: 0x"<<std::hex<<word<<std::dec);
784 return {-99, -99};
785 }
786
787 //returns an std::array<float,2> {eta, phi}
788 return it->second;
789
790}
791
793StatusCode jFexRoiByteStreamTool::convertToBS(std::vector<WROBF*>& vrobf,
795 const EventContext& eventContext) {
796
797 FragmentMap blocks;
798 if (tc && !tc->empty()) {
799 const xAOD::TrigComposite& l1 = *tc->at(0);
800 bucketContainer<xAOD::jFexSRJetRoI >(l1, blocks);
801 bucketContainer<xAOD::jFexLRJetRoI >(l1, blocks);
802 bucketContainer<xAOD::jFexTauRoI >(l1, blocks);
803 bucketContainer<xAOD::jFexFwdElRoI >(l1, blocks);
804 bucketContainer<xAOD::jFexMETRoI >(l1, blocks);
805 bucketContainer<xAOD::jFexSumETRoI >(l1, blocks);
806 }
807
808 std::vector<uint32_t> words;
809 for (const auto& [key, blk] : blocks) {
810 const uint32_t jfex = key.first;
811 const uint32_t fpga = key.second;
812
813 const uint32_t n_jJ = blk.jJ.size();
814 const uint32_t n_jLJ = blk.jLJ.size();
815 const uint32_t n_jTau = blk.jTau.size();
816 const uint32_t n_jEM = blk.jEM.size();
817 const uint32_t n_jTE = blk.jTE.size();
818 const uint32_t n_jXE = blk.jXE.size();
819 const uint32_t n_xjJ = blk.xjJ.size();
820 const uint32_t n_xjLJ = blk.xjLJ.size();
821 const uint32_t n_xjTau = blk.xjTau.size();
822 const uint32_t n_xjEM = blk.xjEM.size();
823
824 const uint32_t total_tobs = n_jJ + n_jLJ + n_jTau + n_jEM + n_jTE + n_jXE
825 + n_xjJ + n_xjLJ + n_xjTau + n_xjEM;
826 const uint32_t paddingWord = (total_tobs % 2 == 0) ? 0 : 1;
827 const uint32_t payload = total_tobs + jBits::TOB_TRAILERS + paddingWord;
828
829 // Layout (low → high addr), reversing the decoder walk:
830 // jJ, jLJ, jTau, jEM, jTE, jXE, xjJ, xjLJ, xjTau, xjEM, [pad],
831 // TOB-counter, xTOB-counter, jFEX-to-ROD w0, jFEX-to-ROD w1
832 // Decoder (TOB mode) does `tobIndex -= n_xtobs` first, then reads jXE → jJ
833 // going downwards, so xTOBs sit at high addresses, just below the trailers.
834 for (uint32_t w : blk.jJ) words.push_back(w);
835 for (uint32_t w : blk.jLJ) words.push_back(w);
836 for (uint32_t w : blk.jTau) words.push_back(w);
837 for (uint32_t w : blk.jEM) words.push_back(w);
838 for (uint32_t w : blk.jTE) words.push_back(w);
839 for (uint32_t w : blk.jXE) words.push_back(w);
840 for (uint32_t w : blk.xjJ) words.push_back(w);
841 for (uint32_t w : blk.xjLJ) words.push_back(w);
842 for (uint32_t w : blk.xjTau) words.push_back(w);
843 for (uint32_t w : blk.xjEM) words.push_back(w);
844 if (paddingWord) words.push_back(0);
845
846 words.push_back(buildTOBCounterTrailer (n_jJ, n_jLJ, n_jTau, n_jEM,
847 n_jTE > 0, n_jXE > 0));
848 words.push_back(buildxTOBCounterTrailer(n_xjJ, n_xjLJ, n_xjTau, n_xjEM));
849 const auto rod = buildjFEXtoRODTrailer(payload, fpga, jfex);
850 words.push_back(rod[0]);
851 words.push_back(rod[1]);
852 }
853
854 // ROD trailer (decoder reads only 7-bit error in word1 — write 0)
855 words.push_back(0);
856 words.push_back(0);
857
858 clearCache(eventContext);
859 uint32_t* data = newRodData(eventContext, words.size());
860 std::copy(words.begin(), words.end(), data);
861
862 // jFex packs all 24 FPGA blocks (6 modules × 4 FPGAs) into a single ROB.
863 eformat::helper::SourceIdentifier sid(eformat::TDAQ_CALO_FEAT_EXTRACT_ROI, 0x2000);
864 vrobf.push_back(newRobFragment(eventContext, sid.code(), words.size(), data, 0));
865
866 return StatusCode::SUCCESS;
867}
868
869
870void jFexRoiByteStreamTool::printError(const std::string& location, const std::string& title, MSG::Level type, const std::string& detail) const{
871
872 if(m_UseMonitoring){
874 Monitored::Scalar("jfexDecoderErrorLocation",location.empty() ? std::string("UNKNOWN") : location),
875 Monitored::Scalar("jfexDecoderErrorTitle" ,title.empty() ? std::string("UNKNOWN") : title)
876 );
877 }
878 else {
879 msg() << type << detail << endmsg;
880 }
881}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment ROBF
void printError()
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
static Double_t tc
OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment WROBF
static const Attributes_t empty
Derived DataVector<T>.
Definition DataVector.h:795
Group of local monitoring quantities and retain correlation when filling histograms
Declare a monitored scalar variable.
static std::string find_calib_file(const std::string &logical_file_name)
virtual bool isValid() override final
Can the handle be successfully dereferenced?
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.
unsigned int resolutionMeV() const
Gaudi::Property< bool > m_convertExtendedTOBs
uint32_t buildxTOBCounterTrailer(uint32_t n_xjJ, uint32_t n_xjLJ, uint32_t n_xjTau, uint32_t n_xjEM) const
virtual StatusCode convertFromBS(const std::vector< const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment * > &vrobf, const EventContext &eventContext) const override
BS->xAOD conversion.
static constexpr unsigned int mapIndex(unsigned int jfex, unsigned int fpga, unsigned int iEta, unsigned int iPhi)
virtual StatusCode initialize() override
std::array< float, 2 > getEtaPhi(unsigned int jfex, unsigned int fpga, uint32_t word, const char *obj) const
std::array< uint32_t, 4 > jFEXtoRODTrailer(uint32_t word0, uint32_t word1) const
SG::WriteHandleKey< xAOD::jFexSumETRoIContainer > m_jTEWriteKey
void printError(const std::string &location, const std::string &title, MSG::Level type, const std::string &detail) const
{map index, {eta,phi}}
SG::ReadHandleKey< TrigConf::L1Menu > m_l1MenuKey
SG::WriteHandleKey< xAOD::jFexSRJetRoIContainer > m_jJWriteKey
SG::WriteHandleKey< xAOD::jFexFwdElRoIContainer > m_jEMWriteKey
std::unordered_map< unsigned int, std::array< float, 2 > > m_TobPos_map
virtual StatusCode start() override
SG::WriteHandleKey< xAOD::jFexLRJetRoIContainer > m_jLJWriteKey
std::array< uint32_t, 4 > xTOBCounterTrailer(uint32_t word) const
uint32_t buildTOBCounterTrailer(uint32_t n_jJ, uint32_t n_jLJ, uint32_t n_jTau, uint32_t n_jEM, uint32_t has_jTE, uint32_t has_jXE) const
virtual StatusCode convertToBS(std::vector< OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment * > &vrobf, const xAOD::TrigCompositeContainer *tc, const EventContext &eventContext) override
xAOD->BS conversion
std::array< uint32_t, 2 > buildjFEXtoRODTrailer(uint32_t payload, uint32_t fpga, uint32_t jfex) const
SG::WriteHandleKey< xAOD::jFexTauRoIContainer > m_jTauWriteKey
ToolHandle< GenericMonitoringTool > m_monTool
jFexRoiByteStreamTool(const std::string &type, const std::string &name, const IInterface *parent)
std::array< uint32_t, 6 > TOBCounterTrailer(uint32_t word) const
Gaudi::Property< std::string > m_TobMapping
std::array< uint32_t, 1 > RODTrailer(uint32_t word0, uint32_t word1) const
void jFEXtoRODHeader(uint32_t word0, uint32_t word1) const
std::array< uint8_t, 2 > unpackLocalCoords(uint32_t word) const
StatusCode ReadfromFile(const std::string &)
SG::WriteHandleKey< xAOD::jFexMETRoIContainer > m_jXEWriteKey
struct color C
static constexpr uint32_t PAYLOAD_ROD_TRAILER
Bit positions for jFEX to ROB Trailer.
Definition jFexBits.h:88
static constexpr uint32_t ROD_TRAILER_20b
Definition jFexBits.h:85
static constexpr uint32_t ROD_TRAILER_6b
Definition jFexBits.h:83
static constexpr uint32_t ERROR_SAFE_MODE
Definition jFexBits.h:98
static constexpr uint32_t ERROR_HEADER_MISMATCH
Definition jFexBits.h:101
static constexpr uint32_t ROD_WORDS
Number of jFEX to ROD trailer words.
Definition jFexBits.h:16
static constexpr uint32_t jTE_TOB_COUNTS
Definition jFexBits.h:53
static constexpr uint32_t jXE_TOB_COUNTS
Definition jFexBits.h:54
static constexpr uint32_t jFEX_ROD_TRAILER
Definition jFexBits.h:90
static constexpr uint32_t ERROR_ROD_TRAILER
Definition jFexBits.h:94
static constexpr uint32_t ROD_TRAILER_1b
Masking words.
Definition jFexBits.h:80
static constexpr uint32_t TOB_TRAILERS
Definition jFexBits.h:20
static constexpr uint32_t jEM_TOB_COUNTS
Definition jFexBits.h:52
static constexpr uint32_t RO_ROD_TRAILER
Definition jFexBits.h:91
static constexpr uint32_t FPGA_U1
Definition jFexBits.h:37
static constexpr uint32_t ROD_ERROR_LENGTH_MISMATCH
Definition jFexBits.h:113
static constexpr uint32_t TSN_ROD_TRAILER
Definition jFexBits.h:92
static constexpr uint32_t TOB_COUNTS_6b
Masking for TOB/xTOB Counter Trailer of jEM, jTau, jJ and jLJ.
Definition jFexBits.h:45
static constexpr uint32_t ROD_ERROR_HEADER_CRC
Definition jFexBits.h:111
static constexpr uint32_t jLJ_TOB_COUNTS
Definition jFexBits.h:50
static constexpr uint32_t ROD_TRAILER_2b
Definition jFexBits.h:81
static constexpr uint32_t ROD_TRAILER_7b
Masking words.
Definition jFexBits.h:107
static constexpr uint32_t ERROR_CORR_TRAILER
Definition jFexBits.h:97
static constexpr uint32_t jFEX2ROD_WORDS
Definition jFexBits.h:17
static constexpr uint32_t jTau_TOB_COUNTS
Definition jFexBits.h:51
static constexpr uint32_t ROD_ERROR_HEADER_MISMATCH
Definition jFexBits.h:114
static constexpr uint32_t TOB_COUNTS_1b
Masking for TOB Counter Trailer of jXE and jTE.
Definition jFexBits.h:47
static constexpr uint32_t jJ_TOB_COUNTS
Bit positions for TOB Counter Trailer.
Definition jFexBits.h:49
static constexpr uint32_t ROD_ERROR_PAYLOAD_CRC
Definition jFexBits.h:110
static constexpr uint32_t FPGA_ROD_TRAILER
Definition jFexBits.h:89
static constexpr uint32_t CRC_ROD_TRAILER
Definition jFexBits.h:95
static constexpr uint32_t ERROR_PROC_TIMEOUT
Definition jFexBits.h:102
static constexpr uint32_t ERROR_PROTOCOL_ERROR
Definition jFexBits.h:99
static constexpr uint32_t ROD_ERROR_RESERVED
Definition jFexBits.h:112
static constexpr uint32_t ROD_TRAILER_4b
Definition jFexBits.h:82
static constexpr uint32_t ROD_ERROR_CORR_TRAILER
Definition jFexBits.h:109
static constexpr uint32_t ROD_ERROR_PROC_TIMEOUT
Definition jFexBits.h:115
static constexpr uint32_t ERROR_LENGTH_MISMATCH
Definition jFexBits.h:100
static constexpr uint32_t ROD_TRAILER_16b
Definition jFexBits.h:84
static constexpr uint32_t FPGA_U4
Definition jFexBits.h:40
eformat::write::ROBFragment ROBFragment
Definition RawEvent.h:33
eformat::ROBFragment< PointerType > ROBFragment
Definition RawEvent.h:27
pointer & link(pointer p) const
Return a reference to the link for an element.
Definition index.py:1
jFexFwdElRoI_v1 jFexFwdElRoI
Define the latest version of the jFexFwdElJetRoI class.
TrigCompositeContainer_v1 TrigCompositeContainer
Declare the latest version of the container.
TrigComposite_v1 TrigComposite
Declare the latest version of the class.
jFexSumETRoI_v1 jFexSumETRoI
Define the latest version of the jFexSumETJetRoI class.
jFexLRJetRoI_v1 jFexLRJetRoI
Define the latest version of the jFexLRJetRoI class.
jFexTauRoI_v1 jFexTauRoI
Define the latest version of the jFexSRJetRoI class.
Definition jFexTauRoI.h:13
jFexSRJetRoI_v1 jFexSRJetRoI
Define the latest version of the jFexSRJetRoI class.
jFexMETRoI_v1 jFexMETRoI
Define the latest version of the jFexMETRoI class.
Definition jFexMETRoI.h:13
std::string B_PURPLE
std::string YELLOW
std::string PURPLE
std::string B_RED
std::string GREEN
std::string B_GRAY
std::string B_GREEN
std::string B_BLUE
std::string B_ORANGE
std::string ORANGE
MsgStream & msg
Definition testRead.cxx:32