ATLAS Offline Software
Loading...
Searching...
No Matches
Muon::RpcROD_Decoder Class Reference

#include <RpcROD_Decoder.h>

Inheritance diagram for Muon::RpcROD_Decoder:
Collaboration diagram for Muon::RpcROD_Decoder:

Public Member Functions

 RpcROD_Decoder (const std::string &type, const std::string &name, const IInterface *p)
virtual ~RpcROD_Decoder ()=default
virtual StatusCode initialize () override
virtual StatusCode finalize () override
StatusCode fillCollections (const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment &robFrag, RpcPadContainer &rdoIdc, const std::vector< IdentifierHash > &collections, RpcSectorLogicContainer *, const bool &decodeSL) const override
int specialROBNumber () const
bool isSector13Data () const

Private Types

typedef OFFLINE_FRAGMENTS_NAMESPACE::PointerType BS

Private Member Functions

StatusCode fillCollection_v240 (BS data, const uint32_t data_size, RpcPad &v) const
 fill RpcPads from a block of integers Decode collection for old data format 2.4.0
StatusCode fillCollection_v300 (BS data, const uint32_t data_size, RpcPad &v, const uint16_t &subDetector, RpcSectorLogicContainer *) const
 fill RpcPads from a block of integers New version for data format 3.0 (ATLAS cosmics)
StatusCode fillCollection_v302new (BS data, const uint32_t data_size, RpcPad &v, const uint32_t &sourceId, RpcSectorLogicContainer *, const bool &) const
StatusCode fillCollection_v302 (BS data, const uint32_t data_size, RpcPad &v, const uint32_t &sourceId, RpcSectorLogicContainer *) const
 fill RpcPads from a block of integers New version for data format 3.1 (ATLAS cosmics - NEW RPC READOUT)
StatusCode fillCollectionsFromRob_v302 (BS data, const uint32_t data_size, std::map< Identifier, RpcPad * > &vmap, const uint32_t &sourceId, RpcSectorLogicContainer *, const bool &decodeSL) const
std::vector< uint16_t > get16bits (BS data, const int size, const int nHeader, const int nFooter) const
std::vector< uint16_t > get16bits_v301 (BS data, const int size, const int nHeader, const int nFooter) const
StatusCode checkdataformat (std::vector< uint16_t > *, int, int) const
void printcheckformat () const

Private Attributes

int m_printerror = 0
std::atomic_int m_RPCcheckfail [13] {}
IntegerProperty m_maxprinterror
Gaudi::Property< int > m_nobxs { this, "NOBXS", 8, "Number of bunch crossings in readout"}
ServiceHandle< Muon::IMuonIdHelperSvcm_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
SG::ReadCondHandleKey< RpcCablingCondDatam_rpcReadKey {this, "RpcCablingKey", "RpcCablingCondData", "Key of RpcCablingCondData"}
IntegerProperty m_specialROBNumber
BooleanProperty m_sector13Data

Detailed Description

Definition at line 48 of file RpcROD_Decoder.h.

Member Typedef Documentation

◆ BS

Constructor & Destructor Documentation

◆ RpcROD_Decoder()

Muon::RpcROD_Decoder::RpcROD_Decoder ( const std::string & type,
const std::string & name,
const IInterface * p )

Definition at line 16 of file RpcROD_Decoder.cxx.

16 :
17 base_class(type, name, parent) {
18 declareProperty("SpecialROBNumber", m_specialROBNumber = -1);
19 declareProperty("Sector13Data", m_sector13Data = false);
20 declareProperty("DataErrorPrintLimit", m_maxprinterror = 1000);
21}
IntegerProperty m_specialROBNumber
BooleanProperty m_sector13Data
IntegerProperty m_maxprinterror

◆ ~RpcROD_Decoder()

virtual Muon::RpcROD_Decoder::~RpcROD_Decoder ( )
virtualdefault

Member Function Documentation

◆ checkdataformat()

StatusCode Muon::RpcROD_Decoder::checkdataformat ( std::vector< uint16_t > * pdata,
int ini,
int end ) const
inlineprivate

Definition at line 110 of file RpcROD_Decoder.h.

110 {
111 // ===================================
112 // Check ROB fragment structure
113 // ===================================
114
115 int decoded;
116 MatrixReadOut matrix;
117 StatusCode sc = StatusCode::SUCCESS;
118
119 int previous = 0;
120
121 // Loop on buffer
122 for (int i = ini; i < end; i++) {
123 decoded = ((*pdata)[i] & 0xf000) >> 12;
124
125 // RX Header
126 if (decoded == 0x9) {
127 if (previous == 0) {
128 previous = 1;
129 } else {
130 ++m_RPCcheckfail[0];
131 previous = 0;
132 // m_bsErrCont->addError((*pdata)[i],Muon::RXHeaderErrors);
133 sc = StatusCode::FAILURE;
134 return sc;
135 }
136 }
137
138 // RX SubHeader
139 else if (decoded == 0xe) {
140 if (previous == 1) {
141 previous = 2;
142 } else {
143 ++m_RPCcheckfail[1];
144 previous = 0;
145 sc = StatusCode::FAILURE;
146 return sc;
147 }
148 }
149 // PAD Header
150 else if (decoded == 0x5) {
151 if (previous == 2) {
152 previous = 3;
153 } else {
154 ++m_RPCcheckfail[2];
155 previous = 0;
156 sc = StatusCode::FAILURE;
157 return sc;
158 }
159 }
160
161 // PAD or SL Subheader
162 else if (decoded == 0x6) {
163 if (previous == 3) {
164 previous = 4;
165 } else if (previous == 8) {
166 previous = 9;
167 } else {
168 ++m_RPCcheckfail[3];
169 previous = 0;
170 sc = StatusCode::FAILURE;
171 return sc;
172 }
173 }
174
175 // CM Header
176 else if (decoded == 0xc) {
177 if (previous == 4) {
178 previous = 5;
179 } else {
180 ++m_RPCcheckfail[4];
181 previous = 0;
182 sc = StatusCode::FAILURE;
183 return sc;
184 }
185 }
186
187 // CM Subheader
188 else if (decoded == 0x8) {
189 if (previous == 5) {
190 previous = 6;
191 } else {
192 ++m_RPCcheckfail[5];
193 previous = 0;
194 sc = StatusCode::FAILURE;
195 return sc;
196 }
197 }
198
199 // CM Footer
200 else if (decoded == 0x4) {
201 if (previous == -1 || previous == 6) {
202 previous = 4;
203 if (matrix.checkCRC8((ubit16)(*pdata)[i])) {
204 } else {
205 ++m_RPCcheckfail[12];
206 sc = StatusCode::RECOVERABLE;
207 }
208 } else {
209 ++m_RPCcheckfail[6];
210 previous = 0;
211 sc = StatusCode::FAILURE;
212 return sc;
213 }
214 }
215
216 // PAD Prefooter
217 else if (decoded == 0xa) {
218 if (previous == 4) {
219 previous = 7;
220 } else {
221 ++m_RPCcheckfail[7];
222 previous = 0;
223 sc = StatusCode::FAILURE;
224 return sc;
225 }
226 }
227
228 // PAD Footer
229 else if (decoded == 0x7) {
230 if (previous == 7) {
231 previous = 2;
232 } else {
233 ++m_RPCcheckfail[8];
234 previous = 0;
235 sc = StatusCode::FAILURE;
236 return sc;
237 }
238 }
239
240 // SL Header
241 else if (decoded == 0xd) {
242 if (previous == 2) {
243 previous = 8;
244 } else {
245 ++m_RPCcheckfail[9];
246 previous = 0;
247 sc = StatusCode::FAILURE;
248 return sc;
249 }
250 }
251
252 // SL Footer
253 else if (decoded == 0xf) {
254 if (previous == 9 || previous == -1) {
255 previous = 10;
256 } else {
257 ++m_RPCcheckfail[10];
258 previous = 0;
259 sc = StatusCode::FAILURE;
260 return sc;
261 }
262 }
263 // RX Footer
264 else if (decoded == 0xb) {
265 if (previous == 10) {
266 previous = 0;
267 // ===== end of fragment reached =====
268 return sc;
269 } else {
270 ++m_RPCcheckfail[11];
271 previous = 0;
272 sc = StatusCode::FAILURE;
273 return sc;
274 }
275 } else {
276 previous = -1;
277 }
278 }
279 sc = StatusCode::FAILURE;
280 return sc;
281 }
static Double_t sc
unsigned short int ubit16
std::atomic_int m_RPCcheckfail[13]
::StatusCode StatusCode
StatusCode definition for legacy code.
@ previous
Definition BinningData.h:32

◆ fillCollection_v240()

StatusCode Muon::RpcROD_Decoder::fillCollection_v240 ( BS data,
const uint32_t data_size,
RpcPad & v ) const
inlineprivate

fill RpcPads from a block of integers Decode collection for old data format 2.4.0

Definition at line 1429 of file RpcROD_Decoder.h.

1429 {
1430 const int rodHeader = 8;
1431 const int rodFooter = 3;
1432 bool printMessage = true; // to print only once per call
1433
1434 /*
1435 msg(MSG::VERBOSE) << "**********Decoder dumping the words******** " << endmsg;
1436 if (data_size > 0 ) {
1437 msg(MSG::VERBOSE) << "The size of this ROD-read is " << data_size << endmsg;
1438 for (int i=0; i < data_size; i++)
1439 msg(MSG::VERBOSE) << "word " << i << " = " << MSG::hex << p[i] << MSG::dec << endmsg;
1440 }
1441 */
1442
1443 // the identifier of this collection
1444 Identifier thisPadOfflineId = v.identify();
1445
1446 if (msgLvl(MSG::VERBOSE))
1447 msg(MSG::VERBOSE) << "The offline ID request for conversion is "
1448 << m_idHelperSvc->rpcIdHelper().show_to_string(thisPadOfflineId) << endmsg;
1449
1450 // remove the rod header and footer then
1451 // convert the rest of 32-bits into 16-bit words
1452 std::vector<uint16_t> v16 = get16bits(data, data_size, rodHeader, rodFooter);
1453
1454 int word16Count = 0;
1455 int size16 = v16.size();
1456
1457 assert(size16 > 0 && size16 == (int)(2 * (data_size - rodHeader - rodFooter)));
1458
1459 RPCRODStructure rodReadout;
1460 RXReadOutStructure rxReadout;
1461 PadReadOutStructure padReadout;
1462 MatrixReadOutStructure matrixReadout;
1463
1464 // first 8 32-bit words are the ROD headers
1465 // then come a series of 16-bit words: the data
1466 // followed by 3 32-bit ROD footer
1467
1468 // before moving to the first receiver header
1469 // find out where we are: half A or C?
1470
1471 rodReadout.decodeSourceID(data[3]);
1472 uint16_t subDetectorID = rodReadout.getSourceIDSubdetectorID();
1473
1474 if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << "subDetectorID = 0x" << MSG::hex << subDetectorID << MSG::dec << endmsg;
1475
1476 uint16_t side = (subDetectorID == eformat::MUON_RPC_BARREL_A_SIDE) ? 0 : 1;
1477 uint16_t rodId = rodReadout.getSourceIDRODID();
1478
1479 if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << "rodID = 0x" << MSG::hex << rodId << MSG::dec << endmsg;
1480
1481 assert(rodId <= 15);
1482
1483 // loop over 2 possible receivers per ROD
1484 char rxHeader = 'U';
1485 if (!ensure_more_data(word16Count, size16, msg(), printMessage, "start of data")) return StatusCode::FAILURE;
1486 uint16_t receiverHeaderFragment = v16[word16Count];
1487 rxReadout.decodeFragment(receiverHeaderFragment, rxHeader);
1488 if (rxHeader == 'H') {
1489 word16Count += 1;
1490 if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << "Found a receiver header " << endmsg;
1491 } else if (msgLvl(MSG::VERBOSE))
1492 msg(MSG::VERBOSE) << "RpcROD_Decoder::ERROR : Expecting a receiver header "
1493 << "bailing out"
1494 << " Fragment ID is " << MSG::hex << rxHeader << MSG::dec << endmsg;
1495
1496 while (rxHeader == 'H' && word16Count < size16) {
1497 if (msgLvl(MSG::VERBOSE))
1498 msg(MSG::VERBOSE) << "The receiver header word is " << MSG::hex << receiverHeaderFragment << MSG::dec << endmsg;
1499 uint16_t slogic = 2 * rodId + rxReadout.RXid();
1500 uint16_t sectorID = side * 32 + slogic;
1501 assert(slogic <= 31);
1502 char padHeader = 'U';
1503 uint16_t padHeaderFragment = v16[word16Count];
1504 padReadout.decodeFragment(padHeaderFragment, padHeader);
1505 if (padHeader == 'H') {
1506 word16Count += 1;
1507 if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << "Found a pad header " << endmsg;
1508 } else if (msgLvl(MSG::VERBOSE))
1509 msg(MSG::VERBOSE) << "Rpc_ROD_Decoder::ERROR : Expecting a pad header "
1510 << " Fragment ID is " << padHeader << endmsg;
1511
1512 while (padHeader == 'H') {
1513 uint16_t padId = padReadout.padid();
1514
1515 uint16_t status = 0;
1516
1517 SG::ReadCondHandle<RpcCablingCondData> cablingCondData{m_rpcReadKey, Gaudi::Hive::currentContext()};
1518 const RpcCablingCondData* rpcCabling{*cablingCondData};
1519
1520 Identifier padOfflineId;
1521 if (!rpcCabling->giveOfflineId(side, slogic, padId, padOfflineId)) {
1522 if (msgLvl(MSG::VERBOSE))
1523 msg(MSG::VERBOSE) << "Cannot retrieve the OfflineID for the PAD n. " << padId << " at side " << side
1524 << " and sector " << slogic << endmsg;
1525 } else if (msgLvl(MSG::VERBOSE))
1526 msg(MSG::VERBOSE) << "ID " << m_idHelperSvc->rpcIdHelper().show_to_string(padOfflineId) << " associated to PAD n. "
1527 << padId << " at side " << side << " and sector " << slogic << endmsg;
1528
1529 // check if this the collection requested
1530 // otherwise created a new collection and
1531 // record the new collection into StoreGate
1532 // so that the next time the new collection is requested,
1533 // it will be already in StoreGate!!!
1534 if (thisPadOfflineId == padOfflineId) {
1535 if (msgLvl(MSG::VERBOSE))
1536 msg(MSG::VERBOSE) << "Found the collection to return "
1537 << m_idHelperSvc->rpcIdHelper().show_to_string(thisPadOfflineId) << endmsg;
1538 v.setOnlineId(padId);
1539 v.setStatus(status);
1540 v.setSector(sectorID);
1541 } else {
1542 if (msgLvl(MSG::VERBOSE))
1543 msg(MSG::VERBOSE) << m_idHelperSvc->rpcIdHelper().show_to_string(thisPadOfflineId)
1544 << "!=" << m_idHelperSvc->rpcIdHelper().show_to_string(padOfflineId) << endmsg;
1545 }
1546 char cmaHeader = 'U';
1547 if (!ensure_more_data(word16Count, size16, msg(), printMessage, "padHeader")) break;
1548 uint16_t cmaHeaderFragment = v16[word16Count];
1549 matrixReadout.decodeFragment(cmaHeaderFragment, cmaHeader);
1550 if (cmaHeader == 'H') {
1551 word16Count += 1;
1552 if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << "Found a cma header" << endmsg;
1553 } else if (msgLvl(MSG::VERBOSE))
1554 msg(MSG::VERBOSE) << "RpcROD_Decoder::ERROR : Expecting a cma header"
1555 << " Fragment ID is " << cmaHeader << endmsg;
1556
1557 while (cmaHeader == 'H') {
1558 uint16_t cmaId = matrixReadout.cmid();
1559 uint16_t fel1id = matrixReadout.fel1id();
1560 char cmaSubHeader = 'U';
1561 uint16_t febcid = static_cast<uint16_t>(-1);
1562 if (!ensure_more_data(word16Count, size16, msg(), printMessage, "cmaHeader")) break;
1563 uint16_t cmaSubHeaderFragment = v16[word16Count];
1564 matrixReadout.decodeFragment(cmaSubHeaderFragment, cmaSubHeader);
1565 if (cmaSubHeader == 'S') {
1566 febcid = matrixReadout.febcid();
1567 word16Count += 1;
1568 if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << "Found a cma sub-header" << endmsg;
1569 } else if (msgLvl(MSG::VERBOSE))
1570 msg(MSG::VERBOSE) << "RpcROD_Decoder::ERROR : Expecting a cma sub-header"
1571 << " Fragment ID is " << cmaSubHeader << endmsg;
1572
1573 if (!ensure_more_data(word16Count, size16, msg(), printMessage, "cmtSubHeader")) break;
1574 RpcCoinMatrix* coinMatrix = new RpcCoinMatrix(padOfflineId, cmaId, fel1id, febcid);
1575 char cmaBody = 'U';
1576 uint16_t cmaBodyFragment = v16[word16Count];
1577 matrixReadout.decodeFragment(cmaBodyFragment, cmaBody);
1578 if (cmaBody == 'B') {
1579 word16Count += 1;
1580 if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << "Found a cma body " << MSG::hex << cmaBodyFragment << endmsg;
1581 } else if (msgLvl(MSG::VERBOSE))
1582 msg(MSG::VERBOSE) << "Expecting cma body"
1583 << " Fragment ID is " << cmaBody << endmsg;
1584 while (cmaBody == 'B') {
1585 uint16_t bcid = matrixReadout.bcid();
1586 uint16_t time = matrixReadout.time();
1587 uint16_t ijk = matrixReadout.ijk();
1588
1589 RpcFiredChannel* firedChannel = 0;
1590 if (ijk < 7) {
1591 uint16_t channel = matrixReadout.channel();
1592 firedChannel = new RpcFiredChannel(bcid, time, ijk, channel);
1593 coinMatrix->push_back(firedChannel);
1594 } else if (ijk == 7) {
1595 uint16_t threshold = matrixReadout.threshold();
1596 uint16_t overlap = matrixReadout.overlap();
1597 firedChannel = new RpcFiredChannel(bcid, time, ijk, threshold, overlap);
1598 coinMatrix->push_back(firedChannel);
1599 } else {
1600 if (msgLvl(MSG::VERBOSE))
1601 msg(MSG::VERBOSE) << "RpcROD_Decoder::ERROR : Wrong ijk value " << ijk << "in cma body " << endmsg;
1602 }
1603 if (!ensure_more_data(word16Count, size16, msg(), printMessage, "cmaBody")) {
1604 delete coinMatrix;
1605 coinMatrix = 0;
1606 break;
1607 }
1608 cmaBodyFragment = v16[word16Count];
1609 matrixReadout.decodeFragment(cmaBodyFragment, cmaBody);
1610 if (cmaBody == 'B') {
1611 word16Count += 1;
1612 if (msgLvl(MSG::VERBOSE))
1613 msg(MSG::VERBOSE) << "Found a cma body"
1614 << " " << MSG::hex << cmaBodyFragment << MSG::dec << endmsg;
1615 } else
1616 ATH_MSG_VERBOSE(" No more body fragment found " << cmaBody << " " << MSG::hex << cmaBodyFragment << MSG::dec);
1617 if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << "End of a cma body" << endmsg;
1618 } // end of fired channels
1619 char cmaFooter = 'U';
1620 if (!ensure_more_data(word16Count, size16, msg(), printMessage, "after cmaBody")) {
1621 delete coinMatrix;
1622 coinMatrix = 0;
1623 break;
1624 }
1625 uint16_t cmaFooterFragment = v16[word16Count];
1626 matrixReadout.decodeFragment(cmaFooterFragment, cmaFooter);
1627 if (cmaFooter == 'F') {
1628 uint16_t crc = matrixReadout.crc();
1629 if (coinMatrix)
1630 coinMatrix->setCRC(crc); // Added to try to "fix" CID 12374
1631 else
1632 ATH_MSG_ERROR("Trying to call null coinMatrix - this should never happen!");
1633 word16Count += 1;
1634 if (msgLvl(MSG::VERBOSE))
1635 msg(MSG::VERBOSE) << "Found a cma Footer " << MSG::hex << cmaFooterFragment << MSG::dec << endmsg;
1636 } else { // of cma, record it into a pad
1637 if (msgLvl(MSG::VERBOSE))
1638 msg(MSG::VERBOSE) << "RpcROD_Decoder::ERROR : Expecting a cma Footer"
1639 << " Fragment ID is " << cmaFooter << " " << MSG::hex << cmaFooterFragment << MSG::dec
1640 << endmsg;
1641 }
1642
1643 if (thisPadOfflineId == padOfflineId)
1644 v.push_back(coinMatrix);
1645 else
1646 delete coinMatrix;
1647
1648 if (!ensure_more_data(word16Count, size16, msg(), printMessage, "cmaFooter")) break;
1649 cmaHeaderFragment = v16[word16Count];
1650 matrixReadout.decodeFragment(cmaHeaderFragment, cmaHeader);
1651 if (cmaHeader == 'H') {
1652 word16Count += 1;
1653 if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << "Found a cma header" << endmsg;
1654 } else if (msgLvl(MSG::VERBOSE))
1655 msg(MSG::VERBOSE) << "End of all CMAs" << endmsg;
1656 } // end of cma
1657 char padFooter = 'U';
1658 uint16_t errorCode = static_cast<uint16_t>(-1);
1659 if (!ensure_more_data(word16Count, size16, msg(), printMessage, "after CMAs")) break;
1660 uint16_t padFooterFragment = v16[word16Count];
1661 padReadout.decodeFragment(padFooterFragment, padFooter);
1662 if (padFooter == 'F') {
1663 word16Count += 1;
1664 errorCode = padReadout.errorCode();
1665 if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << "Found a pad footer " << endmsg;
1666 if (thisPadOfflineId == padOfflineId) {
1667 v.setErrorCode(errorCode);
1668 // we found the pad and it is filled so clean up and return quickly!
1669 return StatusCode::FAILURE;
1670 }
1671 } else if (msgLvl(MSG::VERBOSE))
1672 msg(MSG::VERBOSE) << "RpcROD_Decoder::ERROR : Expecting a pad footer "
1673 << " Fragment ID is " << padFooter << " " << MSG::hex << padFooterFragment << MSG::dec << endmsg;
1674 if (!ensure_more_data(word16Count, size16, msg(), printMessage, "padFooter")) break;
1675 padHeaderFragment = v16[word16Count];
1676 padReadout.decodeFragment(padHeaderFragment, padHeader);
1677 if (padHeader == 'H') {
1678 word16Count += 1;
1679 if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << "Found a pad header " << endmsg;
1680 } else if (msgLvl(MSG::VERBOSE))
1681 msg(MSG::VERBOSE) << "End of all pads " << endmsg;
1682 } // end of pads
1683
1684 char rxFooter = 'U';
1685 if (!ensure_more_data(word16Count, size16, msg(), printMessage, "after pads")) break;
1686 uint16_t receiverFooterFragment = v16[word16Count];
1687 rxReadout.decodeFragment(receiverFooterFragment, rxFooter);
1688 if (rxFooter == 'F') {
1689 word16Count += 1;
1690 if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << "Found a receiver footer " << endmsg;
1691 } else if (msgLvl(MSG::VERBOSE))
1692 msg(MSG::VERBOSE) << "RpcROD_Decoder::ERROR : Expecting a receiver footer "
1693 << " Fragment ID is " << rxFooter << " " << MSG::hex << receiverFooterFragment << MSG::dec << endmsg;
1694
1695 if (word16Count < size16) {
1696 receiverHeaderFragment = v16[word16Count];
1697 rxReadout.decodeFragment(receiverHeaderFragment, rxHeader);
1698 if (rxHeader == 'H') {
1699 word16Count += 1;
1700 if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << "Found a receiver header " << endmsg;
1701 } else if (msgLvl(MSG::VERBOSE))
1702 msg(MSG::VERBOSE) << "End of all receivers " << endmsg;
1703 }
1704
1705 } // end of receivers: while (rxHeader == 'H' && wordCount < size16)
1706
1707 // end of the ROD
1708
1709 return StatusCode::FAILURE;
1710 }
#define endmsg
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
Athena::TPCnvVers::Old Athena::TPCnvVers::Current Athena::TPCnvVers::Old Athena::TPCnvVers::Current Athena::TPCnvVers::Old Athena::TPCnvVers::Current Athena::TPCnvVers::Current RpcCoinMatrix
value_type push_back(value_type pElem)
Add an element to the end of the collection.
ubit16 decodeFragment(ubit16 inputWord, char &field)
SG::ReadCondHandleKey< RpcCablingCondData > m_rpcReadKey
std::vector< uint16_t > get16bits(BS data, const int size, const int nHeader, const int nFooter) const
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
ubit16 decodeFragment(ubit16 inputWord, char &field)
ubit16 getSourceIDSubdetectorID()
ubit16 getSourceIDRODID()
void decodeSourceID(RODword sourceID)
ubit16 decodeFragment(ubit16 inputWord, char &field)
bool giveOfflineId(const unsigned short int side, const unsigned short int sector, const unsigned short int padId, Identifier &id) const
void setCRC(ubit16 crc)
time(flags, cells_name, *args, **kw)
bool ensure_more_data(int index, int size, MsgStream &log, bool &printMessage, const std::string &message)
status
Definition merge.py:16
setEventNumber setTimeStamp bcid
setWord1 uint16_t
MsgStream & msg
Definition testRead.cxx:32

◆ fillCollection_v300()

StatusCode Muon::RpcROD_Decoder::fillCollection_v300 ( BS data,
const uint32_t data_size,
RpcPad & v,
const uint16_t & subDetector,
RpcSectorLogicContainer * sectorLogicContainer ) const
inlineprivate

fill RpcPads from a block of integers New version for data format 3.0 (ATLAS cosmics)

Definition at line 1014 of file RpcROD_Decoder.h.

1015 {
1016 bool skipSectorLogicDecoding = (sectorLogicContainer == nullptr);
1017 if (skipSectorLogicDecoding) ATH_MSG_DEBUG("Skip SectorLogic decoding, so SLROC.decodeFragment is not being processed");
1018
1019 //#ifndef NVERBOSE
1020 if (msgLvl(MSG::VERBOSE)) {
1021 msg(MSG::VERBOSE) << "**********Decoder dumping the words******** " << endmsg;
1022 if (data_size > 0) {
1023 msg(MSG::VERBOSE) << "The size of this ROD-read is " << data_size << endmsg;
1024 for (unsigned int i = 0; i < data_size; i++)
1025 msg(MSG::VERBOSE) << "word " << i << " = " << MSG::hex << data[i] << MSG::dec << endmsg;
1026 }
1027 }
1028 //#endif
1029
1030 uint16_t side = (subDetector == eformat::MUON_RPC_BARREL_A_SIDE) ? 1 : 0;
1031
1032 // TMP FIXME the sector number needs to be fixed !!
1033 uint16_t sector = 0;
1034
1035 // counter of the numerb of sector logic fragments found
1036 uint16_t SLindex = 0;
1037
1038 // the identifier of this collection
1039 Identifier thisPadOfflineId = v.identify();
1040
1041 // Identifier of the collection in data
1042 Identifier padOfflineId;
1043 bool foundPad = false;
1044
1045 bool isSLHeader = false;
1046 bool isSLFooter = false;
1047 bool isSLFragment = false;
1048 bool isRXHeader = false;
1049 bool isRXFooter = false;
1050 bool isPADFragment = false;
1051 bool isPadHeader = false;
1052 bool isPadSubHeader = false;
1053 bool isPadPreFooter = false;
1054 bool isPadFooter = false;
1055
1056 // return;
1057
1058 RPCRODDecode myRPC;
1059 RXReadOutStructure RXROS;
1060 PadReadOutStructure PDROS;
1061 SectorLogicReadOutStructure SLROS;
1062 MatrixReadOutStructure matrixROS;
1063
1064 char recField;
1065 unsigned short int PadID = 99;
1066 unsigned int SLBodyWords = 0;
1067 unsigned int SL_data_size = 500; // same value used for the size of SLBuff
1068 unsigned short int SLBuff[500];
1069
1070 std::unique_ptr<RpcSectorLogic> sl{};
1071
1072 for (uint16_t i = 0; i < data_size; ++i) {
1073 // std::cout << "REGISTER: " << i << std::endl;
1074
1075 isRXHeader = false;
1076 isRXFooter = false;
1077 isPadHeader = false;
1078 isPadSubHeader = false;
1079 isPadPreFooter = false;
1080 isPadFooter = false;
1081 isSLHeader = false;
1082 isSLFooter = false;
1083 uint32_t currentWord = data[i];
1084
1085 //#ifndef NVERBOSE
1086 ATH_MSG_VERBOSE(" -->current data word is " << std::hex << currentWord << std::dec);
1087 //#endif
1088
1089 RXROS.decodeFragment(currentWord, recField);
1090 PDROS.decodeFragment(currentWord, recField);
1091 SLROS.decodeFragment(currentWord, recField);
1092
1093 if (RXROS.isHeader() && !isSLFragment)
1094 isRXHeader = true;
1095 else if (RXROS.isFooter() && !isSLFragment)
1096 isRXFooter = true;
1097 else if (PDROS.isHeader() && !isSLFragment)
1098 isPadHeader = true;
1099 else if (PDROS.isSubHeader() && !isSLFragment)
1100 isPadSubHeader = true;
1101 else if (PDROS.isPreFooter() && !isSLFragment)
1102 isPadPreFooter = true;
1103 else if (PDROS.isFooter() && !isSLFragment)
1104 isPadFooter = true;
1105 else if (SLROS.isHeader())
1106 isSLHeader = true;
1107 else if (SLROS.isFooter())
1108 isSLFooter = true;
1109
1110 // The SLROS functions still return values (based on default values)
1111 if (skipSectorLogicDecoding) {
1112 isSLHeader = false;
1113 isSLFragment = false;
1114 isSLFooter = false;
1115 }
1116
1117 //#ifndef NVERBOSE
1118 if (msgLvl(MSG::VERBOSE)) {
1119 msg(MSG::VERBOSE) << " RX Header: " << isRXHeader << " RX Footer: " << isRXFooter << endmsg;
1120 msg(MSG::VERBOSE) << " Pad Header: " << isPadHeader << " Pad SubHeader: " << isPadSubHeader
1121 << " Pad PreFooter: " << isPadPreFooter << " Pad Footer: " << isPadFooter << endmsg;
1122 msg(MSG::VERBOSE) << " isPADFragment: " << isPADFragment << endmsg;
1123 msg(MSG::VERBOSE) << " SL Header: " << isSLHeader << " SL Footer: " << isSLFooter << endmsg;
1124 msg(MSG::VERBOSE) << " isSLFragment: " << isSLFragment << endmsg;
1125 }
1126 //#endif
1127
1128 if (isRXHeader) {
1129 //#ifndef NVERBOSE
1130 if (msgLvl(MSG::VERBOSE)) {
1131 msg(MSG::VERBOSE) << " this is a RX Header " << endmsg;
1132 msg(MSG::VERBOSE) << " Sector ID=" << RXROS.RXid() << endmsg;
1133 }
1134 //#endif
1135
1136 // set sector ID, old format of RX header
1137 // sector = RXROS.RXid();
1138 sector = RXROS.status();
1139
1140 uint16_t errorCode = RXROS.errorCode();
1141
1142 // set to zero the index of the SL fragment
1143 SLindex = 0;
1144
1145 // check if the SL already exists
1146 if (sectorLogicContainer && !sectorLogicContainer->findSector(sector, 0)) {
1147 // Create the new sector logic object
1148 sl = std::make_unique<RpcSectorLogic>(sector, 0, 0, errorCode);
1149
1150 } else if (sectorLogicContainer) {
1151 for (RpcSectorLogicContainer::iterator itSL = sectorLogicContainer->begin(); itSL != sectorLogicContainer->end();
1152 ++itSL) {
1153 if ((*itSL)->sectorId() == sector) {
1154 sl.reset(*itSL);
1155 break;
1156 }
1157 }
1158 }
1159
1160 } else if (isRXFooter) {
1161 //#ifndef NVERBOSE
1162 if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << " this is a RX Footer " << endmsg;
1163 //#endif
1164 } else if (isSLHeader || isSLFragment) {
1165 isSLFooter ? isSLFragment = false : isSLFragment = true;
1166
1167 // push only the lowest 16 bits
1168 int foundSL = myRPC.pushWord(currentWord, 0, m_nobxs);
1169
1170 // Check the Sector Logic Fragment
1171 if (foundSL) {
1172 //#ifndef NVERBOSE
1173 if (msgLvl(MSG::VERBOSE)) {
1174 msg(MSG::VERBOSE) << "SectorLogicReadOut checkFragment: " << myRPC.SLFragment()->checkFragment() << endmsg;
1175 msg(MSG::VERBOSE) << myRPC.SLFragment() << endmsg;
1176 }
1177 //#endif
1178 }
1179
1180 if (isSLHeader) SLBodyWords = 0;
1181
1182 // Decode the sector logic footer
1183 else if (isSLFooter) {
1184#ifndef NVERBOSE
1185 if (SLindex > 1) { msg(MSG::ERROR) << "More than 2 SL fragments in sector " << sector << endmsg; }
1186#endif
1187
1188#ifndef NVERBOSE
1189 msg(MSG::VERBOSE) << " Number of data words in SectorLogicReadOut= " << SLBodyWords << endmsg;
1190 msg(MSG::VERBOSE) << " TEST SL: " << foundSL << endmsg;
1191#endif
1192
1193#ifndef NVERBOSE
1194 // Print out a raw dump of the SL fragment
1195 for (unsigned short j = 0; j < SLBodyWords; j++) {
1196 msg(MSG::VERBOSE) << " SL data word " << j << " : " << std::hex << SLBuff[j] << MSG::dec << endmsg;
1197 }
1198#endif
1199
1200 // Found the sector logic footer, the sector logic fragment
1201 // can be added to the sector logic container
1202
1203 // Check if the sector was already added to the container
1204 if (sectorLogicContainer && !sectorLogicContainer->findSector(sector, SLindex)) {
1205 SectorLogicReadOut* sectorLogic = myRPC.SLFragment();
1206 // decode the SL hits and push back in the sector logic
1207 uint16_t nSLlink = 2;
1208 uint16_t nSLgate = 7;
1209
1210 // fill the hit content
1211 for (int igate = 0; igate < nSLgate; ++igate) {
1212 for (int ilink = 0; ilink < nSLlink; ++ilink) {
1213 uint16_t ptid = sectorLogic->ptid(ilink, igate);
1214
1215 if (ptid != 0) {
1216 uint16_t cmadd = sectorLogic->cmadd(ilink, igate);
1217
1218 uint16_t bcid = igate;
1219 uint16_t tower = ilink + 2 * SLindex;
1220
1221 uint16_t opl = sectorLogic->opl(ilink, igate);
1222 uint16_t ovphi = sectorLogic->ovphi(ilink, igate);
1223 uint16_t oveta = sectorLogic->oveta(ilink, igate);
1224
1225 uint16_t triggerBcid = sectorLogic->bcid(ilink, igate);
1226
1227 // create the hit and push back in the sl
1228 RpcSLTriggerHit* slHit = new RpcSLTriggerHit(bcid, tower, ptid, cmadd, opl, ovphi, oveta, triggerBcid);
1229 sl->push_back(slHit);
1230 }
1231 }
1232 }
1233
1234 // set the trigger rates
1235 // add the trigger rate of the second tower only if it is
1236 // the first sector logic fragment
1237 sl->addTriggerRate(sectorLogic->padTriggerRate(0));
1238 if (SLindex == 0) { sl->addTriggerRate(sectorLogic->padTriggerRate(1)); }
1239
1240 // push back the counters
1241 uint16_t nSLcount = sectorLogic->numberOfCounterWords();
1242
1243 for (int icount = 0; icount < nSLcount; ++icount) {
1244 uint16_t counter = ((sectorLogic->readSLCounterCurrent()) & 0x1fff);
1245 sl->addCounter(counter);
1246 }
1247
1248 // Flag the sector as initialized
1249 // bool setSector = sectorLogicContainer->setSector(sector,SLindex);
1250
1251 if (SLindex == 0 && sectorLogicContainer) { sectorLogicContainer->push_back(std::move(sl)); }
1252 }
1253
1254 // increment the SLindex counter of the number of fragments
1255 SLindex++;
1256
1257 } else {
1258 if (SLBodyWords >= SL_data_size) {
1259 if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << "Sector Logic payload corrupted" << endmsg;
1260 return StatusCode::FAILURE;
1261 }
1262 SLBuff[SLBodyWords] = currentWord;
1263 SLBodyWords++;
1264 } // isSLHeader
1265
1266 } else if (isPadHeader || isPADFragment) {
1267 // Now decoding the header of the pad
1268#ifndef NVERBOSE
1269 msg(MSG::VERBOSE) << " Pad Header or Pad Fragment " << endmsg;
1270#endif
1271
1272 PDROS.decodeFragment(currentWord, recField);
1273
1274 if (recField == 'H') {
1275 PadID = PDROS.padid();
1276
1277 uint16_t status = 0;
1278
1279 side = (sector < 32) ? 0 : 1;
1280 uint16_t sectorLogic = sector - side * 32;
1281#ifndef NVERBOSE
1282 msg(MSG::VERBOSE) << " Pad Identifier= " << PadID << " Status: " << status << endmsg;
1283#endif
1284
1285 SG::ReadCondHandle<RpcCablingCondData> cablingCondData{m_rpcReadKey, Gaudi::Hive::currentContext()};
1286 const RpcCablingCondData* rpcCabling{*cablingCondData};
1287
1288 // get the offline ID of the pad
1289 if (!rpcCabling->giveOfflineId(side, sectorLogic, PadID, padOfflineId)) {
1290 if (msgLvl(MSG::VERBOSE))
1291 msg(MSG::VERBOSE) << "Cannot retrieve the OfflineID for the PAD n. " << PadID << " at side " << side
1292 << " and sector " << sectorLogic << endmsg;
1293 } else if (msgLvl(MSG::VERBOSE))
1294 msg(MSG::VERBOSE) << "ID " << m_idHelperSvc->rpcIdHelper().show_to_string(padOfflineId) << " associated to PAD n. "
1295 << PadID << " at side " << side << " and sector " << sectorLogic << endmsg;
1296
1297 // check if it's the pad to convert
1298 if (thisPadOfflineId == padOfflineId) {
1299 if (msgLvl(MSG::VERBOSE))
1300 msg(MSG::VERBOSE) << " match found with ID " << m_idHelperSvc->rpcIdHelper().show_to_string(thisPadOfflineId)
1301 << " requested for the conversion; return this collection" << endmsg;
1302
1303 foundPad = true;
1304#ifndef NVERBOSE
1305 msg(MSG::VERBOSE) << "Found the pad to convert !" << endmsg;
1306#endif
1307 v.setOnlineId(PadID);
1308 v.setStatus(status);
1309 v.setSector(sector);
1310
1311 // set the lvl1 id
1312 v.setLvl1Id(PDROS.l1id());
1313
1314 } else {
1315 if (msgLvl(MSG::VERBOSE))
1316 msg(MSG::VERBOSE) << " match NOT found with ID "
1317 << m_idHelperSvc->rpcIdHelper().show_to_string(thisPadOfflineId)
1318 << " requested for the conversion" << endmsg;
1319 }
1320 }
1321
1322 // if it's a subheader, set the bcid
1323 if (recField == 'S') {
1324 if (foundPad) {
1325 v.setBcId(PDROS.bcid());
1326#ifndef NVERBOSE
1327 msg(MSG::VERBOSE) << "Found the subheader, setting bcid to: " << PDROS.bcid() << endmsg;
1328#endif
1329 }
1330 }
1331
1332 if (recField == 'F') {
1333#ifndef NVERBOSE
1334 msg(MSG::VERBOSE) << " Pad Footer " << endmsg;
1335#endif
1336 // found the pad, bail out
1337 if (foundPad) {
1338 foundPad = false;
1339 return StatusCode::SUCCESS;
1340 }
1341 }
1342
1343 isPadFooter ? isPADFragment = false : isPADFragment = true;
1344
1345#ifndef NVERBOSE
1346 msg(MSG::VERBOSE) << " current word " << std::hex << currentWord << MSG::dec << endmsg;
1347
1348 msg(MSG::VERBOSE) << " ==isPADFragment= " << isPADFragment << endmsg;
1349 msg(MSG::VERBOSE) << " calling pushword: " << std::hex << currentWord << MSG::dec << endmsg;
1350#endif
1351
1352 int foundCM = 0;
1353 foundCM = myRPC.pushWord(currentWord, 0, m_nobxs);
1354
1355 if (foundCM == 1) {
1356#ifndef NVERBOSE
1357 msg(MSG::VERBOSE) << myRPC.CMFragment() << endmsg;
1358#endif
1359 // If the pad is the good one, add the CMs to the container
1360 if (foundPad) {
1361 MatrixReadOut* matrix = myRPC.CMFragment();
1362
1363 // std::cout << myRPC.CMFragment()<< std::endl;
1364
1365 matrixROS = matrix->getHeader();
1366 uint16_t cmaId = matrixROS.cmid();
1367 uint16_t fel1id = matrixROS.fel1id();
1368
1369 matrixROS = matrix->getSubHeader();
1370 uint16_t febcid = matrixROS.febcid();
1371
1372#ifndef NVERBOSE
1373 msg(MSG::VERBOSE) << "Creating a new CM, cmaId=" << cmaId << " fel1id=" << fel1id << " febcid=" << febcid << endmsg;
1374#endif
1375
1376 // Create the new cm
1377 RpcCoinMatrix* coinMatrix = new RpcCoinMatrix(padOfflineId, cmaId, fel1id, febcid);
1378
1379 // std::cout << matrix->numberOfBodyWords() << std::endl;
1380
1381 // Loop on the hits and push them in the coin matrix
1382 for (int i = 0; i < matrix->numberOfBodyWords(); ++i) {
1383 matrixROS = matrix->getCMAHit(i);
1384
1385 uint16_t bcid = matrixROS.bcid();
1386 uint16_t time = matrixROS.time();
1387 uint16_t ijk = matrixROS.ijk();
1388
1389 RpcFiredChannel* firedChan = 0;
1390
1391 if (ijk < 7) {
1392 uint16_t channel = matrixROS.channel();
1393 firedChan = new RpcFiredChannel(bcid, time, ijk, channel);
1394#ifndef NVERBOSE
1395 msg(MSG::VERBOSE) << "Adding a fired channel, bcid=" << bcid << " time="
1396 << " ijk=" << ijk << " channel=" << channel << endmsg;
1397#endif
1398 // add the fired channel to the matrix
1399 coinMatrix->push_back(firedChan);
1400 } else if (ijk == 7) {
1401 uint16_t overlap = matrixROS.overlap();
1402 uint16_t threshold = matrixROS.threshold();
1403 firedChan = new RpcFiredChannel(bcid, time, ijk, threshold, overlap);
1404#ifndef NVERBOSE
1405 msg(MSG::VERBOSE) << "Adding a fired channel, bcid=" << bcid << " time="
1406 << " ijk=" << ijk << " overlap=" << overlap << " threshold=" << threshold << endmsg;
1407#endif
1408 // add the fired channel to the matrix
1409 coinMatrix->push_back(firedChan);
1410 }
1411 }
1412
1413 v.push_back(coinMatrix);
1414
1415 } // end of the matrix decoding
1416
1417 (myRPC.CMFragment())->reset(m_nobxs);
1418
1419 } // end of the pad decoding
1420 }
1421 }
1422
1423 return StatusCode::SUCCESS;
1424 }
#define ATH_MSG_DEBUG(x)
DataModel_detail::iterator< DataVector > iterator
Definition DataVector.h:842
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
void reset(uint NOBXS)
Gaudi::Property< int > m_nobxs
MatrixReadOut * CMFragment()
SectorLogicReadOut * SLFragment()
int pushWord(const ubit16 inword, uint NOBXS)
bool findSector(const uint16_t sectorId, const uint16_t side=0) const
Check if the sector has already been decoded.
ubit16 decodeFragment(ubit16 inputWord, char &field)
ubit16 ptid(ubit16 indexLink, ubit16 indexGate)
ubit16 oveta(ubit16 indexLink, ubit16 indexGate)
ubit16 opl(ubit16 indexLink, ubit16 indexGate)
ubit16 ovphi(ubit16 indexLink, ubit16 indexGate)
float padTriggerRate(ubit16 padAddress)
ubit16 cmadd(ubit16 indexLink, ubit16 indexGate)
ubit16 bcid(ubit16 indexLink, ubit16 indexGate)
setEventNumber uint32_t

◆ fillCollection_v302()

StatusCode Muon::RpcROD_Decoder::fillCollection_v302 ( BS data,
const uint32_t data_size,
RpcPad & v,
const uint32_t & sourceId,
RpcSectorLogicContainer * sectorLogicContainer ) const
inlineprivate

fill RpcPads from a block of integers New version for data format 3.1 (ATLAS cosmics - NEW RPC READOUT)

Definition at line 467 of file RpcROD_Decoder.h.

468 {
469 bool skipSectorLogicDecoding = (sectorLogicContainer == nullptr);
470 if (skipSectorLogicDecoding) ATH_MSG_DEBUG("Skip SectorLogic decoding, so SLROC.decodeFragment is not being processed");
471
472 /* for (unsigned int i = 0; i<1000; ++i) { */
473 /* //std::cout<<" aaa "<<std::endl; */
474 /* msg(MSG::VERBOSE) << "try to increase cpu time "<<log(pow(((double)i+1.)/999.,3))<<endmsg; */
475 /* } */
476
477 // m_bench.point(1);
478 // unpack the 32 bits words into 16 bits
479 // no ROD header and footer
480 std::vector<uint16_t> p = get16bits_v301(data, data_size, 0, 0);
481
482 const int size = p.size();
483
484 ATH_MSG_VERBOSE("**********Decoder v302 dumping the words******** ");
486 /* #ifndef NVERBOSE */
487 /* std::cout<<" printing something for testing"<<std::endl; */
488 /* #endif */
489
490 if (size > 0 && msgLvl(MSG::VERBOSE)) {
491 msg(MSG::VERBOSE) << "The size of this ROD-read is " << size << endmsg;
492 int decoded;
493 char decoded_char[1000];
494 for (int i = 0; i < size; i++) {
495 decoded = (p[i] & 0xf000) >> 12;
496 if (decoded < 0x4) sprintf(decoded_char, "Hit data");
497 if (decoded == 0x4) sprintf(decoded_char, "CM Footer");
498 if (decoded == 0x5) sprintf(decoded_char, "PAD Header");
499 if (decoded == 0x6) sprintf(decoded_char, "PAD/SL Subheader");
500 if (decoded == 0x7) sprintf(decoded_char, "PAD Footer");
501 if (decoded == 0x8) sprintf(decoded_char, "CM Subheader");
502 if (decoded == 0x9) sprintf(decoded_char, "RX Header");
503 if (decoded == 0xa) sprintf(decoded_char, "PAD Prefooter");
504 if (decoded == 0xb) sprintf(decoded_char, "RX Footer");
505 if (decoded == 0xc) sprintf(decoded_char, "CM Header");
506 if (decoded == 0xd) sprintf(decoded_char, "SL Header");
507 if (decoded == 0xe) sprintf(decoded_char, "RX Subheader");
508 if (decoded == 0xf) sprintf(decoded_char, "SL Footer");
509
510 msg(MSG::VERBOSE) << "word " << i << " = " << MSG::hex << p[i] << MSG::dec << " " << MSG::hex << decoded << MSG::dec << " "
511 << decoded_char << endmsg;
512 }
513 }
514
515 if (size == 0) {
516 ATH_MSG_VERBOSE(" Buffer size 0 ! ");
517 return StatusCode::FAILURE;
518 }
519
520 if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << "The source ID is: " << MSG::hex << sourceId << endmsg;
521
522 uint16_t sectorForCabling = 0;
523 uint16_t sector = 0;
524
525 // counter of the numerb of sector logic fragments found
526 uint16_t SLindex = 0;
527
528 // the identifier of this collection
529 Identifier thisPadOfflineId = v.identify();
530
531 // Identifier of the collection in data
532 Identifier padOfflineId;
533 bool foundPad = false;
534
535 if (msgLvl(MSG::VERBOSE))
536 msg(MSG::VERBOSE) << "The offline ID request for conversion is "
537 << m_idHelperSvc->rpcIdHelper().show_to_string(thisPadOfflineId) << endmsg;
538
539 bool isSLHeader = false;
540 bool isSLSubHeader = false;
541 bool isSLFooter = false;
542 bool isSLFragment = false;
543 bool isRXHeader = false;
544 bool isRXFooter = false;
545 bool isPADFragment = false;
546 bool isPadHeader = false;
547 bool isPadSubHeader = false;
548 bool isPadPreFooter = false;
549 bool isPadFooter = false;
550
551 // return;
552
553 RPCRXRODDecode myRPC;
554 RXReadOutStructure RXROS;
555 PadReadOutStructure PDROS;
556 SectorLogicRXReadOutStructure SLROS;
557 MatrixReadOutStructure matrixROS;
558 RPCRODStructure rodReadout;
559
560 char recField;
561 unsigned short int PadID = 99;
562 uint16_t slfel1id = 0;
563 uint16_t slid = 0;
564 uint16_t slbcid = 0;
565 uint16_t slstatus = 0;
566 uint16_t slcrc = 0;
567 unsigned int SLBodyWords = 0;
568 unsigned int SL_data_sise = 500; // same value used for the size of SLBuff
569 unsigned short int SLBuff[500];
570
571 // decode the source Id and set side and sector number
572 rodReadout.decodeSourceID(sourceId);
573 uint16_t subDetectorID = (sourceId & 0xff0000) >> 16;
574
575 uint16_t side = (subDetectorID == eformat::MUON_RPC_BARREL_A_SIDE) ? 1 : 0;
576 uint16_t rodId = rodReadout.getSourceIDRODID();
577 if (msgLvl(MSG::VERBOSE)) {
578 msg(MSG::VERBOSE) << "subDetectorID = 0x" << MSG::hex << subDetectorID << MSG::dec << endmsg;
579
580 msg(MSG::VERBOSE) << "rodID = 0x" << MSG::hex << rodId << MSG::dec << endmsg;
581 msg(MSG::VERBOSE) << "The side is " << side << endmsg;
582 }
583
584 // RpcSectorLogic* sl;
585
586 for (uint16_t i = 0; i < size; ++i) {
587 // std::cout << "REGISTER: " << i << std::endl;
588
589 isRXHeader = false;
590 isRXFooter = false;
591 isPadHeader = false;
592 isPadSubHeader = false;
593 isPadPreFooter = false;
594 isPadFooter = false;
595 isSLHeader = false;
596 isSLSubHeader = false;
597 isSLFooter = false;
598 uint32_t currentWord = p[i];
599
600 RXROS.decodeFragment(currentWord, recField);
601 PDROS.decodeFragment(currentWord, recField);
602 if (!skipSectorLogicDecoding) { SLROS.decodeFragment(currentWord, recField); }
603
604 if (RXROS.isHeader()) {
605 isRXHeader = true;
606 isSLFragment = false;
607 isPADFragment = false;
608 } else if (PDROS.isSubHeader() && !isSLFragment) {
609 isPadSubHeader = true;
610 } else if (RXROS.isFooter()) {
611 isRXFooter = true;
612 } else if (PDROS.isHeader()) {
613 isPadHeader = true;
614 isSLFragment = false;
615 } else if (PDROS.isPreFooter()) {
616 isPadPreFooter = true;
617 } else if (PDROS.isFooter()) {
618 isPadFooter = true;
619 } else if (SLROS.isHeader()) {
620 isSLHeader = true;
621 isSLFragment = true;
622 isPADFragment = false;
623 } else if (SLROS.isFooter()) {
624 isSLFooter = true;
625 isSLFragment = false;
626 } else if (SLROS.isSubHeader() && isSLFragment) {
627 isSLSubHeader = true;
628 }
629
630 // The SLROS functions still return values (based on default values)
631 if (skipSectorLogicDecoding) {
632 isSLHeader = false;
633 isSLSubHeader = false;
634 isSLFragment = false;
635 isSLFooter = false;
636 }
637
638 SG::ReadCondHandle<RpcCablingCondData> cablingCondData{m_rpcReadKey, Gaudi::Hive::currentContext()};
639 const RpcCablingCondData* rpcCabling{*cablingCondData};
640
641 if (msgLvl(MSG::VERBOSE)) {
642 char decoded_char[256];
643 if (isRXHeader) {
644 sprintf(decoded_char, " RX Header");
645 } else if (isRXFooter) {
646 sprintf(decoded_char, " RX Footer");
647 } else if (isSLHeader) {
648 sprintf(decoded_char, " SL Header");
649 } else if (isSLSubHeader) {
650 sprintf(decoded_char, " SL SubHeader");
651 } else if (isSLFooter) {
652 sprintf(decoded_char, " SL Footer");
653 } else if (isPadHeader) {
654 sprintf(decoded_char, " Pad Header");
655 } else if (isPadSubHeader) {
656 sprintf(decoded_char, " Pad SubHeader");
657 } else if (isPadPreFooter) {
658 sprintf(decoded_char, " Pad PreFooter");
659 } else if (isPadFooter) {
660 sprintf(decoded_char, " Pad Footer");
661 } else if (isSLFragment) {
662 sprintf(decoded_char, " SL Fragment");
663 } else if (isPADFragment) {
664 sprintf(decoded_char, " Pad Fragment");
665 } else {
666 sprintf(decoded_char, " Undecoded");
667 }
668
669 msg(MSG::VERBOSE) << i << " -->current data word is " << MSG::hex << currentWord << MSG::dec << decoded_char << endmsg;
670 }
671 if (isRXHeader) {
672 if (msgLvl(MSG::VERBOSE)) {
673 msg(MSG::VERBOSE) << " this is a RX Header " << endmsg;
674 msg(MSG::VERBOSE) << " Sector ID=" << RXROS.RXid() << endmsg;
675 }
676
677 // get the sector id according to the new format
678 // not yet implemented in the readout classes
679
680 // uint16_t rxid = (currentWord & 0x800) >> 11;
681
682 uint16_t rxid = RXROS.RXid();
683 sectorForCabling = 2 * rodId + rxid;
684 sector = side * 32 + sectorForCabling;
685
686 // fix for M3
687 if ((rodId == 3 || rodId == 1) && (m_specialROBNumber > 0)) {
688 sector = 39;
689 sectorForCabling = 7;
690 // fix for M3 with runnumber up to 11533 (SFI)
691 if (m_specialROBNumber == 0x650001) {
692 sector = 40;
693 sectorForCabling = 8;
694 }
695 } else if ((rodId == 4 || rodId == 2) && (m_specialROBNumber > 0)) {
696 sector = 40;
697 sectorForCabling = 8;
698 }
699
700 } else if (isRXFooter) {
701 ATH_MSG_VERBOSE(" this is a RX Footer ");
702 } else if (isSLHeader || isSLFragment || isSLSubHeader || isSLFooter) {
703 // push only the lowest 16 bits
704 int foundSL = myRPC.pushWord(currentWord, 0, m_nobxs);
705
706 if (isSLHeader) {
707 SLBodyWords = 0;
708 slfel1id = SLROS.fel1id();
709 slid = SLROS.slid();
710
711 ATH_MSG_VERBOSE(" SL Header: slfel1id " << slfel1id << " slid: " << slid);
712 } else if (isSLSubHeader) {
713 slbcid = SLROS.slbcid();
714
715 ATH_MSG_VERBOSE("SL subheader: slbcid: " << slbcid);
716
717 }
718 // Decode the sector logic footer
719 else if (isSLFooter) {
720 if (SLindex > 1) { ATH_MSG_VERBOSE("More than 2 SL fragments in sector " << sector); }
721
722 if (msgLvl(MSG::VERBOSE)) {
723 msg(MSG::VERBOSE) << " Number of data words in SectorLogicReadOut= " << SLBodyWords << endmsg;
724 msg(MSG::VERBOSE) << " TEST SL: " << foundSL << endmsg;
725
726 // Print out a raw dump of the SL fragment
727 for (unsigned short j = 0; j < SLBodyWords; j++) {
728 msg(MSG::VERBOSE) << " SL data word " << j << " : " << MSG::hex << SLBuff[j] << MSG::dec << endmsg;
729 }
730 }
731
732 // Found the sector logic footer, the sector logic fragment
733 // can be added to the sector logic container
734
735 SectorLogicRXReadOut* sectorLogic = myRPC.SLFragment();
736
737 if (sectorLogicContainer && !sectorLogicContainer->findSector(sector, side)) {
738 slstatus = SLROS.status();
739 slcrc = SLROS.crc();
740 // fill the hit content for the first sector
741 RpcSectorLogic* sl = new RpcSectorLogic(sector, slfel1id, slbcid, slstatus, slcrc);
742 bool inputHeaderFound = false;
743 bool outputHeaderFound = false;
744 ATH_MSG_VERBOSE("New RpcSectorLogic: sector=" << sector << " fel1id=" << slfel1id << " BCID=" << slbcid);
745
746 uint16_t rowinBcid = 999;
747 uint16_t slPadId = 999;
748
749 for (int islwords = 0; islwords < sectorLogic->numberOfInputWords(); ++islwords) {
750 uint16_t ptid;
751 uint16_t roi;
752 uint16_t outerPlane;
753 uint16_t overlapPhi;
754 uint16_t overlapEta;
755
756 uint16_t slWord = sectorLogic->readSLHitCurrent();
757
758 ATH_MSG_VERBOSE("SLhit word: " << std::hex << slWord << std::dec);
759 SLROS.decodeFragment(slWord, recField);
760
761 uint16_t triggerBcid;
762
763 if (SLROS.isInputHeader()) {
764 rowinBcid = SLROS.inputRowinBcid();
765 slPadId = SLROS.inputPadId();
766 inputHeaderFound = true;
767 } else if (SLROS.isInputBody()) {
768 if (!inputHeaderFound) {
769 ATH_MSG_VERBOSE("ERROR: inputSLHeader missing !!");
770 } else {
771 ptid = SLROS.inputThreshold();
772 roi = SLROS.inputRoi();
773 outerPlane = SLROS.inputOuterPlane();
774 overlapPhi = SLROS.inputOverlapPhi();
775 overlapEta = SLROS.inputOverlapEta();
776 triggerBcid = SLROS.inputTriggerBcid();
777
778 RpcSLTriggerHit* slHit =
779 new RpcSLTriggerHit(rowinBcid, slPadId, ptid, roi, outerPlane, overlapPhi, overlapEta, triggerBcid);
780 slHit->setIsInput(true);
781 sl->push_back(slHit);
782 ATH_MSG_VERBOSE("New input RpcSLTriggerHit: ptid, roi= " << ptid << " " << roi);
783 }
784 } else if (SLROS.isOutputHeader()) {
785 rowinBcid = SLROS.outputRowinBcid();
786 outputHeaderFound = true;
787 } else if (SLROS.isOutputBody()) {
788 if (!outputHeaderFound) {
789 rowinBcid = 999;
790 if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << "ERROR: outputSLHeader missing !!" << endmsg;
791 } else {
792 if (SLROS.isOutputDecoded()) {
793 outerPlane = 0;
794 overlapPhi = 0;
795
796 for (int icand = 0; icand < SLROS.nTriggerCand(); ++icand) {
797 ptid = SLROS.outputThreshold(icand);
798 triggerBcid = SLROS.outputTriggerBcid(icand);
799 roi = SLROS.outputRoi(icand);
800 overlapEta = SLROS.outputOverlap(icand);
801 RpcSLTriggerHit* slHit = new RpcSLTriggerHit(rowinBcid, 0, ptid, roi, outerPlane, overlapPhi,
802 overlapEta, triggerBcid);
803 slHit->setIsInput(false);
804 // use only one out od the two sectors for the moment (???)
805 sl->push_back(slHit);
806 ATH_MSG_VERBOSE("New output RpcSLTriggerHit: ptid, roi= " << ptid << " " << roi);
807 }
808
809 if (SLROS.hasMoreThan2TriggerCand()) { sl->setHasMoreThan2TriggerCand(true); }
810 }
811 }
812 }
813 }
814
815 if (sectorLogicContainer) sectorLogicContainer->push_back(sl);
816
817 if (sectorLogicContainer && !sectorLogicContainer->setSector(sector, side)) {
818 ATH_MSG_VERBOSE("Sector " << sector << " decoded more than once in SL");
819 }
820 }
821
822 } else {
823 if (SLBodyWords >= SL_data_sise) {
824 ATH_MSG_VERBOSE("Sector Logic payload corrupted");
825 return StatusCode::FAILURE;
826 }
827 SLBuff[SLBodyWords] = currentWord;
828 SLBodyWords++;
829 } // isSLHeader
830
831 } else if (isPadHeader || isPADFragment) {
832 // Now decoding the header of the pad
833 ATH_MSG_VERBOSE(" Pad Header or Pad Fragment ");
834
835 PDROS.decodeFragment(currentWord, recField);
836
837 if (recField == 'H') {
838 PadID = PDROS.padid();
839
840 // special setup for Dec06 sector 13 data
841 if (m_sector13Data) {
842 if (PadID < 3) {
843 sector = 56;
844 } else {
845 sector = 55;
846 // move the pad value to the 0-2 range;
847 PadID -= 3;
848 }
849 }
850
851 side = (sector < 32) ? 0 : 1;
852 uint16_t sectorLogic = sector - side * 32;
853
854 // get the offline ID of the pad
855 if (!rpcCabling->giveOfflineId(side, sectorLogic, PadID, padOfflineId)) {
856 if (msgLvl(MSG::VERBOSE))
857 msg(MSG::VERBOSE) << "Cannot retrieve the OfflineID for the PAD n. " << PadID << " at side " << side
858 << " and sector " << sectorLogic << endmsg;
859 } else {
860 if (msgLvl(MSG::VERBOSE))
861 msg(MSG::VERBOSE) << "ID " << m_idHelperSvc->rpcIdHelper().show_to_string(padOfflineId)
862 << " associated to PAD n. " << PadID << " at side " << side << " and sector " << sectorLogic
863 << endmsg;
864 }
865
866 // check if it's the pad to convert
867 if (thisPadOfflineId == padOfflineId) {
868 if (msgLvl(MSG::VERBOSE))
869 msg(MSG::VERBOSE) << " match found with ID " << m_idHelperSvc->rpcIdHelper().show_to_string(thisPadOfflineId)
870 << " requested for the conversion; return this collection" << endmsg;
871
872 foundPad = true;
873
874 v.setOnlineId(PadID);
875 v.setSector(sector);
876
877 // set the lvl1 id
878 v.setLvl1Id(PDROS.l1id());
879
880 } else {
881 if (msgLvl(MSG::VERBOSE))
882 msg(MSG::VERBOSE) << " match NOT found with ID "
883 << m_idHelperSvc->rpcIdHelper().show_to_string(thisPadOfflineId)
884 << " requested for the conversion" << endmsg;
885 }
886 }
887
888 // if it's a subheader, set the bcid
889 if (recField == 'S') {
890 if (foundPad) {
891 v.setBcId(PDROS.bcid());
892 if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << "Found the subheader, setting bcid to: " << PDROS.bcid() << endmsg;
893 }
894 }
895
896 if (recField == 'P') {
897 if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << "Found the prefooter" << endmsg;
898 // v.setStatus(currentWord&0x0fff );
899 v.setStatus(PDROS.status());
900
901 if (currentWord & 0x0fff) {
902 if (msgLvl(MSG::VERBOSE))
903 msg(MSG::VERBOSE) << "Pad Busy status not zero ! value: " << MSG::hex << (currentWord & 0x0fff) << MSG::dec
904 << endmsg;
905 }
906 }
907
908 if (recField == 'F') {
909 if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << " Pad Footer " << endmsg;
910 v.setErrorCode(PDROS.errorCode());
911 if (msgLvl(MSG::VERBOSE) && PDROS.errorCode() != 0) {
912 msg(MSG::VERBOSE) << "Pad Error flag not zero ! value: " << MSG::hex << PDROS.errorCode() << MSG::dec << endmsg;
913 }
914
915 // found the pad, bail out
916 if (foundPad) {
917 foundPad = false;
918 // std::cout << "found pad " << PadID << " sector " << sector << " " << sector%2 << std::endl;
919 // M.C. : CONTINUE TO SCAN TILL THE END of the ROB TO FIND LAST SectorLogic:
920 if (!(PadID > 3 && sector % 2 > 0)) { return StatusCode::SUCCESS; }
921 }
922 }
923
924 isPadFooter ? isPADFragment = false : isPADFragment = true;
925
926 if (msgLvl(MSG::VERBOSE)) {
927 msg(MSG::VERBOSE) << " current word " << MSG::hex << currentWord << MSG::dec << endmsg;
928
929 msg(MSG::VERBOSE) << " ==isPADFragment= " << isPADFragment << endmsg;
930 msg(MSG::VERBOSE) << " calling pushword: " << MSG::hex << currentWord << MSG::dec << endmsg;
931 }
932
933 int foundCM = 0;
934 foundCM = myRPC.pushWord(currentWord, 0, m_nobxs);
935
936 if (foundCM == 1) {
937 if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << myRPC.CMFragment() << endmsg;
938
939 // If the pad is the good one, add the CMs to the container
940 if (foundPad) {
941 MatrixReadOut* matrix = myRPC.CMFragment();
942
943 // std::cout << myRPC.CMFragment()<< std::endl;
944
945 matrixROS = matrix->getHeader();
946 uint16_t cmaId = matrixROS.cmid();
947 uint16_t fel1id = matrixROS.fel1id();
948
949 matrixROS = matrix->getSubHeader();
950 uint16_t febcid = matrixROS.febcid();
951
952 if (msgLvl(MSG::VERBOSE))
953 msg(MSG::VERBOSE) << "Creating a new CM, cmaId=" << cmaId << " fel1id=" << fel1id << " febcid=" << febcid
954 << endmsg;
955
956 // Create the new cm
957 RpcCoinMatrix* coinMatrix = new RpcCoinMatrix(padOfflineId, cmaId, fel1id, febcid);
958
959 matrixROS = matrix->getFooter();
960 coinMatrix->setCRC(matrixROS.crc());
961
962 // std::cout << matrix->numberOfBodyWords() << std::endl;
963
964 // Loop on the hits and push them in the coin matrix
965 for (int i = 0; i < matrix->numberOfBodyWords(); ++i) {
966 matrixROS = matrix->getCMAHit(i);
967
968 uint16_t bcid = matrixROS.bcid();
969 uint16_t time = matrixROS.time();
970 uint16_t ijk = matrixROS.ijk();
971
972 RpcFiredChannel* firedChan = 0;
973
974 if (ijk < 7) {
975 uint16_t channel = matrixROS.channel();
976 firedChan = new RpcFiredChannel(bcid, time, ijk, channel);
977
978 ATH_MSG_VERBOSE("Adding a fired channel, bcid=" << bcid << " time="
979 << " ijk=" << ijk << " channel=" << channel);
980
981 // add the fired channel to the matrix
982 coinMatrix->push_back(firedChan);
983 } else if (ijk == 7) {
984 uint16_t overlap = matrixROS.overlap();
985 uint16_t threshold = matrixROS.threshold();
986 firedChan = new RpcFiredChannel(bcid, time, ijk, threshold, overlap);
987
988 ATH_MSG_VERBOSE("Adding a fired channel, bcid=" << bcid << " time="
989 << " ijk=" << ijk << " overlap=" << overlap
990 << " threshold=" << threshold);
991
992 // add the fired channel to the matrix
993 coinMatrix->push_back(firedChan);
994 }
995 }
996
997 v.push_back(coinMatrix);
998
999 } // end of the matrix decoding
1000
1001 (myRPC.CMFragment())->reset(m_nobxs);
1002
1003 } // end of the pad decoding
1004 }
1005 }
1006 ATH_MSG_VERBOSE("Required Pad NOT FOUND in this ROB");
1007 // m_bench.point(2);
1008 return StatusCode::SUCCESS;
1009 }
std::vector< uint16_t > get16bits_v301(BS data, const int size, const int nHeader, const int nFooter) const
int pushWord(const ubit16 inword, uint NOBXS)
MatrixReadOut * CMFragment()
SectorLogicRXReadOut * SLFragment()
void setIsInput(bool isInput)
bool setSector(uint16_t sectorId, const uint16_t side=0)
Flag the sector as already decoded.
void setHasMoreThan2TriggerCand(const bool a)
ubit16 decodeFragment(ubit16 inputWord, char &field)

◆ fillCollection_v302new()

StatusCode Muon::RpcROD_Decoder::fillCollection_v302new ( BS data,
const uint32_t data_size,
RpcPad & v,
const uint32_t & sourceId,
RpcSectorLogicContainer * ,
const bool &  ) const
private

◆ fillCollections()

StatusCode Muon::RpcROD_Decoder::fillCollections ( const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment & robFrag,
RpcPadContainer & rdoIdc,
const std::vector< IdentifierHash > & collections,
RpcSectorLogicContainer * RPC_SECTORLOGIC,
const bool & decodeSL ) const
inlineoverride

Definition at line 306 of file RpcROD_Decoder.h.

308 {
309 try {
310 robFrag.check();
311 } catch (eformat::Issue& ex) {
312 ATH_MSG_VERBOSE(ex.what());
313 return StatusCode::FAILURE; // error in fragment
314 }
315
316 if (RPC_SECTORLOGIC == nullptr) { ATH_MSG_DEBUG("RPC_SECTORLOGIC is null, so we will skip decoding the sector logic information"); }
317
318 // get the pointer to the data
319 BS data;
320 robFrag.rod_data(data);
321
322 // here decide the version of the decoding to be called
323 uint32_t version = robFrag.rod_version();
324 uint32_t sourceId = robFrag.source_id();
325 uint32_t rod_sourceId = robFrag.rod_source_id();
326 uint16_t subDetector = (sourceId & 0xff0000) >> 16;
327
328 ATH_MSG_VERBOSE("ROD version: " << MSG::hex << version << MSG::dec << " ROB source ID: " << MSG::hex << sourceId << MSG::dec
329 << " ROD source ID: " << MSG::hex << rod_sourceId << MSG::dec << " Subdetector: " << MSG::hex
330 << subDetector << MSG::dec);
331
332 // chose the right decoding routine
333 bool isSimulated = (data[0] == 0xee1234ee) ? true : false;
334 int type = 0;
335
336 if (((version & 0x03000000) == 0x03000000) && (data[2] != 0x00) && ((data[0] & 0xffff0000) == 0)) {
337 type = 1;
338 ATH_MSG_VERBOSE("choosing fillCollection_v300");
339 } else if (version == 0x2400000 || isSimulated) {
340 type = 0;
341 ATH_MSG_VERBOSE("choosing fillCollection_v240");
342 } else if (((version & 0x03000000) == 0x03000000) &&
343 ((data[0] & 0xffff0000) != 0)) // this is the current data format - 2011 May 13
344 {
345 type = 2;
346 ATH_MSG_VERBOSE("choosing fillCollection_v302");
347 ATH_MSG_VERBOSE("with decodeSL when decoding from ROB " << decodeSL); // Only meaningful for this function
348 }
349
350 // for the time being use the old decoding schema .... to be optimized
351
352 StatusCode cnv_sc;
353
354 SG::ReadCondHandle<RpcCablingCondData> cablingCondData{m_rpcReadKey, Gaudi::Hive::currentContext()};
355 const RpcCablingCondData* rpcCabling{*cablingCondData};
356
357 // here optimize decoding of ROB fragment (for data only type==2)
358 if (type == 2) {
359 std::map<Identifier, RpcPad*> mapOfCollections;
360 // Request to update to range-based for-loop
361 for (const IdentifierHash& it : collections) {
362 // Normally, we would get a write handle and put a lock, but we do not process the decoding in this loop
363 // Therefore, we just query the cache via the container and process the hashes which have not been decoded yet
364 // Note that this means different threads may decode the same data if processing simultaneously
365 // However, only one will be written to the cache using the lock
366
367 bool alreadyPresent = rdoIdc.tryAddFromCache(it);
368
369 if (alreadyPresent) {
370 ATH_MSG_DEBUG("RPC RDO collection already exist with collection hash = " << static_cast<unsigned int>(it)
371 << " converting is skipped!");
372 } else {
373 ATH_MSG_DEBUG("Created new Pad Collection Hash ID = " << static_cast<unsigned int>(it));
374
375 // create new collection - I should be doing this with unique_ptr but it requires changing downstream functions
376 RpcPad* coll = new RpcPad(rpcCabling->identifier(it), it);
377 mapOfCollections[coll->identify()] = coll;
378
379 } // endif collection not found in the container
380 } // end loop over vector of hash id
381
382 if (mapOfCollections.empty()) {
383 ATH_MSG_VERBOSE("mapOfCollections is empty; fillCollectionsFromRob_v302 will not be called");
384 cnv_sc = StatusCode::SUCCESS;
385 return cnv_sc;
386 }
387
388 // RpcPadCollections not decoded and in container are identified and passed explicitly to decoder
389 cnv_sc = fillCollectionsFromRob_v302(data, robFrag.rod_ndata(), mapOfCollections, rod_sourceId, RPC_SECTORLOGIC, decodeSL);
390 if (cnv_sc != StatusCode::SUCCESS) {
391 if (cnv_sc == StatusCode::RECOVERABLE) {
392 ATH_MSG_DEBUG("Decoding errors found ");
393 } else
394 return cnv_sc; // exit if failure
395 }
396
397 // All un-decoded collections were decoded successfully, so they are passed back to the IDC
398 // Request to update to range-based for-loop
399 for (const std::map<Identifier, RpcPad*>::value_type& it : mapOfCollections) {
400 // Get the WriteHandle for this hash but we need to then check if it has already been decoded and
401 // added to the event cache for this hash in a different view
402 RpcPadContainer::IDC_WriteHandle lock = rdoIdc.getWriteHandle((it.second)->identifyHash());
403
404 if (lock.alreadyPresent()) {
405 ATH_MSG_DEBUG("RpcPad collection with hash " << (int)(it.second)->identifyHash()
406 << " was already decoded in a parallel view");
407 } else {
408 // Take the pointer and pass ownership to unique_ptr and pass to the IDC_WriteHandle
409 StatusCode status_lock = lock.addOrDelete(std::unique_ptr<RpcPad>(it.second));
410
411 if (status_lock != StatusCode::SUCCESS) {
412 ATH_MSG_ERROR("Failed to add RPC PAD collection to container with hash " << (int)(it.second)->identifyHash());
413 } else {
414 ATH_MSG_DEBUG("Adding RpcPad collection with hash " << (int)(it.second)->identifyHash()
415 << " to the RpcPad Container | size = " << (it.second)->size());
416 }
417 }
418 }
419 return cnv_sc;
420 } // endif (type==2)
421
422 // Request to update to range-based for-loop
423 for (const IdentifierHash& it : collections) {
424 // IDC_WriteHandle
426
427 if (lock.alreadyPresent()) {
428 ATH_MSG_DEBUG("RPC RDO collection already exist with collection hash = " << static_cast<unsigned int>(it)
429 << " converting is skipped!");
430 } else {
431 ATH_MSG_VERBOSE(" Created new Pad Collection Hash ID = " << static_cast<unsigned int>(it));
432
433 // create new collection - I should be doing this with unique_ptr but it requires changing downstream functions
434 RpcPad* coll = new RpcPad(rpcCabling->identifier(it), it);
435
436 // convert collection - note case3 will never be used due to statement above
437 switch (type) {
438 case 0: cnv_sc = fillCollection_v240(data, robFrag.rod_ndata(), *coll); break;
439 case 1: cnv_sc = fillCollection_v300(data, robFrag.rod_ndata(), *coll, subDetector, RPC_SECTORLOGIC); break;
440 case 2: cnv_sc = fillCollection_v302(data, robFrag.rod_ndata(), *coll, sourceId, RPC_SECTORLOGIC); break;
441 default: cnv_sc = fillCollection_v240(data, robFrag.rod_ndata(), *coll); break;
442 }
443
444 if (cnv_sc.isFailure()) { ATH_MSG_VERBOSE("Error into the RPC fillCollections decoding"); }
445
446 // Here need to implement writing for all the other fill methods
447 // Take the pointer and pass ownership to unique_ptr and pass to the IDC_WriteHandle
448 StatusCode status_lock = lock.addOrDelete(std::unique_ptr<RpcPad>(coll));
449
450 // add collection into IDC
451 if (status_lock != StatusCode::SUCCESS) {
452 ATH_MSG_ERROR("Failed to add RPC PAD collection to container");
453 // report the error condition
454 } else
455 ATH_MSG_DEBUG("Adding RpcPad collection with hash " << (int)(it)
456 << " to the RpcPad Container | size = " << coll->size());
457 }
458 }
459 return cnv_sc;
460 } // end fillCollections
Athena::TPCnvVers::Old Athena::TPCnvVers::Current Athena::TPCnvVers::Old Athena::TPCnvVers::Current Athena::TPCnvVers::Old Athena::TPCnvVers::Current Athena::TPCnvVers::Current Athena::TPCnvVers::Current RpcPad
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)
virtual bool tryAddFromCache(IdentifierHash hashId) override final
Looks in the cache to see if item already exists if not it returns false, If it does exist it incorpo...
StatusCode fillCollection_v300(BS data, const uint32_t data_size, RpcPad &v, const uint16_t &subDetector, RpcSectorLogicContainer *) const
fill RpcPads from a block of integers New version for data format 3.0 (ATLAS cosmics)
StatusCode fillCollection_v240(BS data, const uint32_t data_size, RpcPad &v) const
fill RpcPads from a block of integers Decode collection for old data format 2.4.0
StatusCode fillCollectionsFromRob_v302(BS data, const uint32_t data_size, std::map< Identifier, RpcPad * > &vmap, const uint32_t &sourceId, RpcSectorLogicContainer *, const bool &decodeSL) const
OFFLINE_FRAGMENTS_NAMESPACE::PointerType BS
StatusCode fillCollection_v302(BS data, const uint32_t data_size, RpcPad &v, const uint32_t &sourceId, RpcSectorLogicContainer *) const
fill RpcPads from a block of integers New version for data format 3.1 (ATLAS cosmics - NEW RPC READOU...
Identifier identifier(int i) const
Identifier identify() const
Definition RpcPad.h:100

◆ fillCollectionsFromRob_v302()

StatusCode Muon::RpcROD_Decoder::fillCollectionsFromRob_v302 ( BS data,
const uint32_t data_size,
std::map< Identifier, RpcPad * > & vmap,
const uint32_t & sourceId,
RpcSectorLogicContainer * ,
const bool & decodeSL ) const
private

◆ finalize()

StatusCode Muon::RpcROD_Decoder::finalize ( )
overridevirtual

Definition at line 43 of file RpcROD_Decoder.cxx.

43 {
44 //==LBTAG print format failure final statistics
46 return StatusCode::SUCCESS;
47}
void printcheckformat() const

◆ get16bits()

std::vector< uint16_t > Muon::RpcROD_Decoder::get16bits ( BS data,
const int size,
const int nHeader,
const int nFooter ) const
inlineprivate

Definition at line 1728 of file RpcROD_Decoder.h.

1728 {
1729 uint32_t mask = 0x0000FFFF;
1730 uint32_t pos[2] = {0, 16};
1731
1732 std::vector<uint16_t> result;
1733
1734 for (int i = nHeader; i < (size - nFooter); i++) {
1735 for (uint32_t j = 0; j < 2; j++) {
1736 uint32_t vshift = v32[i] >> pos[j];
1737 uint16_t fragment = (uint16_t)(vshift & mask);
1738 result.push_back(fragment);
1739 }
1740 }
1741 return result;
1742 }

◆ get16bits_v301()

std::vector< uint16_t > Muon::RpcROD_Decoder::get16bits_v301 ( BS data,
const int size,
const int nHeader,
const int nFooter ) const
inlineprivate

Definition at line 1712 of file RpcROD_Decoder.h.

1712 {
1713 uint32_t mask = 0x0000FFFF;
1714 uint32_t pos[2] = {16, 0};
1715
1716 std::vector<uint16_t> result;
1717
1718 for (int i = nHeader; i < (size - nFooter); i++) {
1719 for (uint32_t j = 0; j < 2; j++) {
1720 uint32_t vshift = v32[i] >> pos[j];
1721 uint16_t fragment = (uint16_t)(vshift & mask);
1722 result.push_back(fragment);
1723 }
1724 }
1725 return result;
1726 }

◆ initialize()

StatusCode Muon::RpcROD_Decoder::initialize ( )
overridevirtual

Definition at line 23 of file RpcROD_Decoder.cxx.

23 {
24 ATH_CHECK(m_idHelperSvc.retrieve());
25
26 ATH_CHECK(m_rpcReadKey.initialize());
27
28 if (m_specialROBNumber > 0) { ATH_MSG_DEBUG("Setting the special ROB Number to: 0x" << MSG::hex << m_specialROBNumber << MSG::dec); }
29
30 //==LBTAG initialize vector and variables for format failure check
31 for (int i = 0; i < 13; i++) m_RPCcheckfail[i] = 0;
32 m_printerror = 0;
33 if(m_nobxs>8){
34 //The RPC simulation uses many arrays that assume maximum 8 BCs are readout
35 //See TrigT1/TrigT1RPChardware/Matrix.h for example
36 ATH_MSG_ERROR("Readout of more than 8 BCs is not supported by the simulation");
37 return StatusCode::FAILURE;
38 }
39
40 return StatusCode::SUCCESS;
41}
#define ATH_CHECK
Evaluate an expression and check for errors.

◆ isSector13Data()

bool Muon::RpcROD_Decoder::isSector13Data ( ) const
inline

Definition at line 64 of file RpcROD_Decoder.h.

64{ return m_sector13Data; }

◆ printcheckformat()

void Muon::RpcROD_Decoder::printcheckformat ( ) const
inlineprivate

Definition at line 283 of file RpcROD_Decoder.h.

283 {
284 // ===================================
285 // Print check ROB fragment statistics
286 // ===================================
287 MsgStream log(Athena::getMessageSvc(), "RpcROD_Decoder::printcheckformat");
288 log << MSG::INFO << " ============ FINAL RPC DATA FORMAT STAT. =========== " << endmsg;
289 int tmp = m_RPCcheckfail[0].load();
290 log << MSG::INFO << " RX Header Errors............." << tmp << endmsg;
291 log << MSG::INFO << " RX SubHeader Errors.........." << m_RPCcheckfail[1] << endmsg;
292 log << MSG::INFO << " PAD Header Errors............" << m_RPCcheckfail[2] << endmsg;
293 log << MSG::INFO << " PAD/SL SubHeader Errors......" << m_RPCcheckfail[3] << endmsg;
294 log << MSG::INFO << " CM Header Errors............." << m_RPCcheckfail[4] << endmsg;
295 log << MSG::INFO << " CM SubHeader Errors.........." << m_RPCcheckfail[5] << endmsg;
296 log << MSG::INFO << " CM Footer Errors............." << m_RPCcheckfail[6] << endmsg;
297 log << MSG::INFO << " PAD PreFooter Errors........." << m_RPCcheckfail[7] << endmsg;
298 log << MSG::INFO << " PAD Footer Errors............" << m_RPCcheckfail[8] << endmsg;
299 log << MSG::INFO << " SL Header Errors............." << m_RPCcheckfail[9] << endmsg;
300 log << MSG::INFO << " SL Footer Errors............." << m_RPCcheckfail[10] << endmsg;
301 log << MSG::INFO << " RX Footer Errors............." << m_RPCcheckfail[11] << endmsg;
302 log << MSG::INFO << " CRC8 check Failures.........." << m_RPCcheckfail[12] << endmsg;
303 log << MSG::INFO << " ==================================================== " << endmsg;
304 }
IMessageSvc * getMessageSvc(bool quiet=false)

◆ specialROBNumber()

int Muon::RpcROD_Decoder::specialROBNumber ( ) const
inline

Definition at line 62 of file RpcROD_Decoder.h.

62{ return m_specialROBNumber; }

Member Data Documentation

◆ m_idHelperSvc

ServiceHandle<Muon::IMuonIdHelperSvc> Muon::RpcROD_Decoder::m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
private

Definition at line 100 of file RpcROD_Decoder.h.

100{this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};

◆ m_maxprinterror

IntegerProperty Muon::RpcROD_Decoder::m_maxprinterror
private

Definition at line 91 of file RpcROD_Decoder.h.

◆ m_nobxs

Gaudi::Property<int> Muon::RpcROD_Decoder::m_nobxs { this, "NOBXS", 8, "Number of bunch crossings in readout"}
private

Definition at line 96 of file RpcROD_Decoder.h.

96{ this, "NOBXS", 8, "Number of bunch crossings in readout"};

◆ m_printerror

int Muon::RpcROD_Decoder::m_printerror = 0
private

Definition at line 89 of file RpcROD_Decoder.h.

◆ m_RPCcheckfail

std::atomic_int Muon::RpcROD_Decoder::m_RPCcheckfail[13] {}
mutableprivate

Definition at line 90 of file RpcROD_Decoder.h.

90{};

◆ m_rpcReadKey

SG::ReadCondHandleKey<RpcCablingCondData> Muon::RpcROD_Decoder::m_rpcReadKey {this, "RpcCablingKey", "RpcCablingCondData", "Key of RpcCablingCondData"}
private

Definition at line 102 of file RpcROD_Decoder.h.

102{this, "RpcCablingKey", "RpcCablingCondData", "Key of RpcCablingCondData"};

◆ m_sector13Data

BooleanProperty Muon::RpcROD_Decoder::m_sector13Data
private

Definition at line 107 of file RpcROD_Decoder.h.

◆ m_specialROBNumber

IntegerProperty Muon::RpcROD_Decoder::m_specialROBNumber
private

Definition at line 105 of file RpcROD_Decoder.h.


The documentation for this class was generated from the following files: