Skip to content

Commit

Permalink
avoid storing empty DetSet containers in the pixel digi collection
Browse files Browse the repository at this point in the history
  • Loading branch information
ferencek committed Feb 22, 2022
1 parent fec3825 commit d951d12
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 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,6 +202,14 @@ void PixelDataFormatter::interpretRawData(
local = std::make_unique<LocalPixel>(localDP); // local pixel coordinate
}

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

GlobalPixel global = rocp->toGlobal(*local); // global pixel coordinate (in module)
(*detDigis).data.emplace_back(global.row, global.col, adc);
LogTrace("") << (*detDigis).data.back();
Expand Down

0 comments on commit d951d12

Please sign in to comment.