121 ATH_MSG_DEBUG(
"===================================================");
122 ATH_MSG_DEBUG(
"in CscROD_Decode::fillCollection() - ROD version 2");
124 const uint32_t& detev_type = robFrag.rod_detev_type();
132 SourceIdentifier sid(robFrag.rod_source_id());
133 uint16_t subDetectorId = sid.subdetector_id();
134 uint32_t onlineRodId = sid.module_id();
135 ATH_MSG_DEBUG(
"Online ROD id is 0x" << MSG::hex << onlineRodId << MSG::dec);
137 uint16_t rodId = 0xFFFF;
138 bool check =
m_cabling->offlineId(onlineRodId, rodId);
140 ATH_MSG_ERROR(
"enable to convert online ROD Id to offline ROD Id - "
141 <<
"check the cabling service ");
142 uint16_t idColl =
m_cabling->collectionId(subDetectorId, rodId);
144 ATH_MSG_DEBUG(
"Online ROD / ROD / collection / subDetector IDs are 0x" << MSG::hex << onlineRodId << MSG::dec <<
" " << rodId <<
" "
145 << idColl <<
" " << subDetectorId);
150 std::unique_ptr<CscRawDataCollection> rawCollection(
nullptr);
153 ATH_MSG_DEBUG(
"CSC RDO collection already exist with collection hash = " << idColl <<
" collection filling is skipped!");
156 ATH_MSG_DEBUG(
"CSC RDO collection does not exist - creating a new one with hash = " << idColl);
157 rawCollection = std::make_unique<CscRawDataCollection>(idColl);
161 rawCollection->setSubDetectorId(subDetectorId);
162 rawCollection->setRodId(onlineRodId);
163 rawCollection->setOnlineId(idColl);
166 rawCollection->set_eventType(detev_type);
169 bool isSparsified = rawCollection->sparsified();
172 bool ne = rawCollection->neutron();
175 bool cal = rawCollection->calEnabled();
178 uint16_t latency = rawCollection->latency();
181 uint16_t calLayer = rawCollection->calLayer();
184 uint16_t calAmplitude = rawCollection->calAmplitude();
187 uint16_t samplingTime = rawCollection->rate();
190 uint16_t numSamples = detev_type & 0xFF;
192 ATH_MSG_DEBUG(
"Event Type: " << MSG::hex << detev_type << MSG::dec);
193 ATH_MSG_DEBUG(
"Sampling Time: " << samplingTime <<
" Number of Samples: " << numSamples);
194 ATH_MSG_DEBUG(
"Is Calibration Enabled?: " << cal <<
" Calibration Amplitude: " << calAmplitude);
195 ATH_MSG_DEBUG(
"Calibration Layer: " << calLayer <<
" Latency: " << latency);
196 ATH_MSG_DEBUG(
"Is neutron rejection ON?: " << ne <<
" Is sparsified data?: " << isSparsified);
200 uint32_t counter = 0;
201 uint32_t rpuSize = 0;
203 const unsigned int size = robFrag.rod_ndata();
204 ATH_MSG_DEBUG(
"CscROD_Decoder Total words received = " << size);
208 robFrag.rod_data(vint);
210 bool isHeaderWordNull =
false;
211 bool isClusterWordsUnrealistic =
false;
212 while (counter < size) {
214 uint32_t
header = vint[counter];
217 isHeaderWordNull =
true;
223 uint16_t rpuID_raw = (
header >> 24) & 0xFF;
227 if (rpuID_raw == 13) {
228 rpuID = uint16_t(rpuID_raw - 2);
235 rawCollection->addRPU(rpuID);
238 uint16_t dataType = (
header >> 16) & 0xFF;
239 rawCollection->addDataType(dataType);
242 uint32_t rSize =
header & 0xFFFF;
256 else if (dataType == 2) {
257 counter += rSize - 1;
258 ATH_MSG_DEBUG(
"Error condition encounted on RPU ID = " << rpuID <<
" continuing ...");
264 ATH_MSG_DEBUG(
"TTTT Type = " << dataType <<
" with no data and no errors. "
265 <<
" Continue to next RPU ...");
270 uint32_t scaAddress = vint[counter];
272 rawCollection->set_scaAddress(scaAddress);
276 uint32_t precisionClusters = vint[counter];
277 ATH_MSG_DEBUG(
"Number of Precision Cluster word 0x" << MSG::hex << precisionClusters << MSG::dec);
278 uint32_t precisionClusterCounts = 0;
279 for (uint16_t k = 0; k < 4; k++) {
280 uint16_t counts = (precisionClusters >> (24 - k * 8)) & 0xFF;
281 precisionClusterCounts += counts;
283 <<
"Layer Index = " << k <<
" Cluster Counts = " << counts);
284 unsigned int index = 0;
287 else if (rpuID == 11)
291 rawCollection->set_spuCount(
index, counts);
296 uint32_t secondClusterWord = vint[counter];
297 ATH_MSG_DEBUG(
"Second cluster word 0x" << MSG::hex << secondClusterWord << MSG::dec);
301 uint16_t nonPrecisionClusterCounts = (secondClusterWord >> 24) & 0xFF;
302 ATH_MSG_DEBUG(
"Summed Number of Clusters for non-precision layers " << nonPrecisionClusterCounts);
303 if (rpuID == 5) rawCollection->set_spuCount(4, nonPrecisionClusterCounts);
305 rawCollection->set_spuCount(9, nonPrecisionClusterCounts);
308 bool triggerType = (secondClusterWord >> 21) & 0x1;
309 if (triggerType) rawCollection->set_triggerType();
312 bool samplingPhase = (secondClusterWord >> 20) & 0x1;
313 if (samplingPhase) rawCollection->set_samplingPhase();
316 uint8_t firstBitSummary = (secondClusterWord >> 16) & 0xF;
317 rawCollection->set_firstBitSummary(firstBitSummary);
320 uint16_t clusterDataWords = secondClusterWord & 0xFFFF;
324 uint32_t totalClusterCounts = nonPrecisionClusterCounts + precisionClusterCounts;
325 ATH_MSG_DEBUG(
"Total summed Cluster Count for precision and non-precision layers = " << totalClusterCounts);
327 if (totalClusterCounts == 0) {
329 counter += rSize - 4;
334 uint16_t clusterCount = 0;
336 while (clusterCount < totalClusterCounts) {
338 uint32_t address = vint[counter];
340 ATH_MSG_DEBUG(
"cluster location word 0x" << MSG::hex << address << MSG::dec);
345 int stationId =
m_idHelperSvc->cscIdHelper().stationName(channelId);
346 int currentLayer =
m_idHelperSvc->cscIdHelper().wireLayer(channelId);
347 int orientation =
m_idHelperSvc->cscIdHelper().measuresPhi(channelId);
353 uint32_t time_width = vint[counter];
354 ATH_MSG_DEBUG(
" cluster time size word : stripId (CscIdHelper) 0x" << MSG::hex << time_width << MSG::dec <<
" " << stripId);
356 uint16_t time = (time_width >> 16) & 0xFFF;
357 uint16_t
width = time_width & 0xFFFF;
359 isClusterWordsUnrealistic =
true;
362 bool isTimeComputed = (time_width >> 28) & 0x1;
364 uint16_t totalSampleWords =
width * numSamples / 2 + (
width * numSamples) % 2;
367 std::vector<uint16_t> amplitude;
368 for (
int j = 0; j < totalSampleWords; ++j) {
371 amplitude.push_back(amp1);
372 amplitude.push_back(amp2);
378 uint16_t spuID = 0x0;
379 if (orientation == 0)
380 spuID =
static_cast<uint16_t
>((stationId - 50) * 5 + currentLayer - 1);
382 spuID =
static_cast<uint16_t
>(((stationId - 50) + 1) * 5 - 1);
388 ATH_MSG_INFO(
"Location word is not available and CscRawData is discarded!!");
395 rawCollection->push_back(rawData);
397 << idColl <<
" " << hashId <<
" " << spuID <<
" " << stationId <<
" :: measphi" << orientation <<
" L"
398 << currentLayer <<
" strId " << stripId <<
" nStr " <<
width <<
" T" << time <<
" nSampWords "
399 << totalSampleWords <<
" " <<
m_idHelperSvc->cscIdHelper().show_to_string(channelId));
402 ATH_MSG_DEBUG(
"****Total Cluster count = " << clusterCount <<
" for RPU ID " << rpuID);
406 if (counter > rpuSize) {
407 ATH_MSG_INFO(
"ROB Fragment with ID 0x" << std::hex << robFrag.rod_source_id() << std::dec <<
" has word Counter ="
408 << counter <<
" must not exceed summed RPU sizes =" << rpuSize <<
" Discarded!!");
410 rawCollection->erase(rawCollection->begin(), rawCollection->end());
415 if (counter < rpuSize) {
416 ATH_MSG_DEBUG(
"" << (rpuSize - counter) <<
" ghost words at the end of this RPU - skipping ...");
423 if (isHeaderWordNull) {
424 ATH_MSG_INFO(
" ROB Fragment with ID " << std::hex << robFrag.rod_source_id() << std::dec <<
" has null rpuID. Discarded!!");
425 rawCollection->erase(rawCollection->begin(), rawCollection->end());
427 if (isClusterWordsUnrealistic) {
428 ATH_MSG_INFO(
" ROB Fragment with ID 0x" << std::hex << robFrag.rod_source_id() << std::dec
429 <<
" has too many cluster words. Discarded!!");
430 rawCollection->erase(rawCollection->begin(), rawCollection->end());
434 StatusCode status_lock = lock.
addOrDelete(std::move(rawCollection));
435 if (status_lock.isFailure()) {
436 ATH_MSG_ERROR(
"Could not insert CscRawDataCollection into CscRawDataContainer...");
445 ATH_MSG_DEBUG(
"in CscROD_Decode::fillCollection() - ROD version 1");
450 rodReadOut.
set(
nullptr);
453 SourceIdentifier sid(robFrag.rod_source_id());
455 uint16_t subDetectorId = sid.subdetector_id();
456 uint16_t rodId = sid.module_id();
458 uint16_t idColl =
m_cabling->collectionId(subDetectorId, rodId);
463 std::unique_ptr<CscRawDataCollection> rawCollection(
nullptr);
466 ATH_MSG_DEBUG(
"CSC RDO collection already exist with collection hash = " << idColl <<
" converting is skipped!");
469 ATH_MSG_DEBUG(
"CSC RDO collection does not exist - creating a new one with hash = " << idColl);
470 rawCollection = std::make_unique<CscRawDataCollection>(idColl);
474 rawCollection->setSubDetectorId(subDetectorId);
475 rawCollection->setRodId(rodId);
476 rawCollection->setOnlineId(idColl);
478 const unsigned int size = robFrag.rod_ndata();
479 ATH_MSG_DEBUG(
"CscROD_Decoder Total words received = " << size);
486 uint32_t numSamples = p[0];
487 rawCollection->setNumSamples((uint16_t)numSamples);
490 uint16_t latency = (uint16_t)p[1];
491 rawCollection->setLatency(latency);
494 uint16_t samplingRate = (uint16_t)p[2];
495 rawCollection->setSamplingRate(samplingRate);
499 uint32_t numDPU = p[3];
500 rawCollection->setNumDPU((uint16_t)numDPU);
509 bool dpuFragment = rodReadOut.
isDPU(p[rodHeader]);
515 uint32_t i = rodHeader;
517 while (dpuFragment && i < (size - rodFooter)) {
520 uint32_t dpuID = p[i];
524 uint32_t numChannel = p[i];
540 if (!rodReadOut.
discard(numChannel)) {
541 for (
unsigned int j = 0; j < numChannel; j++) {
549 std::vector<uint16_t> amplitude;
550 for (
unsigned int j = 1; j <= numSamples; j++) {
553 amplitude.push_back(rodReadOut.
getAmp1());
554 if (amplitude.size() < numSamples) amplitude.push_back(rodReadOut.
getAmp2());
558 uint32_t address = rodReadOut.
address();
560 rawCollection->push_back(rawData);
563 ATH_MSG_INFO(
"this is a discard::numChannel = " << MSG::hex << numChannel);
566 if (i < (size - rodFooter)) dpuFragment = rodReadOut.
isDPU(p[i]);
570 StatusCode status_lock = lock.
addOrDelete(std::move(rawCollection));
571 if (status_lock.isFailure()) {
572 ATH_MSG_ERROR(
"Could not insert CscRawDataCollection into CscRawDataContainer...");
580 ATH_MSG_DEBUG(
"in CscROD_Decode::fillCollection() - ROD version 0");
585 rodReadOut.
set(
nullptr);
587 const unsigned int size = robFrag.rod_ndata();
588 ATH_MSG_DEBUG(
"CscROD_Decoder Total words received = " << size);
596 uint16_t rodId = rodReadOut.
rodId();
600 uint16_t subId = (subDetectorId == 0x0) ? 0x6A : 0x69;
602 uint16_t idColl =
m_cabling->collectionId(subId, rodId);
605 std::unique_ptr<CscRawDataCollection> rawCollection(
nullptr);
608 ATH_MSG_DEBUG(
"CSC RDO collection already exist with collection hash = " << idColl <<
" converting is skipped!");
611 ATH_MSG_DEBUG(
"CSC RDO collection does not exist - creating a new one with hash = " << idColl);
612 rawCollection = std::make_unique<CscRawDataCollection>(idColl);
616 rawCollection->setSubDetectorId(subDetectorId);
617 rawCollection->setRodId(rodId);
618 rawCollection->setOnlineId(idColl);
624 bool bodyFragment = rodReadOut.
isBody(p[rodHeader]);
629 uint32_t i = rodHeader;
630 while (bodyFragment && i < (size - rodFooter)) {
656 std::vector<uint16_t> amplitudes;
657 amplitudes.push_back(rodReadOut.
getAmp1());
658 amplitudes.push_back(rodReadOut.
getAmp2());
659 amplitudes.push_back(rodReadOut.
getAmp3());
660 amplitudes.push_back(rodReadOut.
getAmp4());
663 rawCollection->push_back(rawData);
666 bodyFragment = rodReadOut.
isBody(p[i]);
670 StatusCode status_lock = lock.
addOrDelete(std::move(rawCollection));
671 if (status_lock.isFailure()) {
672 ATH_MSG_ERROR(
"Could not insert CscRawDataCollection into CscRawDataContainer...");