CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions
PixelThresholdClusterizerForBricked Class Referencefinal

A specific threshold-based pixel clustering algorithm. More...

#include <PixelThresholdClusterizerForBricked.h>

Inheritance diagram for PixelThresholdClusterizerForBricked:
PixelThresholdClusterizer PixelClusterizerBase

Public Member Functions

void clusterizeDetUnit (const edm::DetSet< PixelDigi > &input, const PixelGeomDetUnit *pixDet, const TrackerTopology *tTopo, const std::vector< short > &badChannels, edmNew::DetSetVector< SiPixelCluster >::FastFiller &output) override
 
void clusterizeDetUnit (const edmNew::DetSet< SiPixelCluster > &input, const PixelGeomDetUnit *pixDet, const TrackerTopology *tTopo, const std::vector< short > &badChannels, edmNew::DetSetVector< SiPixelCluster >::FastFiller &output) override
 
 PixelThresholdClusterizerForBricked (edm::ParameterSet const &conf)
 
 ~PixelThresholdClusterizerForBricked () override
 
- Public Member Functions inherited from PixelThresholdClusterizer
 PixelThresholdClusterizer (edm::ParameterSet const &conf)
 
 ~PixelThresholdClusterizer () override
 
- Public Member Functions inherited from PixelClusterizerBase
void setSiPixelGainCalibrationService (SiPixelGainCalibrationServiceBase *in)
 
virtual ~PixelClusterizerBase ()
 

Private Member Functions

template<typename T >
void clusterizeDetUnitT (const T &input, const PixelGeomDetUnit *pixDet, const TrackerTopology *tTopo, const std::vector< short > &badChannels, edmNew::DetSetVector< SiPixelCluster >::FastFiller &output)
 Cluster pixels. This method operates on a matrix of pixels and finds the largest contiguous cluster around each seed pixel. Input and output data stored in DetSet. More...
 
SiPixelCluster make_cluster_bricked (const SiPixelCluster::PixelPos &pix, edmNew::DetSetVector< SiPixelCluster >::FastFiller &output, bool isbarrel)
 The actual clustering algorithm: group the neighboring pixels around the seed. More...
 

Additional Inherited Members

- Public Types inherited from PixelClusterizerBase
typedef edmNew::DetSet< SiPixelCluster >::const_iterator ClusterIterator
 
typedef edm::DetSet< PixelDigi >::const_iterator DigiIterator
 
- Static Public Member Functions inherited from PixelThresholdClusterizer
static void fillPSetDescription (edm::ParameterSetDescription &desc)
 
- Protected Member Functions inherited from PixelThresholdClusterizer
int calibrate (int adc, int col, int row)
 
void clear_buffer (DigiIterator begin, DigiIterator end)
 Clear the internal buffer array. More...
 
void clear_buffer (ClusterIterator begin, ClusterIterator end)
 
template<typename T >
void clusterizeDetUnitT (const T &input, const PixelGeomDetUnit *pixDet, const TrackerTopology *tTopo, const std::vector< short > &badChannels, edmNew::DetSetVector< SiPixelCluster >::FastFiller &output)
 Cluster pixels. This method operates on a matrix of pixels and finds the largest contiguous cluster around each seed pixel. Input and output data stored in DetSet. More...
 
void copy_to_buffer (DigiIterator begin, DigiIterator end)
 Copy adc counts from PixelDigis into the buffer, identify seeds. More...
 
void copy_to_buffer (ClusterIterator begin, ClusterIterator end)
 
SiPixelCluster make_cluster (const SiPixelCluster::PixelPos &pix, edmNew::DetSetVector< SiPixelCluster >::FastFiller &output)
 The actual clustering algorithm: group the neighboring pixels around the seed. More...
 
bool setup (const PixelGeomDetUnit *pixDet)
 Private helper methods: More...
 
- Protected Attributes inherited from PixelThresholdClusterizer
const bool doMissCalibrate
 
const bool doPhase2Calibration
 
const bool doSplitClusters
 
SiPixelArrayBuffer theBuffer
 Data storage. More...
 
std::vector< SiPixelClustertheClusters
 
const int theClusterThreshold
 
const int theClusterThreshold_L1
 
float theClusterThresholdInNoiseUnits
 
const int theConversionFactor
 
const int theConversionFactor_L1
 
uint32_t theDetid
 
const double theElectronPerADCGain
 
std::vector< bool > theFakePixels
 
int theLayer
 
int theNumOfCols
 
int theNumOfRows
 Geometry-related information. More...
 
const int theOffset
 
const int theOffset_L1
 
const double thePhase2DigiBaseline
 
const int thePhase2KinkADC
 
const int thePhase2ReadoutMode
 
std::vector< uint8_t > thePixelOccurrence
 
const int thePixelThreshold
 
float thePixelThresholdInNoiseUnits
 Clustering-related quantities: More...
 
std::vector< SiPixelCluster::PixelPostheSeeds
 
const int theSeedThreshold
 
float theSeedThresholdInNoiseUnits
 
- Protected Attributes inherited from PixelClusterizerBase
SiPixelGainCalibrationServiceBasetheSiPixelGainCalibrationService_
 

Detailed Description

A specific threshold-based pixel clustering algorithm.

An explicit threshold-based clustering algorithm.

Same logic as the base class PixelThresholdClusterizer but specialized for bricked pixels topology

A threshold-based clustering algorithm which clusters SiPixelDigis into SiPixelClusters for each DetUnit. The algorithm is straightforward and purely topological: the clustering process starts with seed pixels and continues by adding adjacent pixels above the pixel threshold. Once the cluster is made, it has to be above the cluster threshold as well.

The clusterization is performed on a matrix with size equal to the size of the pixel detector, each cell containing the ADC count of the corresponding pixel. The matrix is reset after each clusterization.

The search starts from seed pixels, i.e. pixels with sufficiently large amplitudes, found at the time of filling of the matrix and stored in a

At this point the noise and dead channels are ignored, but soon they won't be.

SiPixelCluster contains a barrycenter, but it should be noted that that information is largely useless. One must use a PositionEstimator class to compute the RecHit position and its error for every given cluster.

Author
Largely copied from NewPixelClusterizer in ORCA written by Danek Kotlinski (PSI). Ported to CMSSW by Petar Maksimovic (JHU). DetSetVector data container implemented by V.Chiochia (Uni Zurich)

Sets the PixelArrayBuffer dimensions and pixel thresholds. Makes clusters and stores them in theCache if the option useCache has been set.

Definition at line 46 of file PixelThresholdClusterizerForBricked.h.

Constructor & Destructor Documentation

◆ PixelThresholdClusterizerForBricked()

PixelThresholdClusterizerForBricked::PixelThresholdClusterizerForBricked ( edm::ParameterSet const &  conf)

Constructor: Initilize the buffer to hold pixels from a detector module. This is a vector of 44k ints, stays valid all the time.

Definition at line 30 of file PixelThresholdClusterizerForBricked.cc.

31  : PixelThresholdClusterizer(conf) {}
PixelThresholdClusterizer(edm::ParameterSet const &conf)

◆ ~PixelThresholdClusterizerForBricked()

PixelThresholdClusterizerForBricked::~PixelThresholdClusterizerForBricked ( )
override

Definition at line 33 of file PixelThresholdClusterizerForBricked.cc.

33 {}

Member Function Documentation

◆ clusterizeDetUnit() [1/2]

void PixelThresholdClusterizerForBricked::clusterizeDetUnit ( const edm::DetSet< PixelDigi > &  input,
const PixelGeomDetUnit pixDet,
const TrackerTopology tTopo,
const std::vector< short > &  badChannels,
edmNew::DetSetVector< SiPixelCluster >::FastFiller &  output 
)
inlineoverridevirtual

Reimplemented from PixelThresholdClusterizer.

Definition at line 52 of file PixelThresholdClusterizerForBricked.h.

References PixelThresholdClusterizer::clusterizeDetUnitT(), input, and convertSQLitetoXML_cfg::output.

56  {
57  clusterizeDetUnitT(input, pixDet, tTopo, badChannels, output);
58  }
static std::string const input
Definition: EdmProvDump.cc:47
void clusterizeDetUnitT(const T &input, const PixelGeomDetUnit *pixDet, const TrackerTopology *tTopo, const std::vector< short > &badChannels, edmNew::DetSetVector< SiPixelCluster >::FastFiller &output)
Cluster pixels. This method operates on a matrix of pixels and finds the largest contiguous cluster a...

◆ clusterizeDetUnit() [2/2]

void PixelThresholdClusterizerForBricked::clusterizeDetUnit ( const edmNew::DetSet< SiPixelCluster > &  input,
const PixelGeomDetUnit pixDet,
const TrackerTopology tTopo,
const std::vector< short > &  badChannels,
edmNew::DetSetVector< SiPixelCluster >::FastFiller &  output 
)
inlineoverridevirtual

Reimplemented from PixelThresholdClusterizer.

Definition at line 59 of file PixelThresholdClusterizerForBricked.h.

References PixelThresholdClusterizer::clusterizeDetUnitT(), input, and convertSQLitetoXML_cfg::output.

63  {
64  clusterizeDetUnitT(input, pixDet, tTopo, badChannels, output);
65  }
static std::string const input
Definition: EdmProvDump.cc:47
void clusterizeDetUnitT(const T &input, const PixelGeomDetUnit *pixDet, const TrackerTopology *tTopo, const std::vector< short > &badChannels, edmNew::DetSetVector< SiPixelCluster >::FastFiller &output)
Cluster pixels. This method operates on a matrix of pixels and finds the largest contiguous cluster a...

◆ clusterizeDetUnitT()

template<typename T >
void PixelThresholdClusterizerForBricked::clusterizeDetUnitT ( const T input,
const PixelGeomDetUnit pixDet,
const TrackerTopology tTopo,
const std::vector< short > &  badChannels,
edmNew::DetSetVector< SiPixelCluster >::FastFiller &  output 
)
private

Cluster pixels. This method operates on a matrix of pixels and finds the largest contiguous cluster around each seed pixel. Input and output data stored in DetSet.

Definition at line 43 of file PixelThresholdClusterizerForBricked.cc.

References cms::cuda::assert(), SiPixelCluster::charge(), GetRecoTauVFromDQM_MC_cff::cl2, PixelThresholdClusterizer::clear_buffer(), EMEnrichingFilter_cfi::clusterThreshold, PixelThresholdClusterizer::copy_to_buffer(), mps_fire::end, mps_fire::i, input, PixelPluginsPhase0_cfi::isBarrel, PixelThresholdClusterizer::make_cluster(), make_cluster_bricked(), SiPixelCluster::minPixelRow(), eostools::move(), convertSQLitetoXML_cfg::output, PixelSubdetector::PixelBarrel, TrackerTopology::pxbLayer(), PixelThresholdClusterizer::setup(), PixelGeomDetUnit::specificTopology(), DetId::subdetId(), PixelThresholdClusterizer::theBuffer, PixelThresholdClusterizer::theClusterThreshold, PixelThresholdClusterizer::theClusterThreshold_L1, PixelThresholdClusterizer::theDetid, PixelThresholdClusterizer::theFakePixels, PixelThresholdClusterizer::theLayer, PixelThresholdClusterizer::theSeeds, and PixelThresholdClusterizer::theSeedThreshold.

47  {
48  typename T::const_iterator begin = input.begin();
49  typename T::const_iterator end = input.end();
50 
51  edm::LogInfo("PixelThresholdClusterizerForBricked::clusterizeDetUnitT()");
52 
53  // this should never happen and the raw2digi does not create empty detsets
54  if (begin == end) {
55  edm::LogError("PixelThresholdClusterizerForBricked")
56  << "@SUB=PixelThresholdClusterizerForBricked::clusterizeDetUnitT()"
57  << " No digis to clusterize";
58  }
59 
60  // Set up the clusterization on this DetId.
61  if (!setup(pixDet))
62  return;
63 
64  theDetid = input.detId();
65 
67  // Set separate cluster threshold for L1 (needed for phase1)
69  theLayer = (DetId(theDetid).subdetId() == 1) ? tTopo->pxbLayer(theDetid) : 0;
70  if (theLayer == 1)
72 
73  // Copy PixelDigis to the buffer array; select the seed pixels
74  // on the way, and store them in theSeeds.
75  if (end > begin)
76  copy_to_buffer(begin, end);
77 
78  assert(output.empty());
79  // Loop over all seeds. TO DO: wouldn't using iterators be faster?
80  for (unsigned int i = 0; i < theSeeds.size(); i++) {
81  // Gavril : The charge of seeds that were already inlcuded in clusters is set to 1 electron
82  // so we don't want to call "make_cluster" for these cases
83  if (theBuffer(theSeeds[i]) >= theSeedThreshold) { // Is this seed still valid?
84  // Make a cluster around this seed
85  SiPixelCluster cluster;
86  if ((&pixDet->specificTopology())->isBricked()) {
88  } else {
89  cluster = make_cluster(theSeeds[i], output);
90  }
91 
92  // Check if the cluster is above threshold
93  // (TO DO: one is signed, other unsigned, gcc warns...)
94  if (cluster.charge() >= clusterThreshold) {
95  // sort by row (x)
96  output.push_back(std::move(cluster));
97  std::push_heap(output.begin(), output.end(), [](SiPixelCluster const& cl1, SiPixelCluster const& cl2) {
98  return cl1.minPixelRow() < cl2.minPixelRow();
99  });
100  }
101  }
102  }
103  // sort by row (x) maybe sorting the seed would suffice....
104  std::sort_heap(output.begin(), output.end(), [](SiPixelCluster const& cl1, SiPixelCluster const& cl2) {
105  return cl1.minPixelRow() < cl2.minPixelRow();
106  });
107 
108  // Erase the seeds.
109  theSeeds.clear();
110 
111  // Need to clean unused pixels from the buffer array.
112  clear_buffer(begin, end);
113 
114  theFakePixels.clear();
115 }
unsigned int pxbLayer(const DetId &id) const
SiPixelArrayBuffer theBuffer
Data storage.
SiPixelCluster make_cluster(const SiPixelCluster::PixelPos &pix, edmNew::DetSetVector< SiPixelCluster >::FastFiller &output)
The actual clustering algorithm: group the neighboring pixels around the seed.
Log< level::Error, false > LogError
assert(be >=bs)
static std::string const input
Definition: EdmProvDump.cc:47
int minPixelRow() const
int charge() const
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
Log< level::Info, false > LogInfo
Definition: DetId.h:17
void clear_buffer(DigiIterator begin, DigiIterator end)
Clear the internal buffer array.
SiPixelCluster make_cluster_bricked(const SiPixelCluster::PixelPos &pix, edmNew::DetSetVector< SiPixelCluster >::FastFiller &output, bool isbarrel)
The actual clustering algorithm: group the neighboring pixels around the seed.
Pixel cluster – collection of neighboring pixels above threshold.
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
bool setup(const PixelGeomDetUnit *pixDet)
Private helper methods:
std::vector< SiPixelCluster::PixelPos > theSeeds
def move(src, dest)
Definition: eostools.py:511
void copy_to_buffer(DigiIterator begin, DigiIterator end)
Copy adc counts from PixelDigis into the buffer, identify seeds.

◆ make_cluster_bricked()

SiPixelCluster PixelThresholdClusterizerForBricked::make_cluster_bricked ( const SiPixelCluster::PixelPos pix,
edmNew::DetSetVector< SiPixelCluster >::FastFiller &  output,
bool  isbarrel 
)
private

The actual clustering algorithm: group the neighboring pixels around the seed.

Definition at line 120 of file PixelThresholdClusterizerForBricked.cc.

References PixelClusterizerBase::AccretionCluster::adc, PixelClusterizerBase::AccretionCluster::add(), SiPixelCluster::add(), c, SiPixelCluster::charge(), GetRecoTauVFromDQM_MC_cff::cl2, EMEnrichingFilter_cfi::clusterThreshold, SiPixelCluster::PixelPos::col(), SiPixelArrayBuffer::columns(), PixelThresholdClusterizer::doSplitClusters, PixelClusterizerBase::AccretionCluster::empty(), mps_fire::i, createfilelist::int, PixelClusterizerBase::AccretionCluster::isize, SiStripPI::max, SiStripPI::min, SiPixelCluster::minPixelRow(), convertSQLitetoXML_cfg::output, SiPixelCluster::pixels(), PixelClusterizerBase::AccretionCluster::pop(), alignCSCRings::r, SiPixelCluster::PixelPos::row(), SiPixelArrayBuffer::rows(), SiPixelArrayBuffer::set_adc(), PixelThresholdClusterizer::theBuffer, PixelThresholdClusterizer::theClusterThreshold, PixelThresholdClusterizer::theClusterThreshold_L1, PixelThresholdClusterizer::theLayer, PixelThresholdClusterizer::thePixelThreshold, PixelClusterizerBase::AccretionCluster::top(), PixelClusterizerBase::AccretionCluster::x, PixelClusterizerBase::AccretionCluster::xmin, PixelClusterizerBase::AccretionCluster::y, and PixelClusterizerBase::AccretionCluster::ymin.

Referenced by clusterizeDetUnitT().

121  {
122  //First we acquire the seeds for the clusters
123  std::stack<SiPixelCluster::PixelPos, std::vector<SiPixelCluster::PixelPos> > dead_pixel_stack;
124 
125  //The individual modules have been loaded into a buffer.
126  //After each pixel has been considered by the clusterizer, we set the adc count to 1
127  //to mark that we have already considered it.
128  //The only difference between dead/noisy pixels and standard ones is that for dead/noisy pixels,
129  //We consider the charge of the pixel to always be zero.
130 
131  // Note: each ADC value is limited here to 65535 (std::numeric_limits<uint16_t>::max),
132  // as it is later stored as uint16_t in SiPixelCluster and PixelClusterizerBase/AccretionCluster
133  // (reminder: ADC values here may be expressed in number of electrons)
134  uint16_t seed_adc = std::min(theBuffer(pix.row(), pix.col()), int(std::numeric_limits<uint16_t>::max()));
135  theBuffer.set_adc(pix, 1);
136 
137  AccretionCluster acluster;
138  acluster.add(pix, seed_adc);
139 
140  //Here we search all pixels adjacent to all pixels in the cluster.
141  bool dead_flag = false;
142  while (!acluster.empty()) {
143  //This is the standard algorithm to find and add a pixel
144  auto curInd = acluster.top();
145  acluster.pop();
146 
147  for (auto r = std::max(0, int(acluster.x[curInd]) - 1); r < std::min(int(acluster.x[curInd]) + 2, theBuffer.rows());
148  ++r) {
149  int LowerAccLimity = 0;
150  int UpperAccLimity = 0;
151 
152  if (r % 2 == int(acluster.x[curInd]) % 2) {
153  LowerAccLimity = std::max(0, int(acluster.y[curInd]) - 1);
154  UpperAccLimity = std::min(int(acluster.y[curInd]) + 2, theBuffer.columns());
155  }
156 
157  else {
158  int parity_curr = int(acluster.x[curInd]) % 2;
159  int parity_hit = r % 2;
160 
161  LowerAccLimity = std::max(0, int(acluster.y[curInd]) - parity_hit);
162  UpperAccLimity = std::min(int(acluster.y[curInd]) + parity_curr + 1, theBuffer.columns());
163  }
164 
165  /*
166  for (auto c = std::max(0, int(acluster.y[curInd]) - 1);
167  c < std::min(int(acluster.y[curInd]) + 2, theBuffer.columns());
168  ++c)
169  */
170  for (auto c = LowerAccLimity; c < UpperAccLimity; ++c) {
171  if (theBuffer(r, c) >= thePixelThreshold) {
172  SiPixelCluster::PixelPos newpix(r, c);
173  auto const newpix_adc = std::min(theBuffer(r, c), int(std::numeric_limits<uint16_t>::max()));
174  if (!acluster.add(newpix, newpix_adc))
175  goto endClus;
176  if (isbarrel)
177  edm::LogInfo("make_cluster_bricked()") << "add" << r << c << theBuffer(r, c);
178  theBuffer.set_adc(newpix, 1);
179  //std::cout<<"col "<<c<<" row "<<r<<std::endl;
180  }
181  }
182  }
183 
184  } // while accretion
185 endClus:
186  SiPixelCluster cluster(acluster.isize, acluster.adc, acluster.x, acluster.y, acluster.xmin, acluster.ymin);
187  //Here we split the cluster, if the flag to do so is set and we have found a dead or noisy pixel.
188 
189  if (dead_flag && doSplitClusters) {
190  // Set separate cluster threshold for L1 (needed for phase1)
192  if (theLayer == 1)
194 
195  //Set the first cluster equal to the existing cluster.
196  SiPixelCluster first_cluster = cluster;
197  bool have_second_cluster = false;
198  while (!dead_pixel_stack.empty()) {
199  //consider each found dead pixel
200  SiPixelCluster::PixelPos deadpix = dead_pixel_stack.top();
201  dead_pixel_stack.pop();
202  theBuffer.set_adc(deadpix, 1);
203 
204  //Clusterize the split cluster using the dead pixel as a seed
205  SiPixelCluster second_cluster = make_cluster_bricked(deadpix, output, isbarrel);
206 
207  //If both clusters would normally have been found by the clusterizer, put them into output
208  if (second_cluster.charge() >= clusterThreshold && first_cluster.charge() >= clusterThreshold) {
209  output.push_back(second_cluster);
210  have_second_cluster = true;
211  }
212 
213  //We also want to keep the merged cluster in data and let the RecHit algorithm decide which set to keep
214  //This loop adds the second cluster to the first.
215  const std::vector<SiPixelCluster::Pixel>& branch_pixels = second_cluster.pixels();
216  for (unsigned int i = 0; i < branch_pixels.size(); i++) {
217  auto const temp_x = branch_pixels[i].x;
218  auto const temp_y = branch_pixels[i].y;
219  auto const temp_adc = branch_pixels[i].adc;
220  SiPixelCluster::PixelPos newpix(temp_x, temp_y);
221  cluster.add(newpix, temp_adc);
222  }
223  }
224 
225  //Remember to also add the first cluster if we added the second one.
226  if (first_cluster.charge() >= clusterThreshold && have_second_cluster) {
227  output.push_back(first_cluster);
228  std::push_heap(output.begin(), output.end(), [](SiPixelCluster const& cl1, SiPixelCluster const& cl2) {
229  return cl1.minPixelRow() < cl2.minPixelRow();
230  });
231  }
232  }
233 
234  return cluster;
235 }
SiPixelArrayBuffer theBuffer
Data storage.
void set_adc(int row, int col, int adc)
int minPixelRow() const
int charge() const
const std::vector< Pixel > pixels() const
Log< level::Info, false > LogInfo
SiPixelCluster make_cluster_bricked(const SiPixelCluster::PixelPos &pix, edmNew::DetSetVector< SiPixelCluster >::FastFiller &output, bool isbarrel)
The actual clustering algorithm: group the neighboring pixels around the seed.
Pixel cluster – collection of neighboring pixels above threshold.
constexpr int row() const
constexpr int col() const