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

Avoid storing empty DetSet containers in the pixel digi collection #37035

Merged
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
27 changes: 19 additions & 8 deletions EventFilter/SiPixelRawToDigi/src/PixelDataFormatter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ void PixelDataFormatter::interpretRawData(
int link = -1;
int roc = -1;
int layer = 0;
unsigned int rawId = 0;
unsigned int nrawId = 0;
PixelROC const* rocp = nullptr;
bool skipROC = false;
edm::DetSet<PixelDigi>* detDigis = nullptr;
Expand Down Expand Up @@ -147,7 +149,7 @@ void PixelDataFormatter::interpretRawData(
skipROC = true;
continue;
}
auto rawId = rocp->rawId();
rawId = rocp->rawId();
bool barrel = PixelModuleName::isBarrel(rawId);
if (barrel)
layer = PixelROC::bpixLayerPhase1(rawId);
Expand All @@ -163,10 +165,6 @@ void PixelDataFormatter::interpretRawData(
skipROC = modulesToUnpack_ && (modulesToUnpack_->find(rawId) == modulesToUnpack_->end());
if (skipROC)
continue;

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

// skip is roc to be skipped ot invalid
Expand Down Expand Up @@ -204,9 +202,22 @@ void PixelDataFormatter::interpretRawData(
local = std::make_unique<LocalPixel>(localDP); // local pixel coordinate
}

GlobalPixel global = rocp->toGlobal(*local); // global pixel coordinate (in module)
(*detDigis).data.emplace_back(global.row, global.col, adc);
LogTrace("") << (*detDigis).data.back();
if (nrawId != rawId) {
nrawId = rawId;
detDigis = &digis.find_or_insert(rawId);
if ((*detDigis).empty()) {
(*detDigis).data.reserve(32); // avoid the first relocations
}
}

if (detDigis) {
GlobalPixel global = rocp->toGlobal(*local); // global pixel coordinate (in module)
(*detDigis).data.emplace_back(global.row, global.col, adc);
LogTrace("") << (*detDigis).data.back();
} else {
LogError("NullPointerException") << "@SUB=PixelDataFormatter::interpretRawData"
<< "DetSet pointer not set. This is not supposed to happen.";
}
}
}

Expand Down