diff --git a/DataFormats/SiPixelCluster/interface/SiPixelCluster.h b/DataFormats/SiPixelCluster/interface/SiPixelCluster.h index a017e6785a85f..2b664d5b4591b 100644 --- a/DataFormats/SiPixelCluster/interface/SiPixelCluster.h +++ b/DataFormats/SiPixelCluster/interface/SiPixelCluster.h @@ -60,6 +60,7 @@ class SiPixelCluster { constexpr int row() const { return row_; } constexpr int col() const { return col_; } constexpr PixelPos operator+(const Shift& shift) const { return PixelPos(row() + shift.dx(), col() + shift.dy()); } + constexpr bool operator==(const PixelPos& pos) const { return (row() == pos.row() && col() == pos.col()); } private: int row_; diff --git a/RecoLocalTracker/SiPixelClusterizer/plugins/PixelThresholdClusterizer.cc b/RecoLocalTracker/SiPixelClusterizer/plugins/PixelThresholdClusterizer.cc index a521e3dab36af..dce1f82bffb42 100644 --- a/RecoLocalTracker/SiPixelClusterizer/plugins/PixelThresholdClusterizer.cc +++ b/RecoLocalTracker/SiPixelClusterizer/plugins/PixelThresholdClusterizer.cc @@ -63,6 +63,7 @@ PixelThresholdClusterizer::PixelThresholdClusterizer(edm::ParameterSet const& co doSplitClusters(conf.getParameter("SplitClusters")) { theBuffer.setSize(theNumOfRows, theNumOfCols); theFakePixels.clear(); + thePixelOccurrence.clear(); } ///////////////////////////////////////////////////////////////////////////// PixelThresholdClusterizer::~PixelThresholdClusterizer() {} @@ -112,6 +113,8 @@ bool PixelThresholdClusterizer::setup(const PixelGeomDetUnit* pixDet) { theFakePixels.resize(nrows * ncols, false); + thePixelOccurrence.resize(nrows * ncols, 0); + return true; } //---------------------------------------------------------------------------- @@ -185,6 +188,8 @@ void PixelThresholdClusterizer::clusterizeDetUnitT(const T& input, clear_buffer(begin, end); theFakePixels.clear(); + + thePixelOccurrence.clear(); } //---------------------------------------------------------------------------- @@ -291,12 +296,29 @@ void PixelThresholdClusterizer::copy_to_buffer(DigiIterator begin, DigiIterator */ if (adc >= thePixelThreshold) { - theBuffer.set_adc(row, col, adc); - // VV: add pixel to the fake list. Only when running on digi collection - if (di->flag() != 0) - theFakePixels[row * theNumOfCols + col] = true; - if (adc >= theSeedThreshold) - theSeeds.push_back(SiPixelCluster::PixelPos(row, col)); + thePixelOccurrence[theBuffer.index(row, col)]++; // increment the occurrence counter + uint8_t occurrence = thePixelOccurrence[theBuffer.index(row, col)]; // get the occurrence counter + + switch(occurrence) { + // the 1st occurrence (standard treatment) + case 1: + theBuffer.set_adc(row, col, adc); + // VV: add pixel to the fake list. Only when running on digi collection + if (di->flag() != 0) + theFakePixels[row * theNumOfCols + col] = true; + if (adc >= theSeedThreshold) + theSeeds.push_back(SiPixelCluster::PixelPos(row, col)); + break; + + // the 2nd occurrence (duplicate pixel: reset the buffer to 0 and remove from the list of seed pixels) + case 2: + theBuffer.set_adc(row, col, 0); + std::remove(theSeeds.begin(), theSeeds.end(), SiPixelCluster::PixelPos(row, col)); + break; + + // in case a pixel appears more than twice, nothing needs to be done because it was already removed at the 2nd occurrence + + } } } assert(i == (end - begin)); diff --git a/RecoLocalTracker/SiPixelClusterizer/plugins/PixelThresholdClusterizer.h b/RecoLocalTracker/SiPixelClusterizer/plugins/PixelThresholdClusterizer.h index c1dafd3793f78..70e2964cff0c1 100644 --- a/RecoLocalTracker/SiPixelClusterizer/plugins/PixelThresholdClusterizer.h +++ b/RecoLocalTracker/SiPixelClusterizer/plugins/PixelThresholdClusterizer.h @@ -92,6 +92,8 @@ class dso_hidden PixelThresholdClusterizer : public PixelClusterizerBase { std::vector theFakePixels; // fake pixels introduced to guide clustering + std::vector thePixelOccurrence; // the number of times each pixel occurs (for tracking duplicate pixels) + //! Clustering-related quantities: float thePixelThresholdInNoiseUnits; // Pixel threshold in units of noise float theSeedThresholdInNoiseUnits; // Pixel cluster seed in units of noise