Skip to content

Commit

Permalink
Merge pull request #37035 from CMSTrackerDPG/AvoidEmptyPixelDigiDetSe…
Browse files Browse the repository at this point in the history
…ts_from_CMSSW_12_3_0_pre5

Avoid storing empty DetSet containers in the pixel digi collection
  • Loading branch information
cmsbuild committed Mar 2, 2022
2 parents 0ee444a + 8ce818f commit fd8e64b
Showing 1 changed file with 19 additions and 8 deletions.
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

0 comments on commit fd8e64b

Please sign in to comment.