Skip to content

Commit

Permalink
remove all duplicate pixels from clustering
Browse files Browse the repository at this point in the history
  • Loading branch information
ferencek committed Apr 13, 2022
1 parent 320b545 commit d50b2f5
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 6 deletions.
1 change: 1 addition & 0 deletions DataFormats/SiPixelCluster/interface/SiPixelCluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ PixelThresholdClusterizer::PixelThresholdClusterizer(edm::ParameterSet const& co
doSplitClusters(conf.getParameter<bool>("SplitClusters")) {
theBuffer.setSize(theNumOfRows, theNumOfCols);
theFakePixels.clear();
thePixelOccurrence.clear();
}
/////////////////////////////////////////////////////////////////////////////
PixelThresholdClusterizer::~PixelThresholdClusterizer() {}
Expand Down Expand Up @@ -112,6 +113,8 @@ bool PixelThresholdClusterizer::setup(const PixelGeomDetUnit* pixDet) {

theFakePixels.resize(nrows * ncols, false);

thePixelOccurrence.resize(nrows * ncols, 0);

return true;
}
//----------------------------------------------------------------------------
Expand Down Expand Up @@ -185,6 +188,8 @@ void PixelThresholdClusterizer::clusterizeDetUnitT(const T& input,
clear_buffer(begin, end);

theFakePixels.clear();

thePixelOccurrence.clear();
}

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ class dso_hidden PixelThresholdClusterizer : public PixelClusterizerBase {

std::vector<bool> theFakePixels; // fake pixels introduced to guide clustering

std::vector<uint8_t> 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
Expand Down

0 comments on commit d50b2f5

Please sign in to comment.