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
 
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 }

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

◆ ~PixelThresholdClusterizer()

PixelThresholdClusterizer::~PixelThresholdClusterizer ( )
override

Definition at line 67 of file PixelThresholdClusterizer.cc.

67 {}

Member Function Documentation

◆ calibrate()

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

Definition at line 309 of file PixelThresholdClusterizer.cc.

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

References ecalLiteDTU::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 199 of file PixelThresholdClusterizer.cc.

199  {
200  for (ClusterIterator ci = begin; ci != end; ++ci) {
201  for (int i = 0; i < ci->size(); ++i) {
202  const SiPixelCluster::Pixel pixel = ci->pixel(i);
203 
204  theBuffer.set_adc(pixel.x, pixel.y, 0); // reset pixel adc to 0
205  }
206  }
207 }

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 193 of file PixelThresholdClusterizer.cc.

193  {
194  for (DigiIterator di = begin; di != end; ++di) {
195  theBuffer.set_adc(di->row(), di->column(), 0); // reset pixel adc to 0
196  }
197 }

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 123 of file PixelThresholdClusterizer.cc.

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

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, theLayer, theSeeds, and theSeedThreshold.

◆ copy_to_buffer() [1/2]

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

Definition at line 287 of file PixelThresholdClusterizer.cc.

287  {
288  // loop over clusters
289  for (ClusterIterator ci = begin; ci != end; ++ci) {
290  // loop over pixels
291  for (int i = 0; i < ci->size(); ++i) {
292  const SiPixelCluster::Pixel pixel = ci->pixel(i);
293 
294  int row = pixel.x;
295  int col = pixel.y;
296  int adc = pixel.adc;
297  if (adc >= thePixelThreshold) {
298  theBuffer.add_adc(row, col, adc);
299  if (adc >= theSeedThreshold)
300  theSeeds.push_back(SiPixelCluster::PixelPos(row, col));
301  }
302  }
303  }
304 }

References ecalLiteDTU::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 212 of file PixelThresholdClusterizer.cc.

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

References ecalLiteDTU::adc(), cms::cuda::assert(), calibrate(), cuy::col, gather_cfg::cout, doMissCalibrate, doPhase2Calibration, metsig::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, theLayer, theOffset, theOffset_L1, thePixelThreshold, theSeeds, and theSeedThreshold.

Referenced by clusterizeDetUnitT().

◆ fillPSetDescription()

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

Definition at line 70 of file PixelThresholdClusterizer.cc.

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

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 390 of file PixelThresholdClusterizer.cc.

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

References PixelClusterizerBase::AccretionCluster::adc, PixelClusterizerBase::AccretionCluster::add(), SiPixelCluster::add(), HltBtagPostValidation_cff::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, theLayer, 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 92 of file PixelThresholdClusterizer.cc.

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

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

Referenced by clusterizeDetUnitT().

Member Data Documentation

◆ doMissCalibrate

const bool PixelThresholdClusterizer::doMissCalibrate
private

Definition at line 119 of file PixelThresholdClusterizer.h.

Referenced by calibrate(), and copy_to_buffer().

◆ doPhase2Calibration

const bool PixelThresholdClusterizer::doPhase2Calibration
private

Definition at line 109 of file PixelThresholdClusterizer.h.

Referenced by calibrate(), and copy_to_buffer().

◆ doSplitClusters

const bool PixelThresholdClusterizer::doSplitClusters
private

Definition at line 120 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 100 of file PixelThresholdClusterizer.h.

Referenced by clusterizeDetUnitT(), and make_cluster().

◆ theClusterThreshold_L1

const int PixelThresholdClusterizer::theClusterThreshold_L1
private

Definition at line 101 of file PixelThresholdClusterizer.h.

Referenced by clusterizeDetUnitT(), and make_cluster().

◆ theClusterThresholdInNoiseUnits

float PixelThresholdClusterizer::theClusterThresholdInNoiseUnits
private

Definition at line 96 of file PixelThresholdClusterizer.h.

◆ theConversionFactor

const int PixelThresholdClusterizer::theConversionFactor
private

Definition at line 102 of file PixelThresholdClusterizer.h.

Referenced by calibrate(), and copy_to_buffer().

◆ theConversionFactor_L1

const int PixelThresholdClusterizer::theConversionFactor_L1
private

Definition at line 103 of file PixelThresholdClusterizer.h.

Referenced by calibrate(), and copy_to_buffer().

◆ theDetid

uint32_t PixelThresholdClusterizer::theDetid
private

Definition at line 117 of file PixelThresholdClusterizer.h.

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

◆ theElectronPerADCGain

const double PixelThresholdClusterizer::theElectronPerADCGain
private

Definition at line 107 of file PixelThresholdClusterizer.h.

Referenced by calibrate(), and copy_to_buffer().

◆ theLayer

int PixelThresholdClusterizer::theLayer
private

◆ theNumOfCols

int PixelThresholdClusterizer::theNumOfCols
private

Definition at line 116 of file PixelThresholdClusterizer.h.

Referenced by PixelThresholdClusterizer(), and setup().

◆ theNumOfRows

int PixelThresholdClusterizer::theNumOfRows
private

Geometry-related information.

Definition at line 115 of file PixelThresholdClusterizer.h.

Referenced by PixelThresholdClusterizer(), and setup().

◆ theOffset

const int PixelThresholdClusterizer::theOffset
private

Definition at line 104 of file PixelThresholdClusterizer.h.

Referenced by calibrate(), and copy_to_buffer().

◆ theOffset_L1

const int PixelThresholdClusterizer::theOffset_L1
private

Definition at line 105 of file PixelThresholdClusterizer.h.

Referenced by calibrate(), and copy_to_buffer().

◆ thePhase2DigiBaseline

const double PixelThresholdClusterizer::thePhase2DigiBaseline
private

Definition at line 111 of file PixelThresholdClusterizer.h.

Referenced by calibrate().

◆ thePhase2KinkADC

const int PixelThresholdClusterizer::thePhase2KinkADC
private

Definition at line 112 of file PixelThresholdClusterizer.h.

Referenced by calibrate().

◆ thePhase2ReadoutMode

const int PixelThresholdClusterizer::thePhase2ReadoutMode
private

Definition at line 110 of file PixelThresholdClusterizer.h.

Referenced by calibrate().

◆ thePixelThreshold

const int PixelThresholdClusterizer::thePixelThreshold
private

Definition at line 98 of file PixelThresholdClusterizer.h.

Referenced by copy_to_buffer(), and make_cluster().

◆ thePixelThresholdInNoiseUnits

float PixelThresholdClusterizer::thePixelThresholdInNoiseUnits
private

Clustering-related quantities:

Definition at line 94 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 99 of file PixelThresholdClusterizer.h.

Referenced by clusterizeDetUnitT(), and copy_to_buffer().

◆ theSeedThresholdInNoiseUnits

float PixelThresholdClusterizer::theSeedThresholdInNoiseUnits
private

Definition at line 95 of file PixelThresholdClusterizer.h.

PixelClusterizerBase::DigiIterator
edm::DetSet< PixelDigi >::const_iterator DigiIterator
Definition: PixelClusterizerBase.h:19
hgcalPlots.ncols
ncols
Definition: hgcalPlots.py:105
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:20
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:92
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:115
SiPixelGainCalibrationServiceBase::isDead
virtual bool isDead(const uint32_t &detID, const int &col, const int &row)=0
PixelThresholdClusterizer::theOffset
const int theOffset
Definition: PixelThresholdClusterizer.h:104
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:101
cuy.col
col
Definition: cuy.py:1010
gather_cfg.cout
cout
Definition: gather_cfg.py:144
PixelClusterizerBase::theSiPixelGainCalibrationService_
SiPixelGainCalibrationServiceBase * theSiPixelGainCalibrationService_
Definition: PixelClusterizerBase.h:73
PixelThresholdClusterizer::theClusterThreshold
const int theClusterThreshold
Definition: PixelThresholdClusterizer.h:100
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:116
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:390
PixelThresholdClusterizer::thePhase2KinkADC
const int thePhase2KinkADC
Definition: PixelThresholdClusterizer.h:112
GetRecoTauVFromDQM_MC_cff.cl2
cl2
Definition: GetRecoTauVFromDQM_MC_cff.py:44
SiPixelCluster
Pixel cluster – collection of neighboring pixels above threshold.
Definition: SiPixelCluster.h:27
SiPixelCluster::Pixel
Definition: SiPixelCluster.h:29
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:212
TrackerTopology::pxbLayer
unsigned int pxbLayer(const DetId &id) const
Definition: TrackerTopology.h:144
ecalLiteDTU::adc
constexpr int adc(sample_type sample)
get the ADC sample (12 bits)
Definition: EcalLiteDTUSample.h:12
DetId
Definition: DetId.h:17
SiPixelArrayBuffer::columns
int columns() const
Definition: SiPixelArrayBuffer.h:34
SiPixelCluster::minPixelRow
int minPixelRow() const
Definition: SiPixelCluster.h:138
mps_fire.end
end
Definition: mps_fire.py:242
metsig::electron
Definition: SignAlgoResolutions.h:48
PixelTopology::ncolumns
virtual int ncolumns() const =0
EMEnrichingFilter_cfi.clusterThreshold
clusterThreshold
Definition: EMEnrichingFilter_cfi.py:12
PixelThresholdClusterizer::thePhase2DigiBaseline
const double thePhase2DigiBaseline
Definition: PixelThresholdClusterizer.h:111
PixelTopology
Definition: PixelTopology.h:10
PixelThresholdClusterizer::thePhase2ReadoutMode
const int thePhase2ReadoutMode
Definition: PixelThresholdClusterizer.h:110
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:123
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:118
PixelThresholdClusterizer::thePixelThreshold
const int thePixelThreshold
Definition: PixelThresholdClusterizer.h:98
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:193
recoMuon::in
Definition: RecoMuonEnumerators.h:6
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:105
EcalCondDBWriter_cfi.pedestal
pedestal
Definition: EcalCondDBWriter_cfi.py:49
PixelThresholdClusterizer::theConversionFactor
const int theConversionFactor
Definition: PixelThresholdClusterizer.h:102
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
PixelThresholdClusterizer::theConversionFactor_L1
const int theConversionFactor_L1
Definition: PixelThresholdClusterizer.h:103
alignCSCRings.r
r
Definition: alignCSCRings.py:93
PixelThresholdClusterizer::doSplitClusters
const bool doSplitClusters
Definition: PixelThresholdClusterizer.h:120
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:56
SiPixelCluster::charge
int charge() const
Definition: SiPixelCluster.h:130
PixelThresholdClusterizer::doPhase2Calibration
const bool doPhase2Calibration
Definition: PixelThresholdClusterizer.h:109
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:147
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:119
PixelThresholdClusterizer::theSeedThreshold
const int theSeedThreshold
Definition: PixelThresholdClusterizer.h:99
SiPixelCluster::PixelPos
Definition: SiPixelCluster.h:52
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:309
PixelThresholdClusterizer::theElectronPerADCGain
const double theElectronPerADCGain
Definition: PixelThresholdClusterizer.h:107
SiPixelCluster::PixelPos::col
constexpr int col() const
Definition: SiPixelCluster.h:57
PixelThresholdClusterizer::theDetid
uint32_t theDetid
Definition: PixelThresholdClusterizer.h:117
SiPixelGainCalibrationServiceBase::isNoisy
virtual bool isNoisy(const uint32_t &detID, const int &col, const int &row)=0