45 bufferAlreadySet(
false),
47 thePixelThreshold( conf.
getParameter<
int>(
"ChannelThreshold") ),
48 theSeedThreshold( conf.
getParameter<
int>(
"SeedThreshold") ),
49 theClusterThreshold( conf.
getParameter<
int>(
"ClusterThreshold") ),
50 theClusterThreshold_L1( conf.
getParameter<
int>(
"ClusterThreshold_L1") ),
51 theConversionFactor( conf.
getParameter<
int>(
"VCaltoElectronGain") ),
52 theConversionFactor_L1( conf.
getParameter<
int>(
"VCaltoElectronGain_L1") ),
53 theOffset( conf.
getParameter<
int>(
"VCaltoElectronOffset") ),
54 theOffset_L1( conf.
getParameter<
int>(
"VCaltoElectronOffset_L1") ),
55 theStackADC_( conf.
exists(
"AdcFullScaleStack") ? conf.
getParameter<
int>(
"AdcFullScaleStack") : 255 ),
56 theFirstStack_( conf.
exists(
"FirstStackLayer") ? conf.
getParameter<
int>(
"FirstStackLayer") : 5 ),
57 theElectronPerADCGain_( conf.
exists(
"ElectronPerADCGain") ? conf.
getParameter<
double>(
"ElectronPerADCGain") : 135. ),
58 theNumOfRows(0), theNumOfCols(0), detid_(0),
61 doSplitClusters( conf.
getParameter<
bool>(
"SplitClusters") )
63 theBuffer.setSize( theNumOfRows, theNumOfCols );
75 desc.
add<
int>(
"ChannelThreshold", 1000);
77 desc.
add<
bool>(
"SplitClusters",
false);
78 desc.
add<
int>(
"VCaltoElectronGain", 65);
79 desc.
add<
int>(
"VCaltoElectronGain_L1", 65);
80 desc.
add<
int>(
"VCaltoElectronOffset", -414);
81 desc.
add<
int>(
"VCaltoElectronOffset_L1", -414);
83 desc.
add<
int>(
"SeedThreshold", 1000);
84 desc.
add<
int>(
"ClusterThreshold_L1", 4000);
85 desc.
add<
int>(
"ClusterThreshold", 4000);
86 desc.
add<
int>(
"maxNumberOfClusters", -1);
87 descriptions.
add(
"siPixelClusters", desc);
100 int nrows = topol.
nrows();
103 theNumOfRows = nrows;
104 theNumOfCols =
ncols;
106 if ( nrows > theBuffer.rows() ||
107 ncols > theBuffer.columns() )
115 theBuffer.setSize(nrows,ncols);
116 bufferAlreadySet =
true;
132 const std::vector<short>& badChannels,
135 typename T::const_iterator
begin = input.begin();
136 typename T::const_iterator
end = input.end();
142 if ( !
setup(pixDet) )
145 detid_ = input.detId();
148 auto clusterThreshold = theClusterThreshold;
150 if (
layer_==1) clusterThreshold = theClusterThreshold_L1;
154 copy_to_buffer(begin, end);
156 assert(output.
empty());
159 for (
unsigned int i = 0;
i < theSeeds.size();
i++)
164 if ( theBuffer(theSeeds[
i]) >= theSeedThreshold )
171 if ( cluster.
charge() >= clusterThreshold)
187 clear_buffer(begin, end);
204 theBuffer.set_adc( di->row(), di->column(), 0 );
212 for(
int i = 0;
i < ci->size(); ++
i)
216 theBuffer.set_adc( pixel.
x, pixel.
y, 0 );
226 #ifdef PIXELREGRESSION 227 static std::atomic<int> s_ic=0;
234 memset(electron, 0,
sizeof(electron));
235 if ( doMissCalibrate ) {
237 (*theSiPixelGainCalibrationService_).calibrate(detid_,begin,end,theConversionFactor_L1, theOffset_L1,electron);
239 (*theSiPixelGainCalibrationService_).calibrate(detid_,begin,end,theConversionFactor, theOffset, electron);
244 auto adc = di->adc();
245 const float gain = theElectronPerADCGain_;
247 electron[
i] =
int(
adc * gain + pedestal);
248 if (
layer_>=theFirstStack_) {
249 if (theStackADC_==1&&
adc==1) {
250 electron[
i] =
int(255*135);
252 if (theStackADC_>1&&theStackADC_!=255&&
adc>=1){
253 const float gain = theElectronPerADCGain_;
254 electron[
i] =
int((
adc-1) * gain * 255/
float(theStackADC_-1));
259 assert(i==(end-begin));
263 #ifdef PIXELREGRESSION 264 static std::atomic<int> eqD=0;
268 int col = di->column();
269 int adc = electron[i++];
270 #ifdef PIXELREGRESSION 271 int adcOld = calibrate(di->adc(),
col,row);
273 if (adc!=adcOld)
std::cout <<
"VI " << eqD <<
' '<< ic <<
' '<< end-begin <<
' '<< i <<
' '<< di->adc() <<
' ' << adc <<
' '<< adcOld << std::endl;
else ++eqD;
275 if ( adc >= thePixelThreshold) {
276 theBuffer.set_adc( row, col, adc);
280 assert(i==(end-begin));
289 for(
int i = 0;
i < ci->size(); ++
i) {
295 if ( adc >= thePixelThreshold) {
296 theBuffer.add_adc( row, col, adc);
310 if ( doMissCalibrate )
314 if ( !theSiPixelGainCalibrationService_->isDead(detid_,col,row) &&
315 !theSiPixelGainCalibrationService_->isNoisy(detid_,col,row) )
326 float DBgain = theSiPixelGainCalibrationService_->getGain(detid_, col, row);
327 float DBpedestal = theSiPixelGainCalibrationService_->getPedestal(detid_, col, row) * DBgain;
334 float vcal = adc * DBgain - DBpedestal;
350 electrons =
int( vcal * theConversionFactor_L1 + theOffset_L1);
352 electrons =
int( vcal * theConversionFactor + theOffset);
359 const float gain = theElectronPerADCGain_;
361 electrons =
int(adc * gain + pedestal);
362 if (
layer_>=theFirstStack_) {
363 if (theStackADC_==1&&adc==1)
365 electrons =
int(255*135);
367 if (theStackADC_>1&&theStackADC_!=255&&adc>=1)
369 const float gain = theElectronPerADCGain_;
370 electrons =
int((adc-1) * gain * 255/
float(theStackADC_-1));
388 stack<SiPixelCluster::PixelPos, vector<SiPixelCluster::PixelPos> > dead_pixel_stack;
407 seed_adc = theBuffer(pix.
row(), pix.
col());
408 theBuffer.set_adc( pix, 1);
412 acluster.
add(pix, seed_adc);
415 bool dead_flag =
false;
416 while ( ! acluster.
empty())
419 auto curInd = acluster.
top(); acluster.
pop();
420 for (
auto c =
std::max(0,
int(acluster.
y[curInd])-1);
c <
std::min(
int(acluster.
y[curInd])+2,theBuffer.columns()) ; ++
c) {
421 for (
auto r =
std::max(0,
int(acluster.
x[curInd])-1);
r <
std::min(
int(acluster.
x[curInd])+2,theBuffer.rows()); ++
r) {
422 if ( theBuffer(
r,
c) >= thePixelThreshold) {
424 if (!acluster.
add( newpix, theBuffer(
r,
c)))
goto endClus;
425 theBuffer.set_adc( newpix, 1);
463 if (dead_flag && doSplitClusters)
466 auto clusterThreshold = theClusterThreshold;
467 if (
layer_==1) clusterThreshold = theClusterThreshold_L1;
471 bool have_second_cluster =
false;
472 while ( !dead_pixel_stack.empty() )
476 theBuffer.set_adc(deadpix, 1);
482 if ( second_cluster.
charge() >= clusterThreshold &&
483 first_cluster.
charge() >= clusterThreshold )
486 have_second_cluster =
true;
491 const std::vector<SiPixelCluster::Pixel>& branch_pixels = second_cluster.
pixels();
492 for (
unsigned int i = 0;
i<branch_pixels.size();
i++)
494 int temp_x = branch_pixels[
i].x;
495 int temp_y = branch_pixels[
i].y;
496 int temp_adc = branch_pixels[
i].adc;
498 cluster.
add(newpix, temp_adc);}
502 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
static const char layer_[]
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.
bool exists(std::string const ¶meterName) const
checks if a parameter exists
def setup(process, global_tag, zero_tesla=False)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
static std::string const input
~PixelThresholdClusterizer()
edm::DetSet< PixelDigi >::const_iterator DigiIterator
void add(const PixelPos &pix, int adc)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
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:
int calibrate(int adc, int col, int row)
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.