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), theNumOfCols(0), theDetid(0),
62 doSplitClusters( conf.
getParameter<
bool>(
"SplitClusters") )
64 theBuffer.setSize( theNumOfRows, theNumOfCols );
76 desc.
add<
int>(
"ChannelThreshold", 1000);
78 desc.
add<
bool>(
"SplitClusters",
false);
79 desc.
add<
int>(
"VCaltoElectronGain", 65);
80 desc.
add<
int>(
"VCaltoElectronGain_L1", 65);
81 desc.
add<
int>(
"VCaltoElectronOffset", -414);
82 desc.
add<
int>(
"VCaltoElectronOffset_L1", -414);
84 desc.
add<
int>(
"SeedThreshold", 1000);
85 desc.
add<
int>(
"ClusterThreshold_L1", 4000);
86 desc.
add<
int>(
"ClusterThreshold", 4000);
87 desc.
add<
int>(
"maxNumberOfClusters", -1);
88 desc.
add<
double>(
"ElectronPerADCGain", 135.);
89 desc.
add<
bool>(
"Phase2Calibration",
false);
90 desc.
add<
int>(
"Phase2ReadoutMode", -1);
91 desc.
add<
double>(
"Phase2DigiBaseline", 1200.);
92 desc.
add<
int>(
"Phase2KinkADC", 8);
93 descriptions.
add(
"siClustersFromPixelThresholdClusterizer", desc);
106 int nrows = topol.
nrows();
109 theNumOfRows = nrows;
110 theNumOfCols =
ncols;
112 if ( nrows > theBuffer.rows() ||
113 ncols > theBuffer.columns() )
121 theBuffer.setSize(nrows,ncols);
137 const std::vector<short>& badChannels,
140 typename T::const_iterator
begin = input.begin();
141 typename T::const_iterator
end = input.end();
147 if ( !
setup(pixDet) )
150 theDetid = input.detId();
153 auto clusterThreshold = theClusterThreshold;
155 if (theLayer==1) clusterThreshold = theClusterThreshold_L1;
159 copy_to_buffer(begin, end);
161 assert(output.
empty());
164 for (
unsigned int i = 0;
i < theSeeds.size();
i++)
169 if ( theBuffer(theSeeds[
i]) >= theSeedThreshold )
176 if ( cluster.
charge() >= clusterThreshold)
192 clear_buffer(begin, end);
209 theBuffer.set_adc( di->row(), di->column(), 0 );
217 for(
int i = 0;
i < ci->size(); ++
i)
221 theBuffer.set_adc( pixel.
x, pixel.
y, 0 );
231 #ifdef PIXELREGRESSION 232 static std::atomic<int> s_ic=0;
239 memset(electron, 0,
sizeof(electron));
241 if (doPhase2Calibration) {
244 electron[
i] = calibrate(di->adc(), di->column(), di->row());
247 assert(i==(end-begin));
251 if ( doMissCalibrate ) {
253 (*theSiPixelGainCalibrationService_).calibrate(theDetid,begin,end,theConversionFactor_L1, theOffset_L1,electron);
255 (*theSiPixelGainCalibrationService_).calibrate(theDetid,begin,end,theConversionFactor, theOffset, electron);
259 const float gain = theElectronPerADCGain;
261 auto adc = di->adc();
263 electron[
i] =
int(
adc * gain + pedestal);
266 assert(i==(end-begin));
271 #ifdef PIXELREGRESSION 272 static std::atomic<int> eqD=0;
276 int col = di->column();
277 int adc = electron[i++];
279 #ifdef PIXELREGRESSION 280 int adcOld = calibrate(di->adc(),
col,row);
282 if (adc!=adcOld)
std::cout <<
"VI " << eqD <<
' '<< ic <<
' '<< end-begin <<
' '<< i <<
' '<< di->adc() <<
' ' << adc <<
' '<< adcOld << std::endl;
else ++eqD;
290 if ( adc >= thePixelThreshold) {
291 theBuffer.set_adc( row, col, adc);
295 assert(i==(end-begin));
304 for(
int i = 0;
i < ci->size(); ++
i) {
310 if ( adc >= thePixelThreshold) {
311 theBuffer.add_adc( row, col, adc);
325 if (doPhase2Calibration) {
327 const float gain = theElectronPerADCGain;
328 int p2rm = (thePhase2ReadoutMode < -1 ? -1 : thePhase2ReadoutMode);
331 electrons =
int(adc * gain);
334 if (adc < thePhase2KinkADC) {
335 electrons =
int((adc - 0.5) * gain);
338 const int dualslopeparam = (thePhase2ReadoutMode < 10 ? thePhase2ReadoutMode : 10);
339 const int dualslope =
int(dualslopeparam <= 1 ? 1. :
pow(2, dualslopeparam-1));
340 adc -= (thePhase2KinkADC-1);
342 adc += (thePhase2KinkADC-1);
343 electrons =
int((adc - 0.5 * dualslope) * gain);
345 electrons +=
int(thePhase2DigiBaseline);
352 if ( doMissCalibrate )
356 if ( !theSiPixelGainCalibrationService_->isDead(theDetid,col,row) &&
357 !theSiPixelGainCalibrationService_->isNoisy(theDetid,col,row) )
368 float DBgain = theSiPixelGainCalibrationService_->getGain(theDetid, col, row);
369 float pedestal = theSiPixelGainCalibrationService_->getPedestal(theDetid, col, row);
370 float DBpedestal = pedestal * DBgain;
376 float vcal = adc * DBgain - DBpedestal;
392 electrons =
int( vcal * theConversionFactor_L1 + theOffset_L1);
394 electrons =
int( vcal * theConversionFactor + theOffset);
402 const float gain = theElectronPerADCGain;
404 electrons =
int(adc * gain + pedestal);
420 stack<SiPixelCluster::PixelPos, vector<SiPixelCluster::PixelPos> > dead_pixel_stack;
439 seed_adc = theBuffer(pix.
row(), pix.
col());
440 theBuffer.set_adc( pix, 1);
444 acluster.
add(pix, seed_adc);
447 bool dead_flag =
false;
448 while ( ! acluster.
empty())
451 auto curInd = acluster.
top(); acluster.
pop();
452 for (
auto c =
std::max(0,
int(acluster.
y[curInd])-1);
c <
std::min(
int(acluster.
y[curInd])+2,theBuffer.columns()) ; ++
c) {
453 for (
auto r =
std::max(0,
int(acluster.
x[curInd])-1);
r <
std::min(
int(acluster.
x[curInd])+2,theBuffer.rows()); ++
r) {
454 if ( theBuffer(
r,
c) >= thePixelThreshold) {
456 if (!acluster.
add( newpix, theBuffer(
r,
c)))
goto endClus;
457 theBuffer.set_adc( newpix, 1);
495 if (dead_flag && doSplitClusters)
498 auto clusterThreshold = theClusterThreshold;
499 if (theLayer==1) clusterThreshold = theClusterThreshold_L1;
503 bool have_second_cluster =
false;
504 while ( !dead_pixel_stack.empty() )
508 theBuffer.set_adc(deadpix, 1);
514 if ( second_cluster.
charge() >= clusterThreshold &&
515 first_cluster.
charge() >= clusterThreshold )
518 have_second_cluster =
true;
523 const std::vector<SiPixelCluster::Pixel>& branch_pixels = second_cluster.
pixels();
524 for (
unsigned int i = 0;
i<branch_pixels.size();
i++)
526 int temp_x = branch_pixels[
i].x;
527 int temp_y = branch_pixels[
i].y;
528 int temp_adc = branch_pixels[
i].adc;
530 cluster.
add(newpix, temp_adc);}
534 if ( first_cluster.
charge() >= clusterThreshold && have_second_cluster)
int adc(sample_type sample)
get the ADC sample (12 bits)
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...
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
void push_back(data_type const &d)
virtual int nrows() const =0
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
PixelThresholdClusterizer(edm::ParameterSet const &conf)
SiPixelCluster make_cluster(const SiPixelCluster::PixelPos &pix, edmNew::DetSetVector< SiPixelCluster >::FastFiller &output)
The actual clustering algorithm: group the neighboring pixels around the seed.
def setup(process, global_tag, zero_tesla=False)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
static std::string const input
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
edm::DetSet< PixelDigi >::const_iterator DigiIterator
void add(const PixelPos &pix, int adc)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool add(SiPixelCluster::PixelPos const &p, UShort const iadc)
constexpr int col() const
unsigned int pxbLayer(const DetId &id) const
edmNew::DetSet< SiPixelCluster >::const_iterator ClusterIterator
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.
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Pixel cluster – collection of neighboring pixels above threshold.
virtual int ncolumns() const =0
bool setup(const PixelGeomDetUnit *pixDet)
Private helper methods:
~PixelThresholdClusterizer() override
int calibrate(int adc, int col, int row)
Power< A, B >::type pow(const A &a, const B &b)
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.