CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
PixelThresholdClusterizer Class Reference

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

#include <PixelThresholdClusterizer.h>

Inheritance diagram for PixelThresholdClusterizer:
PixelClusterizerBase PixelThresholdClusterizerForBricked

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)
 

Protected Member Functions

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

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
 
- Protected Attributes inherited from PixelClusterizerBase
SiPixelGainCalibrationServiceBasetheSiPixelGainCalibrationService_
 

Additional Inherited Members

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

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

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

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

◆ ~PixelThresholdClusterizer()

PixelThresholdClusterizer::~PixelThresholdClusterizer ( )
override

Definition at line 69 of file PixelThresholdClusterizer.cc.

69 {}

Member Function Documentation

◆ calibrate()

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

Definition at line 328 of file PixelThresholdClusterizer.cc.

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().

328  {
329  int electrons = 0;
330 
331  if (doPhase2Calibration) {
332  const float gain = theElectronPerADCGain;
333  int p2rm = (thePhase2ReadoutMode < -1 ? -1 : thePhase2ReadoutMode);
334 
335  if (p2rm == -1) {
336  electrons = int(adc * gain);
337  } else {
338  if (adc < thePhase2KinkADC) {
339  electrons = int((adc + 0.5) * gain);
340  } else {
341  const int dualslopeparam = (thePhase2ReadoutMode < 10 ? thePhase2ReadoutMode : 10);
342  const int dualslope = int(dualslopeparam <= 1 ? 1. : pow(2, dualslopeparam - 1));
344  adc *= dualslope;
346  electrons = int((adc + 0.5 * dualslope) * gain);
347  }
349  }
350 
351  return electrons;
352  }
353 
354  if (doMissCalibrate) {
355  // do not perform calibration if pixel is dead!
356 
359  // Linear approximation of the TANH response
360  // Pixel(0,0,0)
361  //const float gain = 2.95; // 1 ADC = 2.95 VCALs (1/0.339)
362  //const float pedestal = -83.; // -28/0.339
363  // Roc-0 average
364  //const float gain = 1./0.357; // 1 ADC = 2.80 VCALs
365  //const float pedestal = -28.2 * gain; // -79.
366 
367  float DBgain = theSiPixelGainCalibrationService_->getGain(theDetid, col, row);
369  float DBpedestal = pedestal * DBgain;
370 
371  // Roc-6 average
372  //const float gain = 1./0.313; // 1 ADC = 3.19 VCALs
373  //const float pedestal = -6.2 * gain; // -19.8
374  //
375  float vcal = adc * DBgain - DBpedestal;
376 
377  // atanh calibration
378  // Roc-6 average
379  //const float p0 = 0.00492;
380  //const float p1 = 1.998;
381  //const float p2 = 90.6;
382  //const float p3 = 134.1;
383  // Roc-6 average
384  //const float p0 = 0.00382;
385  //const float p1 = 0.886;
386  //const float p2 = 112.7;
387  //const float p3 = 113.0;
388  //float vcal = ( atanh( (adc-p3)/p2) + p1)/p0;
389 
390  if (theLayer == 1) {
392  } else {
394  }
395  }
396  } else { // No misscalibration in the digitizer
397  // Simple (default) linear gain
398  const float gain = theElectronPerADCGain; // default: 1 ADC = 135 electrons
399  const float pedestal = 0.; //
400  electrons = int(adc * gain + pedestal);
401  }
402 
403  return electrons;
404 }
virtual bool isDead(const uint32_t &detID, const int &col, const int &row)=0
virtual float getPedestal(const uint32_t &detID, const int &col, const int &row)=0
SiPixelGainCalibrationServiceBase * theSiPixelGainCalibrationService_
col
Definition: cuy.py:1009
virtual float getGain(const uint32_t &detID, const int &col, const int &row)=0
virtual bool isNoisy(const uint32_t &detID, const int &col, const int &row)=0
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
uint16_t *__restrict__ uint16_t const *__restrict__ adc

◆ clear_buffer() [1/2]

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

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

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

Referenced by PixelThresholdClusterizerForBricked::clusterizeDetUnitT(), and clusterizeDetUnitT().

200  {
201  for (DigiIterator di = begin; di != end; ++di) {
202  theBuffer.set_adc(di->row(), di->column(), 0); // reset pixel adc to 0
203  }
204 }
SiPixelArrayBuffer theBuffer
Data storage.
void set_adc(int row, int col, int adc)
edm::DetSet< PixelDigi >::const_iterator DigiIterator

◆ clear_buffer() [2/2]

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

Definition at line 206 of file PixelThresholdClusterizer.cc.

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

206  {
207  for (ClusterIterator ci = begin; ci != end; ++ci) {
208  for (int i = 0; i < ci->size(); ++i) {
209  const SiPixelCluster::Pixel pixel = ci->pixel(i);
210 
211  theBuffer.set_adc(pixel.x, pixel.y, 0); // reset pixel adc to 0
212  }
213  }
214 }
SiPixelArrayBuffer theBuffer
Data storage.
void set_adc(int row, int col, int adc)
edmNew::DetSet< SiPixelCluster >::const_iterator ClusterIterator

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

Reimplemented in PixelThresholdClusterizerForBricked.

Definition at line 63 of file PixelThresholdClusterizer.h.

References input, and convertSQLitetoXML_cfg::output.

67  {
68  clusterizeDetUnitT(input, pixDet, tTopo, badChannels, output);
69  }
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...
static std::string const input
Definition: EdmProvDump.cc:47

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

Reimplemented in PixelThresholdClusterizerForBricked.

Definition at line 70 of file PixelThresholdClusterizer.h.

References input, and convertSQLitetoXML_cfg::output.

74  {
75  clusterizeDetUnitT(input, pixDet, tTopo, badChannels, output);
76  }
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...
static std::string const input
Definition: EdmProvDump.cc:47

◆ 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 
)
protected

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.

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.

Referenced by PixelThresholdClusterizerForBricked::clusterizeDetUnit().

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

◆ copy_to_buffer() [1/2]

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

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

Definition at line 219 of file PixelThresholdClusterizer.cc.

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 PixelThresholdClusterizerForBricked::clusterizeDetUnitT(), and clusterizeDetUnitT().

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

◆ copy_to_buffer() [2/2]

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

Definition at line 306 of file PixelThresholdClusterizer.cc.

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

306  {
307  // loop over clusters
308  for (ClusterIterator ci = begin; ci != end; ++ci) {
309  // loop over pixels
310  for (int i = 0; i < ci->size(); ++i) {
311  const SiPixelCluster::Pixel pixel = ci->pixel(i);
312 
313  int row = pixel.x;
314  int col = pixel.y;
315  int adc = pixel.adc;
316  if (adc >= thePixelThreshold) {
317  theBuffer.add_adc(row, col, adc);
318  if (adc >= theSeedThreshold)
319  theSeeds.push_back(SiPixelCluster::PixelPos(row, col));
320  }
321  }
322  }
323 }
SiPixelArrayBuffer theBuffer
Data storage.
void add_adc(int row, int col, int adc)
edmNew::DetSet< SiPixelCluster >::const_iterator ClusterIterator
col
Definition: cuy.py:1009
std::vector< SiPixelCluster::PixelPos > theSeeds
uint16_t *__restrict__ uint16_t const *__restrict__ adc

◆ fillPSetDescription()

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

Definition at line 72 of file PixelThresholdClusterizer.cc.

References submitPVResolutionJobs::desc.

Referenced by SiPixelClusterProducer::fillDescriptions().

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

◆ make_cluster()

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

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

Definition at line 409 of file PixelThresholdClusterizer.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(), doSplitClusters, PixelClusterizerBase::AccretionCluster::empty(), mps_fire::i, 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(), 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 PixelThresholdClusterizerForBricked::clusterizeDetUnitT(), and clusterizeDetUnitT().

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

◆ setup()

bool PixelThresholdClusterizer::setup ( const PixelGeomDetUnit pixDet)
protected

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

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

Referenced by PixelThresholdClusterizerForBricked::clusterizeDetUnitT(), and clusterizeDetUnitT().

94  {
95  // Cache the topology.
96  const PixelTopology& topol = pixDet->specificTopology();
97 
98  // Get the new sizes.
99  int nrows = topol.nrows(); // rows in x
100  int ncols = topol.ncolumns(); // cols in y
101 
102  theNumOfRows = nrows; // Set new sizes
104 
105  if (nrows > theBuffer.rows() || ncols > theBuffer.columns()) { // change only when a larger is needed
106  if (nrows != theNumOfRows || ncols != theNumOfCols)
107  edm::LogWarning("setup()") << "pixel buffer redefined to" << nrows << " * " << ncols;
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 }
SiPixelArrayBuffer theBuffer
Data storage.
virtual int ncolumns() const =0
virtual int nrows() const =0
int theNumOfRows
Geometry-related information.
void setSize(int rows, int cols)
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
Log< level::Warning, false > LogWarning

Member Data Documentation

◆ doMissCalibrate

const bool PixelThresholdClusterizer::doMissCalibrate
protected

Definition at line 121 of file PixelThresholdClusterizer.h.

Referenced by calibrate(), and copy_to_buffer().

◆ doPhase2Calibration

const bool PixelThresholdClusterizer::doPhase2Calibration
protected

Definition at line 111 of file PixelThresholdClusterizer.h.

Referenced by calibrate(), and copy_to_buffer().

◆ doSplitClusters

const bool PixelThresholdClusterizer::doSplitClusters
protected

◆ theBuffer

SiPixelArrayBuffer PixelThresholdClusterizer::theBuffer
protected

◆ theClusters

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

Definition at line 91 of file PixelThresholdClusterizer.h.

◆ theClusterThreshold

const int PixelThresholdClusterizer::theClusterThreshold
protected

◆ theClusterThreshold_L1

const int PixelThresholdClusterizer::theClusterThreshold_L1
protected

◆ theClusterThresholdInNoiseUnits

float PixelThresholdClusterizer::theClusterThresholdInNoiseUnits
protected

Definition at line 98 of file PixelThresholdClusterizer.h.

◆ theConversionFactor

const int PixelThresholdClusterizer::theConversionFactor
protected

Definition at line 104 of file PixelThresholdClusterizer.h.

Referenced by calibrate(), and copy_to_buffer().

◆ theConversionFactor_L1

const int PixelThresholdClusterizer::theConversionFactor_L1
protected

Definition at line 105 of file PixelThresholdClusterizer.h.

Referenced by calibrate(), and copy_to_buffer().

◆ theDetid

uint32_t PixelThresholdClusterizer::theDetid
protected

◆ theElectronPerADCGain

const double PixelThresholdClusterizer::theElectronPerADCGain
protected

Definition at line 109 of file PixelThresholdClusterizer.h.

Referenced by calibrate(), and copy_to_buffer().

◆ theFakePixels

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

◆ theLayer

int PixelThresholdClusterizer::theLayer
protected

◆ theNumOfCols

int PixelThresholdClusterizer::theNumOfCols
protected

◆ theNumOfRows

int PixelThresholdClusterizer::theNumOfRows
protected

Geometry-related information.

Definition at line 117 of file PixelThresholdClusterizer.h.

Referenced by PixelThresholdClusterizer(), and setup().

◆ theOffset

const int PixelThresholdClusterizer::theOffset
protected

Definition at line 106 of file PixelThresholdClusterizer.h.

Referenced by calibrate(), and copy_to_buffer().

◆ theOffset_L1

const int PixelThresholdClusterizer::theOffset_L1
protected

Definition at line 107 of file PixelThresholdClusterizer.h.

Referenced by calibrate(), and copy_to_buffer().

◆ thePhase2DigiBaseline

const double PixelThresholdClusterizer::thePhase2DigiBaseline
protected

Definition at line 113 of file PixelThresholdClusterizer.h.

Referenced by calibrate().

◆ thePhase2KinkADC

const int PixelThresholdClusterizer::thePhase2KinkADC
protected

Definition at line 114 of file PixelThresholdClusterizer.h.

Referenced by calibrate().

◆ thePhase2ReadoutMode

const int PixelThresholdClusterizer::thePhase2ReadoutMode
protected

Definition at line 112 of file PixelThresholdClusterizer.h.

Referenced by calibrate().

◆ thePixelThreshold

const int PixelThresholdClusterizer::thePixelThreshold
protected

◆ thePixelThresholdInNoiseUnits

float PixelThresholdClusterizer::thePixelThresholdInNoiseUnits
protected

Clustering-related quantities:

Definition at line 96 of file PixelThresholdClusterizer.h.

◆ theSeeds

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

◆ theSeedThreshold

const int PixelThresholdClusterizer::theSeedThreshold
protected

◆ theSeedThresholdInNoiseUnits

float PixelThresholdClusterizer::theSeedThresholdInNoiseUnits
protected

Definition at line 97 of file PixelThresholdClusterizer.h.