120 ATH_MSG_DEBUG(
"===================================================");
121 ATH_MSG_DEBUG(
"in CscROD_Decode::fillCollection() - ROD version 2");
123 const uint32_t& detev_type = robFrag.rod_detev_type();
131 SourceIdentifier sid(robFrag.rod_source_id());
132 uint16_t subDetectorId = sid.subdetector_id();
133 uint32_t onlineRodId = sid.module_id();
134 ATH_MSG_DEBUG(
"Online ROD id is 0x" << MSG::hex << onlineRodId << MSG::dec);
136 uint16_t rodId = 0xFFFF;
137 bool check =
m_cabling->offlineId(onlineRodId, rodId);
139 ATH_MSG_ERROR(
"enable to convert online ROD Id to offline ROD Id - "
140 <<
"check the cabling service ");
141 uint16_t idColl =
m_cabling->collectionId(subDetectorId, rodId);
143 ATH_MSG_DEBUG(
"Online ROD / ROD / collection / subDetector IDs are 0x" << MSG::hex << onlineRodId << MSG::dec <<
" " << rodId <<
" "
144 << idColl <<
" " << subDetectorId);
149 std::unique_ptr<CscRawDataCollection> rawCollection(
nullptr);
152 ATH_MSG_DEBUG(
"CSC RDO collection already exist with collection hash = " << idColl <<
" collection filling is skipped!");
155 ATH_MSG_DEBUG(
"CSC RDO collection does not exist - creating a new one with hash = " << idColl);
156 rawCollection = std::make_unique<CscRawDataCollection>(idColl);
160 rawCollection->setSubDetectorId(subDetectorId);
161 rawCollection->setRodId(onlineRodId);
162 rawCollection->setOnlineId(idColl);
165 rawCollection->set_eventType(detev_type);
168 bool isSparsified = rawCollection->sparsified();
171 bool ne = rawCollection->neutron();
174 bool cal = rawCollection->calEnabled();
177 uint16_t latency = rawCollection->latency();
180 uint16_t calLayer = rawCollection->calLayer();
183 uint16_t calAmplitude = rawCollection->calAmplitude();
186 uint16_t samplingTime = rawCollection->rate();
189 uint16_t numSamples = detev_type & 0xFF;
191 ATH_MSG_DEBUG(
"Event Type: " << MSG::hex << detev_type << MSG::dec);
192 ATH_MSG_DEBUG(
"Sampling Time: " << samplingTime <<
" Number of Samples: " << numSamples);
193 ATH_MSG_DEBUG(
"Is Calibration Enabled?: " << cal <<
" Calibration Amplitude: " << calAmplitude);
194 ATH_MSG_DEBUG(
"Calibration Layer: " << calLayer <<
" Latency: " << latency);
195 ATH_MSG_DEBUG(
"Is neutron rejection ON?: " << ne <<
" Is sparsified data?: " << isSparsified);
199 uint32_t counter = 0;
200 uint32_t rpuSize = 0;
202 const unsigned int size = robFrag.rod_ndata();
203 ATH_MSG_DEBUG(
"CscROD_Decoder Total words received = " << size);
207 robFrag.rod_data(vint);
209 bool isHeaderWordNull =
false;
210 bool isClusterWordsUnrealistic =
false;
211 while (counter < size) {
213 uint32_t
header = vint[counter];
216 isHeaderWordNull =
true;
222 uint16_t rpuID_raw = (
header >> 24) & 0xFF;
226 if (rpuID_raw == 13) {
227 rpuID = uint16_t(rpuID_raw - 2);
234 rawCollection->addRPU(rpuID);
237 uint16_t dataType = (
header >> 16) & 0xFF;
238 rawCollection->addDataType(dataType);
241 uint32_t rSize =
header & 0xFFFF;
255 else if (dataType == 2) {
256 counter += rSize - 1;
257 ATH_MSG_DEBUG(
"Error condition encounted on RPU ID = " << rpuID <<
" continuing ...");
263 ATH_MSG_DEBUG(
"TTTT Type = " << dataType <<
" with no data and no errors. "
264 <<
" Continue to next RPU ...");
269 uint32_t scaAddress = vint[counter];
271 rawCollection->set_scaAddress(scaAddress);
275 uint32_t precisionClusters = vint[counter];
276 ATH_MSG_DEBUG(
"Number of Precision Cluster word 0x" << MSG::hex << precisionClusters << MSG::dec);
277 uint32_t precisionClusterCounts = 0;
278 for (uint16_t k = 0; k < 4; k++) {
279 uint16_t counts = (precisionClusters >> (24 - k * 8)) & 0xFF;
280 precisionClusterCounts += counts;
282 <<
"Layer Index = " << k <<
" Cluster Counts = " << counts);
283 unsigned int index = 0;
286 else if (rpuID == 11)
290 rawCollection->set_spuCount(
index, counts);
295 uint32_t secondClusterWord = vint[counter];
296 ATH_MSG_DEBUG(
"Second cluster word 0x" << MSG::hex << secondClusterWord << MSG::dec);
300 uint16_t nonPrecisionClusterCounts = (secondClusterWord >> 24) & 0xFF;
301 ATH_MSG_DEBUG(
"Summed Number of Clusters for non-precision layers " << nonPrecisionClusterCounts);
302 if (rpuID == 5) rawCollection->set_spuCount(4, nonPrecisionClusterCounts);
304 rawCollection->set_spuCount(9, nonPrecisionClusterCounts);
307 bool triggerType = (secondClusterWord >> 21) & 0x1;
308 if (triggerType) rawCollection->set_triggerType();
311 bool samplingPhase = (secondClusterWord >> 20) & 0x1;
312 if (samplingPhase) rawCollection->set_samplingPhase();
315 uint8_t firstBitSummary = (secondClusterWord >> 16) & 0xF;
316 rawCollection->set_firstBitSummary(firstBitSummary);
319 uint16_t clusterDataWords = secondClusterWord & 0xFFFF;
323 uint32_t totalClusterCounts = nonPrecisionClusterCounts + precisionClusterCounts;
324 ATH_MSG_DEBUG(
"Total summed Cluster Count for precision and non-precision layers = " << totalClusterCounts);
326 if (totalClusterCounts == 0) {
328 counter += rSize - 4;
333 uint16_t clusterCount = 0;
335 while (clusterCount < totalClusterCounts) {
337 uint32_t address = vint[counter];
339 ATH_MSG_DEBUG(
"cluster location word 0x" << MSG::hex << address << MSG::dec);
344 int stationId =
m_idHelperSvc->cscIdHelper().stationName(channelId);
345 int currentLayer =
m_idHelperSvc->cscIdHelper().wireLayer(channelId);
346 int orientation =
m_idHelperSvc->cscIdHelper().measuresPhi(channelId);
352 uint32_t time_width = vint[counter];
353 ATH_MSG_DEBUG(
" cluster time size word : stripId (CscIdHelper) 0x" << MSG::hex << time_width << MSG::dec <<
" " << stripId);
355 uint16_t time = (time_width >> 16) & 0xFFF;
356 uint16_t
width = time_width & 0xFFFF;
358 isClusterWordsUnrealistic =
true;
361 bool isTimeComputed = (time_width >> 28) & 0x1;
363 uint16_t totalSampleWords =
width * numSamples / 2 + (
width * numSamples) % 2;
366 std::vector<uint16_t> amplitude;
367 for (
int j = 0; j < totalSampleWords; ++j) {
370 amplitude.push_back(amp1);
371 amplitude.push_back(amp2);
377 uint16_t spuID = 0x0;
378 if (orientation == 0)
379 spuID =
static_cast<uint16_t
>((stationId - 50) * 5 + currentLayer - 1);
381 spuID =
static_cast<uint16_t
>(((stationId - 50) + 1) * 5 - 1);
387 ATH_MSG_INFO(
"Location word is not available and CscRawData is discarded!!");
394 rawCollection->push_back(rawData);
396 << idColl <<
" " << hashId <<
" " << spuID <<
" " << stationId <<
" :: measphi" << orientation <<
" L"
397 << currentLayer <<
" strId " << stripId <<
" nStr " <<
width <<
" T" << time <<
" nSampWords "
398 << totalSampleWords <<
" " <<
m_idHelperSvc->cscIdHelper().show_to_string(channelId));
401 ATH_MSG_DEBUG(
"****Total Cluster count = " << clusterCount <<
" for RPU ID " << rpuID);
405 if (counter > rpuSize) {
406 ATH_MSG_INFO(
"ROB Fragment with ID 0x" << std::hex << robFrag.rod_source_id() << std::dec <<
" has word Counter ="
407 << counter <<
" must not exceed summed RPU sizes =" << rpuSize <<
" Discarded!!");
409 rawCollection->erase(rawCollection->begin(), rawCollection->end());
414 if (counter < rpuSize) {
415 ATH_MSG_DEBUG(
"" << (rpuSize - counter) <<
" ghost words at the end of this RPU - skipping ...");
422 if (isHeaderWordNull) {
423 ATH_MSG_INFO(
" ROB Fragment with ID " << std::hex << robFrag.rod_source_id() << std::dec <<
" has null rpuID. Discarded!!");
424 rawCollection->erase(rawCollection->begin(), rawCollection->end());
426 if (isClusterWordsUnrealistic) {
427 ATH_MSG_INFO(
" ROB Fragment with ID 0x" << std::hex << robFrag.rod_source_id() << std::dec
428 <<
" has too many cluster words. Discarded!!");
429 rawCollection->erase(rawCollection->begin(), rawCollection->end());
433 StatusCode status_lock = lock.
addOrDelete(std::move(rawCollection));
434 if (status_lock.isFailure()) {
435 ATH_MSG_ERROR(
"Could not insert CscRawDataCollection into CscRawDataContainer...");
444 ATH_MSG_DEBUG(
"in CscROD_Decode::fillCollection() - ROD version 1");
449 rodReadOut.
set(
nullptr);
452 SourceIdentifier sid(robFrag.rod_source_id());
454 uint16_t subDetectorId = sid.subdetector_id();
455 uint16_t rodId = sid.module_id();
457 uint16_t idColl =
m_cabling->collectionId(subDetectorId, rodId);
462 std::unique_ptr<CscRawDataCollection> rawCollection(
nullptr);
465 ATH_MSG_DEBUG(
"CSC RDO collection already exist with collection hash = " << idColl <<
" converting is skipped!");
468 ATH_MSG_DEBUG(
"CSC RDO collection does not exist - creating a new one with hash = " << idColl);
469 rawCollection = std::make_unique<CscRawDataCollection>(idColl);
473 rawCollection->setSubDetectorId(subDetectorId);
474 rawCollection->setRodId(rodId);
475 rawCollection->setOnlineId(idColl);
477 const unsigned int size = robFrag.rod_ndata();
478 ATH_MSG_DEBUG(
"CscROD_Decoder Total words received = " << size);
485 uint32_t numSamples = p[0];
486 rawCollection->setNumSamples((uint16_t)numSamples);
489 uint16_t latency = (uint16_t)p[1];
490 rawCollection->setLatency(latency);
493 uint16_t samplingRate = (uint16_t)p[2];
494 rawCollection->setSamplingRate(samplingRate);
498 uint32_t numDPU = p[3];
499 rawCollection->setNumDPU((uint16_t)numDPU);
508 bool dpuFragment = rodReadOut.
isDPU(p[rodHeader]);
514 uint32_t i = rodHeader;
516 while (dpuFragment && i < (size - rodFooter)) {
519 uint32_t dpuID = p[i];
523 uint32_t numChannel = p[i];
539 if (!rodReadOut.
discard(numChannel)) {
540 for (
unsigned int j = 0; j < numChannel; j++) {
548 std::vector<uint16_t> amplitude;
549 for (
unsigned int j = 1; j <= numSamples; j++) {
552 amplitude.push_back(rodReadOut.
getAmp1());
553 if (amplitude.size() < numSamples) amplitude.push_back(rodReadOut.
getAmp2());
557 uint32_t address = rodReadOut.
address();
559 rawCollection->push_back(rawData);
562 ATH_MSG_INFO(
"this is a discard::numChannel = " << MSG::hex << numChannel);
565 if (i < (size - rodFooter)) dpuFragment = rodReadOut.
isDPU(p[i]);
569 StatusCode status_lock = lock.
addOrDelete(std::move(rawCollection));
570 if (status_lock.isFailure()) {
571 ATH_MSG_ERROR(
"Could not insert CscRawDataCollection into CscRawDataContainer...");
579 ATH_MSG_DEBUG(
"in CscROD_Decode::fillCollection() - ROD version 0");
584 rodReadOut.
set(
nullptr);
586 const unsigned int size = robFrag.rod_ndata();
587 ATH_MSG_DEBUG(
"CscROD_Decoder Total words received = " << size);
595 uint16_t rodId = rodReadOut.
rodId();
599 uint16_t subId = (subDetectorId == 0x0) ? 0x6A : 0x69;
601 uint16_t idColl =
m_cabling->collectionId(subId, rodId);
604 std::unique_ptr<CscRawDataCollection> rawCollection(
nullptr);
607 ATH_MSG_DEBUG(
"CSC RDO collection already exist with collection hash = " << idColl <<
" converting is skipped!");
610 ATH_MSG_DEBUG(
"CSC RDO collection does not exist - creating a new one with hash = " << idColl);
611 rawCollection = std::make_unique<CscRawDataCollection>(idColl);
615 rawCollection->setSubDetectorId(subDetectorId);
616 rawCollection->setRodId(rodId);
617 rawCollection->setOnlineId(idColl);
623 bool bodyFragment = rodReadOut.
isBody(p[rodHeader]);
628 uint32_t i = rodHeader;
629 while (bodyFragment && i < (size - rodFooter)) {
647 std::vector<uint16_t> amplitudes;
648 amplitudes.push_back(rodReadOut.
getAmp1());
649 amplitudes.push_back(rodReadOut.
getAmp2());
650 amplitudes.push_back(rodReadOut.
getAmp3());
651 amplitudes.push_back(rodReadOut.
getAmp4());
654 rawCollection->push_back(rawData);
657 bodyFragment = rodReadOut.
isBody(p[i]);
661 StatusCode status_lock = lock.
addOrDelete(std::move(rawCollection));
662 if (status_lock.isFailure()) {
663 ATH_MSG_ERROR(
"Could not insert CscRawDataCollection into CscRawDataContainer...");