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 EventContext &ctx, 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 (const EventContext &ctx, 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 (const EventContext &ctx, 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 (const EventContext &ctx, BS data, const uint32_t data_size, RpcPad &v, const uint32_t &sourceId, RpcSectorLogicContainer *, const bool &) const
StatusCode fillCollection_v302 (const EventContext &ctx, 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 (const EventContext &ctx, 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 115 of file RpcROD_Decoder.h.

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

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

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

◆ fillCollection_v302()

StatusCode Muon::RpcROD_Decoder::fillCollection_v302 ( const EventContext & ctx,
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 473 of file RpcROD_Decoder.h.

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

Definition at line 311 of file RpcROD_Decoder.h.

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

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

◆ 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 1718 of file RpcROD_Decoder.h.

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

◆ 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 65 of file RpcROD_Decoder.h.

65{ return m_sector13Data; }

◆ printcheckformat()

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

Definition at line 288 of file RpcROD_Decoder.h.

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

◆ specialROBNumber()

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

Definition at line 63 of file RpcROD_Decoder.h.

63{ 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 105 of file RpcROD_Decoder.h.

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

◆ m_maxprinterror

IntegerProperty Muon::RpcROD_Decoder::m_maxprinterror
private

Definition at line 96 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 101 of file RpcROD_Decoder.h.

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

◆ m_printerror

int Muon::RpcROD_Decoder::m_printerror = 0
private

Definition at line 94 of file RpcROD_Decoder.h.

◆ m_RPCcheckfail

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

Definition at line 95 of file RpcROD_Decoder.h.

95{};

◆ m_rpcReadKey

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

Definition at line 107 of file RpcROD_Decoder.h.

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

◆ m_sector13Data

BooleanProperty Muon::RpcROD_Decoder::m_sector13Data
private

Definition at line 112 of file RpcROD_Decoder.h.

◆ m_specialROBNumber

IntegerProperty Muon::RpcROD_Decoder::m_specialROBNumber
private

Definition at line 110 of file RpcROD_Decoder.h.


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