From d951d1256feb6148f3707f39a2f10753cb9677d4 Mon Sep 17 00:00:00 2001 From: Dinko Ferencek Date: Tue, 22 Feb 2022 20:24:17 +0100 Subject: [PATCH 1/2] avoid storing empty DetSet containers in the pixel digi collection --- .../SiPixelRawToDigi/src/PixelDataFormatter.cc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/EventFilter/SiPixelRawToDigi/src/PixelDataFormatter.cc b/EventFilter/SiPixelRawToDigi/src/PixelDataFormatter.cc index f203187aa79fb..db00d4e99eaf2 100644 --- a/EventFilter/SiPixelRawToDigi/src/PixelDataFormatter.cc +++ b/EventFilter/SiPixelRawToDigi/src/PixelDataFormatter.cc @@ -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* detDigis = nullptr; @@ -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); @@ -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 @@ -204,6 +202,14 @@ void PixelDataFormatter::interpretRawData( local = std::make_unique(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(); From 8ce818f209f075944ca3dcc470628ba2f9fb6ac9 Mon Sep 17 00:00:00 2001 From: Dinko F Date: Thu, 24 Feb 2022 14:43:40 +0100 Subject: [PATCH 2/2] add protection for null pointer Co-authored-by: Andrea Perrotta --- .../SiPixelRawToDigi/src/PixelDataFormatter.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/EventFilter/SiPixelRawToDigi/src/PixelDataFormatter.cc b/EventFilter/SiPixelRawToDigi/src/PixelDataFormatter.cc index db00d4e99eaf2..c489f6e198bff 100644 --- a/EventFilter/SiPixelRawToDigi/src/PixelDataFormatter.cc +++ b/EventFilter/SiPixelRawToDigi/src/PixelDataFormatter.cc @@ -210,9 +210,14 @@ void PixelDataFormatter::interpretRawData( } } - GlobalPixel global = rocp->toGlobal(*local); // global pixel coordinate (in module) - (*detDigis).data.emplace_back(global.row, global.col, adc); - LogTrace("") << (*detDigis).data.back(); + 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."; + } } }