Skip to content

Commit

Permalink
Merge pull request #40660 from fabferro/bugfixPixelRaw2Digi
Browse files Browse the repository at this point in the history
PPS pixel bug fix in error filling
  • Loading branch information
cmsbuild authored Feb 3, 2023
2 parents d51ac5f + f5b2421 commit fd8fb10
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 26 deletions.
6 changes: 6 additions & 0 deletions CondFormats/PPSObjects/interface/CTPPSPixelROC.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ class CTPPSPixelROC {
/// ROC number in Link (given by token passage),
CTPPSPixelROC(uint32_t du, int idInDU, int idLk);

void setParameters(uint32_t du, int idInDU, int idLk) {
theDetUnit = du;
theIdDU = idInDU;
theIdLk = idLk;
}

/// return the DetUnit to which this ROC belongs to.
uint32_t rawId() const { return theDetUnit; }

Expand Down
64 changes: 38 additions & 26 deletions EventFilter/CTPPSRawToDigi/src/CTPPSPixelDataFormatter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,63 +124,75 @@ void CTPPSPixelDataFormatter::interpretRawData(
ew--;
m_WordCounter--;
}

for (auto word = bw; word < ew; ++word) {
LogTrace("") << "DATA: " << print(*word);

auto ww = *word;
if UNLIKELY (ww == 0) {
m_WordCounter--;
continue;
}

int nlink = (ww >> m_LINK_shift) & m_LINK_mask;
int nroc = (ww >> m_ROC_shift) & m_ROC_mask;
int FMC = 0;
uint32_t iD = RPixErrorChecker::dummyDetId; //0xFFFFFFFF; //dummyDetId
int convroc = nroc - 1;
CTPPSPixelFramePosition fPos(fedId, FMC, nlink, convroc);

CTPPSPixelROC rocp;
CTPPSPixelFramePosition fPos(fedId, FMC, nlink, convroc);
std::map<CTPPSPixelFramePosition, CTPPSPixelROCInfo>::const_iterator mit;
mit = m_Mapping.find(fPos);

if (mit == m_Mapping.end()) {
if (nlink >= maxLinkIndex) {
m_ErrorCheck.conversionError(fedId, iD, InvalidLinkId, ww, errors);
edm::LogError("CTPPSPixelDataFormatter") << " Invalid linkId ";
} else if ((nroc - 1) >= maxRocIndex) {
// if RocId wrong try to recover at least plane id
CTPPSPixelFramePosition fPosDummyROC(fedId, FMC, nlink, 0);
mit = m_Mapping.find(fPosDummyROC);
if (mit != m_Mapping.end())
iD = (*mit).second.iD;
m_ErrorCheck.conversionError(fedId, iD, InvalidROCId, ww, errors);
edm::LogError("CTPPSPixelDataFormatter")
<< " Invalid ROC Id " << convroc << " in nlink " << nlink << " of FED " << fedId << " in DetId " << iD;
} else {
m_ErrorCheck.conversionError(fedId, iD, Unknown, ww, errors);
edm::LogError("CTPPSPixelDataFormatter") << " Error unknown ";
}
continue; //skip word
if (mit != m_Mapping.end()) {
CTPPSPixelROCInfo rocInfo = (*mit).second;
iD = rocInfo.iD;
rocp.setParameters(iD, rocInfo.roc, convroc);
}

CTPPSPixelROCInfo rocInfo = (*mit).second;
iD = rocInfo.iD;
CTPPSPixelROC rocp(iD, rocInfo.roc, convroc);

if ((nlink != link) | (nroc != roc)) { // new roc
link = nlink;
roc = nroc;

skipROC = LIKELY((roc - 1) < maxRocIndex) ? false : !m_ErrorCheck.checkROC(errorsInEvent, fedId, iD, ww, errors);
if ((roc - 1) < maxRocIndex) {
skipROC = false;
} else {
// using dummy detId - recovering of FED channel foreseen in DQM
iD = RPixErrorChecker::dummyDetId;
skipROC = !m_ErrorCheck.checkROC(errorsInEvent, fedId, iD, ww, errors);
}
if (skipROC)
continue;

if (mit == m_Mapping.end()) {
if (nlink >= maxLinkIndex) {
m_ErrorCheck.conversionError(fedId, iD, InvalidLinkId, ww, errors);
edm::LogError("CTPPSPixelDataFormatter") << " Invalid linkId ";
} else if ((nroc - 1) >= maxRocIndex) {
m_ErrorCheck.conversionError(fedId, iD, InvalidROCId, ww, errors);
edm::LogError("CTPPSPixelDataFormatter")
<< " Invalid ROC Id " << convroc << " in nlink " << nlink << " of FED " << fedId << " in DetId " << iD;
} else {
m_ErrorCheck.conversionError(fedId, iD, Unknown, ww, errors);
edm::LogError("CTPPSPixelDataFormatter") << " Error unknown ";
}
skipROC = true; // skipping roc due to mapping errors
continue;
}
if (rocp.rawId() == 0) {
skipROC = true;
continue;
}

auto rawId = rocp.rawId();

detDigis = &digis.find_or_insert(rawId);
if ((*detDigis).empty())
(*detDigis).data.reserve(32); // avoid the first relocations
}

if (skipROC || rocp.rawId() == 0)
continue;

int adc = (ww >> m_ADC_shift) & m_ADC_mask;

int dcol = (ww >> m_DCOL_shift) & m_DCOL_mask;
Expand Down

0 comments on commit fd8fb10

Please sign in to comment.