62 eformat::SubDetector detid[6];
64 detid[0] = eformat::TILECAL_LASER_CRATE;
65 detid[1] = eformat::TILECAL_BARREL_A_SIDE;
66 detid[2] = eformat::TILECAL_BARREL_C_SIDE;
67 detid[3] = eformat::TILECAL_EXT_A_SIDE;
68 detid[4] = eformat::TILECAL_EXT_C_SIDE;
69 detid[5] = eformat::TDAQ_BEAM_CRATE;
72 std::vector<HWIdentifier>::const_iterator first =
m_tileHWID->drawer_begin();
73 std::vector<HWIdentifier>::const_iterator last =
m_tileHWID->drawer_end();
75 for ( ; first!=last; ++first) {
86 id = ((drawer & 0xFC) >> 1) | (drawer & 0x1) ;
92 }
else if (drawer>0x7 && drawer < 0xFF) {
97 SourceIdentifier sid = SourceIdentifier(detid[ros],
id);
98 uint32_t rod_id = sid.code();
104 if (runnum>=400000) {
132 eformat::SubDetector detid[6];
134 detid[0] = eformat::TILECAL_LASER_CRATE;
135 detid[1] = eformat::TILECAL_BARREL_A_SIDE;
136 detid[2] = eformat::TILECAL_BARREL_C_SIDE;
137 detid[3] = eformat::TILECAL_EXT_A_SIDE;
138 detid[4] = eformat::TILECAL_EXT_C_SIDE;
139 detid[5] = eformat::TDAQ_BEAM_CRATE;
142 std::vector<HWIdentifier>::const_iterator first =
m_tileHWID->drawer_begin();
143 std::vector<HWIdentifier>::const_iterator last =
m_tileHWID->drawer_end();
145 for ( ; first!=last; ++first) {
156 id = (drawer >> 3) + 0x100;
160 id = (drawer >> 2) + 0x100;
163 SourceIdentifier sid = SourceIdentifier(detid[ros],
id);
164 uint32_t rod_id = sid.code();
211 uint32_t runnum =
event->run_no();
212 if ( ( (runnum>318000 &&
m_runnum<=318000) || (runnum<=318000 && m_runnum>318000) ) ) {
213 log << MSG::INFO <<
"Reinitializing TileHid2RESrcID for run " << runnum <<
endmsg;
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;
220 std::vector<int> fragIDs;
222 bool cisparFound =
false;
223 uint32_t lascisROB = 0;
225 uint32_t ndet =
event->nchildren();
226 for (
size_t idet=0; idet<ndet; ++idet) {
227 const uint32_t* fpdet;
228 event->child(fpdet, idet);
231 uint32_t ROBid = robf.source_id();
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) {
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();
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;
249 const uint32_t *
data;
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);
257 switch ( subdet_id ) {
266 unsigned int offset = 0, sizePos = 1, idPos = 2;
267 if ( *(
data) != 0xff1234ff ) {
272 while ( offset+idPos < size ) {
274 uint32_t fragsize = *(
data + offset + sizePos);
275 uint32_t fragid = ( *(
data + offset + idPos) ) & 0xFFFF;
276 uint32_t upperhalf = ( *(
data + offset + idPos) ) >> 16;
279 if ( fragsize <= idPos || fragsize > size)
break;
281 int fragtype = upperhalf & 0xFF;
283 if (fragtype >= 0x40 && fragtype < 0x50) {
285 int ros = subdet_id&0xF;
286 if (ros>0 && ros<=4) {
287 uint32_t vers = fragid;
288 int nmod = (ros>2)?8:4;
289 fragid = (ros<<8) | (source_id&0xF)*nmod;
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;
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;
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;
309 for (
int nf=0; nf<nmod; ++nf) {
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;
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;
331 log << MSG::DEBUG <<
"Frag 0x" << MSG::hex << fragid
332 <<
" found in ROB 0x" << (*it).second
333 <<
" as expected" << MSG::dec <<
endmsg;
341 }
else if (fragid < 0x100) {
344 if (fragtype == 0x30) {
350 }
else if (fragid < 0x500 || fragtype == 6) {
359 if (fragtype == 4) flags = upperhalf;
360 else if (fragtype == 5) {
362 fragIDs.push_back((
int)fragid);
377 log << MSG::INFO <<
"TileHid2RESrcID: Attention! Taking CISpar from lastROD 0x" << MSG::hex << lascisROB << MSG::dec <<
endmsg;
379 log << MSG::INFO <<
"TileHid2RESrcID: no CISpar in the data" <<
endmsg;
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;
388 log << MSG::INFO <<
" ) and " << nRODfrag <<
" ROD sub-frags (";
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;
396 log <<
" ) was found in the data" <<
endmsg;
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);
409 log << MSG::DEBUG <<
"OF2 flag in data is " << ((of2)?
"True":
"False") <<
endmsg;
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;