209{
210
212 if ( ( (runnum>318000 &&
m_runnum<=318000) || (runnum<=318000 && m_runnum>318000) ) ) {
213 log << MSG::INFO <<
"Reinitializing TileHid2RESrcID for run " <<
runnum <<
endmsg;
215 }
216
217 uint32_t nBeamFrag=0, nRODfrag=0, nDataFrag[10]={0,0,0,0,0,0,0,0,0,0},
flags=0xFFFF,
flags5=0xFFFF;
218 std::map<int,int> fragMap;
219 std::map<int,int> beamMap;
221
222 bool cisparFound = false;
224
226 for (size_t idet=0; idet<ndet; ++idet) {
228 event->child(fpdet, idet);
229 const eformat::ROBFragment<const uint32_t*> robf(fpdet);
230
232
233 const auto ROBSubDetID = eformat::helper::SourceIdentifier(ROBid).subdetector_id();
234 const auto ROBSubDetGroup = eformat::helper::SourceIdentifier(ROBid).subdetector_group();
235 if (ROBSubDetGroup == eformat::SubDetectorGroup::TILECAL ||
236 ROBSubDetID == eformat::SubDetector::TDAQ_BEAM_CRATE || ROBSubDetID == 0) {
237
238 unsigned int source_id = robf.rod_source_id();
239 eformat::helper::SourceIdentifier id = eformat::helper::SourceIdentifier(source_id);
240 unsigned int subdet_id = id.subdetector_id();
241
242 unsigned int size = robf.rod_ndata();
243 unsigned int max_allowed_size = robf.rod_fragment_size_word();
244 unsigned int delta = robf.rod_header_size_word() + robf.rod_trailer_size_word();
245 if (max_allowed_size > delta) max_allowed_size-=delta; else max_allowed_size=0;
246 if (size > max_allowed_size) size = max_allowed_size;
247 if ( size > 0 ) {
248
250 if (robf.rod_status_position()==0 &&
251 robf.rod_nstatus() + robf.rod_header_size_word() + robf.rod_trailer_size_word() >= robf.rod_fragment_size_word()) {
252 robf.rod_status(
data);
253 } else {
255 }
256
257 switch ( subdet_id ) {
264 {
265
266 unsigned int offset = 0, sizePos = 1, idPos = 2;
267 if ( *(
data) != 0xff1234ff ) {
268 --sizePos;
269 --idPos;
270 }
271
272 while ( offset+idPos < size ) {
273
278
279 if ( fragsize <= idPos || fragsize > size) break;
280
281 int fragtype = upperhalf & 0xFF;
282
283 if (fragtype >= 0x40 && fragtype < 0x50) {
284
285 int ros = subdet_id&0xF;
286 if (ros>0 && ros<=4) {
289 fragid = (
ros<<8) | (source_id&0xF)*
nmod;
290
293 log << MSG::INFO <<
"New TMDB frag 0x" << MSG::hex << fragid
294 << " type 0x" << fragtype << " vers 0x"<< vers
295 <<
" in ROB 0x" << ROBid << MSG::dec <<
endmsg;
296 } else {
297 if ( (*it).second != ROBid ) {
298 log << MSG::INFO <<
"TMDB frag 0x" << MSG::hex << fragid
299 << " type 0x" << fragtype << " vers 0x"<< vers
300 << " remapping from ROB 0x" << (*it).second
301 <<
" to 0x" << ROBid << MSG::dec <<
endmsg;
302 } else {
303 log << MSG::DEBUG <<
"TMDB frag 0x" << MSG::hex << fragid
304 << " type 0x" << fragtype << " vers 0x"<< vers
305 << " found in ROB 0x" << (*it).second
306 <<
" as expected" << MSG::dec <<
endmsg;
307 }
308 }
309 for (
int nf=0; nf<
nmod; ++nf) {
311 ++fragid;
312 }
313 }
314 break;
315 }
316
317 if (fragtype == 6) {
319 }
320
321 FRAGFULLMAP::const_iterator
it =
m_frag2ROD.find(fragid);
323 log << MSG::INFO <<
"New frag 0x" << MSG::hex << fragid
324 <<
" in ROB 0x" << ROBid << MSG::dec <<
endmsg;
325 } else {
326 if ( (*it).second[0] != ROBid ) {
327 log << MSG::INFO <<
"Frag 0x" << MSG::hex << fragid
328 <<" remapping from ROB 0x" << (*it).second[0]
329 <<
" to 0x" << ROBid << MSG::dec <<
endmsg;
330 } else {
331 log << MSG::DEBUG <<
"Frag 0x" << MSG::hex << fragid
332 <<" found in ROB 0x" << (*it).second
333 <<
" as expected" << MSG::dec <<
endmsg;
334 }
335 }
336
337 if (fragid < 0xff) {
338 ++nBeamFrag;
340 ++beamMap[fragtype];
341 } else if (fragid < 0x100) {
342 ++nBeamFrag;
343 ++beamMap[fragtype];
344 if (fragtype == 0x30) {
345 lascisROB = ROBid;
346 } else {
348 cisparFound = true;
349 }
350 } else if (fragid < 0x500 || fragtype == 6) {
351 ++nRODfrag;
353 if (frag_id < 0) {
355 } else {
357 }
358 ++fragMap[fragtype];
359 if (fragtype == 4)
flags = upperhalf;
360 else if (fragtype == 5) {
362 fragIDs.push_back((
int)fragid);
363 }
364 }
365 }
366 break;
367 }
368 default:
369 break;
370 }
371 }
372 }
373 }
374 if (!cisparFound) {
375 if (lascisROB) {
377 log << MSG::INFO <<
"TileHid2RESrcID: Attention! Taking CISpar from lastROD 0x" << MSG::hex << lascisROB << MSG::dec <<
endmsg;
378 } else {
379 log << MSG::INFO <<
"TileHid2RESrcID: no CISpar in the data" <<
endmsg;
380 }
381 }
382 log << MSG::INFO <<
"TileHid2RESrcID: " << nBeamFrag <<
" beam sub-frags (";
383 std::map<int,int>::const_iterator itr=beamMap.begin();
384 std::map<int,int>::const_iterator
end=beamMap.end();
385 for (; itr!=
end; ++itr) {
386 log <<
" type=0x" << MSG::hex << itr->first << MSG::dec <<
" nf="<<itr->second;
387 }
388 log << MSG::INFO <<
" ) and " << nRODfrag <<
" ROD sub-frags (";
389 itr=fragMap.begin();
391 for (; itr!=
end; ++itr) {
392 log <<
" type=0x" << MSG::hex << itr->first << MSG::dec <<
" nf="<<itr->second;
393 if (itr->first < 10) nDataFrag[itr->first]+=itr->second;
394
395 }
396 log <<
" ) was found in the data" <<
endmsg;
397
400
401 bool of2=true;
402 if (nDataFrag[4]!=0) {
403 if ((flags & 0x3000) < 0x3000)
404 of2 = ((
flags & 0x400) != 0);
405 } else if (nDataFrag[5]!=0) {
406 if ((flags5 & 0x3000) < 0x3000)
407 of2 = ((
flags5 & 0x400) != 0);
408 }
409 log << MSG::DEBUG <<
"OF2 flag in data is " << ((of2)?
"True":
"False") <<
endmsg;
410
411 if (of2 != of2Default) {
412 log << MSG::INFO <<
"Setting OF2 flag in in TileROD_Decoder to " << ((of2) ?
"True" :
"False")
413 <<
" instead of " << ((of2Default) ?
"True" :
"False") <<
endmsg;
414 of2Default = of2;
415 }
416
418}
char data[hepevt_bytes_allocation_ATLAS]
#define TILE_BEAM_ID
definition of various fragments expected in BS files from testbeam
int getOfflineFragID(uint32_t bs_frag_id) const
Retrieve extra info - ByteStream frag ID and drawer typefor a given transient fragment ID.