CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | 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 std::vector< short > &badChannels, edmNew::DetSetVector< SiPixelCluster >::FastFiller &output)
 
void clusterizeDetUnit (const edmNew::DetSet< SiPixelCluster > &input, const PixelGeomDetUnit *pixDet, const std::vector< short > &badChannels, edmNew::DetSetVector< SiPixelCluster >::FastFiller &output)
 
 PixelThresholdClusterizer (edm::ParameterSet const &conf)
 
 ~PixelThresholdClusterizer ()
 
- Public Member Functions inherited from PixelClusterizerBase
void setSiPixelGainCalibrationService (SiPixelGainCalibrationServiceBase *in)
 
virtual ~PixelClusterizerBase ()
 

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

Private Attributes

bool bufferAlreadySet
 
bool dead_flag
 
uint32_t detid_
 
const bool doMissCalibrate
 
const bool doSplitClusters
 
SiPixelArrayBuffer theBuffer
 Data storage. More...
 
std::vector< SiPixelClustertheClusters
 
const float theClusterThreshold
 
float theClusterThresholdInNoiseUnits
 
const int theConversionFactor
 
const double theElectronPerADCGain_
 
const int theFirstStack_
 
int theNumOfCols
 
int theNumOfRows
 Geometry-related information. More...
 
const int theOffset
 
const int thePixelThreshold
 
float thePixelThresholdInNoiseUnits
 Clustering-related quantities: More...
 
std::vector
< SiPixelCluster::PixelPos
theSeeds
 
const int theSeedThreshold
 
float theSeedThresholdInNoiseUnits
 
const int theStackADC_
 

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

Constructor & Destructor Documentation

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

45  :
46  bufferAlreadySet(false),
47  // Get thresholds in electrons
48  thePixelThreshold( conf.getParameter<int>("ChannelThreshold") ),
49  theSeedThreshold( conf.getParameter<int>("SeedThreshold") ),
50  theClusterThreshold( conf.getParameter<double>("ClusterThreshold") ),
51  theConversionFactor( conf.getParameter<int>("VCaltoElectronGain") ),
52  theOffset( conf.getParameter<int>("VCaltoElectronOffset") ),
53  theStackADC_( conf.exists("AdcFullScaleStack") ? conf.getParameter<int>("AdcFullScaleStack") : 255 ),
54  theFirstStack_( conf.exists("FirstStackLayer") ? conf.getParameter<int>("FirstStackLayer") : 5 ),
55  theElectronPerADCGain_( conf.exists("ElectronPerADCGain") ? conf.getParameter<double>("ElectronPerADCGain") : 135. ),
56  theNumOfRows(0), theNumOfCols(0), detid_(0),
57  // Get the constants for the miss-calibration studies
58  doMissCalibrate( conf.getUntrackedParameter<bool>("MissCalibrate",true) ),
59  doSplitClusters( conf.getParameter<bool>("SplitClusters") )
60 {
62 }
SiPixelArrayBuffer theBuffer
Data storage.
int theNumOfRows
Geometry-related information.
void setSize(int rows, int cols)
PixelThresholdClusterizer::~PixelThresholdClusterizer ( )

Definition at line 64 of file PixelThresholdClusterizer.cc.

64 {}

Member Function Documentation

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

Definition at line 268 of file PixelThresholdClusterizer.cc.

References HI_PhotonSkim_cff::electrons, PXBDetId::layer(), and EcalCondDBWriter_cfi::pedestal.

269 {
270  int electrons = 0;
271  int layer= 0;
272  if (DetId(detid_).subdetId()==1){ layer = PXBDetId(detid_).layer();}
273 
274  if ( doMissCalibrate )
275  {
276  // do not perform calibration if pixel is dead!
277 
280  {
281 
282  // Linear approximation of the TANH response
283  // Pixel(0,0,0)
284  //const float gain = 2.95; // 1 ADC = 2.95 VCALs (1/0.339)
285  //const float pedestal = -83.; // -28/0.339
286  // Roc-0 average
287  //const float gain = 1./0.357; // 1 ADC = 2.80 VCALs
288  //const float pedestal = -28.2 * gain; // -79.
289 
290  float DBgain = theSiPixelGainCalibrationService_->getGain(detid_, col, row);
291  float DBpedestal = theSiPixelGainCalibrationService_->getPedestal(detid_, col, row) * DBgain;
292 
293 
294  // Roc-6 average
295  //const float gain = 1./0.313; // 1 ADC = 3.19 VCALs
296  //const float pedestal = -6.2 * gain; // -19.8
297  //
298  float vcal = adc * DBgain - DBpedestal;
299 
300  // atanh calibration
301  // Roc-6 average
302  //const float p0 = 0.00492;
303  //const float p1 = 1.998;
304  //const float p2 = 90.6;
305  //const float p3 = 134.1;
306  // Roc-6 average
307  //const float p0 = 0.00382;
308  //const float p1 = 0.886;
309  //const float p2 = 112.7;
310  //const float p3 = 113.0;
311  //float vcal = ( atanh( (adc-p3)/p2) + p1)/p0;
312 
313  electrons = int( vcal * theConversionFactor + theOffset);
314  }
315  }
316  else
317  { // No misscalibration in the digitizer
318  // Simple (default) linear gain
319  const float gain = theElectronPerADCGain_; // default: 1 ADC = 135 electrons
320  const float pedestal = 0.; //
321  electrons = int(adc * gain + pedestal);
322  if (layer>=theFirstStack_) {
323  if (theStackADC_==1&&adc==1)
324  {
325  electrons = int(255*135); // Arbitrarily use overflow value.
326  }
327  if (theStackADC_>1&&theStackADC_!=255&&adc>=1)
328  {
329  const float gain = theElectronPerADCGain_; // default: 1 ADC = 135 electrons
330  electrons = int((adc-1) * gain * 255/float(theStackADC_-1));
331  }
332  }
333  }
334 
335  return electrons;
336 }
int adc(sample_type sample)
get the ADC sample (12 bits)
virtual bool isDead(const uint32_t &detID, const int &col, const int &row)=0
unsigned int layer() const
layer id
Definition: PXBDetId.h:35
virtual float getPedestal(const uint32_t &detID, const int &col, const int &row)=0
Definition: DetId.h:18
SiPixelGainCalibrationServiceBase * theSiPixelGainCalibrationService_
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
int col
Definition: cuy.py:1008
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 165 of file PixelThresholdClusterizer.cc.

References end.

166 {
167  for(DigiIterator di = begin; di != end; ++di )
168  {
169  theBuffer.set_adc( di->row(), di->column(), 0 ); // reset pixel adc to 0
170  }
171 }
SiPixelArrayBuffer theBuffer
Data storage.
void set_adc(int row, int col, int adc)
edm::DetSet< PixelDigi >::const_iterator DigiIterator
#define end
Definition: vmac.h:37
#define begin
Definition: vmac.h:30
void PixelThresholdClusterizer::clear_buffer ( ClusterIterator  begin,
ClusterIterator  end 
)
private

Definition at line 173 of file PixelThresholdClusterizer.cc.

References end, i, SiPixelCluster::Pixel::x, and SiPixelCluster::Pixel::y.

174 {
175  for(ClusterIterator ci = begin; ci != end; ++ci )
176  {
177  for(int i = 0; i < ci->size(); ++i)
178  {
179  const SiPixelCluster::Pixel pixel = ci->pixel(i);
180 
181  theBuffer.set_adc( pixel.x, pixel.y, 0 ); // reset pixel adc to 0
182  }
183  }
184 }
int i
Definition: DBlmapReader.cc:9
SiPixelArrayBuffer theBuffer
Data storage.
void set_adc(int row, int col, int adc)
#define end
Definition: vmac.h:37
edmNew::DetSet< SiPixelCluster >::const_iterator ClusterIterator
#define begin
Definition: vmac.h:30
void PixelThresholdClusterizer::clusterizeDetUnit ( const edm::DetSet< PixelDigi > &  input,
const PixelGeomDetUnit pixDet,
const std::vector< short > &  badChannels,
edmNew::DetSetVector< SiPixelCluster >::FastFiller &  output 
)
inlinevirtual

Implements PixelClusterizerBase.

Definition at line 63 of file PixelThresholdClusterizer.h.

66  { clusterizeDetUnitT(input, pixDet, badChannels, output); }
void clusterizeDetUnitT(const T &input, const PixelGeomDetUnit *pixDet, 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...
void PixelThresholdClusterizer::clusterizeDetUnit ( const edmNew::DetSet< SiPixelCluster > &  input,
const PixelGeomDetUnit pixDet,
const std::vector< short > &  badChannels,
edmNew::DetSetVector< SiPixelCluster >::FastFiller &  output 
)
inlinevirtual

Implements PixelClusterizerBase.

Definition at line 67 of file PixelThresholdClusterizer.h.

70  { clusterizeDetUnitT(input, pixDet, badChannels, output); }
void clusterizeDetUnitT(const T &input, const PixelGeomDetUnit *pixDet, 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...
template<typename T >
void PixelThresholdClusterizer::clusterizeDetUnitT ( const T input,
const PixelGeomDetUnit pixDet,
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 105 of file PixelThresholdClusterizer.cc.

References begin, SiPixelCluster::charge(), end, i, eostools::move(), edmNew::DetSetVector< T >::FastFiller::push_back(), and GeneralSetup::setup().

108  {
109 
110  typename T::const_iterator begin = input.begin();
111  typename T::const_iterator end = input.end();
112 
113  // Do not bother for empty detectors
114  //if (begin == end) cout << " PixelThresholdClusterizer::clusterizeDetUnit - No digis to clusterize";
115 
116  // Set up the clusterization on this DetId.
117  if ( !setup(pixDet) )
118  return;
119 
120  detid_ = input.detId();
121 
122  // Copy PixelDigis to the buffer array; select the seed pixels
123  // on the way, and store them in theSeeds.
124  copy_to_buffer(begin, end);
125 
126  // Loop over all seeds. TO DO: wouldn't using iterators be faster?
127  // edm::LogError("PixelThresholdClusterizer") << "Starting clusterizing" << endl;
128  for (unsigned int i = 0; i < theSeeds.size(); i++)
129  {
130 
131  // Gavril : The charge of seeds that were already inlcuded in clusters is set to 1 electron
132  // so we don't want to call "make_cluster" for these cases
133  if ( theBuffer(theSeeds[i]) >= theSeedThreshold )
134  { // Is this seed still valid?
135  // Make a cluster around this seed
136  SiPixelCluster && cluster = make_cluster( theSeeds[i] , output);
137 
138  // Check if the cluster is above threshold
139  // (TO DO: one is signed, other unsigned, gcc warns...)
140  if ( cluster.charge() >= theClusterThreshold)
141  {
142  // std::cout << "putting in this cluster " << i << " " << cluster.charge() << " " << cluster.pixelADC().size() << endl;
143  output.push_back( std::move(cluster) );
144  }
145  }
146  }
147 
148  // Erase the seeds.
149  theSeeds.clear();
150 
151  // Need to clean unused pixels from the buffer array.
152  clear_buffer(begin, end);
153 
154 }
int i
Definition: DBlmapReader.cc:9
float charge() const
void push_back(data_type const &d)
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.
static std::string const input
Definition: EdmProvDump.cc:44
def move
Definition: eostools.py:510
#define end
Definition: vmac.h:37
void clear_buffer(DigiIterator begin, DigiIterator end)
Clear the internal buffer array.
Pixel cluster – collection of neighboring pixels above threshold.
#define begin
Definition: vmac.h:30
bool setup(const PixelGeomDetUnit *pixDet)
Private helper methods:
std::vector< SiPixelCluster::PixelPos > theSeeds
void copy_to_buffer(DigiIterator begin, DigiIterator end)
Copy adc counts from PixelDigis into the buffer, identify seeds.
void PixelThresholdClusterizer::copy_to_buffer ( DigiIterator  begin,
DigiIterator  end 
)
private

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

Definition at line 189 of file PixelThresholdClusterizer.cc.

References ecalMGPA::adc(), assert(), begin, cuy::col, gather_cfg::cout, metsig::electron, end, i, recoMuon::in, PXBDetId::layer(), EcalCondDBWriter_cfi::pedestal, and DetId::subdetId().

190 {
191 #ifdef PIXELREGRESSION
192  static std::atomic<int> s_ic=0;
193  in ic = ++s_ic;
194  if (ic==1) {
195  // std::cout << (doMissCalibrate ? "VI from db" : "VI linear") << std::endl;
196  }
197 #endif
198  int electron[end-begin];
199  memset(electron, 0, sizeof(electron));
200  if ( doMissCalibrate ) {
201  (*theSiPixelGainCalibrationService_).calibrate(detid_,begin,end,theConversionFactor, theOffset,electron);
202  } else {
203  int layer = (DetId(detid_).subdetId()==1) ? PXBDetId(detid_).layer() : 0;
204  int i=0;
205  for(DigiIterator di = begin; di != end; ++di) {
206  auto adc = di->adc();
207  const float gain = theElectronPerADCGain_; // default: 1 ADC = 135 electrons
208  const float pedestal = 0.; //
209  electron[i] = int(adc * gain + pedestal);
210  if (layer>=theFirstStack_) {
211  if (theStackADC_==1&&adc==1) {
212  electron[i] = int(255*135); // Arbitrarily use overflow value.
213  }
214  if (theStackADC_>1&&theStackADC_!=255&&adc>=1){
215  const float gain = theElectronPerADCGain_; // default: 1 ADC = 135 electrons
216  electron[i] = int((adc-1) * gain * 255/float(theStackADC_-1));
217  }
218  }
219  ++i;
220  }
221  assert(i==(end-begin));
222  }
223 
224  int i=0;
225 #ifdef PIXELREGRESSION
226  static std::atomic<int> eqD=0;
227 #endif
228  for(DigiIterator di = begin; di != end; ++di) {
229  int row = di->row();
230  int col = di->column();
231  int adc = electron[i++];
232 #ifdef PIXELREGRESSION
233  int adcOld = calibrate(di->adc(),col,row);
234  //assert(adc==adcOld);
235  if (adc!=adcOld) std::cout << "VI " << eqD <<' '<< ic <<' '<< end-begin <<' '<< i <<' '<< di->adc() <<' ' << adc <<' '<< adcOld << std::endl; else ++eqD;
236 #endif
237  if ( adc >= thePixelThreshold) {
238  theBuffer.set_adc( row, col, adc);
239  if ( adc >= theSeedThreshold) theSeeds.push_back( SiPixelCluster::PixelPos(row,col) );
240  }
241  }
242  assert(i==(end-begin));
243 
244 }
int adc(sample_type sample)
get the ADC sample (12 bits)
int i
Definition: DBlmapReader.cc:9
SiPixelArrayBuffer theBuffer
Data storage.
assert(m_qm.get())
unsigned int layer() const
layer id
Definition: PXBDetId.h:35
void set_adc(int row, int col, int adc)
edm::DetSet< PixelDigi >::const_iterator DigiIterator
#define end
Definition: vmac.h:37
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
Definition: DetId.h:18
#define begin
Definition: vmac.h:30
tuple cout
Definition: gather_cfg.py:145
int calibrate(int adc, int col, int row)
int col
Definition: cuy.py:1008
std::vector< SiPixelCluster::PixelPos > theSeeds
void PixelThresholdClusterizer::copy_to_buffer ( ClusterIterator  begin,
ClusterIterator  end 
)
private

Definition at line 246 of file PixelThresholdClusterizer.cc.

References ecalMGPA::adc(), SiPixelCluster::Pixel::adc, cuy::col, end, i, SiPixelCluster::Pixel::x, and SiPixelCluster::Pixel::y.

247 {
248  // loop over clusters
249  for(ClusterIterator ci = begin; ci != end; ++ci) {
250  // loop over pixels
251  for(int i = 0; i < ci->size(); ++i) {
252  const SiPixelCluster::Pixel pixel = ci->pixel(i);
253 
254  int row = pixel.x;
255  int col = pixel.y;
256  int adc = pixel.adc;
257  if ( adc >= thePixelThreshold) {
258  theBuffer.add_adc( row, col, adc);
259  if ( adc >= theSeedThreshold) theSeeds.push_back( SiPixelCluster::PixelPos(row,col) );
260  }
261  }
262  }
263 }
int adc(sample_type sample)
get the ADC sample (12 bits)
int i
Definition: DBlmapReader.cc:9
SiPixelArrayBuffer theBuffer
Data storage.
void add_adc(int row, int col, int adc)
#define end
Definition: vmac.h:37
edmNew::DetSet< SiPixelCluster >::const_iterator ClusterIterator
#define begin
Definition: vmac.h:30
int col
Definition: cuy.py:1008
std::vector< SiPixelCluster::PixelPos > theSeeds
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 342 of file PixelThresholdClusterizer.cc.

References PixelClusterizerBase::AccretionCluster::adc, PixelClusterizerBase::AccretionCluster::add(), SiPixelCluster::add(), EnergyCorrector::c, SiPixelCluster::charge(), SiPixelCluster::PixelPos::col(), PixelClusterizerBase::AccretionCluster::empty(), i, PixelClusterizerBase::AccretionCluster::isize, bookConverter::max, min(), SiPixelCluster::pixels(), PixelClusterizerBase::AccretionCluster::pop(), edmNew::DetSetVector< T >::FastFiller::push_back(), alignCSCRings::r, SiPixelCluster::PixelPos::row(), PixelClusterizerBase::AccretionCluster::top(), PixelClusterizerBase::AccretionCluster::x, PixelClusterizerBase::AccretionCluster::xmin, PixelClusterizerBase::AccretionCluster::y, and PixelClusterizerBase::AccretionCluster::ymin.

344 {
345 
346  //First we acquire the seeds for the clusters
347  int seed_adc;
348  stack<SiPixelCluster::PixelPos, vector<SiPixelCluster::PixelPos> > dead_pixel_stack;
349 
350  //The individual modules have been loaded into a buffer.
351  //After each pixel has been considered by the clusterizer, we set the adc count to 1
352  //to mark that we have already considered it.
353  //The only difference between dead/noisy pixels and standard ones is that for dead/noisy pixels,
354  //We consider the charge of the pixel to always be zero.
355 
356  /* this is not possible as dead and noisy pixel cannot make it into a seed...
357  if ( doMissCalibrate &&
358  (theSiPixelGainCalibrationService_->isDead(detid_,pix.col(),pix.row()) ||
359  theSiPixelGainCalibrationService_->isNoisy(detid_,pix.col(),pix.row())) )
360  {
361  std::cout << "IMPOSSIBLE" << std::endl;
362  seed_adc = 0;
363  theBuffer.set_adc(pix, 1);
364  }
365  else {
366  */
367  seed_adc = theBuffer(pix.row(), pix.col());
368  theBuffer.set_adc( pix, 1);
369  // }
370 
371  AccretionCluster acluster;
372  acluster.add(pix, seed_adc);
373 
374  //Here we search all pixels adjacent to all pixels in the cluster.
375  bool dead_flag = false;
376  while ( ! acluster.empty())
377  {
378  //This is the standard algorithm to find and add a pixel
379  auto curInd = acluster.top(); acluster.pop();
380  for ( auto c = std::max(0,int(acluster.y[curInd])-1); c < std::min(int(acluster.y[curInd])+2,theBuffer.columns()) ; ++c) {
381  for ( auto r = std::max(0,int(acluster.x[curInd])-1); r < std::min(int(acluster.x[curInd])+2,theBuffer.rows()); ++r) {
382  if ( theBuffer(r,c) >= thePixelThreshold) {
383  SiPixelCluster::PixelPos newpix(r,c);
384  if (!acluster.add( newpix, theBuffer(r,c))) goto endClus;
385  theBuffer.set_adc( newpix, 1);
386  }
387 
388 
389  /* //Commenting out the addition of dead pixels to the cluster until further testing -- dfehling 06/09
390  //Check on the bounds of the module; this is to keep the isDead and isNoisy modules from returning errors
391  else if(r>= 0 && c >= 0 && (r <= (theNumOfRows-1.)) && (c <= (theNumOfCols-1.))){
392  //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.
393  if((theSiPixelGainCalibrationService_->isDead(detid_,c,r) || theSiPixelGainCalibrationService_->isNoisy(detid_,c,r)) && theBuffer(r,c) != 1){
394 
395  //If a pixel is dead or noisy, check to see if we want to split the clusters or not.
396  //Push it into a dead pixel stack in case we want to split the clusters. Otherwise add it to the cluster.
397  //If we are splitting the clusters, we will iterate over the dead pixel stack later.
398 
399  SiPixelCluster::PixelPos newpix(r,c);
400  if(!doSplitClusters){
401 
402  cluster.add(newpix, theBuffer(r,c));}
403  else if(doSplitClusters){
404  dead_pixel_stack.push(newpix);
405  dead_flag = true;}
406 
407  theBuffer.set_adc(newpix, 1);
408  }
409 
410  }
411  */
412 
413 
414 
415  }
416  }
417 
418  } // while accretion
419  endClus:
420  SiPixelCluster cluster(acluster.isize,acluster.adc, acluster.x,acluster.y, acluster.xmin,acluster.ymin);
421  //Here we split the cluster, if the flag to do so is set and we have found a dead or noisy pixel.
422 
423  if (dead_flag && doSplitClusters)
424  {
425  //Set the first cluster equal to the existing cluster.
426  SiPixelCluster first_cluster = cluster;
427  bool have_second_cluster = false;
428  while ( !dead_pixel_stack.empty() )
429  {
430  //consider each found dead pixel
431  SiPixelCluster::PixelPos deadpix = dead_pixel_stack.top(); dead_pixel_stack.pop();
432  theBuffer.set_adc(deadpix, 1);
433 
434  //Clusterize the split cluster using the dead pixel as a seed
435  SiPixelCluster second_cluster = make_cluster(deadpix, output);
436 
437  //If both clusters would normally have been found by the clusterizer, put them into output
438  if ( second_cluster.charge() >= theClusterThreshold &&
439  first_cluster.charge() >= theClusterThreshold )
440  {
441  output.push_back( second_cluster );
442  have_second_cluster = true;
443  }
444 
445  //We also want to keep the merged cluster in data and let the RecHit algorithm decide which set to keep
446  //This loop adds the second cluster to the first.
447  const std::vector<SiPixelCluster::Pixel>& branch_pixels = second_cluster.pixels();
448  for ( unsigned int i = 0; i<branch_pixels.size(); i++)
449  {
450  int temp_x = branch_pixels[i].x;
451  int temp_y = branch_pixels[i].y;
452  int temp_adc = branch_pixels[i].adc;
453  SiPixelCluster::PixelPos newpix(temp_x, temp_y);
454  cluster.add(newpix, temp_adc);}
455  }
456 
457  //Remember to also add the first cluster if we added the second one.
458  if ( first_cluster.charge() >= theClusterThreshold && have_second_cluster)
459  {
460  output.push_back( first_cluster );
461  }
462  }
463 
464  return cluster;
465 }
int i
Definition: DBlmapReader.cc:9
float charge() const
void push_back(data_type const &d)
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)
T min(T a, T b)
Definition: MathUtil.h:58
constexpr int col() const
Pixel cluster – collection of neighboring pixels above threshold.
constexpr int row() const
const std::vector< Pixel > pixels() const
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 70 of file PixelThresholdClusterizer.cc.

References PixelTopology::ncolumns(), PixelTopology::nrows(), and PixelGeomDetUnit::specificTopology().

71 {
72  // Cache the topology.
73  const PixelTopology & topol = pixDet->specificTopology();
74 
75  // Get the new sizes.
76  int nrows = topol.nrows(); // rows in x
77  int ncols = topol.ncolumns(); // cols in y
78 
79  theNumOfRows = nrows; // Set new sizes
80  theNumOfCols = ncols;
81 
82  if ( nrows > theBuffer.rows() ||
83  ncols > theBuffer.columns() )
84  { // change only when a larger is needed
85  //if( nrows != theNumOfRows || ncols != theNumOfCols ) {
86  //cout << " PixelThresholdClusterizer: pixel buffer redefined to "
87  // << nrows << " * " << ncols << endl;
88  //theNumOfRows = nrows; // Set new sizes
89  //theNumOfCols = ncols;
90  // Resize the buffer
91  theBuffer.setSize(nrows,ncols); // Modify
92  bufferAlreadySet = true;
93  }
94 
95  return true;
96 }
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.

Member Data Documentation

bool PixelThresholdClusterizer::bufferAlreadySet
private

Definition at line 82 of file PixelThresholdClusterizer.h.

bool PixelThresholdClusterizer::dead_flag
private

Definition at line 105 of file PixelThresholdClusterizer.h.

uint32_t PixelThresholdClusterizer::detid_
private

Definition at line 104 of file PixelThresholdClusterizer.h.

const bool PixelThresholdClusterizer::doMissCalibrate
private

Definition at line 106 of file PixelThresholdClusterizer.h.

const bool PixelThresholdClusterizer::doSplitClusters
private

Definition at line 107 of file PixelThresholdClusterizer.h.

SiPixelArrayBuffer PixelThresholdClusterizer::theBuffer
private

Data storage.

Definition at line 81 of file PixelThresholdClusterizer.h.

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

Definition at line 84 of file PixelThresholdClusterizer.h.

const float PixelThresholdClusterizer::theClusterThreshold
private

Definition at line 93 of file PixelThresholdClusterizer.h.

float PixelThresholdClusterizer::theClusterThresholdInNoiseUnits
private

Definition at line 89 of file PixelThresholdClusterizer.h.

const int PixelThresholdClusterizer::theConversionFactor
private

Definition at line 94 of file PixelThresholdClusterizer.h.

const double PixelThresholdClusterizer::theElectronPerADCGain_
private

Definition at line 99 of file PixelThresholdClusterizer.h.

const int PixelThresholdClusterizer::theFirstStack_
private

Definition at line 98 of file PixelThresholdClusterizer.h.

int PixelThresholdClusterizer::theNumOfCols
private

Definition at line 103 of file PixelThresholdClusterizer.h.

int PixelThresholdClusterizer::theNumOfRows
private

Geometry-related information.

Definition at line 102 of file PixelThresholdClusterizer.h.

const int PixelThresholdClusterizer::theOffset
private

Definition at line 95 of file PixelThresholdClusterizer.h.

const int PixelThresholdClusterizer::thePixelThreshold
private

Definition at line 91 of file PixelThresholdClusterizer.h.

float PixelThresholdClusterizer::thePixelThresholdInNoiseUnits
private

Clustering-related quantities:

Definition at line 87 of file PixelThresholdClusterizer.h.

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

Definition at line 83 of file PixelThresholdClusterizer.h.

const int PixelThresholdClusterizer::theSeedThreshold
private

Definition at line 92 of file PixelThresholdClusterizer.h.

float PixelThresholdClusterizer::theSeedThresholdInNoiseUnits
private

Definition at line 88 of file PixelThresholdClusterizer.h.

const int PixelThresholdClusterizer::theStackADC_
private

Definition at line 97 of file PixelThresholdClusterizer.h.