ATLAS Offline Software
Loading...
Searching...
No Matches
RpcByteStreamDecoder Class Reference

#include <RpcByteStreamDecoder.h>

Collaboration diagram for RpcByteStreamDecoder:

Public Member Functions

 RpcByteStreamDecoder (const RPCbytestream *p_bytestream, const RpcCablingCondData *readCdo, const RpcIdHelper *rpcId, MsgStream *log=nullptr)
 ~RpcByteStreamDecoder ()
StatusCode decodeByteStream ()
std::vector< RpcPad * > * getPads ()
void print ()

Private Member Functions

RpcPaddecodePad (PADreadout &pad)
RpcCoinMatrixdecodeMatrix (MatrixReadOut *matrix, Identifier &id)
RpcByteStreamDecoderoperator= (const RpcByteStreamDecoder &right)
 RpcByteStreamDecoder (const RpcByteStreamDecoder &)

Private Attributes

const RPCbytestreamm_bytestream
const RpcCablingCondDatam_cabling
const RpcIdHelperm_rpcIdHelper
std::vector< RpcPad * > * m_rpcpads
MsgStream * m_log
bool m_debug
bool m_verbose

Detailed Description

Definition at line 24 of file RpcByteStreamDecoder.h.

Constructor & Destructor Documentation

◆ RpcByteStreamDecoder() [1/2]

RpcByteStreamDecoder::RpcByteStreamDecoder ( const RPCbytestream * p_bytestream,
const RpcCablingCondData * readCdo,
const RpcIdHelper * rpcId,
MsgStream * log = nullptr )

Definition at line 11 of file RpcByteStreamDecoder.cxx.

12 :
13 m_bytestream(p_bytestream), m_cabling(readCdo), m_rpcIdHelper(rpcId) {
14 m_rpcpads = new std::vector<RpcPad*>;
15 m_log = log;
16 if (m_log) {
17 m_debug = m_log->level() <= MSG::DEBUG;
18 m_verbose = m_log->level() <= MSG::VERBOSE;
19 } else {
20 m_debug = false;
21 m_verbose = false;
22 }
23}
const RpcCablingCondData * m_cabling
const RpcIdHelper * m_rpcIdHelper
std::vector< RpcPad * > * m_rpcpads
const RPCbytestream * m_bytestream

◆ ~RpcByteStreamDecoder()

RpcByteStreamDecoder::~RpcByteStreamDecoder ( )

Definition at line 25 of file RpcByteStreamDecoder.cxx.

25 {
26 if (m_rpcpads != nullptr) {
27 delete m_rpcpads;
28 m_rpcpads = nullptr;
29 }
30}

◆ RpcByteStreamDecoder() [2/2]

RpcByteStreamDecoder::RpcByteStreamDecoder ( const RpcByteStreamDecoder & )
private

Member Function Documentation

◆ decodeByteStream()

StatusCode RpcByteStreamDecoder::decodeByteStream ( )

Definition at line 32 of file RpcByteStreamDecoder.cxx.

32 {
33 if (m_debug && m_log) *m_log << MSG::DEBUG << "Start decoding" << endmsg;
34
35 PAD_Readout padReadout = m_bytestream->pad_readout();
36
37 // Iterate on the readout PADS and decode them
38 for (PAD_Readout::iterator it = padReadout.begin(); it != padReadout.end(); ++it) {
39 PADreadout pad = (*it).second;
40 RpcPad* newpad = decodePad(pad);
41
42 // Push back the decoded pad in the vector
43 m_rpcpads->push_back(newpad);
44 }
45
46 if (m_debug && m_log) *m_log << MSG::DEBUG << "Number of decoded Pads : " << m_rpcpads->size() << endmsg;
47
48 return StatusCode::SUCCESS;
49}
#define endmsg
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
std::map< int, PADreadout, std::less< int > > PAD_Readout
RpcPad * decodePad(PADreadout &pad)

◆ decodeMatrix()

RpcCoinMatrix * RpcByteStreamDecoder::decodeMatrix ( MatrixReadOut * matrix,
Identifier & id )
private

Definition at line 129 of file RpcByteStreamDecoder.cxx.

129 {
130 if (m_debug && m_log) *m_log << MSG::DEBUG << "Decoding a new RpcCoinMatrix" << endmsg;
131
132 // Matrix Header and SubHeader
133 MatrixReadOutStructure matrix_header = matrix->getHeader();
134 MatrixReadOutStructure matrix_subheader = matrix->getSubHeader();
135 MatrixReadOutStructure matrix_footer = matrix->getFooter();
136 // Check the data structure
137 // cppcheck-suppress assertWithSideEffect
138 assert(matrix_header.isHeader());
139 // cppcheck-suppress assertWithSideEffect
140 assert(matrix_subheader.isSubHeader());
141 // cppcheck-suppress assertWithSideEffect
142 assert(matrix_footer.isFooter());
143
144 // Create the coincidence matrix
145 RpcCoinMatrix* coinMatrix =
146 new RpcCoinMatrix(id, matrix_header.cmid(), matrix_footer.crc(), matrix_header.fel1id(), matrix_subheader.febcid());
147
148 // Iterate on fired channels and decode them
149 MatrixReadOutStructure cm_hit;
150 for (int j = 0; j < matrix->numberOfBodyWords(); ++j) {
151 cm_hit = matrix->getCMAHit(j);
152 // cppcheck-suppress assertWithSideEffect
153 assert(cm_hit.isBody());
154 RpcFiredChannel* firedChannel = nullptr;
155
156 if (cm_hit.ijk() < rpcRawHitWordLength) {
157 firedChannel = new RpcFiredChannel(cm_hit.bcid(), cm_hit.time(), cm_hit.ijk(), cm_hit.channel());
158 } else if (cm_hit.ijk() == rpcRawHitWordLength) {
159 firedChannel = new RpcFiredChannel(cm_hit.bcid(), cm_hit.time(), cm_hit.ijk(), cm_hit.threshold(), cm_hit.overlap());
160 }
161
162 coinMatrix->push_back(firedChannel);
163 }
164
165 if (m_debug && m_log) *m_log << MSG::DEBUG << "Number of Fired Channels in Matrix : " << coinMatrix->size() << endmsg;
166 return coinMatrix;
167}
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.
size_type size() const noexcept
Returns the number of elements in the collection.

◆ decodePad()

RpcPad * RpcByteStreamDecoder::decodePad ( PADreadout & pad)
private

Definition at line 52 of file RpcByteStreamDecoder.cxx.

52 {
53 if (m_debug && m_log) *m_log << MSG::DEBUG << "Decoding a new RpcPad" << endmsg;
54
55 // Identifier elements
56 int name = 0;
57 int eta = 0;
58 int phi = 0;
59 int doublet_r = 0;
60 int doublet_z = 0;
61 int doublet_phi = 0;
62 int gas_gap = 0;
63 int measures_phi = 0;
64 int strip = 0;
65
66 PadReadOut* readout = pad.give_pad_readout();
67
68 // Retrieve PAD sector and PAD ID
69 int sector = pad.sector();
70 int pad_id = pad.PAD();
71 // Compute side and logic sector
72 int side = (sector < 32) ? 0 : 1;
73 int logic_sector = sector % 32;
74 // Compute the key to retrieve the offline id from the map (as from LVL1 sim.)
75 int key = side * 10000 + logic_sector * 100 + pad_id;
76
77 if (m_debug && m_log) *m_log << MSG::DEBUG << "Pad: Side " << side << " Sector logic" << logic_sector << " Id " << pad_id << endmsg;
78
79 // Retrieve the identifier elements from the map
80 const RpcCablingCondData::RDOmap& pad_map = m_cabling->give_RDOs();
81 RDOindex index = (*pad_map.find(key)).second;
82
83 index.offline_indexes(name, eta, phi, doublet_r, doublet_z, doublet_phi, gas_gap, measures_phi, strip);
84
85 // Build the pad offline identifier
86 bool valid{false};
87 Identifier id = m_rpcIdHelper->padID(name, eta, phi, doublet_r, doublet_z, doublet_phi, valid);
88
89 if (m_log && !valid) {
90 *m_log << MSG::ERROR << "Invalid pad offline indices " << endmsg;
91 *m_log << MSG::ERROR << "Name : " << name << endmsg;
92 *m_log << MSG::ERROR << "Eta " << eta << " Phi " << phi << endmsg;
93 *m_log << MSG::ERROR << "Doublet r " << doublet_r << " Doublet_z " << doublet_z << " Doublet_phi " << doublet_phi << endmsg;
94 *m_log << MSG::ERROR << "Gas gap " << gas_gap << " Measures_phi " << measures_phi << " Strip " << strip << endmsg;
95 }
96
97 // Retrieve Pad status and error code from Pad header and footer
98 PadReadOutStructure pad_header = readout->getHeader();
99 PadReadOutStructure pad_footer = readout->getFooter();
100 // Check the data format
101 // cppcheck-suppress assertWithSideEffect
102 assert(pad_header.isHeader());
103 // cppcheck-suppress assertWithSideEffect
104 assert(pad_footer.isFooter());
105
106 unsigned int hashId = index.hash();
107 unsigned int onlineId = pad_id;
108 // unsigned int status = pad_header.status();
109 unsigned int status = 0;
110 unsigned int errorCode = pad_footer.errorCode();
111
112 // Construct the new Pad
113 RpcPad* rpc_pad = new RpcPad(id, hashId, onlineId, status, errorCode, sector);
114
115 // Iterate on the matrices and decode them
116 for (int i = 0; i < readout->numberOfCMROFragments(); ++i) {
117 MatrixReadOut* matrix = pad.matrices_readout(i);
118 RpcCoinMatrix* coinMatrix = decodeMatrix(matrix, id);
119 // Add the matrix to the pad
120 rpc_pad->push_back(coinMatrix);
121 }
122
123 if (m_debug && m_log) *m_log << MSG::DEBUG << "Number of matrices in Pad : " << rpc_pad->size() << endmsg;
124
125 return rpc_pad;
126}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
PadReadOut * give_pad_readout(void)
MatrixReadOut * matrices_readout(int) const
int sector(void) const
Definition PADreadout.h:40
int PAD(void) const
Definition PADreadout.h:41
PadReadOutStructure getFooter()
PadReadOutStructure getHeader()
ubit16 numberOfCMROFragments()
Definition PadReadOut.h:30
RpcCoinMatrix * decodeMatrix(MatrixReadOut *matrix, Identifier &id)
std::map< int, RDOindex, std::less< int > > RDOmap
str index
Definition DeMoScan.py:362
list valid
Definition calibdata.py:44
status
Definition merge.py:16

◆ getPads()

std::vector< RpcPad * > * RpcByteStreamDecoder::getPads ( )
inline

Definition at line 35 of file RpcByteStreamDecoder.h.

35{ return m_rpcpads; };

◆ operator=()

RpcByteStreamDecoder & RpcByteStreamDecoder::operator= ( const RpcByteStreamDecoder & right)
private

◆ print()

void RpcByteStreamDecoder::print ( )

Definition at line 170 of file RpcByteStreamDecoder.cxx.

170 {
171 std::cout << "Printing out RPC RDO's : " << std::endl;
172 std::cout << "Number of Pads in event : " << m_rpcpads->size() << std::endl;
173 std::vector<RpcPad*>::const_iterator pad_it;
174 int ipad = 1;
175 // Iterate on pads
176 for (pad_it = m_rpcpads->begin(); pad_it != m_rpcpads->end(); ++pad_it, ++ipad) {
177 std::cout << "Pad number " << ipad << " Identifier : " << std::endl;
178 (*pad_it)->identify().show();
179 std::cout << std::endl;
180 std::cout << "Number of Matrices in Pad : " << (*pad_it)->size() << std::endl;
181 // Iterate on the pad's coincidence matrices
183 int imat = 1;
184 for (mat_it = (*pad_it)->begin(); mat_it != (*pad_it)->end(); ++mat_it, ++imat) {
185 std::cout << "Matrix number " << imat << std::endl;
186 std::cout << "Number of fired channels: " << (*mat_it)->size() << std::endl;
188 int ichan = 1;
189 // Printout the fired channels
190 for (chan_it = (*mat_it)->begin(); chan_it != (*mat_it)->end(); ++chan_it, ++ichan) {
191 std::cout << "Fired Channel " << ichan << " :: bcid " << (*chan_it)->bcid() << " ijk " << (*chan_it)->ijk()
192 << " channel " << (*chan_it)->channel() << std::endl;
193 }
194 }
195 }
196}
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838

Member Data Documentation

◆ m_bytestream

const RPCbytestream* RpcByteStreamDecoder::m_bytestream
private

Definition at line 46 of file RpcByteStreamDecoder.h.

◆ m_cabling

const RpcCablingCondData* RpcByteStreamDecoder::m_cabling
private

Definition at line 47 of file RpcByteStreamDecoder.h.

◆ m_debug

bool RpcByteStreamDecoder::m_debug
private

Definition at line 52 of file RpcByteStreamDecoder.h.

◆ m_log

MsgStream* RpcByteStreamDecoder::m_log
private

Definition at line 51 of file RpcByteStreamDecoder.h.

◆ m_rpcIdHelper

const RpcIdHelper* RpcByteStreamDecoder::m_rpcIdHelper
private

Definition at line 48 of file RpcByteStreamDecoder.h.

◆ m_rpcpads

std::vector<RpcPad*>* RpcByteStreamDecoder::m_rpcpads
private

Definition at line 49 of file RpcByteStreamDecoder.h.

◆ m_verbose

bool RpcByteStreamDecoder::m_verbose
private

Definition at line 53 of file RpcByteStreamDecoder.h.


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