CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
PixelThresholdClusterizer Class Referencefinal

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

#include <PixelThresholdClusterizer.h>

Inheritance diagram for 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
 
 PixelThresholdClusterizer (edm::ParameterSet const &conf)
 
 ~PixelThresholdClusterizer () override
 
- Public Member Functions inherited from PixelClusterizerBase
void setSiPixelGainCalibrationService (SiPixelGainCalibrationServiceBase *in)
 
virtual ~PixelClusterizerBase ()
 

Static Public Member Functions

static void fillPSetDescription (edm::ParameterSetDescription &desc)
 

Private Member Functions

int calibrate (int adc, int col, int row)
 
void clear_buffer (ClusterIterator begin, ClusterIterator end)
 
void clear_buffer (DigiIterator begin, DigiIterator end)
 Clear the internal buffer array. More...
 
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 (ClusterIterator begin, ClusterIterator end)
 
void copy_to_buffer (DigiIterator begin, DigiIterator end)
 Copy adc counts from PixelDigis into the buffer, identify seeds. More...
 
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...
 

Private Attributes

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
 
const int thePixelThreshold
 
float thePixelThresholdInNoiseUnits
 Clustering-related quantities: More...
 
std::vector< SiPixelCluster::PixelPostheSeeds
 
const int theSeedThreshold
 
float theSeedThresholdInNoiseUnits
 

Additional Inherited Members

- Public Types inherited from PixelClusterizerBase
typedef edmNew::DetSet< SiPixelCluster >::const_iterator ClusterIterator
 
typedef edm::DetSet< PixelDigi >::const_iterator DigiIterator
 
- Protected Attributes inherited from PixelClusterizerBase
SiPixelGainCalibrationServiceBasetheSiPixelGainCalibrationService_
 

Detailed Description

A specific threshold-based pixel clustering algorithm.

An explicit threshold-based clustering algorithm.

General logic of PixelThresholdClusterizer:

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 SiPixelArrayBuffer.

Translate the pixel charge to electrons, we are suppose to do the calibrations ADC->electrons here. Modify the thresholds to be in electrons, convert adc to electrons. d.k. 20/3/06 Get rid of the noiseVector. d.k. 28/3/06

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 57 of file PixelThresholdClusterizer.h.

Constructor & Destructor Documentation

◆ PixelThresholdClusterizer()

PixelThresholdClusterizer::PixelThresholdClusterizer ( 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 43 of file PixelThresholdClusterizer.cc.

44  : // Get thresholds in electrons
45  thePixelThreshold(conf.getParameter<int>("ChannelThreshold")),
46  theSeedThreshold(conf.getParameter<int>("SeedThreshold")),
47  theClusterThreshold(conf.getParameter<int>("ClusterThreshold")),
48  theClusterThreshold_L1(conf.getParameter<int>("ClusterThreshold_L1")),
49  theConversionFactor(conf.getParameter<int>("VCaltoElectronGain")),
50  theConversionFactor_L1(conf.getParameter<int>("VCaltoElectronGain_L1")),
51  theOffset(conf.getParameter<int>("VCaltoElectronOffset")),
52  theOffset_L1(conf.getParameter<int>("VCaltoElectronOffset_L1")),
53  theElectronPerADCGain(conf.getParameter<double>("ElectronPerADCGain")),
54  doPhase2Calibration(conf.getParameter<bool>("Phase2Calibration")),
55  thePhase2ReadoutMode(conf.getParameter<int>("Phase2ReadoutMode")),
56  thePhase2DigiBaseline(conf.getParameter<double>("Phase2DigiBaseline")),
57  thePhase2KinkADC(conf.getParameter<int>("Phase2KinkADC")),
58  theNumOfRows(0),
59  theNumOfCols(0),
60  theDetid(0),
61  // Get the constants for the miss-calibration studies
62  doMissCalibrate(conf.getParameter<bool>("MissCalibrate")),
63  doSplitClusters(conf.getParameter<bool>("SplitClusters")) {
65  theFakePixels.clear();
66 }

References SiPixelArrayBuffer::setSize(), theBuffer, theFakePixels, theNumOfCols, and theNumOfRows.

◆ ~PixelThresholdClusterizer()

PixelThresholdClusterizer::~PixelThresholdClusterizer ( )
override

Definition at line 68 of file PixelThresholdClusterizer.cc.

68 {}

Member Function Documentation

◆ calibrate()

int PixelThresholdClusterizer::calibrate ( int  adc,
int  col,
int  row 
)
private

Definition at line 319 of file PixelThresholdClusterizer.cc.

319  {
320  int electrons = 0;
321 
322  if (doPhase2Calibration) {
323  const float gain = theElectronPerADCGain;
324  int p2rm = (thePhase2ReadoutMode < -1 ? -1 : thePhase2ReadoutMode);
325 
326  if (p2rm == -1) {
327  electrons = int(adc * gain);
328  } else {
329  if (adc < thePhase2KinkADC) {
330  electrons = int((adc + 0.5) * gain);
331  } else {
332  const int dualslopeparam = (thePhase2ReadoutMode < 10 ? thePhase2ReadoutMode : 10);
333  const int dualslope = int(dualslopeparam <= 1 ? 1. : pow(2, dualslopeparam - 1));
335  adc *= dualslope;
337  electrons = int((adc + 0.5 * dualslope) * gain);
338  }
340  }
341 
342  return electrons;
343  }
344 
345  if (doMissCalibrate) {
346  // do not perform calibration if pixel is dead!
347 
350  // Linear approximation of the TANH response
351  // Pixel(0,0,0)
352  //const float gain = 2.95; // 1 ADC = 2.95 VCALs (1/0.339)
353  //const float pedestal = -83.; // -28/0.339
354  // Roc-0 average
355  //const float gain = 1./0.357; // 1 ADC = 2.80 VCALs
356  //const float pedestal = -28.2 * gain; // -79.
357 
358  float DBgain = theSiPixelGainCalibrationService_->getGain(theDetid, col, row);
360  float DBpedestal = pedestal * DBgain;
361 
362  // Roc-6 average
363  //const float gain = 1./0.313; // 1 ADC = 3.19 VCALs
364  //const float pedestal = -6.2 * gain; // -19.8
365  //
366  float vcal = adc * DBgain - DBpedestal;
367 
368  // atanh calibration
369  // Roc-6 average
370  //const float p0 = 0.00492;
371  //const float p1 = 1.998;
372  //const float p2 = 90.6;
373  //const float p3 = 134.1;
374  // Roc-6 average
375  //const float p0 = 0.00382;
376  //const float p1 = 0.886;
377  //const float p2 = 112.7;
378  //const float p3 = 113.0;
379  //float vcal = ( atanh( (adc-p3)/p2) + p1)/p0;
380 
381  if (theLayer == 1) {
383  } else {
385  }
386  }
387  } else { // No misscalibration in the digitizer
388  // Simple (default) linear gain
389  const float gain = theElectronPerADCGain; // default: 1 ADC = 135 electrons
390  const float pedestal = 0.; //
391  electrons = int(adc * gain + pedestal);
392  }
393 
394  return electrons;
395 }

References gpuClustering::adc, cuy::col, doMissCalibrate, doPhase2Calibration, pwdgSkimBPark_cfi::electrons, PedestalClient_cfi::gain, SiPixelGainCalibrationServiceBase::getGain(), SiPixelGainCalibrationServiceBase::getPedestal(), createfilelist::int, SiPixelGainCalibrationServiceBase::isDead(), SiPixelGainCalibrationServiceBase::isNoisy(), EcalCondDBWriter_cfi::pedestal, funct::pow(), theConversionFactor, theConversionFactor_L1, theDetid, theElectronPerADCGain, theLayer, theOffset, theOffset_L1, thePhase2DigiBaseline, thePhase2KinkADC, thePhase2ReadoutMode, and PixelClusterizerBase::theSiPixelGainCalibrationService_.

Referenced by copy_to_buffer().

◆ clear_buffer() [1/2]

void PixelThresholdClusterizer::clear_buffer ( ClusterIterator  begin,
ClusterIterator  end 
)
private

Definition at line 204 of file PixelThresholdClusterizer.cc.

204  {
205  for (ClusterIterator ci = begin; ci != end; ++ci) {
206  for (int i = 0; i < ci->size(); ++i) {
207  const SiPixelCluster::Pixel pixel = ci->pixel(i);
208 
209  theBuffer.set_adc(pixel.x, pixel.y, 0); // reset pixel adc to 0
210  }
211  }
212 }

References mps_fire::end, mps_fire::i, muonClassificationByHits_cfi::pixel, SiPixelArrayBuffer::set_adc(), and theBuffer.

◆ clear_buffer() [2/2]

void PixelThresholdClusterizer::clear_buffer ( DigiIterator  begin,
DigiIterator  end 
)
private

Clear the internal buffer array.

Pixels which are not part of recognized clusters are NOT ERASED during the cluster finding. Erase them now.

TO DO: ask Danek... wouldn't it be faster to simply memcopy() zeros into the whole buffer array?

Definition at line 198 of file PixelThresholdClusterizer.cc.

198  {
199  for (DigiIterator di = begin; di != end; ++di) {
200  theBuffer.set_adc(di->row(), di->column(), 0); // reset pixel adc to 0
201  }
202 }

References mps_fire::end, SiPixelArrayBuffer::set_adc(), and theBuffer.

Referenced by clusterizeDetUnitT().

◆ clusterizeDetUnit() [1/2]

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

Implements PixelClusterizerBase.

Definition at line 63 of file PixelThresholdClusterizer.h.

67  {
68  clusterizeDetUnitT(input, pixDet, tTopo, badChannels, output);
69  }

References input, and convertSQLitetoXML_cfg::output.

◆ clusterizeDetUnit() [2/2]

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

Implements PixelClusterizerBase.

Definition at line 70 of file PixelThresholdClusterizer.h.

74  {
75  clusterizeDetUnitT(input, pixDet, tTopo, badChannels, output);
76  }

References input, and convertSQLitetoXML_cfg::output.

◆ clusterizeDetUnitT()

template<typename T >
void PixelThresholdClusterizer::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 126 of file PixelThresholdClusterizer.cc.

130  {
131  typename T::const_iterator begin = input.begin();
132  typename T::const_iterator end = input.end();
133 
134  // Do not bother for empty detectors
135  //if (begin == end) cout << " PixelThresholdClusterizer::clusterizeDetUnit - No digis to clusterize";
136 
137  // Set up the clusterization on this DetId.
138  if (!setup(pixDet))
139  return;
140 
141  theDetid = input.detId();
142 
143  // Set separate cluster threshold for L1 (needed for phase1)
145  theLayer = (DetId(theDetid).subdetId() == 1) ? tTopo->pxbLayer(theDetid) : 0;
146  if (theLayer == 1)
148 
149  // Copy PixelDigis to the buffer array; select the seed pixels
150  // on the way, and store them in theSeeds.
151  copy_to_buffer(begin, end);
152 
153  assert(output.empty());
154  // Loop over all seeds. TO DO: wouldn't using iterators be faster?
155  // edm::LogError("PixelThresholdClusterizer") << "Starting clusterizing" << endl;
156  for (unsigned int i = 0; i < theSeeds.size(); i++) {
157  // Gavril : The charge of seeds that were already inlcuded in clusters is set to 1 electron
158  // so we don't want to call "make_cluster" for these cases
159  if (theBuffer(theSeeds[i]) >= theSeedThreshold) { // Is this seed still valid?
160  // Make a cluster around this seed
162 
163  // Check if the cluster is above threshold
164  // (TO DO: one is signed, other unsigned, gcc warns...)
165  if (cluster.charge() >= clusterThreshold) {
166  // std::cout << "putting in this cluster " << i << " " << cluster.charge() << " " << cluster.pixelADC().size() << endl;
167  // sort by row (x)
168  output.push_back(std::move(cluster));
169  std::push_heap(output.begin(), output.end(), [](SiPixelCluster const& cl1, SiPixelCluster const& cl2) {
170  return cl1.minPixelRow() < cl2.minPixelRow();
171  });
172  }
173  }
174  }
175  // sort by row (x) maybe sorting the seed would suffice....
176  std::sort_heap(output.begin(), output.end(), [](SiPixelCluster const& cl1, SiPixelCluster const& cl2) {
177  return cl1.minPixelRow() < cl2.minPixelRow();
178  });
179 
180  // Erase the seeds.
181  theSeeds.clear();
182 
183  // Need to clean unused pixels from the buffer array.
184  clear_buffer(begin, end);
185 
186  theFakePixels.clear();
187 }

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

◆ copy_to_buffer() [1/2]

void PixelThresholdClusterizer::copy_to_buffer ( ClusterIterator  begin,
ClusterIterator  end 
)
private

Definition at line 297 of file PixelThresholdClusterizer.cc.

297  {
298  // loop over clusters
299  for (ClusterIterator ci = begin; ci != end; ++ci) {
300  // loop over pixels
301  for (int i = 0; i < ci->size(); ++i) {
302  const SiPixelCluster::Pixel pixel = ci->pixel(i);
303 
304  int row = pixel.x;
305  int col = pixel.y;
306  int adc = pixel.adc;
307  if (adc >= thePixelThreshold) {
308  theBuffer.add_adc(row, col, adc);
309  if (adc >= theSeedThreshold)
310  theSeeds.push_back(SiPixelCluster::PixelPos(row, col));
311  }
312  }
313  }
314 }

References gpuClustering::adc, SiPixelArrayBuffer::add_adc(), cuy::col, mps_fire::end, mps_fire::i, muonClassificationByHits_cfi::pixel, theBuffer, thePixelThreshold, theSeeds, and theSeedThreshold.

◆ copy_to_buffer() [2/2]

void PixelThresholdClusterizer::copy_to_buffer ( DigiIterator  begin,
DigiIterator  end 
)
private

Copy adc counts from PixelDigis into the buffer, identify seeds.

Definition at line 217 of file PixelThresholdClusterizer.cc.

217  {
218 #ifdef PIXELREGRESSION
219  static std::atomic<int> s_ic = 0;
220  in ic = ++s_ic;
221  if (ic == 1) {
222  // std::cout << (doMissCalibrate ? "VI from db" : "VI linear") << std::endl;
223  }
224 #endif
225  int electron[end - begin]; // pixel charge in electrons
226  memset(electron, 0, (end - begin) * sizeof(int));
227 
228  if (doPhase2Calibration) {
229  int i = 0;
230  for (DigiIterator di = begin; di != end; ++di) {
231  electron[i] = calibrate(di->adc(), di->column(), di->row());
232  i++;
233  }
234  assert(i == (end - begin));
235  }
236 
237  else {
238  if (doMissCalibrate) {
239  if (theLayer == 1) {
240  (*theSiPixelGainCalibrationService_)
242  } else {
243  (*theSiPixelGainCalibrationService_).calibrate(theDetid, begin, end, theConversionFactor, theOffset, electron);
244  }
245  } else {
246  int i = 0;
247  const float gain = theElectronPerADCGain; // default: 1 ADC = 135 electrons
248  for (DigiIterator di = begin; di != end; ++di) {
249  auto adc = di->adc();
250  const float pedestal = 0.; //
251  electron[i] = int(adc * gain + pedestal);
252  ++i;
253  }
254  assert(i == (end - begin));
255  }
256  }
257 
258  int i = 0;
259 #ifdef PIXELREGRESSION
260  static std::atomic<int> eqD = 0;
261 #endif
262  for (DigiIterator di = begin; di != end; ++di) {
263  int row = di->row();
264  int col = di->column();
265  // VV: do not calibrate a fake pixel, it already has a unit of 10e-:
266  int adc = (di->flag() != 0) ? di->adc() * 10 : electron[i]; // this is in electrons
267  i++;
268 
269 #ifdef PIXELREGRESSION
270  int adcOld = calibrate(di->adc(), col, row);
271  //assert(adc==adcOld);
272  if (adc != adcOld)
273  std::cout << "VI " << eqD << ' ' << ic << ' ' << end - begin << ' ' << i << ' ' << di->adc() << ' ' << adc << ' '
274  << adcOld << std::endl;
275  else
276  ++eqD;
277 #endif
278 
279  if (adc < 100)
280  adc = 100; // put all negative pixel charges into the 100 elec bin
281  /* This is semi-random good number. The exact number (in place of 100) is irrelevant from the point
282  of view of the final cluster charge since these are typically >= 20000.
283  */
284 
285  if (adc >= thePixelThreshold) {
286  theBuffer.set_adc(row, col, adc);
287  // VV: add pixel to the fake list. Only when running on digi collection
288  if (di->flag() != 0)
289  theFakePixels[row * theNumOfCols + col] = true;
290  if (adc >= theSeedThreshold)
291  theSeeds.push_back(SiPixelCluster::PixelPos(row, col));
292  }
293  }
294  assert(i == (end - begin));
295 }

References gpuClustering::adc, cms::cuda::assert(), calibrate(), cuy::col, gather_cfg::cout, doMissCalibrate, doPhase2Calibration, HPSPFTauProducerPuppi_cfi::electron, mps_fire::end, PedestalClient_cfi::gain, mps_fire::i, recoMuon::in, createfilelist::int, EcalCondDBWriter_cfi::pedestal, SiPixelArrayBuffer::set_adc(), theBuffer, theConversionFactor, theConversionFactor_L1, theDetid, theElectronPerADCGain, theFakePixels, theLayer, theNumOfCols, theOffset, theOffset_L1, thePixelThreshold, theSeeds, and theSeedThreshold.

Referenced by clusterizeDetUnitT().

◆ fillPSetDescription()

void PixelThresholdClusterizer::fillPSetDescription ( edm::ParameterSetDescription desc)
static

Definition at line 71 of file PixelThresholdClusterizer.cc.

71  {
72  desc.add<int>("ChannelThreshold", 1000);
73  desc.add<bool>("MissCalibrate", true);
74  desc.add<bool>("SplitClusters", false);
75  desc.add<int>("VCaltoElectronGain", 65);
76  desc.add<int>("VCaltoElectronGain_L1", 65);
77  desc.add<int>("VCaltoElectronOffset", -414);
78  desc.add<int>("VCaltoElectronOffset_L1", -414);
79  desc.add<int>("SeedThreshold", 1000);
80  desc.add<int>("ClusterThreshold_L1", 4000);
81  desc.add<int>("ClusterThreshold", 4000);
82  desc.add<double>("ElectronPerADCGain", 135.);
83  desc.add<bool>("Phase2Calibration", false);
84  desc.add<int>("Phase2ReadoutMode", -1);
85  desc.add<double>("Phase2DigiBaseline", 1200.);
86  desc.add<int>("Phase2KinkADC", 8);
87 }

References submitPVResolutionJobs::desc.

Referenced by SiPixelClusterProducer::fillDescriptions().

◆ make_cluster()

SiPixelCluster PixelThresholdClusterizer::make_cluster ( const SiPixelCluster::PixelPos pix,
edmNew::DetSetVector< SiPixelCluster >::FastFiller &  output 
)
private

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

Definition at line 400 of file PixelThresholdClusterizer.cc.

401  {
402  //First we acquire the seeds for the clusters
403  int seed_adc;
404  stack<SiPixelCluster::PixelPos, vector<SiPixelCluster::PixelPos> > dead_pixel_stack;
405 
406  //The individual modules have been loaded into a buffer.
407  //After each pixel has been considered by the clusterizer, we set the adc count to 1
408  //to mark that we have already considered it.
409  //The only difference between dead/noisy pixels and standard ones is that for dead/noisy pixels,
410  //We consider the charge of the pixel to always be zero.
411 
412  /* this is not possible as dead and noisy pixel cannot make it into a seed...
413  if ( doMissCalibrate &&
414  (theSiPixelGainCalibrationService_->isDead(theDetid,pix.col(),pix.row()) ||
415  theSiPixelGainCalibrationService_->isNoisy(theDetid,pix.col(),pix.row())) )
416  {
417  std::cout << "IMPOSSIBLE" << std::endl;
418  seed_adc = 0;
419  theBuffer.set_adc(pix, 1);
420  }
421  else {
422  */
423  seed_adc = theBuffer(pix.row(), pix.col());
424  theBuffer.set_adc(pix, 1);
425  // }
426 
427  AccretionCluster acluster, cldata;
428  acluster.add(pix, seed_adc);
429  cldata.add(pix, seed_adc);
430 
431  //Here we search all pixels adjacent to all pixels in the cluster.
432  bool dead_flag = false;
433  while (!acluster.empty()) {
434  //This is the standard algorithm to find and add a pixel
435  auto curInd = acluster.top();
436  acluster.pop();
437  for (auto c = std::max(0, int(acluster.y[curInd]) - 1);
438  c < std::min(int(acluster.y[curInd]) + 2, theBuffer.columns());
439  ++c) {
440  for (auto r = std::max(0, int(acluster.x[curInd]) - 1);
441  r < std::min(int(acluster.x[curInd]) + 2, theBuffer.rows());
442  ++r) {
443  if (theBuffer(r, c) >= thePixelThreshold) {
444  SiPixelCluster::PixelPos newpix(r, c);
445  if (!acluster.add(newpix, theBuffer(r, c)))
446  goto endClus;
447  // VV: no fake pixels in cluster, leads to non-contiguous clusters
448  if (!theFakePixels[r * theNumOfCols + c]) {
449  cldata.add(newpix, theBuffer(r, c));
450  }
451  theBuffer.set_adc(newpix, 1);
452  }
453 
454  /* //Commenting out the addition of dead pixels to the cluster until further testing -- dfehling 06/09
455  //Check on the bounds of the module; this is to keep the isDead and isNoisy modules from returning errors
456  else if(r>= 0 && c >= 0 && (r <= (theNumOfRows-1.)) && (c <= (theNumOfCols-1.))){
457  //Check for dead/noisy pixels check that the buffer is not -1 (already considered). Check whether we want to split clusters separated by dead pixels or not.
458  if((theSiPixelGainCalibrationService_->isDead(theDetid,c,r) || theSiPixelGainCalibrationService_->isNoisy(theDetid,c,r)) && theBuffer(r,c) != 1){
459 
460  //If a pixel is dead or noisy, check to see if we want to split the clusters or not.
461  //Push it into a dead pixel stack in case we want to split the clusters. Otherwise add it to the cluster.
462  //If we are splitting the clusters, we will iterate over the dead pixel stack later.
463 
464  SiPixelCluster::PixelPos newpix(r,c);
465  if(!doSplitClusters){
466 
467  cluster.add(newpix, theBuffer(r,c));}
468  else if(doSplitClusters){
469  dead_pixel_stack.push(newpix);
470  dead_flag = true;}
471 
472  theBuffer.set_adc(newpix, 1);
473  }
474 
475  }
476  */
477  }
478  }
479 
480  } // while accretion
481 endClus:
482  SiPixelCluster cluster(cldata.isize, cldata.adc, cldata.x, cldata.y, cldata.xmin, cldata.ymin);
483  //Here we split the cluster, if the flag to do so is set and we have found a dead or noisy pixel.
484 
485  if (dead_flag && doSplitClusters) {
486  // Set separate cluster threshold for L1 (needed for phase1)
488  if (theLayer == 1)
490 
491  //Set the first cluster equal to the existing cluster.
492  SiPixelCluster first_cluster = cluster;
493  bool have_second_cluster = false;
494  while (!dead_pixel_stack.empty()) {
495  //consider each found dead pixel
496  SiPixelCluster::PixelPos deadpix = dead_pixel_stack.top();
497  dead_pixel_stack.pop();
498  theBuffer.set_adc(deadpix, 1);
499 
500  //Clusterize the split cluster using the dead pixel as a seed
501  SiPixelCluster second_cluster = make_cluster(deadpix, output);
502 
503  //If both clusters would normally have been found by the clusterizer, put them into output
504  if (second_cluster.charge() >= clusterThreshold && first_cluster.charge() >= clusterThreshold) {
505  output.push_back(second_cluster);
506  have_second_cluster = true;
507  }
508 
509  //We also want to keep the merged cluster in data and let the RecHit algorithm decide which set to keep
510  //This loop adds the second cluster to the first.
511  const std::vector<SiPixelCluster::Pixel>& branch_pixels = second_cluster.pixels();
512  for (unsigned int i = 0; i < branch_pixels.size(); i++) {
513  int temp_x = branch_pixels[i].x;
514  int temp_y = branch_pixels[i].y;
515  int temp_adc = branch_pixels[i].adc;
516  SiPixelCluster::PixelPos newpix(temp_x, temp_y);
517  cluster.add(newpix, temp_adc);
518  }
519  }
520 
521  //Remember to also add the first cluster if we added the second one.
522  if (first_cluster.charge() >= clusterThreshold && have_second_cluster) {
523  output.push_back(first_cluster);
524  std::push_heap(output.begin(), output.end(), [](SiPixelCluster const& cl1, SiPixelCluster const& cl2) {
525  return cl1.minPixelRow() < cl2.minPixelRow();
526  });
527  }
528  }
529 
530  return cluster;
531 }

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

Referenced by clusterizeDetUnitT().

◆ setup()

bool PixelThresholdClusterizer::setup ( const PixelGeomDetUnit pixDet)
private

Private helper methods:

Prepare the Clusterizer to work on a particular DetUnit. Re-init the size of the panel/plaquette (so update nrows and ncols),

Definition at line 93 of file PixelThresholdClusterizer.cc.

93  {
94  // Cache the topology.
95  const PixelTopology& topol = pixDet->specificTopology();
96 
97  // Get the new sizes.
98  int nrows = topol.nrows(); // rows in x
99  int ncols = topol.ncolumns(); // cols in y
100 
101  theNumOfRows = nrows; // Set new sizes
103 
104  if (nrows > theBuffer.rows() || ncols > theBuffer.columns()) { // change only when a larger is needed
105  //if( nrows != theNumOfRows || ncols != theNumOfCols ) {
106  //cout << " PixelThresholdClusterizer: pixel buffer redefined to "
107  // << nrows << " * " << ncols << endl;
108  //theNumOfRows = nrows; // Set new sizes
109  //theNumOfCols = ncols;
110  // Resize the buffer
111  theBuffer.setSize(nrows, ncols); // Modify
112  }
113 
114  theFakePixels.resize(nrows * ncols, false);
115 
116  return true;
117 }

References SiPixelArrayBuffer::columns(), hgcalPlots::ncols, PixelTopology::ncolumns(), PixelTopology::nrows(), SiPixelArrayBuffer::rows(), SiPixelArrayBuffer::setSize(), PixelGeomDetUnit::specificTopology(), theBuffer, theFakePixels, theNumOfCols, and theNumOfRows.

Referenced by clusterizeDetUnitT().

Member Data Documentation

◆ doMissCalibrate

const bool PixelThresholdClusterizer::doMissCalibrate
private

Definition at line 121 of file PixelThresholdClusterizer.h.

Referenced by calibrate(), and copy_to_buffer().

◆ doPhase2Calibration

const bool PixelThresholdClusterizer::doPhase2Calibration
private

Definition at line 111 of file PixelThresholdClusterizer.h.

Referenced by calibrate(), and copy_to_buffer().

◆ doSplitClusters

const bool PixelThresholdClusterizer::doSplitClusters
private

Definition at line 122 of file PixelThresholdClusterizer.h.

Referenced by make_cluster().

◆ theBuffer

SiPixelArrayBuffer PixelThresholdClusterizer::theBuffer
private

◆ theClusters

std::vector<SiPixelCluster> PixelThresholdClusterizer::theClusters
private

Definition at line 91 of file PixelThresholdClusterizer.h.

◆ theClusterThreshold

const int PixelThresholdClusterizer::theClusterThreshold
private

Definition at line 102 of file PixelThresholdClusterizer.h.

Referenced by clusterizeDetUnitT(), and make_cluster().

◆ theClusterThreshold_L1

const int PixelThresholdClusterizer::theClusterThreshold_L1
private

Definition at line 103 of file PixelThresholdClusterizer.h.

Referenced by clusterizeDetUnitT(), and make_cluster().

◆ theClusterThresholdInNoiseUnits

float PixelThresholdClusterizer::theClusterThresholdInNoiseUnits
private

Definition at line 98 of file PixelThresholdClusterizer.h.

◆ theConversionFactor

const int PixelThresholdClusterizer::theConversionFactor
private

Definition at line 104 of file PixelThresholdClusterizer.h.

Referenced by calibrate(), and copy_to_buffer().

◆ theConversionFactor_L1

const int PixelThresholdClusterizer::theConversionFactor_L1
private

Definition at line 105 of file PixelThresholdClusterizer.h.

Referenced by calibrate(), and copy_to_buffer().

◆ theDetid

uint32_t PixelThresholdClusterizer::theDetid
private

Definition at line 119 of file PixelThresholdClusterizer.h.

Referenced by calibrate(), clusterizeDetUnitT(), and copy_to_buffer().

◆ theElectronPerADCGain

const double PixelThresholdClusterizer::theElectronPerADCGain
private

Definition at line 109 of file PixelThresholdClusterizer.h.

Referenced by calibrate(), and copy_to_buffer().

◆ theFakePixels

std::vector<bool> PixelThresholdClusterizer::theFakePixels
private

◆ theLayer

int PixelThresholdClusterizer::theLayer
private

◆ theNumOfCols

int PixelThresholdClusterizer::theNumOfCols
private

◆ theNumOfRows

int PixelThresholdClusterizer::theNumOfRows
private

Geometry-related information.

Definition at line 117 of file PixelThresholdClusterizer.h.

Referenced by PixelThresholdClusterizer(), and setup().

◆ theOffset

const int PixelThresholdClusterizer::theOffset
private

Definition at line 106 of file PixelThresholdClusterizer.h.

Referenced by calibrate(), and copy_to_buffer().

◆ theOffset_L1

const int PixelThresholdClusterizer::theOffset_L1
private

Definition at line 107 of file PixelThresholdClusterizer.h.

Referenced by calibrate(), and copy_to_buffer().

◆ thePhase2DigiBaseline

const double PixelThresholdClusterizer::thePhase2DigiBaseline
private

Definition at line 113 of file PixelThresholdClusterizer.h.

Referenced by calibrate().

◆ thePhase2KinkADC

const int PixelThresholdClusterizer::thePhase2KinkADC
private

Definition at line 114 of file PixelThresholdClusterizer.h.

Referenced by calibrate().

◆ thePhase2ReadoutMode

const int PixelThresholdClusterizer::thePhase2ReadoutMode
private

Definition at line 112 of file PixelThresholdClusterizer.h.

Referenced by calibrate().

◆ thePixelThreshold

const int PixelThresholdClusterizer::thePixelThreshold
private

Definition at line 100 of file PixelThresholdClusterizer.h.

Referenced by copy_to_buffer(), and make_cluster().

◆ thePixelThresholdInNoiseUnits

float PixelThresholdClusterizer::thePixelThresholdInNoiseUnits
private

Clustering-related quantities:

Definition at line 96 of file PixelThresholdClusterizer.h.

◆ theSeeds

std::vector<SiPixelCluster::PixelPos> PixelThresholdClusterizer::theSeeds
private

Definition at line 90 of file PixelThresholdClusterizer.h.

Referenced by clusterizeDetUnitT(), and copy_to_buffer().

◆ theSeedThreshold

const int PixelThresholdClusterizer::theSeedThreshold
private

Definition at line 101 of file PixelThresholdClusterizer.h.

Referenced by clusterizeDetUnitT(), and copy_to_buffer().

◆ theSeedThresholdInNoiseUnits

float PixelThresholdClusterizer::theSeedThresholdInNoiseUnits
private

Definition at line 97 of file PixelThresholdClusterizer.h.

PixelClusterizerBase::DigiIterator
edm::DetSet< PixelDigi >::const_iterator DigiIterator
Definition: PixelClusterizerBase.h:20
hgcalPlots.ncols
ncols
Definition: hgcalPlots.py:104
mps_fire.i
i
Definition: mps_fire.py:428
input
static const std::string input
Definition: EdmProvDump.cc:48
PixelClusterizerBase::ClusterIterator
edmNew::DetSet< SiPixelCluster >::const_iterator ClusterIterator
Definition: PixelClusterizerBase.h:21
SiPixelArrayBuffer::rows
int rows() const
Definition: SiPixelArrayBuffer.h:33
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
PixelThresholdClusterizer::setup
bool setup(const PixelGeomDetUnit *pixDet)
Private helper methods:
Definition: PixelThresholdClusterizer.cc:93
SiPixelArrayBuffer::set_adc
void set_adc(int row, int col, int adc)
Definition: SiPixelArrayBuffer.h:67
min
T min(T a, T b)
Definition: MathUtil.h:58
PixelThresholdClusterizer::theNumOfRows
int theNumOfRows
Geometry-related information.
Definition: PixelThresholdClusterizer.h:117
SiPixelGainCalibrationServiceBase::isDead
virtual bool isDead(const uint32_t &detID, const int &col, const int &row)=0
gpuClustering::adc
uint16_t *__restrict__ uint16_t const *__restrict__ adc
Definition: gpuClusterChargeCut.h:20
PixelThresholdClusterizer::theOffset
const int theOffset
Definition: PixelThresholdClusterizer.h:106
SiPixelGainCalibrationServiceBase::getGain
virtual float getGain(const uint32_t &detID, const int &col, const int &row)=0
PixelThresholdClusterizer::theClusterThreshold_L1
const int theClusterThreshold_L1
Definition: PixelThresholdClusterizer.h:103
cuy.col
col
Definition: cuy.py:1009
gather_cfg.cout
cout
Definition: gather_cfg.py:144
PixelClusterizerBase::theSiPixelGainCalibrationService_
SiPixelGainCalibrationServiceBase * theSiPixelGainCalibrationService_
Definition: PixelClusterizerBase.h:83
PixelThresholdClusterizer::theClusterThreshold
const int theClusterThreshold
Definition: PixelThresholdClusterizer.h:102
muonClassificationByHits_cfi.pixel
pixel
Definition: muonClassificationByHits_cfi.py:9
PixelThresholdClusterizer::theSeeds
std::vector< SiPixelCluster::PixelPos > theSeeds
Definition: PixelThresholdClusterizer.h:90
cms::cuda::assert
assert(be >=bs)
PixelThresholdClusterizer::theNumOfCols
int theNumOfCols
Definition: PixelThresholdClusterizer.h:118
PixelThresholdClusterizer::make_cluster
SiPixelCluster make_cluster(const SiPixelCluster::PixelPos &pix, edmNew::DetSetVector< SiPixelCluster >::FastFiller &output)
The actual clustering algorithm: group the neighboring pixels around the seed.
Definition: PixelThresholdClusterizer.cc:400
PixelThresholdClusterizer::thePhase2KinkADC
const int thePhase2KinkADC
Definition: PixelThresholdClusterizer.h:114
GetRecoTauVFromDQM_MC_cff.cl2
cl2
Definition: GetRecoTauVFromDQM_MC_cff.py:44
SiPixelCluster
Pixel cluster – collection of neighboring pixels above threshold.
Definition: SiPixelCluster.h:28
SiPixelCluster::Pixel
Definition: SiPixelCluster.h:31
PixelThresholdClusterizer::copy_to_buffer
void copy_to_buffer(DigiIterator begin, DigiIterator end)
Copy adc counts from PixelDigis into the buffer, identify seeds.
Definition: PixelThresholdClusterizer.cc:217
TrackerTopology::pxbLayer
unsigned int pxbLayer(const DetId &id) const
Definition: TrackerTopology.h:144
DetId
Definition: DetId.h:17
SiPixelArrayBuffer::columns
int columns() const
Definition: SiPixelArrayBuffer.h:34
SiPixelCluster::minPixelRow
int minPixelRow() const
Definition: SiPixelCluster.h:150
mps_fire.end
end
Definition: mps_fire.py:242
PixelTopology::ncolumns
virtual int ncolumns() const =0
EMEnrichingFilter_cfi.clusterThreshold
clusterThreshold
Definition: EMEnrichingFilter_cfi.py:12
PixelThresholdClusterizer::thePhase2DigiBaseline
const double thePhase2DigiBaseline
Definition: PixelThresholdClusterizer.h:113
PixelTopology
Definition: PixelTopology.h:10
PixelThresholdClusterizer::thePhase2ReadoutMode
const int thePhase2ReadoutMode
Definition: PixelThresholdClusterizer.h:112
PixelThresholdClusterizer::clusterizeDetUnitT
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...
Definition: PixelThresholdClusterizer.cc:126
DetId::subdetId
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum)
Definition: DetId.h:48
PixelThresholdClusterizer::theLayer
int theLayer
Definition: PixelThresholdClusterizer.h:120
PixelThresholdClusterizer::thePixelThreshold
const int thePixelThreshold
Definition: PixelThresholdClusterizer.h:100
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
PixelGeomDetUnit::specificTopology
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
Definition: PixelGeomDetUnit.cc:17
PixelThresholdClusterizer::clear_buffer
void clear_buffer(DigiIterator begin, DigiIterator end)
Clear the internal buffer array.
Definition: PixelThresholdClusterizer.cc:198
recoMuon::in
Definition: RecoMuonEnumerators.h:6
PixelThresholdClusterizer::theFakePixels
std::vector< bool > theFakePixels
Definition: PixelThresholdClusterizer.h:93
createfilelist.int
int
Definition: createfilelist.py:10
SiPixelArrayBuffer::add_adc
void add_adc(int row, int col, int adc)
Definition: SiPixelArrayBuffer.h:71
PixelThresholdClusterizer::theOffset_L1
const int theOffset_L1
Definition: PixelThresholdClusterizer.h:107
EcalCondDBWriter_cfi.pedestal
pedestal
Definition: EcalCondDBWriter_cfi.py:49
PixelThresholdClusterizer::theConversionFactor
const int theConversionFactor
Definition: PixelThresholdClusterizer.h:104
PixelThresholdClusterizer::theConversionFactor_L1
const int theConversionFactor_L1
Definition: PixelThresholdClusterizer.h:105
HPSPFTauProducerPuppi_cfi.electron
electron
Definition: HPSPFTauProducerPuppi_cfi.py:13
alignCSCRings.r
r
Definition: alignCSCRings.py:93
PixelThresholdClusterizer::doSplitClusters
const bool doSplitClusters
Definition: PixelThresholdClusterizer.h:122
PedestalClient_cfi.gain
gain
Definition: PedestalClient_cfi.py:37
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
pwdgSkimBPark_cfi.electrons
electrons
Definition: pwdgSkimBPark_cfi.py:6
SiPixelCluster::PixelPos::row
constexpr int row() const
Definition: SiPixelCluster.h:60
SiPixelCluster::charge
int charge() const
Definition: SiPixelCluster.h:142
PixelThresholdClusterizer::doPhase2Calibration
const bool doPhase2Calibration
Definition: PixelThresholdClusterizer.h:111
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
SiPixelCluster::pixels
const std::vector< Pixel > pixels() const
Definition: SiPixelCluster.h:159
SiPixelGainCalibrationServiceBase::getPedestal
virtual float getPedestal(const uint32_t &detID, const int &col, const int &row)=0
SiPixelArrayBuffer::setSize
void setSize(int rows, int cols)
Definition: SiPixelArrayBuffer.h:54
PixelThresholdClusterizer::doMissCalibrate
const bool doMissCalibrate
Definition: PixelThresholdClusterizer.h:121
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:56
PixelThresholdClusterizer::theSeedThreshold
const int theSeedThreshold
Definition: PixelThresholdClusterizer.h:101
SiPixelCluster::PixelPos
Definition: SiPixelCluster.h:56
PixelTopology::nrows
virtual int nrows() const =0
PixelThresholdClusterizer::theBuffer
SiPixelArrayBuffer theBuffer
Data storage.
Definition: PixelThresholdClusterizer.h:89
PixelThresholdClusterizer::calibrate
int calibrate(int adc, int col, int row)
Definition: PixelThresholdClusterizer.cc:319
PixelThresholdClusterizer::theElectronPerADCGain
const double theElectronPerADCGain
Definition: PixelThresholdClusterizer.h:109
SiPixelCluster::PixelPos::col
constexpr int col() const
Definition: SiPixelCluster.h:61
PixelThresholdClusterizer::theDetid
uint32_t theDetid
Definition: PixelThresholdClusterizer.h:119
SiPixelGainCalibrationServiceBase::isNoisy
virtual bool isNoisy(const uint32_t &detID, const int &col, const int &row)=0