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

This class provides conversion from CSC RDO to ROD format. More...

#include <CscROD_Encoder.h>

Collaboration diagram for CscROD_Encoder:

Public Member Functions

 CscROD_Encoder ()
 constructor
 ~CscROD_Encoder ()=default
void setRdo (const CscRawDataCollection *rdo)
 set CscRawDataCollection
StatusCode fillROD (std::vector< uint32_t > &v, MsgStream &mLog)
 convert all CscRawDataCollections in the current list to a vector of 32bit words
void setIdHelper (const CscIdHelper *cscIdHelper)
 setIdHelper

Private Attributes

const CscRawDataCollectionm_cscRdo
const CscIdHelperm_cscIdHelper = nullptr

Detailed Description

This class provides conversion from CSC RDO to ROD format.

Author: Ketevi A. Assamagan BNL December 27 2003 following T. Maeno's example for TGC

Definition at line 25 of file CscROD_Encoder.h.

Constructor & Destructor Documentation

◆ CscROD_Encoder()

CscROD_Encoder::CscROD_Encoder ( )

constructor

Definition at line 19 of file CscROD_Encoder.cxx.

19: m_cscRdo(nullptr) {}
const CscRawDataCollection * m_cscRdo

◆ ~CscROD_Encoder()

CscROD_Encoder::~CscROD_Encoder ( )
default

Member Function Documentation

◆ fillROD()

StatusCode CscROD_Encoder::fillROD ( std::vector< uint32_t > & v,
MsgStream & mLog )

convert all CscRawDataCollections in the current list to a vector of 32bit words

convert CSC RDO to a vector of 32bit words

group the data into RPU's

in case only one RPU has data, write out the header of the empty RPU as well

Sampling phase; Trigger type, First summary bit

encode strip data fragments :: ROD body

this RPU identifier

RPU size from simulation - assume no ghost words: +1 for the RPU header word itsef

Find the size of the SPU - presumably the RPU has 5 SPU The SPU ID should range from 0 to 4. total number of clusters words: The unitWord = 2 at the start of a cluster + total number of words in the cluster: this is basically the number of samples/2 where one sample = 12-bit ADC. The 2 words at the start of the cluster describe the cluster size and location. The %2 accounts for the old number of samples

the RPU size = 1 word for the RPU header 1 word for the SCA channel 2 words for the cluster counts and miscellanous ---> +4

assume normal data type in simulation

RPU header marker - it contains the size of the RPU, the data type and the RPU ID

RPU header

SCA address - assume 0 in simulation

build the cluster counts - the first word is the precision SPU

build the second cluster information word

strip addresses and ADC samples - the first 2 words contain the address and the width+time+timeFlag, following the ADC samplings

we assume no error block nor ghost words int the simulation

Definition at line 23 of file CscROD_Encoder.cxx.

23 {
24 mLog << MSG::DEBUG << " in CscROD_Encoder " << endmsg;
25
26 // ROD readout structure : encoder/decoder
27 CscRODReadOut rodReadOut;
28
29 // initialize the identifier helper
30 rodReadOut.set(m_cscIdHelper);
31
32 // first group the pads into their RPUs
33 typedef std::vector<const CscRawData*> rpu;
34 std::map<uint16_t, rpu> mapRPU;
35
39 uint16_t rpuID = 0x0;
40 for (; it != it_end; ++it) {
41 const CscRawData* rawData = (*it);
42 uint16_t spuID = rawData->rpuID();
43 if (spuID <= 4)
44 rpuID = 5;
45 else if (spuID > 4 && spuID <= 9)
46 rpuID = 11;
47 else {
48 mLog << MSG::ERROR << "CscROD_Encoder : RPU ID out of range for Initial Layout:: SPU ID = " << spuID << endmsg;
49 return StatusCode::FAILURE;
50 }
51 mLog << MSG::DEBUG << "CscROD_Encoder : SPU ID is " << spuID << " for RPU ID= " << rpuID << endmsg;
52 mapRPU[rpuID].push_back(rawData);
53 }
54
56 rpu emptyVect;
57 emptyVect.clear();
58 const std::vector<uint16_t> rpus = m_cscRdo->rpuID();
59 if (rpus.size() == 1) {
60 uint16_t rId = rpus[0];
61 mLog << MSG::DEBUG << "CscROD_Encoder : Only one RPU with data in this ROD - RPU ID = " << rId << endmsg;
62 uint16_t emptyRPU = 5;
63 if (rId == emptyRPU) emptyRPU = 11;
64 mapRPU.insert(std::make_pair(emptyRPU, emptyVect));
65 }
66
68 bool samplingPhase = m_cscRdo->samplingPhase();
69 bool triggerType = m_cscRdo->triggerType();
70 uint8_t firstBitSummary = m_cscRdo->firstBitSummary();
71
73 mLog << MSG::DEBUG << "Number of RPU in this ROD = " << mapRPU.size() << endmsg;
74
75 unsigned int rpuIndex = 0;
76 for (std::pair<const uint16_t, rpu>& rpuPair : mapRPU) {
78 uint16_t rpuID = rpuPair.first;
79 mLog << MSG::DEBUG << "CscROD_Encoder : RPU id " << rpuID << endmsg;
80
83
91 uint32_t spuSize[] = {0, 0, 0, 0, 0};
92 uint16_t numberOfDataWords = 0;
93 uint32_t sampleDataWords = 0;
94 for (const CscRawData* rawData : rpuPair.second) {
95 uint16_t spuID = rawData->rpuID();
96 mLog << MSG::DEBUG << "CscROD_Encoder : The SPU ID " << spuID << endmsg;
97 unsigned int i = 0x800;
98 if (spuID < 4)
99 i = spuID;
100 else if (spuID > 4 && spuID < 9)
101 i = spuID - 5;
102 else if (spuID == 4 || spuID == 9)
103 i = 4;
104 if (i > 4) {
105 mLog << MSG::ERROR << "CscROD_Encoder : SPU ID out of range - " << spuID << " Stop and fix it " << endmsg;
106 } else {
107 mLog << MSG::DEBUG << "CscROD_Encoder : SPU ID and Index = " << spuID << " " << i << endmsg;
108 uint16_t size = (rawData->samples()).size();
109 uint16_t unitSize = size / 2 + size % 2;
110 spuSize[i] += 1;
111 numberOfDataWords += 2 + unitSize;
112 sampleDataWords += unitSize;
113 }
114 }
115 mLog << MSG::DEBUG << "CscROD_Encoder : Total Sample size = " << sampleDataWords << endmsg;
116
120 uint16_t rpuSize = numberOfDataWords + 4;
121
122 mLog << MSG::DEBUG << "CscRDO_Encoder : RPU ID and size (in words) = " << rpuID << " " << rpuSize << endmsg;
123
125 std::vector<uint8_t> dataType = m_cscRdo->dataType();
127 uint16_t typeSize = dataType.size();
128 if (typeSize > rpuIndex)
129 type = dataType[rpuIndex];
130 else if (typeSize == 1)
131 type = dataType[0];
132 else
133 type = 0x0;
134
135 mLog << MSG::DEBUG << "CscROD_Encoder : data type = " << type << endmsg;
136
139 uint32_t rpuHeader = (0xFFFF & rpuSize) | (0x000F & type) << 16 | (0x000F & rpuID) << 24;
140
142 v.push_back(rpuHeader);
143
144 mLog << MSG::DEBUG << "CscROD_Encoder : this rpuHeader = " << MSG::hex << rpuHeader << MSG::dec << endmsg;
145
147 v.push_back(m_cscRdo->scaAddress());
148
150 uint32_t precisionClusterWord = 0x0;
151 for (unsigned int i = 0; i < 4; ++i) {
152 precisionClusterWord = precisionClusterWord | (spuSize[i] << (24 - i * 8));
153 mLog << MSG::DEBUG << "CscROD_Encoder : SPU ID = " << (i + 1) << " cluster Counts " << spuSize[i] << endmsg;
154 }
155 v.push_back(precisionClusterWord);
156
157 mLog << MSG::DEBUG << "CscROD_Encoder : Non-precision "
158 << " cluster Counts " << spuSize[4] << endmsg;
159
160 mLog << MSG::DEBUG << "CscROD_Encoder:: number of Cluster Data Words " << numberOfDataWords << endmsg;
161
163 uint32_t secondClusterWord = (0xFFFF & numberOfDataWords) | (0xF & firstBitSummary) << 16 | (0x1 & samplingPhase) << 17 |
164 (0x1 & triggerType) << 18 | (0xFF & spuSize[4]) << 24;
165 v.push_back(secondClusterWord);
166
169 unsigned int check = 0;
170 for (const CscRawData* rawData : rpuPair.second) {
171 uint32_t address = rawData->address();
172 uint16_t time = rawData->time();
173 uint16_t width = rawData->width();
174 bool isTimeComputed = rawData->isTimeComputed();
175
176 v.push_back(address);
177 check++;
178
179 uint32_t secondWord = (0xFFF & width) | (0xFFFF & time) << 16 | (0x1 & isTimeComputed) << 28;
180
181 v.push_back(secondWord);
182 check++;
183
184 const std::vector<uint16_t> amplitude = rawData->samples();
185 std::vector<uint32_t> v32;
186 rodReadOut.encodeFragments(amplitude, v32);
187 unsigned int n = v32.size();
188 for (unsigned int i = 0; i < n; i++) { v.push_back(v32[i]); }
189 check += n;
190 mLog << MSG::DEBUG << "CscROD_Encoder : The with and the 32-bit sample words " << width << " " << n << endmsg;
191 }
192
193 rpuIndex++;
194
195 mLog << MSG::DEBUG << "CScROD_Encoder : Check and number of data words " << check << " " << numberOfDataWords << endmsg;
196 }
197
199
200 return StatusCode::SUCCESS;
201}
#define endmsg
const double width
void encodeFragments(const std::vector< uint16_t > &amplitude, std::vector< uint32_t > &v) const
void set(const CscIdHelper *cscIdHelper)
const CscIdHelper * m_cscIdHelper
uint16_t time() const
Definition CscRawData.h:127
uint32_t address() const
Definition CscRawData.h:131
uint16_t rpuID() const
data access methods
Definition CscRawData.h:125
uint16_t width() const
Definition CscRawData.h:128
const std::vector< uint16_t > & samples() const
Definition CscRawData.h:130
bool isTimeComputed() const
Definition CscRawData.h:129
DataModel_detail::const_iterator< DataVector > const_iterator
Standard const_iterator.
Definition DataVector.h:838
time(flags, cells_name, *args, **kw)
setWord1 uint16_t
setEventNumber uint32_t

◆ setIdHelper()

void CscROD_Encoder::setIdHelper ( const CscIdHelper * cscIdHelper)
inline

setIdHelper

Definition at line 44 of file CscROD_Encoder.h.

44{ m_cscIdHelper = cscIdHelper; }

◆ setRdo()

void CscROD_Encoder::setRdo ( const CscRawDataCollection * rdo)
inline

set CscRawDataCollection

Definition at line 35 of file CscROD_Encoder.h.

35{ m_cscRdo = rdo; }

Member Data Documentation

◆ m_cscIdHelper

const CscIdHelper* CscROD_Encoder::m_cscIdHelper = nullptr
private

Definition at line 48 of file CscROD_Encoder.h.

◆ m_cscRdo

const CscRawDataCollection* CscROD_Encoder::m_cscRdo
private

Definition at line 47 of file CscROD_Encoder.h.


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