16#include "Identifier/Identifier.h"
17#include "eformat/Issue.h"
18#include "eformat/SourceIdentifier.h"
20using eformat::helper::SourceIdentifier;
29 const IInterface* p) :
46 StatusCode
sc = AthAlgTool::initialize();
48 if(
sc.isFailure())
return sc;
51 if(detStore()->retrieve(
m_tgcIdHelper,
"TGCIDHELPER").isFailure())
54 return StatusCode::FAILURE;
58 return StatusCode::SUCCESS;
65 StatusCode
sc = AthAlgTool::finalize();
69 ATH_MSG_INFO(
"Fraction of fills that use the cache = " << cacheFraction);
82 }
catch (eformat::Issue &ex) {
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);
116 if (sid.module_id()<13){
118 }
else if (sid.module_id()>16){
122 return StatusCode::FAILURE;
126 StatusCode status_lock = lock.
addOrDelete( std::move( rdo ) );
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();
156 const uint32_t* status;
157 robFrag.rod_status(status);
158 if (nstatus == 5 && sid.module_id() < 13){
163 }
else if (nstatus == 3 && sid.module_id() > 16){
179 uint32_t source_id)
const
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++)
204 if(counter.id == counters[iCnt].
id)
206 counters[iCnt].
count = counter.count;
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() );
246 uint16_t slbId = roh.
sbId;
256 else slbId = (roh.
sbId-8)*2+1;
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] );
320 uint16_t slbId = rotrk.
sbId;
329 if(rotrk.
sbId<8) slbId = rotrk.
sbId *2;
330 else slbId = (rotrk.
sbId-8)*2+1;
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] );
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" );
462 uint32_t ndata)
const
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){
581 uint16_t cand_input_bcid
586 for (
int isector = 0; isector < 2; isector++ ){
591 static_cast<uint16_t
>(rdo->
bcId()),
592 static_cast<bool>(nswpos.
fwd),
593 static_cast<uint16_t
>(nswpos.
sector) + isector,
612 if (rpccoin.
type != 7){
624 uint16_t flag_cand_bcid
629 for (
int isector = 0; isector < 2; isector++ ){
634 static_cast<uint16_t
>(rdo->
bcId()),
635 static_cast<bool>(rpcpos.
fwd),
636 static_cast<uint16_t
>(rpcpos.
sector) + isector,
650 ATH_MSG_DEBUG(
"Muon::TGC_RodDecoderReadout::byteStreamSrod2Rdo done" );
655 const uint32_t nstatus,
const uint32_t* status)
const {
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 ****************************");
753 for(uint32_t i=0; i<nstatus && i<maxNStatus; i++) {
754 ATH_MSG_INFO(statusDataWord[i] <<
" status[" << i <<
"]=0x" << std::hex << status[i]);
758 for(
unsigned int j=0; j<maxFirstStatus; j++) {
759 if((status[i] >> j) & 0x1) {
760 ATH_MSG_INFO(std::dec << std::setw(3) << j <<
" : " << firstStatus[j]);
765 for(
unsigned int j=0; j<maxTgcRodEventStatus; j++) {
766 if((status[i] >> j) & 0x1) {
767 ATH_MSG_INFO(std::dec << std::setw(3) << j <<
" : " << tgcRodEventStatus[j]);
772 for(
unsigned int j=0; j<maxSSWs; j++) {
773 if((status[i] >> j) & 0x1) {
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++) {
778 if((status[i] >> j) & 0x1) {
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;
786 if((status[i] >> j) & 0x1) {
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;
794 if((status[i] >> j) & 0x1) {
795 ATH_MSG_INFO(std::dec << std::setw(3) << j <<
" : " << localStatus[j-16]);
801 ATH_MSG_INFO(
"**************************************************************************************");
#define ATH_MSG_WARNING(x)
Athena::TPCnvVers::Old Athena::TPCnvVers::Current Athena::TPCnvVers::Old Athena::TPCnvVers::Current Athena::TPCnvVers::Old Athena::TPCnvVers::Current Athena::TPCnvVers::Current Athena::TPCnvVers::Current Athena::TPCnvVers::Current Athena::TPCnvVers::Current TgcRawData
void fromBS32(uint32_t data, T &s)
unsigned bcTag(unsigned bcBitMap)
value_type push_back(value_type pElem)
Add an element to the end of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
StatusCode addOrDelete(std::unique_ptr< T > ptr)
IDC_WriteHandle getWriteHandle(IdentifierHash hash)
void byteStream2Rdo(OFFLINE_FRAGMENTS_NAMESPACE::PointerType bs, TgcRdo *rdo, uint32_t source_id) const
Convert data contents of ROBFragment to RDO.
virtual StatusCode initialize() override
Standard AlgTool method.
void getCollection(const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment &robFrag, TgcRdo *rdo) const
Retrieve header of ROBFragment.
std::atomic< unsigned int > m_nCache
virtual StatusCode finalize() override
Standard AlgTool method.
std::atomic< unsigned int > m_nNotCache
bool m_showStatusWords
Flag for showStatusWords.
const TgcIdHelper * m_tgcIdHelper
TGC ID helper.
void byteStreamSrod2Rdo(OFFLINE_FRAGMENTS_NAMESPACE::PointerType bs, TgcRdo *rdo, uint32_t source_id, uint32_t ndata) const
bool m_skipCoincidence
Flag for skipping coincidence objects (for TrigT1TGC running on data)
virtual ~TGC_RodDecoderReadout()
default destructor
virtual StatusCode fillCollection(const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment &robFrag, TgcRdoContainer &rdoIdc) const override
Convert ROBFragment to RDO.
void showStatusWords(const uint32_t source_id, const uint16_t rdoId, const int idHash, const uint32_t nstatus, const uint32_t *status) const
Show status words.
TGC_RodDecoderReadout(const std::string &t, const std::string &n, const IInterface *p)
Default constructor.
An unit object of TGC ROD output.
static constexpr uint32_t RPC_CAND_BITSHIFT
static constexpr uint32_t NSW_CAND_BITSHIFT
static constexpr uint32_t RPC_BCID_BITSHIFT
static constexpr uint32_t NSW_INPUT_BITSHIFT
static constexpr uint32_t RPC_FLAG_BITSHIFT
static constexpr uint32_t NSW_BCID_BITSHIFT
void setLocalStatus(uint32_t data)
void setTriggerType(uint16_t v)
void setRodStatus(uint32_t data)
void setOnlineId(uint16_t subDetectorId, uint16_t rodId)
void setOrbit(uint32_t orbit)
void setErrors(uint16_t data)
uint16_t subDetectorId() const
static uint16_t calculateOnlineId(uint16_t subDetectorId, uint16_t rodId)
uint16_t identify() const
int count(std::string s, const std::string ®x)
count how many occurances of a regx are in a string
const DataType * PointerType
eformat::ROBFragment< PointerType > ROBFragment
The struct for fragment count in ByteStream.
The struct for Inner trigger bits in ByteStream.
The struct for HiPt in ByteStream.
The struct for hit in ByteStream.
The struct for tracklet in ByteStream.
The struct for triplet strip in ByteStream.
The struct for SL in ByteStream.
The struct for source ID in ByteStream.