Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PPS pixel bug fix in error filling #40660

Merged
merged 2 commits into from
Feb 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fabferro , just for checking: is it correct that skipROC is defined outside the loop, i.e. it remains set at the value taken during the previous iterations in the loop over word's?

Copy link
Contributor Author

@fabferro fabferro Feb 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Andrea for the question. The use of this flag is very delicate. The way it's assumed to work is that if it happens to be set true (i.e. a roc chip behaving badly) all the words from that roc are skipped. The flag can change inside the loop when the roc number changes (see lines 156-162) and the new roc is checked.

continue;

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

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