CMS 3D CMS Logo

List of all members | Public Member Functions | Static 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 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 fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

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

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

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

44  :
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") ),
60  // Get the constants for the miss-calibration studies
61  doMissCalibrate( conf.getUntrackedParameter<bool>("MissCalibrate",true) ),
62  doSplitClusters( conf.getParameter<bool>("SplitClusters") )
63 {
65 }
SiPixelArrayBuffer theBuffer
Data storage.
int theNumOfRows
Geometry-related information.
void setSize(int rows, int cols)
PixelThresholdClusterizer::~PixelThresholdClusterizer ( )
override

Definition at line 67 of file PixelThresholdClusterizer.cc.

67 {}

Member Function Documentation

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

Definition at line 321 of file PixelThresholdClusterizer.cc.

References electrons_cff::electrons, muonCSCDigis_cfi::gain, createfilelist::int, muonCSCDigis_cfi::pedestal, and funct::pow().

322 {
323  int electrons = 0;
324 
325  if (doPhase2Calibration) {
326 
327  const float gain = theElectronPerADCGain;
328  int p2rm = (thePhase2ReadoutMode < -1 ? -1 : thePhase2ReadoutMode);
329 
330  if (p2rm == -1) {
331  electrons = int(adc * gain);
332  }
333  else {
334  if (adc < thePhase2KinkADC) {
335  electrons = int((adc - 0.5) * gain);
336  }
337  else {
338  const int dualslopeparam = (thePhase2ReadoutMode < 10 ? thePhase2ReadoutMode : 10);
339  const int dualslope = int(dualslopeparam <= 1 ? 1. : pow(2, dualslopeparam-1));
340  adc -= (thePhase2KinkADC-1);
341  adc *= dualslope;
342  adc += (thePhase2KinkADC-1);
343  electrons = int((adc - 0.5 * dualslope) * gain);
344  }
345  electrons += int(thePhase2DigiBaseline);
346  }
347 
348  return electrons;
349 
350  }
351 
352  if ( doMissCalibrate )
353  {
354  // do not perform calibration if pixel is dead!
355 
358  {
359 
360  // Linear approximation of the TANH response
361  // Pixel(0,0,0)
362  //const float gain = 2.95; // 1 ADC = 2.95 VCALs (1/0.339)
363  //const float pedestal = -83.; // -28/0.339
364  // Roc-0 average
365  //const float gain = 1./0.357; // 1 ADC = 2.80 VCALs
366  //const float pedestal = -28.2 * gain; // -79.
367 
368  float DBgain = theSiPixelGainCalibrationService_->getGain(theDetid, col, row);
370  float DBpedestal = pedestal * DBgain;
371 
372  // Roc-6 average
373  //const float gain = 1./0.313; // 1 ADC = 3.19 VCALs
374  //const float pedestal = -6.2 * gain; // -19.8
375  //
376  float vcal = adc * DBgain - DBpedestal;
377 
378  // atanh calibration
379  // Roc-6 average
380  //const float p0 = 0.00492;
381  //const float p1 = 1.998;
382  //const float p2 = 90.6;
383  //const float p3 = 134.1;
384  // Roc-6 average
385  //const float p0 = 0.00382;
386  //const float p1 = 0.886;
387  //const float p2 = 112.7;
388  //const float p3 = 113.0;
389  //float vcal = ( atanh( (adc-p3)/p2) + p1)/p0;
390 
391  if (theLayer==1) {
392  electrons = int( vcal * theConversionFactor_L1 + theOffset_L1);
393  } else {
394  electrons = int( vcal * theConversionFactor + theOffset);
395  }
396 
397  }
398  }
399  else
400  { // No misscalibration in the digitizer
401  // Simple (default) linear gain
402  const float gain = theElectronPerADCGain; // default: 1 ADC = 135 electrons
403  const float pedestal = 0.; //
404  electrons = int(adc * gain + pedestal);
405  }
406 
407  return electrons;
408 }
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
virtual float getPedestal(const uint32_t &detID, const int &col, const int &row)=0
SiPixelGainCalibrationServiceBase * theSiPixelGainCalibrationService_
col
Definition: cuy.py:1010
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:40
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 205 of file PixelThresholdClusterizer.cc.

References end.

206 {
207  for(DigiIterator di = begin; di != end; ++di )
208  {
209  theBuffer.set_adc( di->row(), di->column(), 0 ); // reset pixel adc to 0
210  }
211 }
SiPixelArrayBuffer theBuffer
Data storage.
void set_adc(int row, int col, int adc)
edm::DetSet< PixelDigi >::const_iterator DigiIterator
#define end
Definition: vmac.h:39
#define begin
Definition: vmac.h:32
void PixelThresholdClusterizer::clear_buffer ( ClusterIterator  begin,
ClusterIterator  end 
)
private

Definition at line 213 of file PixelThresholdClusterizer.cc.

References end, mps_fire::i, digitizers_cfi::pixel, SiPixelCluster::Pixel::x, and SiPixelCluster::Pixel::y.

214 {
215  for(ClusterIterator ci = begin; ci != end; ++ci )
216  {
217  for(int i = 0; i < ci->size(); ++i)
218  {
219  const SiPixelCluster::Pixel pixel = ci->pixel(i);
220 
221  theBuffer.set_adc( pixel.x, pixel.y, 0 ); // reset pixel adc to 0
222  }
223  }
224 }
SiPixelArrayBuffer theBuffer
Data storage.
void set_adc(int row, int col, int adc)
#define end
Definition: vmac.h:39
edmNew::DetSet< SiPixelCluster >::const_iterator ClusterIterator
#define begin
Definition: vmac.h:32
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.

Definition at line 66 of file PixelThresholdClusterizer.h.

70  { clusterizeDetUnitT(input, pixDet, tTopo, badChannels, output); }
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...
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.

Definition at line 71 of file PixelThresholdClusterizer.h.

References fillDescriptions(), input, and convertSQLitetoXML_cfg::output.

75  { clusterizeDetUnitT(input, pixDet, tTopo, badChannels, output); }
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...
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 
)
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 134 of file PixelThresholdClusterizer.cc.

References begin, edmNew::DetSetVector< T >::FastFiller::begin(), SiPixelCluster::charge(), GetRecoTauVFromDQM_MC_cff::cl2, edmNew::DetSetVector< T >::FastFiller::empty(), end, edmNew::DetSetVector< T >::FastFiller::end(), mps_fire::i, SiPixelCluster::minPixelRow(), eostools::move(), edmNew::DetSetVector< T >::FastFiller::push_back(), TrackerTopology::pxbLayer(), GeneralSetup::setup(), and DetId::subdetId().

138  {
139 
140  typename T::const_iterator begin = input.begin();
141  typename T::const_iterator end = input.end();
142 
143  // Do not bother for empty detectors
144  //if (begin == end) cout << " PixelThresholdClusterizer::clusterizeDetUnit - No digis to clusterize";
145 
146  // Set up the clusterization on this DetId.
147  if ( !setup(pixDet) )
148  return;
149 
150  theDetid = input.detId();
151 
152  // Set separate cluster threshold for L1 (needed for phase1)
153  auto clusterThreshold = theClusterThreshold;
154  theLayer = (DetId(theDetid).subdetId()==1) ? tTopo->pxbLayer(theDetid) : 0;
155  if (theLayer==1) clusterThreshold = theClusterThreshold_L1;
156 
157  // Copy PixelDigis to the buffer array; select the seed pixels
158  // on the way, and store them in theSeeds.
159  copy_to_buffer(begin, end);
160 
161  assert(output.empty());
162  // Loop over all seeds. TO DO: wouldn't using iterators be faster?
163  // edm::LogError("PixelThresholdClusterizer") << "Starting clusterizing" << endl;
164  for (unsigned int i = 0; i < theSeeds.size(); i++)
165  {
166 
167  // Gavril : The charge of seeds that were already inlcuded in clusters is set to 1 electron
168  // so we don't want to call "make_cluster" for these cases
169  if ( theBuffer(theSeeds[i]) >= theSeedThreshold )
170  { // Is this seed still valid?
171  // Make a cluster around this seed
172  SiPixelCluster && cluster = make_cluster( theSeeds[i] , output);
173 
174  // Check if the cluster is above threshold
175  // (TO DO: one is signed, other unsigned, gcc warns...)
176  if ( cluster.charge() >= clusterThreshold)
177  {
178  // std::cout << "putting in this cluster " << i << " " << cluster.charge() << " " << cluster.pixelADC().size() << endl;
179  // sort by row (x)
180  output.push_back( std::move(cluster) );
181  std::push_heap(output.begin(),output.end(),[](SiPixelCluster const & cl1,SiPixelCluster const & cl2) { return cl1.minPixelRow() < cl2.minPixelRow();});
182  }
183  }
184  }
185  // sort by row (x) maybe sorting the seed would suffice....
186  std::sort_heap(output.begin(),output.end(),[](SiPixelCluster const & cl1,SiPixelCluster const & cl2) { return cl1.minPixelRow() < cl2.minPixelRow();});
187 
188  // Erase the seeds.
189  theSeeds.clear();
190 
191  // Need to clean unused pixels from the buffer array.
192  clear_buffer(begin, end);
193 
194 }
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.
int charge() const
static std::string const input
Definition: EdmProvDump.cc:45
int minPixelRow() const
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:41
#define end
Definition: vmac.h:39
unsigned int pxbLayer(const DetId &id) const
Definition: DetId.h:18
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:32
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.
void PixelThresholdClusterizer::copy_to_buffer ( DigiIterator  begin,
DigiIterator  end 
)
private

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

Definition at line 229 of file PixelThresholdClusterizer.cc.

References ecalMGPA::adc(), begin, cuy::col, gather_cfg::cout, metsig::electron, end, muonCSCDigis_cfi::gain, mps_fire::i, recoMuon::in, createfilelist::int, and muonCSCDigis_cfi::pedestal.

230 {
231 #ifdef PIXELREGRESSION
232  static std::atomic<int> s_ic=0;
233  in ic = ++s_ic;
234  if (ic==1) {
235  // std::cout << (doMissCalibrate ? "VI from db" : "VI linear") << std::endl;
236  }
237 #endif
238  int electron[end-begin]; // pixel charge in electrons
239  memset(electron, 0, sizeof(electron));
240 
241  if (doPhase2Calibration) {
242  int i = 0;
243  for(DigiIterator di = begin; di != end; ++di) {
244  electron[i] = calibrate(di->adc(), di->column(), di->row());
245  i++;
246  }
247  assert(i==(end-begin));
248  }
249 
250  else {
251  if ( doMissCalibrate ) {
252  if (theLayer==1) {
253  (*theSiPixelGainCalibrationService_).calibrate(theDetid,begin,end,theConversionFactor_L1, theOffset_L1,electron);
254  } else {
255  (*theSiPixelGainCalibrationService_).calibrate(theDetid,begin,end,theConversionFactor, theOffset, electron);
256  }
257  } else {
258  int i=0;
259  const float gain = theElectronPerADCGain; // default: 1 ADC = 135 electrons
260  for(DigiIterator di = begin; di != end; ++di) {
261  auto adc = di->adc();
262  const float pedestal = 0.; //
263  electron[i] = int(adc * gain + pedestal);
264  ++i;
265  }
266  assert(i==(end-begin));
267  }
268  }
269 
270  int i=0;
271 #ifdef PIXELREGRESSION
272  static std::atomic<int> eqD=0;
273 #endif
274  for(DigiIterator di = begin; di != end; ++di) {
275  int row = di->row();
276  int col = di->column();
277  int adc = electron[i++]; // this is in electrons
278 
279 #ifdef PIXELREGRESSION
280  int adcOld = calibrate(di->adc(),col,row);
281  //assert(adc==adcOld);
282  if (adc!=adcOld) std::cout << "VI " << eqD <<' '<< ic <<' '<< end-begin <<' '<< i <<' '<< di->adc() <<' ' << adc <<' '<< adcOld << std::endl; else ++eqD;
283 #endif
284 
285  if(adc<100) adc=100; // put all negative pixel charges into the 100 elec bin
286  /* This is semi-random good number. The exact number (in place of 100) is irrelevant from the point
287  of view of the final cluster charge since these are typically >= 20000.
288  */
289 
290  if ( adc >= thePixelThreshold) {
291  theBuffer.set_adc( row, col, adc);
292  if ( adc >= theSeedThreshold) theSeeds.push_back( SiPixelCluster::PixelPos(row,col) );
293  }
294  }
295  assert(i==(end-begin));
296 
297 }
int adc(sample_type sample)
get the ADC sample (12 bits)
SiPixelArrayBuffer theBuffer
Data storage.
void set_adc(int row, int col, int adc)
edm::DetSet< PixelDigi >::const_iterator DigiIterator
#define end
Definition: vmac.h:39
#define begin
Definition: vmac.h:32
col
Definition: cuy.py:1010
int calibrate(int adc, int col, int row)
std::vector< SiPixelCluster::PixelPos > theSeeds
void PixelThresholdClusterizer::copy_to_buffer ( ClusterIterator  begin,
ClusterIterator  end 
)
private

Definition at line 299 of file PixelThresholdClusterizer.cc.

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

300 {
301  // loop over clusters
302  for(ClusterIterator ci = begin; ci != end; ++ci) {
303  // loop over pixels
304  for(int i = 0; i < ci->size(); ++i) {
305  const SiPixelCluster::Pixel pixel = ci->pixel(i);
306 
307  int row = pixel.x;
308  int col = pixel.y;
309  int adc = pixel.adc;
310  if ( adc >= thePixelThreshold) {
311  theBuffer.add_adc( row, col, adc);
312  if ( adc >= theSeedThreshold) theSeeds.push_back( SiPixelCluster::PixelPos(row,col) );
313  }
314  }
315  }
316 }
int adc(sample_type sample)
get the ADC sample (12 bits)
SiPixelArrayBuffer theBuffer
Data storage.
void add_adc(int row, int col, int adc)
#define end
Definition: vmac.h:39
edmNew::DetSet< SiPixelCluster >::const_iterator ClusterIterator
#define begin
Definition: vmac.h:32
col
Definition: cuy.py:1010
std::vector< SiPixelCluster::PixelPos > theSeeds
void PixelThresholdClusterizer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 72 of file PixelThresholdClusterizer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addUntracked(), and AlCaHLTBitMon_QueryRunRegistry::string.

72  {
73  // siPixelClusters
75  desc.add<edm::InputTag>("src", edm::InputTag("siPixelDigis"));
76  desc.add<int>("ChannelThreshold", 1000);
77  desc.addUntracked<bool>("MissCalibrate", true);
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);
83  desc.add<std::string>("payloadType", "Offline");
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);
94 }
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
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 414 of file PixelThresholdClusterizer.cc.

References PixelClusterizerBase::AccretionCluster::adc, PixelClusterizerBase::AccretionCluster::add(), SiPixelCluster::add(), edmNew::DetSetVector< T >::FastFiller::begin(), EnergyCorrector::c, SiPixelCluster::charge(), GetRecoTauVFromDQM_MC_cff::cl2, SiPixelCluster::PixelPos::col(), PixelClusterizerBase::AccretionCluster::empty(), edmNew::DetSetVector< T >::FastFiller::end(), mps_fire::i, PixelClusterizerBase::AccretionCluster::isize, SiStripPI::max, min(), SiPixelCluster::minPixelRow(), 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.

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

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

101 {
102  // Cache the topology.
103  const PixelTopology & topol = pixDet->specificTopology();
104 
105  // Get the new sizes.
106  int nrows = topol.nrows(); // rows in x
107  int ncols = topol.ncolumns(); // cols in y
108 
109  theNumOfRows = nrows; // Set new sizes
111 
112  if ( nrows > theBuffer.rows() ||
113  ncols > theBuffer.columns() )
114  { // change only when a larger is needed
115  //if( nrows != theNumOfRows || ncols != theNumOfCols ) {
116  //cout << " PixelThresholdClusterizer: pixel buffer redefined to "
117  // << nrows << " * " << ncols << endl;
118  //theNumOfRows = nrows; // Set new sizes
119  //theNumOfCols = ncols;
120  // Resize the buffer
121  theBuffer.setSize(nrows,ncols); // Modify
122  }
123 
124  return true;
125 }
virtual int nrows() const =0
SiPixelArrayBuffer theBuffer
Data storage.
int theNumOfRows
Geometry-related information.
void setSize(int rows, int cols)
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
virtual int ncolumns() const =0

Member Data Documentation

const bool PixelThresholdClusterizer::doMissCalibrate
private

Definition at line 119 of file PixelThresholdClusterizer.h.

const bool PixelThresholdClusterizer::doPhase2Calibration
private

Definition at line 109 of file PixelThresholdClusterizer.h.

const bool PixelThresholdClusterizer::doSplitClusters
private

Definition at line 120 of file PixelThresholdClusterizer.h.

SiPixelArrayBuffer PixelThresholdClusterizer::theBuffer
private

Data storage.

Definition at line 89 of file PixelThresholdClusterizer.h.

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

Definition at line 91 of file PixelThresholdClusterizer.h.

const int PixelThresholdClusterizer::theClusterThreshold
private

Definition at line 100 of file PixelThresholdClusterizer.h.

const int PixelThresholdClusterizer::theClusterThreshold_L1
private

Definition at line 101 of file PixelThresholdClusterizer.h.

float PixelThresholdClusterizer::theClusterThresholdInNoiseUnits
private

Definition at line 96 of file PixelThresholdClusterizer.h.

const int PixelThresholdClusterizer::theConversionFactor
private

Definition at line 102 of file PixelThresholdClusterizer.h.

const int PixelThresholdClusterizer::theConversionFactor_L1
private

Definition at line 103 of file PixelThresholdClusterizer.h.

uint32_t PixelThresholdClusterizer::theDetid
private

Definition at line 117 of file PixelThresholdClusterizer.h.

const double PixelThresholdClusterizer::theElectronPerADCGain
private

Definition at line 107 of file PixelThresholdClusterizer.h.

int PixelThresholdClusterizer::theLayer
private

Definition at line 118 of file PixelThresholdClusterizer.h.

int PixelThresholdClusterizer::theNumOfCols
private

Definition at line 116 of file PixelThresholdClusterizer.h.

int PixelThresholdClusterizer::theNumOfRows
private

Geometry-related information.

Definition at line 115 of file PixelThresholdClusterizer.h.

const int PixelThresholdClusterizer::theOffset
private

Definition at line 104 of file PixelThresholdClusterizer.h.

const int PixelThresholdClusterizer::theOffset_L1
private

Definition at line 105 of file PixelThresholdClusterizer.h.

const double PixelThresholdClusterizer::thePhase2DigiBaseline
private

Definition at line 111 of file PixelThresholdClusterizer.h.

const int PixelThresholdClusterizer::thePhase2KinkADC
private

Definition at line 112 of file PixelThresholdClusterizer.h.

const int PixelThresholdClusterizer::thePhase2ReadoutMode
private

Definition at line 110 of file PixelThresholdClusterizer.h.

const int PixelThresholdClusterizer::thePixelThreshold
private

Definition at line 98 of file PixelThresholdClusterizer.h.

float PixelThresholdClusterizer::thePixelThresholdInNoiseUnits
private

Clustering-related quantities:

Definition at line 94 of file PixelThresholdClusterizer.h.

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

Definition at line 90 of file PixelThresholdClusterizer.h.

const int PixelThresholdClusterizer::theSeedThreshold
private

Definition at line 99 of file PixelThresholdClusterizer.h.

float PixelThresholdClusterizer::theSeedThresholdInNoiseUnits
private

Definition at line 95 of file PixelThresholdClusterizer.h.