213 if ( ( (
runnum>318000 &&
m_runnum<=318000) || (runnum<=318000 && m_runnum>318000) ) ) {
214 log << MSG::INFO <<
"Reinitializing TileHid2RESrcID for run " <<
runnum <<
endmsg;
218 uint32_t nBeamFrag=0, nRODfrag=0, nDataFrag[10]={0,0,0,0,0,0,0,0,0,0},
flags=0xFFFF,
flags5=0xFFFF;
219 std::map<int,int> fragMap;
220 std::map<int,int> beamMap;
223 bool cisparFound =
false;
227 for (
size_t idet=0; idet<ndet; ++idet) {
229 event->child(fpdet, idet);
234 const auto ROBSubDetID = eformat::helper::SourceIdentifier(ROBid).subdetector_id();
235 const auto ROBSubDetGroup = eformat::helper::SourceIdentifier(ROBid).subdetector_group();
236 if (ROBSubDetGroup == eformat::SubDetectorGroup::TILECAL ||
237 ROBSubDetID == eformat::SubDetector::TDAQ_BEAM_CRATE || ROBSubDetID == 0) {
239 unsigned int source_id = robf.rod_source_id();
240 eformat::helper::SourceIdentifier
id = eformat::helper::SourceIdentifier(source_id);
241 unsigned int subdet_id =
id.subdetector_id();
243 unsigned int size = robf.rod_ndata();
244 unsigned int max_allowed_size = robf.rod_fragment_size_word();
245 unsigned int delta = robf.rod_header_size_word() + robf.rod_trailer_size_word();
246 if (max_allowed_size > delta) max_allowed_size-=delta;
else max_allowed_size=0;
247 if (
size > max_allowed_size)
size = max_allowed_size;
251 if (robf.rod_status_position()==0 &&
252 robf.rod_nstatus() + robf.rod_header_size_word() + robf.rod_trailer_size_word() >= robf.rod_fragment_size_word()) {
253 robf.rod_status(
data);
258 switch ( subdet_id ) {
267 unsigned int offset = 0, sizePos = 1, idPos = 2;
268 if ( *(
data) != 0xff1234ff ) {
280 if ( fragsize <= idPos || fragsize >
size)
break;
282 int fragtype = upperhalf & 0xFF;
284 if (fragtype >= 0x40 && fragtype < 0x50) {
286 int ros = subdet_id&0xF;
289 int nmod = (
ros>2)?8:4;
290 fragid = (
ros<<8) | (source_id&0xF)*nmod;
294 log << MSG::INFO <<
"New TMDB frag 0x" << MSG::hex << fragid
295 <<
" type 0x" << fragtype <<
" vers 0x"<< vers
296 <<
" in ROB 0x" << ROBid << MSG::dec <<
endmsg;
298 if ( (*it).second != ROBid ) {
299 log << MSG::INFO <<
"TMDB frag 0x" << MSG::hex << fragid
300 <<
" type 0x" << fragtype <<
" vers 0x"<< vers
301 <<
" remapping from ROB 0x" << (*it).second
302 <<
" to 0x" << ROBid << MSG::dec <<
endmsg;
305 <<
" type 0x" << fragtype <<
" vers 0x"<< vers
306 <<
" found in ROB 0x" << (*it).second
307 <<
" as expected" << MSG::dec <<
endmsg;
310 for (
int nf=0; nf<nmod; ++nf) {
322 FRAGFULLMAP::const_iterator
it =
m_frag2ROD.find(fragid);
324 log << MSG::INFO <<
"New frag 0x" << MSG::hex << fragid
325 <<
" in ROB 0x" << ROBid << MSG::dec <<
endmsg;
327 if ( (*it).second[0] != ROBid ) {
328 log << MSG::INFO <<
"Frag 0x" << MSG::hex << fragid
329 <<
" remapping from ROB 0x" << (*it).second[0]
330 <<
" to 0x" << ROBid << MSG::dec <<
endmsg;
333 <<
" found in ROB 0x" << (*it).second
334 <<
" as expected" << MSG::dec <<
endmsg;
342 }
else if (fragid < 0x100) {
345 if (fragtype == 0x30) {
351 }
else if (fragid < 0x500 || fragtype == 6) {
360 if (fragtype == 4)
flags = upperhalf;
361 else if (fragtype == 5) {
363 fragIDs.push_back((
int)fragid);
378 log << MSG::INFO <<
"TileHid2RESrcID: Attention! Taking CISpar from lastROD 0x" << MSG::hex << lascisROB << MSG::dec <<
endmsg;
380 log << MSG::INFO <<
"TileHid2RESrcID: no CISpar in the data" <<
endmsg;
383 log << MSG::INFO <<
"TileHid2RESrcID: " << nBeamFrag <<
" beam sub-frags (";
384 std::map<int,int>::const_iterator itr=beamMap.begin();
385 std::map<int,int>::const_iterator
end=beamMap.end();
386 for (; itr!=
end; ++itr) {
387 log <<
" type=0x" << MSG::hex << itr->first << MSG::dec <<
" nf="<<itr->second;
389 log << MSG::INFO <<
" ) and " << nRODfrag <<
" ROD sub-frags (";
392 for (; itr!=
end; ++itr) {
393 log <<
" type=0x" << MSG::hex << itr->first << MSG::dec <<
" nf="<<itr->second;
394 if (itr->first < 10) nDataFrag[itr->first]+=itr->second;
397 log <<
" ) was found in the data" <<
endmsg;
403 if (nDataFrag[4]!=0) {
404 if ((
flags & 0x3000) < 0x3000)
405 of2 = ((
flags & 0x400) != 0);
406 }
else if (nDataFrag[5]!=0) {
407 if ((
flags5 & 0x3000) < 0x3000)
408 of2 = ((
flags5 & 0x400) != 0);
412 if (of2 != of2Default) {
413 log << MSG::INFO <<
"Setting OF2 flag in in TileROD_Decoder to " << ((of2) ?
"True" :
"False")
414 <<
" instead of " << ((of2Default) ?
"True" :
"False") <<
endmsg;