convert all CscRawDataCollections in the current list to a vector of 32bit words
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
RPU header marker - it contains the size of the RPU, the data type and the RPU ID
strip addresses and ADC samples - the first 2 words contain the address and the width+time+timeFlag, following the ADC samplings
23 {
24 mLog << MSG::DEBUG <<
" in CscROD_Encoder " <<
endmsg;
25
26
27 CscRODReadOut rodReadOut;
28
29
31
32
33 typedef std::vector<const CscRawData*> rpu;
34 std::map<uint16_t, rpu> mapRPU;
35
40 for (;
it != it_end; ++
it) {
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) {
61 mLog << MSG::DEBUG <<
"CscROD_Encoder : Only one RPU with data in this ROD - RPU ID = " << rId <<
endmsg;
63 if (rId == emptyRPU) emptyRPU = 11;
64 mapRPU.insert(std::make_pair(emptyRPU, emptyVect));
65 }
66
68 bool samplingPhase =
m_cscRdo->samplingPhase();
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) {
79 mLog << MSG::DEBUG <<
"CscROD_Encoder : RPU id " << rpuID <<
endmsg;
80
83
91 uint32_t spuSize[] = {0, 0, 0, 0, 0};
94 for (
const CscRawData* rawData : rpuPair.second) {
96 mLog << MSG::DEBUG <<
"CscROD_Encoder : The SPU ID " << spuID <<
endmsg;
97 unsigned int i = 0x800;
98 if (spuID < 4)
100 else if (spuID > 4 && spuID < 9)
102 else if (spuID == 4 || spuID == 9)
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;
109 uint16_t unitSize = size / 2 + size % 2;
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
128 if (typeSize > rpuIndex)
130 else if (typeSize == 1)
132 else
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
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) {
175
176 v.push_back(address);
178
179 uint32_t secondWord = (0xFFF &
width) | (0xFFFF & time) << 16 | (0x1 & isTimeComputed) << 28;
180
181 v.push_back(secondWord);
183
184 const std::vector<uint16_t> amplitude = rawData->
samples();
185 std::vector<uint32_t> v32;
187 unsigned int n = v32.size();
188 for (
unsigned int i = 0;
i <
n;
i++) {
v.push_back(v32[i]); }
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}
void encodeFragments(const std::vector< uint16_t > &litude, std::vector< uint32_t > &v) const
void set(const CscIdHelper *cscIdHelper)
const CscIdHelper * m_cscIdHelper
uint16_t rpuID() const
data access methods
const std::vector< uint16_t > & samples() const
bool isTimeComputed() const
DataModel_detail::const_iterator< DataVector > const_iterator
Standard const_iterator.
time(flags, cells_name, *args, **kw)