45 conf_(conf), bufferAlreadySet(
false), theNumOfRows(0), theNumOfCols(0), detid_(0)
49 conf_.getParameter<
int>(
"ChannelThreshold");
51 conf_.getParameter<
int>(
"SeedThreshold");
53 conf_.getParameter<
double>(
"ClusterThreshold");
55 conf_.getParameter<
int>(
"VCaltoElectronGain");
57 conf_.getParameter<
int>(
"VCaltoElectronOffset");
58 if ( conf_.exists(
"AdcFullScaleStack") ) theStackADC_=conf_.getParameter<
int>(
"AdcFullScaleStack");
61 if ( conf_.exists(
"FirstStackLayer") ) theFirstStack_=conf_.getParameter<
int>(
"FirstStackLayer");
66 doMissCalibrate=conf_.getUntrackedParameter<
bool>(
"MissCalibrate",
true);
67 doSplitClusters = conf.
getParameter<
bool>(
"SplitClusters");
68 theBuffer.setSize( theNumOfRows, theNumOfCols );
83 int nrows = topol.
nrows();
89 if ( nrows > theBuffer.rows() ||
90 ncols > theBuffer.columns() )
98 theBuffer.setSize(nrows,ncols);
99 bufferAlreadySet =
true;
113 const std::vector<short>& badChannels,
123 if ( !
setup(pixDet) )
126 detid_ = input.
detId();
130 copy_to_buffer(begin, end);
140 for (
unsigned int i = 0;
i < theSeeds.size();
i++)
145 if ( theBuffer(theSeeds[
i]) >= theSeedThreshold )
152 if ( cluster.
charge() >= theClusterThreshold)
164 clear_buffer(begin, end);
181 theBuffer.set_adc( di->row(), di->column(), 0 );
193 int col = di->column();
194 int adc = calibrate(di->adc(),
col,row);
195 if ( adc >= thePixelThreshold)
197 theBuffer.set_adc( row, col, adc);
198 if ( adc >= theSeedThreshold)
215 if ( doMissCalibrate )
219 if ( !theSiPixelGainCalibrationService_->isDead(detid_,col,row) &&
220 !theSiPixelGainCalibrationService_->isNoisy(detid_,col,row) )
231 float DBgain = theSiPixelGainCalibrationService_->getGain(detid_, col, row);
232 float DBpedestal = theSiPixelGainCalibrationService_->getPedestal(detid_, col, row) * DBgain;
239 float vcal = adc * DBgain - DBpedestal;
254 electrons = int( vcal * theConversionFactor + theOffset);
260 const float gain = 135.;
261 const float pedestal = 0.;
262 electrons = int(adc * gain + pedestal);
263 if (layer>=theFirstStack_) {
264 if (theStackADC_==1&&adc==1)
266 electrons = int(255*135);
268 if (theStackADC_>1&&theStackADC_!=255&&adc>=1)
270 const float gain = 135.;
271 electrons = int((adc-1) * gain * 255/
float(theStackADC_-1));
282 struct AccretionCluster {
283 typedef unsigned short UShort;
290 unsigned int isize=0;
294 UShort top()
const {
return curr;}
295 void pop() { ++curr;}
296 bool empty() {
return curr==isize;}
299 if (isize==MAXSIZE)
return false;
321 stack<SiPixelCluster::PixelPos, vector<SiPixelCluster::PixelPos> > dead_pixel_stack;
329 if ( doMissCalibrate &&
330 (theSiPixelGainCalibrationService_->isDead(detid_,pix.
col(),pix.
row()) ||
331 theSiPixelGainCalibrationService_->isNoisy(detid_,pix.
col(),pix.
row())) )
334 theBuffer.set_adc(pix, 1);
338 seed_adc = theBuffer(pix.
row(), pix.
col());
339 theBuffer.set_adc( pix, 1);
342 AccretionCluster acluster;
343 acluster.add(pix, seed_adc);
346 bool dead_flag =
false;
347 while ( ! acluster.empty())
350 auto curInd = acluster.top(); acluster.pop();
351 for (
auto r = acluster.x[curInd]-1;
r <= acluster.x[curInd]+1; ++
r)
353 for (
auto c = acluster.y[curInd]-1;
c <= acluster.y[curInd]+1; ++
c)
355 if ( theBuffer(
r,
c) >= thePixelThreshold)
359 if (!acluster.add( newpix, theBuffer(
r,
c)))
goto endClus;
360 theBuffer.set_adc( newpix, 1);
395 SiPixelCluster cluster(acluster.isize,acluster.adc, acluster.x,acluster.y, acluster.xmin,acluster.ymin);
398 if (dead_flag && doSplitClusters)
402 bool have_second_cluster =
false;
403 while ( !dead_pixel_stack.empty() )
407 theBuffer.set_adc(deadpix, 1);
413 if ( second_cluster.
charge() >= theClusterThreshold &&
414 first_cluster.
charge() >= theClusterThreshold )
417 have_second_cluster =
true;
422 const std::vector<SiPixelCluster::Pixel>& branch_pixels = second_cluster.
pixels();
423 for (
unsigned int i = 0;
i<branch_pixels.size();
i++)
425 int temp_x = branch_pixels[
i].x;
426 int temp_y = branch_pixels[
i].y;
427 int temp_adc = branch_pixels[
i].adc;
429 cluster.
add(newpix, temp_adc);}
433 if ( first_cluster.
charge() >= theClusterThreshold && have_second_cluster)
int adc(sample_type sample)
get the ADC sample (12 bits)
T getParameter(std::string const &) const
void push_back(data_type const &d)
void clusterizeDetUnit(const edm::DetSet< PixelDigi > &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...
PixelThresholdClusterizer(edm::ParameterSet const &conf)
det_id_type detId() const
SiPixelCluster make_cluster(const SiPixelCluster::PixelPos &pix, edmNew::DetSetVector< SiPixelCluster >::FastFiller &output)
The actual clustering algorithm: group the neighboring pixels around the seed.
virtual int ncolumns() const =0
virtual int nrows() const =0
void add(const std::vector< const T * > &source, std::vector< const T * > &dest)
unsigned int layer() const
layer id
~PixelThresholdClusterizer()
edm::DetSet< PixelDigi >::const_iterator DigiIterator
void add(const PixelPos &pix, int adc)
constexpr int col() const
void clear_buffer(DigiIterator begin, DigiIterator end)
Clear the internal buffer array.
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
Pixel cluster – collection of neighboring pixels above threshold.
bool setup(const PixelGeomDetUnit *pixDet)
Private helper methods:
int calibrate(int adc, int col, int row)
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
constexpr int row() const
const std::vector< Pixel > pixels() const
void copy_to_buffer(DigiIterator begin, DigiIterator end)
Copy adc counts from PixelDigis into the buffer, identify seeds.