11#include "Identifier/Identifier.h"
16#include "eformat/Issue.h"
17#include "eformat/SourceIdentifier.h"
19using eformat::helper::SourceIdentifier;
36 return StatusCode::SUCCESS;
44 const float cacheFraction =
47 "Fraction of fills that use the cache = " << cacheFraction);
50 return StatusCode::SUCCESS;
57 const EventContext& )
const {
60 }
catch (eformat::Issue& ex) {
62 return StatusCode::SUCCESS;
66 uint32_t source_id = robFrag.rod_source_id();
67 SourceIdentifier sid(source_id);
73 int idHash = rdoIdHash(rdoId);
76 std::unique_ptr<TgcRdo> rdo(
nullptr);
80 " TGC RDO collection already exist with collection hash = "
81 << idHash <<
", ID = " << sid.human()
82 <<
" - converting is skipped!");
86 << sid.human() <<
", hash = " << idHash);
89 rdo = std::make_unique<TgcRdo>(rdoId, idHash);
96 if (sid.module_id() < 13) {
98 }
else if (sid.module_id() > 16) {
100 robFrag.rod_ndata());
103 return StatusCode::FAILURE;
107 StatusCode status_lock = lock.
addOrDelete(std::move(rdo));
108 if (status_lock != StatusCode::SUCCESS) {
110 " Failed to add TGC RDO collection to container with hash "
114 << idHash <<
", source id = " << sid.human()
115 <<
" to the TgcRdo Container");
119 return StatusCode::SUCCESS;
126 uint32_t source_id = robFrag.rod_source_id();
127 SourceIdentifier sid(source_id);
132 int idHash = rdoIdHash(rdoId);
134 rdo->
setL1Id(robFrag.rod_lvl1_id());
135 rdo->
setBcId(robFrag.rod_bc_id());
138 sid.subdetector_id(),
141 uint32_t nstatus = robFrag.rod_nstatus();
143 const uint32_t* status;
144 robFrag.rod_status(status);
145 if (nstatus == 5 && sid.module_id() < 13) {
151 }
else if (nstatus == 3 && sid.module_id() > 16) {
166 uint32_t source_id)
const {
167 ATH_MSG_DEBUG(
"Muon::TGC_RodDecoderReadout::byteStream2Rdo");
174 ATH_MSG_DEBUG(
"Error: input TgcRdo id does not match bytestream id");
181 {0, 5}, {0, 8}, {0, 9}};
185 for (
int iCnt = 0; iCnt < 7; iCnt++) {
187 if (counter.id == counters[iCnt].
id) {
188 counters[iCnt].
count = counter.count;
194 for (
int iCnt = 0; iCnt < 7; iCnt++) {
195 if (counters[iCnt].
count == 0) {
198 switch (counters[iCnt].
id) {
202 << counters[iCnt].
count <<
"words");
203 for (
unsigned iFrag = 0; iFrag < counters[iCnt].
count;
214 << counters[iCnt].
count <<
"words");
216 for (
unsigned iFrag = 0; iFrag < counters[iCnt].
count;
225 <<
" roh.sbId:" << roh.
sbId
226 <<
" rdo.l1Id():" << rdo->
l1Id()
227 <<
" rdo.bcId():" << rdo->
bcId());
229 uint16_t slbId = roh.
sbId;
244 slbId = roh.
sbId * 2;
246 slbId = (roh.
sbId - 8) * 2 + 1;
279 << counters[iCnt].
count <<
"words");
282 for (
unsigned iFrag = 0; iFrag < counters[iCnt].
count;
299 uint16_t slbId = rotrk.
sbId;
313 if (rotrk.
sbId < 8) {
314 slbId = rotrk.
sbId * 2;
316 slbId = (rotrk.
sbId - 8) * 2 + 1;
352 << counters[iCnt].
count <<
"words");
355 for (
unsigned iFrag = 0; iFrag < counters[iCnt].
count;
360 if (hptinner.
sector & 4) {
387 << counters[iCnt].
count <<
"words");
389 for (
unsigned iFrag = 0; iFrag < counters[iCnt].
count;
406 "Error: Muon::TGC_RodDecoderReadout::byteStream2Rdo "
407 "Unsupported fragment type "
408 << counters[iCnt].
id);
414 ATH_MSG_DEBUG(
"Muon::TGC_RodDecoderReadout::byteStream2Rdo done");
419 uint32_t source_id, uint32_t ndata)
const {
420 ATH_MSG_DEBUG(
"Muon::TGC_RodDecoderReadout::byteStreamSrod2Rdo");
430 ATH_MSG_DEBUG(
"Error: input TgcRdo id does not match bytestream id");
435 for (uint32_t iBs = 0; iBs < ndata; iBs++) {
438 switch (tmpfrag.
type) {
445 rdo->
l1Id(), rdo->
bcId(),
static_cast<bool>(roi.
fwd),
457 rdo->
l1Id(), rdo->
bcId(),
static_cast<bool>(
hipt.strip),
468 for (
int isector = 0; isector < 2;
473 rdo->
l1Id(), rdo->
bcId(),
static_cast<bool>(eifi.
fwd),
484 for (
int isector = 0; isector < 2;
489 rdo->
l1Id(), rdo->
bcId(),
false, tmdb.sector + isector,
490 tmdb.module, tmdb.bcid);
502 if (nswang.
type != 5) {
515 uint16_t cand_input_bcid =
520 for (
int isector = 0; isector < 2;
525 rdo->
l1Id(),
static_cast<uint16_t
>(rdo->
bcId()),
526 static_cast<bool>(nswpos.
fwd),
527 static_cast<uint16_t
>(nswpos.
sector) + isector,
543 if (rpccoin.
type != 7) {
555 uint16_t flag_cand_bcid =
560 for (
int isector = 0; isector < 2;
565 rdo->
l1Id(),
static_cast<uint16_t
>(rdo->
bcId()),
566 static_cast<bool>(rpcpos.
fwd),
567 static_cast<uint16_t
>(rpcpos.
sector) + isector,
580 ATH_MSG_DEBUG(
"Muon::TGC_RodDecoderReadout::byteStreamSrod2Rdo done");
584 const uint32_t source_id,
const uint16_t rdoId,
const int idHash,
585 const uint32_t nstatus,
const uint32_t* status)
const {
586 static const unsigned int maxNStatus = 5;
587 static const std::string statusDataWord[maxNStatus] = {
588 "First status word specific|generic:",
589 "TGC ROD event status :",
590 "ROD VME fileter bits | SSW timeout:",
591 "Local status word | presence :",
595 static const unsigned int maxFirstStatus = 5;
596 static const std::string firstStatus[maxFirstStatus] = {
599 "Timeout occurred in at least one of the FE links. Fragment is "
601 "Data may be incorrect, see TGC ROD event status word",
602 "An overflow in one of the ROD internal buffers has occurred. The "
603 "fragment is incomplete."
606 static const unsigned int maxTgcRodEventStatus = 31;
607 static const std::string tgcRodEventStatus[maxTgcRodEventStatus] = {
608 "EC_RXsend : Error in request to send an event via RXlink",
609 "EC_FELdown : A Front End link has gone down - abandoned",
610 "EC_frame : Invalid FE link framing words",
611 "EC_Glnk : Front End link G-link error",
612 "EC_xor : Invalid XOR event checksum",
613 "EC_ovfl : Input FE event is too long or FE FIFO overflow",
614 "EC_timeout : Timeout expired for at least one FE link",
615 "EC_xormezz : Bad XOR checksum from mezz board",
616 "EC_wc0 : Event has WC=0 or WX>max WC",
617 "EC_L1ID : L1ID mismatch (TTC EVID FIFO vs local).",
618 "EC_nohdr : First word is not header",
619 "EC_rectype : Unrecognized record type",
620 "EC_null : Unexpected nulls in FE input",
621 "EC_order : Word is out of order",
622 "EC_LDB : Invalid or unexpected Star Switch ID",
623 "EC_RXovfl : RXfifo has overflowed",
624 "EC_SSWerr : SSW reports T1C, NRC, T2C, or GlinkNoLock error",
625 "EC_sbid : SBid does not match SBinfo table",
626 "EC_SBtype : SBtype does not match SBinfo table",
627 "EC_duprx : RX ID is duplicated in the event",
628 "EC_ec4 : Unexpected SB L1 Event ID(lo 4)",
629 "EC_bc : Unexpected SB BCID",
630 "EC_celladr : Invalid cell address",
631 "EC_hitovfl : Too many hits in event",
632 "EC_trgbit : Unexpected trigger bits",
633 "EC_badEoE : Bad End-of-event marker received, not 0xFCA",
634 "EC_endWCnot0 : WC not 0 after End-of-event marker",
635 "EC_noEoE : No End-of-event marker received",
636 "EC_SLGlink : Sector Logic reports G-Link error",
637 "EC_SLbc : Sector Logic BCID[2:0] does not match its SB BCID",
638 "EC_unxrxid : Data from disabled SSW RX ID"
641 static const unsigned int maxSSWs = 12;
643 static const unsigned int maxPresence = 10;
644 static const std::string presence[maxPresence] = {
647 "hits in readout fmt",
648 "tracklets in readout fmt",
649 "hits in chamber fmt",
650 "tracklets in chamber fmt",
657 static const unsigned int maxLocalStatus = 16;
658 static const std::string localStatus[maxLocalStatus] = {
659 "hit BCs are merged",
660 "tracklet BCs are merged",
662 "tracklets are sorted",
673 "ROI in this fragment",
674 "no L1AID, BCID check wrt ROD"
678 <<
"source_id=0x" << source_id <<
", "
679 <<
"rdoId=0x" << rdoId << (rdoId < 16 ?
" , " :
", ")
680 <<
"idHash=0x" << idHash << (idHash < 16 ?
" , " :
", ")
681 << (idHash < 12 ?
"A" :
"C")
682 << (idHash % 12 + 1 < 10 ?
"0" :
"") << std::dec
683 << idHash % 12 + 1 <<
" ******");
685 "***** Based on http://cern.ch/atlas-tgc/doc/ROBformat.pdf "
686 "****************************");
688 for (uint32_t i = 0; i < nstatus && i < maxNStatus; i++) {
689 ATH_MSG_INFO(statusDataWord[i] <<
" status[" << i <<
"]=0x" << std::hex
695 for (
unsigned int j = 0; j < maxFirstStatus; j++) {
696 if ((status[i] >> j) & 0x1) {
703 for (
unsigned int j = 0; j < maxTgcRodEventStatus; j++) {
704 if ((status[i] >> j) & 0x1) {
706 << tgcRodEventStatus[j]);
711 for (
unsigned int j = 0; j < maxSSWs; j++) {
712 if ((status[i] >> j) & 0x1) {
714 <<
"time-out for SSW" << j);
717 for (
unsigned int j = 0 + 16; j <= maxSSWs + 16; j++) {
718 if ((status[i] >> j) & 0x1) {
720 <<
"data from SSW" << j - 16
721 <<
" gave filter \"accept\"");
726 for (
unsigned int j = 0; j < maxPresence; j++) {
727 if (j == 0 || j == 6 || j == 7) {
730 if ((status[i] >> j) & 0x1) {
737 for (
unsigned int j = 0 + 16; j < maxLocalStatus + 16; j++) {
738 if ((j >= 4 + 16 && j <= 13 + 16)) {
741 if ((status[i] >> j) & 0x1) {
743 << localStatus[j - 16]);
750 "**********************************************************************"
#define ATH_CHECK
Evaluate an expression and check for errors.
#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 fillCollection(const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment &robFrag, TgcRdoContainer &rdoIdc, const EventContext &ctx) const override
Convert ROBFragment to RDO.
virtual StatusCode initialize() override
Standard AlgTool method.
Gaudi::Property< bool > m_skipCoincidence
Flag for skipping coincidence objects (for TrigT1TGC running on data)
Gaudi::Property< bool > m_showStatusWords
Flag for showStatusWords.
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
const TgcIdHelper * m_tgcIdHelper
TGC ID helper.
void byteStreamSrod2Rdo(OFFLINE_FRAGMENTS_NAMESPACE::PointerType bs, TgcRdo *rdo, uint32_t source_id, uint32_t ndata) const
virtual ~TGC_RodDecoderReadout()
default destructor
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.
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.