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)
 
void clusterizeDetUnit (const edmNew::DetSet< SiPixelCluster > &input, const PixelGeomDetUnit *pixDet, const TrackerTopology *tTopo, 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 ()
 

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

bool bufferAlreadySet
 
bool dead_flag
 
uint32_t detid_
 
const bool doMissCalibrate
 
const bool doSplitClusters
 
int layer_
 
SiPixelArrayBuffer theBuffer
 Data storage. More...
 
std::vector< SiPixelClustertheClusters
 
const int theClusterThreshold
 
const int theClusterThreshold_L1
 
float theClusterThresholdInNoiseUnits
 
const int theConversionFactor
 
const int theConversionFactor_L1
 
const double theElectronPerADCGain_
 
const int theFirstStack_
 
int theNumOfCols
 
int theNumOfRows
 Geometry-related information. More...
 
const int theOffset
 
const int theOffset_L1
 
const int thePixelThreshold
 
float thePixelThresholdInNoiseUnits
 Clustering-related quantities: More...
 
std::vector< SiPixelCluster::PixelPostheSeeds
 
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 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  bufferAlreadySet(false),
46  // Get thresholds in electrons
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),
59  // Get the constants for the miss-calibration studies
60  doMissCalibrate( conf.getUntrackedParameter<bool>("MissCalibrate",true) ),
61  doSplitClusters( conf.getParameter<bool>("SplitClusters") )
62 {
64 }
SiPixelArrayBuffer theBuffer
Data storage.
int theNumOfRows
Geometry-related information.
void setSize(int rows, int cols)
PixelThresholdClusterizer::~PixelThresholdClusterizer ( )

Definition at line 66 of file PixelThresholdClusterizer.cc.

66 {}

Member Function Documentation

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

Definition at line 306 of file PixelThresholdClusterizer.cc.

References genericTrackCleaner_cfi::electrons, muonCSCDigis_cfi::gain, createfilelist::int, sistrip::layer_, and muonCSCDigis_cfi::pedestal.

307 {
308  int electrons = 0;
309 
310  if ( doMissCalibrate )
311  {
312  // do not perform calibration if pixel is dead!
313 
316  {
317 
318  // Linear approximation of the TANH response
319  // Pixel(0,0,0)
320  //const float gain = 2.95; // 1 ADC = 2.95 VCALs (1/0.339)
321  //const float pedestal = -83.; // -28/0.339
322  // Roc-0 average
323  //const float gain = 1./0.357; // 1 ADC = 2.80 VCALs
324  //const float pedestal = -28.2 * gain; // -79.
325 
326  float DBgain = theSiPixelGainCalibrationService_->getGain(detid_, col, row);
327  float DBpedestal = theSiPixelGainCalibrationService_->getPedestal(detid_, col, row) * DBgain;
328 
329 
330  // Roc-6 average
331  //const float gain = 1./0.313; // 1 ADC = 3.19 VCALs
332  //const float pedestal = -6.2 * gain; // -19.8
333  //
334  float vcal = adc * DBgain - DBpedestal;
335 
336  // atanh calibration
337  // Roc-6 average
338  //const float p0 = 0.00492;
339  //const float p1 = 1.998;
340  //const float p2 = 90.6;
341  //const float p3 = 134.1;
342  // Roc-6 average
343  //const float p0 = 0.00382;
344  //const float p1 = 0.886;
345  //const float p2 = 112.7;
346  //const float p3 = 113.0;
347  //float vcal = ( atanh( (adc-p3)/p2) + p1)/p0;
348 
349  if (layer_==1) {
350  electrons = int( vcal * theConversionFactor_L1 + theOffset_L1);
351  } else {
352  electrons = int( vcal * theConversionFactor + theOffset);
353  }
354  }
355  }
356  else
357  { // No misscalibration in the digitizer
358  // Simple (default) linear gain
359  const float gain = theElectronPerADCGain_; // default: 1 ADC = 135 electrons
360  const float pedestal = 0.; //
361  electrons = int(adc * gain + pedestal);
362  if (layer_>=theFirstStack_) {
363  if (theStackADC_==1&&adc==1)
364  {
365  electrons = int(255*135); // Arbitrarily use overflow value.
366  }
367  if (theStackADC_>1&&theStackADC_!=255&&adc>=1)
368  {
369  const float gain = theElectronPerADCGain_; // default: 1 ADC = 135 electrons
370  electrons = int((adc-1) * gain * 255/float(theStackADC_-1));
371  }
372  }
373  }
374 
375  return electrons;
376 }
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:1008
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
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 200 of file PixelThresholdClusterizer.cc.

References end.

201 {
202  for(DigiIterator di = begin; di != end; ++di )
203  {
204  theBuffer.set_adc( di->row(), di->column(), 0 ); // reset pixel adc to 0
205  }
206 }
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 208 of file PixelThresholdClusterizer.cc.

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

209 {
210  for(ClusterIterator ci = begin; ci != end; ++ci )
211  {
212  for(int i = 0; i < ci->size(); ++i)
213  {
214  const SiPixelCluster::Pixel pixel = ci->pixel(i);
215 
216  theBuffer.set_adc( pixel.x, pixel.y, 0 ); // reset pixel adc to 0
217  }
218  }
219 }
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 TrackerTopology tTopo,
const std::vector< short > &  badChannels,
edmNew::DetSetVector< SiPixelCluster >::FastFiller &  output 
)
inlinevirtual

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 
)
inlinevirtual

Implements PixelClusterizerBase.

Definition at line 71 of file PixelThresholdClusterizer.h.

References 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 129 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, sistrip::layer_, SiPixelCluster::minPixelRow(), eostools::move(), edmNew::DetSetVector< T >::FastFiller::push_back(), TrackerTopology::pxbLayer(), GeneralSetup::setup(), and DetId::subdetId().

133  {
134 
135  typename T::const_iterator begin = input.begin();
136  typename T::const_iterator end = input.end();
137 
138  // Do not bother for empty detectors
139  //if (begin == end) cout << " PixelThresholdClusterizer::clusterizeDetUnit - No digis to clusterize";
140 
141  // Set up the clusterization on this DetId.
142  if ( !setup(pixDet) )
143  return;
144 
145  detid_ = input.detId();
146 
147  // Set separate cluster threshold for L1 (needed for phase1)
148  auto clusterThreshold = theClusterThreshold;
149  layer_ = (DetId(detid_).subdetId()==1) ? tTopo->pxbLayer(detid_) : 0;
150  if (layer_==1) clusterThreshold = theClusterThreshold_L1;
151 
152  // Copy PixelDigis to the buffer array; select the seed pixels
153  // on the way, and store them in theSeeds.
154  copy_to_buffer(begin, end);
155 
156  assert(output.empty());
157  // Loop over all seeds. TO DO: wouldn't using iterators be faster?
158  // edm::LogError("PixelThresholdClusterizer") << "Starting clusterizing" << endl;
159  for (unsigned int i = 0; i < theSeeds.size(); i++)
160  {
161 
162  // Gavril : The charge of seeds that were already inlcuded in clusters is set to 1 electron
163  // so we don't want to call "make_cluster" for these cases
164  if ( theBuffer(theSeeds[i]) >= theSeedThreshold )
165  { // Is this seed still valid?
166  // Make a cluster around this seed
167  SiPixelCluster && cluster = make_cluster( theSeeds[i] , output);
168 
169  // Check if the cluster is above threshold
170  // (TO DO: one is signed, other unsigned, gcc warns...)
171  if ( cluster.charge() >= clusterThreshold)
172  {
173  // std::cout << "putting in this cluster " << i << " " << cluster.charge() << " " << cluster.pixelADC().size() << endl;
174  // sort by row (x)
175  output.push_back( std::move(cluster) );
176  std::push_heap(output.begin(),output.end(),[](SiPixelCluster const & cl1,SiPixelCluster const & cl2) { return cl1.minPixelRow() < cl2.minPixelRow();});
177  }
178  }
179  }
180  // sort by row (x) maybe sorting the seed would suffice....
181  std::sort_heap(output.begin(),output.end(),[](SiPixelCluster const & cl1,SiPixelCluster const & cl2) { return cl1.minPixelRow() < cl2.minPixelRow();});
182 
183  // Erase the seeds.
184  theSeeds.clear();
185 
186  // Need to clean unused pixels from the buffer array.
187  clear_buffer(begin, end);
188 
189 }
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:44
int minPixelRow() const
#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
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:30
bool setup(const PixelGeomDetUnit *pixDet)
Private helper methods:
std::vector< SiPixelCluster::PixelPos > theSeeds
def move(src, dest)
Definition: eostools.py:510
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 224 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, sistrip::layer_, and muonCSCDigis_cfi::pedestal.

225 {
226 #ifdef PIXELREGRESSION
227  static std::atomic<int> s_ic=0;
228  in ic = ++s_ic;
229  if (ic==1) {
230  // std::cout << (doMissCalibrate ? "VI from db" : "VI linear") << std::endl;
231  }
232 #endif
233  int electron[end-begin];
234  memset(electron, 0, sizeof(electron));
235  if ( doMissCalibrate ) {
236  if (layer_==1) {
237  (*theSiPixelGainCalibrationService_).calibrate(detid_,begin,end,theConversionFactor_L1, theOffset_L1,electron);
238  } else {
239  (*theSiPixelGainCalibrationService_).calibrate(detid_,begin,end,theConversionFactor, theOffset, electron);
240  }
241  } else {
242  int i=0;
243  for(DigiIterator di = begin; di != end; ++di) {
244  auto adc = di->adc();
245  const float gain = theElectronPerADCGain_; // default: 1 ADC = 135 electrons
246  const float pedestal = 0.; //
247  electron[i] = int(adc * gain + pedestal);
248  if (layer_>=theFirstStack_) {
249  if (theStackADC_==1&&adc==1) {
250  electron[i] = int(255*135); // Arbitrarily use overflow value.
251  }
252  if (theStackADC_>1&&theStackADC_!=255&&adc>=1){
253  const float gain = theElectronPerADCGain_; // default: 1 ADC = 135 electrons
254  electron[i] = int((adc-1) * gain * 255/float(theStackADC_-1));
255  }
256  }
257  ++i;
258  }
259  assert(i==(end-begin));
260  }
261 
262  int i=0;
263 #ifdef PIXELREGRESSION
264  static std::atomic<int> eqD=0;
265 #endif
266  for(DigiIterator di = begin; di != end; ++di) {
267  int row = di->row();
268  int col = di->column();
269  int adc = electron[i++];
270 #ifdef PIXELREGRESSION
271  int adcOld = calibrate(di->adc(),col,row);
272  //assert(adc==adcOld);
273  if (adc!=adcOld) std::cout << "VI " << eqD <<' '<< ic <<' '<< end-begin <<' '<< i <<' '<< di->adc() <<' ' << adc <<' '<< adcOld << std::endl; else ++eqD;
274 #endif
275  if ( adc >= thePixelThreshold) {
276  theBuffer.set_adc( row, col, adc);
277  if ( adc >= theSeedThreshold) theSeeds.push_back( SiPixelCluster::PixelPos(row,col) );
278  }
279  }
280  assert(i==(end-begin));
281 
282 }
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:37
#define begin
Definition: vmac.h:30
col
Definition: cuy.py:1008
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 284 of file PixelThresholdClusterizer.cc.

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

285 {
286  // loop over clusters
287  for(ClusterIterator ci = begin; ci != end; ++ci) {
288  // loop over pixels
289  for(int i = 0; i < ci->size(); ++i) {
290  const SiPixelCluster::Pixel pixel = ci->pixel(i);
291 
292  int row = pixel.x;
293  int col = pixel.y;
294  int adc = pixel.adc;
295  if ( adc >= thePixelThreshold) {
296  theBuffer.add_adc( row, col, adc);
297  if ( adc >= theSeedThreshold) theSeeds.push_back( SiPixelCluster::PixelPos(row,col) );
298  }
299  }
300  }
301 }
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:37
edmNew::DetSet< SiPixelCluster >::const_iterator ClusterIterator
#define begin
Definition: vmac.h:30
col
Definition: cuy.py:1008
std::vector< SiPixelCluster::PixelPos > theSeeds
void PixelThresholdClusterizer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 71 of file PixelThresholdClusterizer.cc.

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

71  {
72  // siPixelClusters
74  desc.add<edm::InputTag>("src", edm::InputTag("siPixelDigis"));
75  desc.add<int>("ChannelThreshold", 1000);
76  desc.addUntracked<bool>("MissCalibrate", true);
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);
82  desc.add<std::string>("payloadType", "Offline");
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);
88 }
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 382 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, sistrip::layer_, hpstanc_transforms::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.

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

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

95 {
96  // Cache the topology.
97  const PixelTopology & topol = pixDet->specificTopology();
98 
99  // Get the new sizes.
100  int nrows = topol.nrows(); // rows in x
101  int ncols = topol.ncolumns(); // cols in y
102 
103  theNumOfRows = nrows; // Set new sizes
105 
106  if ( nrows > theBuffer.rows() ||
107  ncols > theBuffer.columns() )
108  { // change only when a larger is needed
109  //if( nrows != theNumOfRows || ncols != theNumOfCols ) {
110  //cout << " PixelThresholdClusterizer: pixel buffer redefined to "
111  // << nrows << " * " << ncols << endl;
112  //theNumOfRows = nrows; // Set new sizes
113  //theNumOfCols = ncols;
114  // Resize the buffer
115  theBuffer.setSize(nrows,ncols); // Modify
116  bufferAlreadySet = true;
117  }
118 
119  return true;
120 }
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

bool PixelThresholdClusterizer::bufferAlreadySet
private

Definition at line 90 of file PixelThresholdClusterizer.h.

bool PixelThresholdClusterizer::dead_flag
private

Definition at line 117 of file PixelThresholdClusterizer.h.

uint32_t PixelThresholdClusterizer::detid_
private

Definition at line 115 of file PixelThresholdClusterizer.h.

const bool PixelThresholdClusterizer::doMissCalibrate
private

Definition at line 118 of file PixelThresholdClusterizer.h.

const bool PixelThresholdClusterizer::doSplitClusters
private

Definition at line 119 of file PixelThresholdClusterizer.h.

int PixelThresholdClusterizer::layer_
private

Definition at line 116 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 92 of file PixelThresholdClusterizer.h.

const int PixelThresholdClusterizer::theClusterThreshold
private

Definition at line 101 of file PixelThresholdClusterizer.h.

const int PixelThresholdClusterizer::theClusterThreshold_L1
private

Definition at line 102 of file PixelThresholdClusterizer.h.

float PixelThresholdClusterizer::theClusterThresholdInNoiseUnits
private

Definition at line 97 of file PixelThresholdClusterizer.h.

const int PixelThresholdClusterizer::theConversionFactor
private

Definition at line 103 of file PixelThresholdClusterizer.h.

const int PixelThresholdClusterizer::theConversionFactor_L1
private

Definition at line 104 of file PixelThresholdClusterizer.h.

const double PixelThresholdClusterizer::theElectronPerADCGain_
private

Definition at line 110 of file PixelThresholdClusterizer.h.

const int PixelThresholdClusterizer::theFirstStack_
private

Definition at line 109 of file PixelThresholdClusterizer.h.

int PixelThresholdClusterizer::theNumOfCols
private

Definition at line 114 of file PixelThresholdClusterizer.h.

int PixelThresholdClusterizer::theNumOfRows
private

Geometry-related information.

Definition at line 113 of file PixelThresholdClusterizer.h.

const int PixelThresholdClusterizer::theOffset
private

Definition at line 105 of file PixelThresholdClusterizer.h.

const int PixelThresholdClusterizer::theOffset_L1
private

Definition at line 106 of file PixelThresholdClusterizer.h.

const int PixelThresholdClusterizer::thePixelThreshold
private

Definition at line 99 of file PixelThresholdClusterizer.h.

float PixelThresholdClusterizer::thePixelThresholdInNoiseUnits
private

Clustering-related quantities:

Definition at line 95 of file PixelThresholdClusterizer.h.

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

Definition at line 91 of file PixelThresholdClusterizer.h.

const int PixelThresholdClusterizer::theSeedThreshold
private

Definition at line 100 of file PixelThresholdClusterizer.h.

float PixelThresholdClusterizer::theSeedThresholdInNoiseUnits
private

Definition at line 96 of file PixelThresholdClusterizer.h.

const int PixelThresholdClusterizer::theStackADC_
private

Definition at line 108 of file PixelThresholdClusterizer.h.