86 ATH_CHECK(jTowersContainer.record(std::make_unique<xAOD::jFexTowerContainer>(), std::make_unique<xAOD::jFexTowerAuxContainer>()));
87 ATH_MSG_DEBUG(
"Recorded jFexTowerContainer with key " << jTowersContainer.key());
92 for (
const ROBF* rob : vrobf) {
96 ATH_MSG_DEBUG(
"Starting to decode " << rob->rod_ndata() <<
" ROD words from ROB 0x" << std::hex << rob->rob_source_id() << std::dec);
99 if(rob->rod_ndata() <= 0){
100 ATH_MSG_DEBUG(
C.
B_RED<<
" No ROD words to decode: " << rob->rod_ndata() <<
" in ROB 0x"<< std::hex << rob->rob_source_id()<< std::dec <<
". Skipping"<<
C.
END);
104 const auto dataArray =
std::span{rob->rod_data(), rob->rod_ndata()};
105 std::vector<uint32_t> vec_words(dataArray.begin(),dataArray.end());
108 unsigned int trailers_pos = rob->rod_ndata();
111 bool READ_WORDS =
true;
114 if( trailers_pos < jBits::jFEX2ROD_WORDS ){
115 std::stringstream sdetail;
116 sdetail <<
"There are not enough words ("<< trailers_pos <<
") for the jFEX to ROD trailer decoder. Expected at least " << jBits::jFEX2ROD_WORDS<<
". Skipping this FPGA(?)" ;
117 std::stringstream slocation;
118 slocation <<
"0x"<< std::hex << rob->rob_source_id();
119 std::stringstream stitle;
120 stitle <<
"Invalid trailer words" ;
121 printError(slocation.str(),stitle.str(),MSG::WARNING,sdetail.str());
132 bool corTrailer = ((
error >> jBits::ERROR_CORR_TRAILER ) & jBits::ROD_TRAILER_1b);
133 bool safemode = ((
error >> jBits::ERROR_SAFE_MODE ) & jBits::ROD_TRAILER_1b);
134 bool proterror = ((
error >> jBits::ERROR_PROTOCOL_ERROR ) & jBits::ROD_TRAILER_1b);
135 bool lenerror = ((
error >> jBits::ERROR_LENGTH_MISMATCH ) & jBits::ROD_TRAILER_1b);
136 bool headmismatch = ((
error >> jBits::ERROR_HEADER_MISMATCH ) & jBits::ROD_TRAILER_1b);
137 bool processerror = ((
error >> jBits::ERROR_PROC_TIMEOUT ) & jBits::ROD_TRAILER_1b);
139 std::stringstream sdetail;
140 sdetail <<
"jFEX to ROD Trailer Error bits set - 6-bits error word: 0x"<< std::hex <<
error << std::dec<< std::endl;
141 sdetail <<
"Corrective Trailer: "<< corTrailer << std::endl;
142 sdetail <<
"Safe Mode : "<< safemode << std::endl;
143 sdetail <<
"Protocol error : "<< proterror << std::endl;
144 sdetail <<
"Length Mismatch : "<< lenerror << std::endl;
145 sdetail <<
"Header Mismatch : "<< headmismatch << std::endl;
146 sdetail <<
"Processor timeout : "<< processerror << std::endl;
147 std::stringstream slocation;
148 slocation <<
"Error bit set";
151 std::stringstream stitle;
152 stitle <<
"Corrective Trailer" ;
153 printError(slocation.str(),stitle.str(),MSG::WARNING,sdetail.str());
157 std::stringstream stitle;
158 stitle <<
"Safe Mode" ;
159 printError(slocation.str(),stitle.str(),MSG::WARNING,sdetail.str());
163 std::stringstream stitle;
164 stitle <<
"Protocol error" ;
165 printError(slocation.str(),stitle.str(),MSG::WARNING,sdetail.str());
169 std::stringstream stitle;
170 stitle <<
"Length mismatch" ;
175 std::stringstream stitle;
176 stitle <<
"Header mismatch" ;
181 std::stringstream stitle;
182 stitle <<
"Processor Timeout" ;
189 if(
payload % jBits::DATA_BLOCKS != 0){
190 ATH_MSG_DEBUG(
" Not full readout activated (" <<
payload <<
"). Data blocks/channels expected (" << jBits::DATA_BLOCKS <<
")"<<
C.
END);
193 if(
payload % jBits::DATA_WORDS_PER_BLOCK != 0) {
194 std::stringstream sdetail;
195 sdetail <<
" Payload number (" <<
payload <<
") not a multiple of data words per channel. Expected: " << jBits::DATA_WORDS_PER_BLOCK ;
196 std::stringstream slocation;
197 slocation <<
"jFEX "<< jfex <<
" FPGA "<< fpga <<
" in 0x"<< std::hex << rob->rob_source_id();
198 std::stringstream stitle;
199 stitle <<
"Invalid Data Blocks" ;
207 unsigned int wordIndex = trailers_pos - (jBits::jFEX2ROD_WORDS);
210 unsigned int Max_iter =
payload/jBits::DATA_WORDS_PER_BLOCK;
212 if(Max_iter>trailers_pos) {
213 std::stringstream sdetail;
214 sdetail <<
"Block size error in fragment 0x"<< std::hex << rob->rob_source_id() << std::dec<<
". Words available: " << trailers_pos <<
". Number of words wanted to decode: " << Max_iter ;
215 std::stringstream slocation;
216 slocation <<
"jFEX "<< jfex <<
" FPGA "<< fpga <<
" in 0x"<< std::hex << rob->rob_source_id();
217 std::stringstream stitle;
218 stitle <<
"Block Size Error" ;
222 return StatusCode::SUCCESS;
229 for (
unsigned int iblock = 0; iblock < Max_iter; iblock++){
232 const auto [DATA13_low , DATA15, DATA14] =
Dataformat1(vec_words.at(wordIndex-3));
233 const auto [DATA13_up,DATA10_up , DATA12, DATA11] =
Dataformat2(vec_words.at(wordIndex-4));
234 const auto [DATA10_low , DATA9 , DATA8 ] =
Dataformat1(vec_words.at(wordIndex-5));
235 const auto [DATA5_low , DATA7 , DATA6 ] =
Dataformat1(vec_words.at(wordIndex-6));
236 const auto [DATA5_up ,DATA2_up , DATA4 , DATA3 ] =
Dataformat2(vec_words.at(wordIndex-7));
237 const auto [DATA2_low , DATA1 , DATA0 ] =
Dataformat1(vec_words.at(wordIndex-8));
240 uint16_t DATA2 = ( DATA2_up << jBits::BS_MERGE_DATA ) + DATA2_low;
241 uint16_t DATA5 = ( DATA5_up << jBits::BS_MERGE_DATA ) + DATA5_low;
242 uint16_t DATA10 = ( DATA10_up << jBits::BS_MERGE_DATA ) + DATA10_low;
243 uint16_t DATA13 = ( DATA13_up << jBits::BS_MERGE_DATA ) + DATA13_low;
245 std::array<uint16_t,16> allDATA = {DATA0, DATA1, DATA2, DATA3, DATA4, DATA5, DATA6, DATA7, DATA8, DATA9, DATA10, DATA11, DATA12, DATA13, DATA14, DATA15 };
248 for(
uint idata = 0; idata < allDATA.size(); idata++){
250 char et_saturation = ((saturation >> idata) & jBits::BS_TRAILER_1b);
268 std::vector<uint16_t> vtower_ET;
270 vtower_ET.push_back(allDATA[idata]);
272 std::vector<char> vtower_SAT;
274 vtower_SAT.push_back(et_saturation);
277 jTowersContainer->push_back( std::make_unique<xAOD::jFexTower>() );
278 jTowersContainer->back()->initialize(
eta,
phi,
iEta,
iPhi, IDsim,
source, vtower_ET, jfex, fpga,
channel, idata, vtower_SAT );
280 if(
m_doThinning && !jTowersContainer->back()->isCore() ){
281 jTowersContainer->pop_back();
303 wordIndex -= jBits::DATA_WORDS_PER_BLOCK;
307 trailers_pos -= (
payload + jBits::jFEX2ROD_WORDS);
309 if(trailers_pos == 0){
315 return StatusCode::SUCCESS;