16 #include "Identifier/Identifier.h"
17 #include "eformat/Issue.h"
18 #include "eformat/SourceIdentifier.h"
20 using eformat::helper::SourceIdentifier;
29 const IInterface*
p) :
31 m_tgcIdHelper(nullptr)
48 if(
sc.isFailure())
return sc;
54 return StatusCode::FAILURE;
58 return StatusCode::SUCCESS;
67 if(m_nCache>0 || m_nNotCache>0) {
68 const float cacheFraction = ((
float)m_nCache) / ((
float)(m_nCache + m_nNotCache));
69 ATH_MSG_INFO(
"Fraction of fills that use the cache = " << cacheFraction);
84 return StatusCode::SUCCESS;
89 uint32_t source_id = robFrag.rod_source_id();
90 SourceIdentifier sid(source_id);
95 int idHash = rdoIdHash(rdoId);
98 std::unique_ptr<TgcRdo> rdo(
nullptr);
101 ATH_MSG_DEBUG (
" TGC RDO collection already exist with collection hash = "
102 << idHash <<
", ID = " << sid.human() <<
" - converting is skipped!");
106 ATH_MSG_DEBUG(
" Created new collection with ID = " << sid.human() <<
", hash = " << idHash );
109 rdo = std::make_unique<TgcRdo>(rdoId, idHash);
112 robFrag.rod_data(bs);
114 getCollection(robFrag, rdo.get() );
116 if (sid.module_id()<13){
117 byteStream2Rdo(bs, rdo.get(), robFrag.rod_source_id() );
118 }
else if (sid.module_id()>16){
119 byteStreamSrod2Rdo(bs, rdo.get(), robFrag.rod_source_id(), robFrag.rod_ndata() );
122 return StatusCode::FAILURE;
127 if(status_lock != StatusCode::SUCCESS){
128 ATH_MSG_ERROR(
" Failed to add TGC RDO collection to container with hash " << idHash );
131 ATH_MSG_DEBUG(
" Adding TgcRdo collection with hash " << idHash <<
", source id = " << sid.human() <<
" to the TgcRdo Container");
135 return StatusCode::SUCCESS;
142 uint32_t source_id = robFrag.rod_source_id();
143 SourceIdentifier sid(source_id);
147 int idHash = rdoIdHash(rdoId);
149 rdo->
setL1Id(robFrag.rod_lvl1_id());
150 rdo->
setBcId(robFrag.rod_bc_id());
152 rdo->
setOnlineId(sid.subdetector_id(), sid.module_id());
154 uint32_t nstatus = robFrag.rod_nstatus();
157 robFrag.rod_status(
status);
158 if (nstatus == 5 && sid.module_id() < 13){
163 }
else if (nstatus == 3 && sid.module_id() > 16){
169 if(m_showStatusWords) {
170 showStatusWords(source_id, rdoId, idHash, nstatus,
status);
181 ATH_MSG_DEBUG(
"Muon::TGC_RodDecoderReadout::byteStream2Rdo" );
189 ATH_MSG_DEBUG(
"Error: input TgcRdo id does not match bytestream id" );
196 {0, 1}, {0, 2}, {0, 3}, {0, 4}, {0, 5}, {0, 8}, {0, 9}
201 for(
int iCnt = 0; iCnt < 7; iCnt++)
212 for(
int iCnt = 0; iCnt < 7; iCnt++)
214 if(counters[iCnt].
count == 0)
216 switch(counters[iCnt].
id)
221 " " << counters[iCnt].
count <<
"words" );
222 for(
unsigned iFrag = 0; iFrag < counters[iCnt].
count; iFrag++)
224 ATH_MSG_DEBUG(
"WORD" << iFrag <<
":" << MSG::hex << bs[iBs] );
232 " " << counters[iCnt].
count <<
"words" );
234 for(
unsigned iFrag = 0; iFrag < counters[iCnt].
count; iFrag++)
236 ATH_MSG_DEBUG(
"WORD" << iFrag <<
":" << MSG::hex << bs[iBs] );
240 <<
" rdo.rodId():" <<rdo->
rodId()
241 <<
" roh.ldbId:" <<roh.
ldbId
242 <<
" roh.sbId:" <<roh.
sbId
243 <<
" rdo.l1Id():"<<rdo->
l1Id()
244 <<
" rdo.bcId():"<<rdo->
bcId() );
256 else slbId = (roh.
sbId-8)*2+1;
289 if(m_skipCoincidence)
break;
292 " " << counters[iCnt].
count <<
"words" );
295 for(
unsigned iFrag = 0; iFrag < counters[iCnt].
count; iFrag++)
297 ATH_MSG_DEBUG(
"WORD" << iFrag <<
":" << MSG::hex << bs[iBs] );
329 if(rotrk.
sbId<8) slbId = rotrk.
sbId *2;
330 else slbId = (rotrk.
sbId-8)*2+1;
366 if(m_skipCoincidence)
break;
369 " " << counters[iCnt].
count <<
"words" );
372 for(
unsigned iFrag = 0; iFrag < counters[iCnt].
count; iFrag++)
374 ATH_MSG_DEBUG(
"WORD" << iFrag <<
":" << MSG::hex << bs[iBs] );
418 if(m_skipCoincidence)
break;
421 " " << counters[iCnt].
count <<
"words" );
423 for(
unsigned iFrag = 0; iFrag < counters[iCnt].
count; iFrag++)
425 ATH_MSG_DEBUG(
"WORD" << iFrag <<
":" << MSG::hex << bs[iBs] );
434 static_cast<bool>(sl.
fwd),
447 ATH_MSG_DEBUG(
"Error: Muon::TGC_RodDecoderReadout::byteStream2Rdo Unsupported fragment type "
448 << counters[iCnt].
id );
454 ATH_MSG_DEBUG(
"Muon::TGC_RodDecoderReadout::byteStream2Rdo done" );
464 ATH_MSG_DEBUG(
"Muon::TGC_RodDecoderReadout::byteStreamSrod2Rdo" );
473 ATH_MSG_DEBUG(
"Error: input TgcRdo id does not match bytestream id" );
478 for(
uint32_t iBs = 0; iBs < ndata; iBs++){
479 ATH_MSG_DEBUG(
"WORD" << iBs <<
":" << MSG::hex << bs[iBs] );
492 static_cast<bool>(roi.
fwd),
496 static_cast<bool>(roi.
charge),
511 static_cast<bool>(
hipt.strip),
512 static_cast<bool>(
hipt.fwd),
516 static_cast<bool>(
hipt.hipt),
528 for (
int isector = 0; isector < 2; isector++ ){
534 static_cast<bool>(eifi.
fwd),
547 for (
int isector = 0; isector < 2; isector++ ){
554 tmdb.sector + isector,
568 if (nswang.
type != 5){
586 for (
int isector = 0; isector < 2; isector++ ){
592 static_cast<bool>(nswpos.
fwd),
612 if (rpccoin.
type != 7){
629 for (
int isector = 0; isector < 2; isector++ ){
635 static_cast<bool>(rpcpos.
fwd),
650 ATH_MSG_DEBUG(
"Muon::TGC_RodDecoderReadout::byteStreamSrod2Rdo done" );
656 static const unsigned int maxNStatus = 5;
657 static const std::string statusDataWord[maxNStatus] = {
658 "First status word specific|generic:",
659 "TGC ROD event status :",
660 "ROD VME fileter bits | SSW timeout:",
661 "Local status word | presence :",
665 static const unsigned int maxFirstStatus = 5;
666 static const std::string firstStatus[maxFirstStatus] = {
669 "Timeout occurred in at least one of the FE links. Fragment is incomplete.",
670 "Data may be incorrect, see TGC ROD event status word",
671 "An overflow in one of the ROD internal buffers has occurred. The fragment is incomplete."
674 static const unsigned int maxTgcRodEventStatus = 31;
675 static const std::string tgcRodEventStatus[maxTgcRodEventStatus] = {
676 "EC_RXsend : Error in request to send an event via RXlink",
677 "EC_FELdown : A Front End link has gone down - abandoned",
678 "EC_frame : Invalid FE link framing words",
679 "EC_Glnk : Front End link G-link error",
680 "EC_xor : Invalid XOR event checksum",
681 "EC_ovfl : Input FE event is too long or FE FIFO overflow",
682 "EC_timeout : Timeout expired for at least one FE link",
683 "EC_xormezz : Bad XOR checksum from mezz board",
684 "EC_wc0 : Event has WC=0 or WX>max WC",
685 "EC_L1ID : L1ID mismatch (TTC EVID FIFO vs local).",
686 "EC_nohdr : First word is not header",
687 "EC_rectype : Unrecognized record type",
688 "EC_null : Unexpected nulls in FE input",
689 "EC_order : Word is out of order",
690 "EC_LDB : Invalid or unexpected Star Switch ID",
691 "EC_RXovfl : RXfifo has overflowed",
692 "EC_SSWerr : SSW reports T1C, NRC, T2C, or GlinkNoLock error",
693 "EC_sbid : SBid does not match SBinfo table",
694 "EC_SBtype : SBtype does not match SBinfo table",
695 "EC_duprx : RX ID is duplicated in the event",
696 "EC_ec4 : Unexpected SB L1 Event ID(lo 4)",
697 "EC_bc : Unexpected SB BCID",
698 "EC_celladr : Invalid cell address",
699 "EC_hitovfl : Too many hits in event",
700 "EC_trgbit : Unexpected trigger bits",
701 "EC_badEoE : Bad End-of-event marker received, not 0xFCA",
702 "EC_endWCnot0 : WC not 0 after End-of-event marker",
703 "EC_noEoE : No End-of-event marker received",
704 "EC_SLGlink : Sector Logic reports G-Link error",
705 "EC_SLbc : Sector Logic BCID[2:0] does not match its SB BCID",
706 "EC_unxrxid : Data from disabled SSW RX ID"
709 static const unsigned int maxSSWs = 12;
711 static const unsigned int maxPresence = 10;
712 static const std::string presence[maxPresence] = {
715 "hits in readout fmt",
716 "tracklets in readout fmt",
717 "hits in chamber fmt",
718 "tracklets in chamber fmt",
725 static const unsigned int maxLocalStatus = 16;
726 static const std::string localStatus[maxLocalStatus] = {
727 "hit BCs are merged",
728 "tracklet BCs are merged",
730 "tracklets are sorted",
741 "ROI in this fragment",
742 "no L1AID, BCID check wrt ROD"
746 <<
"source_id=0x" << source_id <<
", "
747 <<
"rdoId=0x" << rdoId << (rdoId<16 ?
" , " :
", ")
748 <<
"idHash=0x" << idHash << (idHash<16 ?
" , " :
", ")
749 << (idHash<12 ?
"A" :
"C") << (idHash%12+1<10 ?
"0" :
"") << std::dec << idHash%12+1
751 ATH_MSG_INFO(
"***** Based on http://cern.ch/atlas-tgc/doc/ROBformat.pdf ****************************");
758 for(
unsigned int j=0; j<maxFirstStatus; j++) {
760 ATH_MSG_INFO(std::dec << std::setw(3) << j <<
" : " << firstStatus[j]);
765 for(
unsigned int j=0; j<maxTgcRodEventStatus; j++) {
767 ATH_MSG_INFO(std::dec << std::setw(3) << j <<
" : " << tgcRodEventStatus[j]);
772 for(
unsigned int j=0; j<maxSSWs; j++) {
774 ATH_MSG_INFO(std::dec << std::setw(3) << j <<
" : " <<
"time-out for SSW" << j);
777 for(
unsigned int j=0+16; j<=maxSSWs+16; j++) {
779 ATH_MSG_INFO(std::dec << std::setw(3) << j <<
" : " <<
"data from SSW" << j-16 <<
" gave filter \"accept\"");
784 for(
unsigned int j=0; j<maxPresence; j++) {
785 if(j==0 || j==6 || j==7)
continue;
787 ATH_MSG_INFO(std::dec << std::setw(3) << j <<
" : " << presence[j]);
792 for(
unsigned int j=0+16; j<maxLocalStatus+16; j++) {
793 if((j>=4+16 && j<=13+16))
continue;
795 ATH_MSG_INFO(std::dec << std::setw(3) << j <<
" : " << localStatus[j-16]);
801 ATH_MSG_INFO(
"**************************************************************************************");