CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Member Functions
PixelThresholdClusterizerForBricked Class Referencefinal

A specific threshold-based pixel clustering algorithm. More...

#include <PixelThresholdClusterizerForBricked.h>

Inheritance diagram for PixelThresholdClusterizerForBricked:
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
 
 PixelThresholdClusterizerForBricked (edm::ParameterSet const &conf)
 
 ~PixelThresholdClusterizerForBricked () override
 
- Public Member Functions inherited from PixelThresholdClusterizer
 PixelThresholdClusterizer (edm::ParameterSet const &conf)
 
 ~PixelThresholdClusterizer () override
 
- Public Member Functions inherited from PixelClusterizerBase
void setSiPixelGainCalibrationService (SiPixelGainCalibrationServiceBase *in)
 
virtual ~PixelClusterizerBase ()
 

Private Member Functions

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...
 
SiPixelCluster make_cluster_bricked (const SiPixelCluster::PixelPos &pix, edmNew::DetSetVector< SiPixelCluster >::FastFiller &output, bool isbarrel)
 The actual clustering algorithm: group the neighboring pixels around the seed. More...
 

Additional Inherited Members

- Public Types inherited from PixelClusterizerBase
typedef edmNew::DetSet
< SiPixelCluster >
::const_iterator 
ClusterIterator
 
typedef edm::DetSet< PixelDigi >
::const_iterator 
DigiIterator
 
- Static Public Member Functions inherited from PixelThresholdClusterizer
static void fillPSetDescription (edm::ParameterSetDescription &desc)
 
- Protected Member Functions inherited from PixelThresholdClusterizer
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...
 
- Protected Attributes inherited from PixelThresholdClusterizer
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
 
std::vector< bool > theFakePixels
 
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::PixelPos
theSeeds
 
const int theSeedThreshold
 
float theSeedThresholdInNoiseUnits
 
- Protected Attributes inherited from PixelClusterizerBase
SiPixelGainCalibrationServiceBasetheSiPixelGainCalibrationService_
 

Detailed Description

A specific threshold-based pixel clustering algorithm.

An explicit threshold-based clustering algorithm.

Same logic as the base class PixelThresholdClusterizer but specialized for bricked pixels topology

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 46 of file PixelThresholdClusterizerForBricked.h.

Constructor & Destructor Documentation

PixelThresholdClusterizerForBricked::PixelThresholdClusterizerForBricked ( 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 29 of file PixelThresholdClusterizerForBricked.cc.

30  : PixelThresholdClusterizer(conf) {}
PixelThresholdClusterizer(edm::ParameterSet const &conf)
PixelThresholdClusterizerForBricked::~PixelThresholdClusterizerForBricked ( )
override

Definition at line 32 of file PixelThresholdClusterizerForBricked.cc.

32 {}

Member Function Documentation

void PixelThresholdClusterizerForBricked::clusterizeDetUnit ( const edm::DetSet< PixelDigi > &  input,
const PixelGeomDetUnit pixDet,
const TrackerTopology tTopo,
const std::vector< short > &  badChannels,
edmNew::DetSetVector< SiPixelCluster >::FastFiller &  output 
)
inlineoverridevirtual

Reimplemented from PixelThresholdClusterizer.

Definition at line 52 of file PixelThresholdClusterizerForBricked.h.

References PixelThresholdClusterizer::clusterizeDetUnitT().

56  {
57  clusterizeDetUnitT(input, pixDet, tTopo, badChannels, output);
58  }
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 PixelThresholdClusterizerForBricked::clusterizeDetUnit ( const edmNew::DetSet< SiPixelCluster > &  input,
const PixelGeomDetUnit pixDet,
const TrackerTopology tTopo,
const std::vector< short > &  badChannels,
edmNew::DetSetVector< SiPixelCluster >::FastFiller &  output 
)
inlineoverridevirtual

Reimplemented from PixelThresholdClusterizer.

Definition at line 59 of file PixelThresholdClusterizerForBricked.h.

References PixelThresholdClusterizer::clusterizeDetUnitT().

63  {
64  clusterizeDetUnitT(input, pixDet, tTopo, badChannels, output);
65  }
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 PixelThresholdClusterizerForBricked::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 42 of file PixelThresholdClusterizerForBricked.cc.

References cms::cuda::assert(), SplitLinear::begin, edmNew::DetSetVector< T >::FastFiller::begin(), SiPixelCluster::charge(), GetRecoTauVFromDQM_MC_cff::cl2, PixelThresholdClusterizer::clear_buffer(), PixelThresholdClusterizer::copy_to_buffer(), edmNew::DetSetVector< T >::FastFiller::empty(), edmNew::DetSetVector< T >::FastFiller::end(), dataset::end, mps_fire::i, PixelPluginsPhase0_cfi::isBarrel, PixelThresholdClusterizer::make_cluster(), make_cluster_bricked(), SiPixelCluster::minPixelRow(), eostools::move(), PixelSubdetector::PixelBarrel, edmNew::DetSetVector< T >::FastFiller::push_back(), TrackerTopology::pxbLayer(), PixelThresholdClusterizer::setup(), PixelGeomDetUnit::specificTopology(), DetId::subdetId(), PixelThresholdClusterizer::theBuffer, PixelThresholdClusterizer::theClusterThreshold, PixelThresholdClusterizer::theClusterThreshold_L1, PixelThresholdClusterizer::theDetid, PixelThresholdClusterizer::theFakePixels, PixelThresholdClusterizer::theLayer, PixelThresholdClusterizer::theSeeds, and PixelThresholdClusterizer::theSeedThreshold.

46  {
47  typename T::const_iterator begin = input.begin();
48  typename T::const_iterator end = input.end();
49 
50  edm::LogInfo("PixelThresholdClusterizerForBricked::clusterizeDetUnitT()");
51 
52  // this should never happen and the raw2digi does not create empty detsets
53  if (begin == end) {
54  edm::LogError("PixelThresholdClusterizerForBricked")
55  << "@SUB=PixelThresholdClusterizerForBricked::clusterizeDetUnitT()"
56  << " No digis to clusterize";
57  }
58 
59  // Set up the clusterization on this DetId.
60  if (!setup(pixDet))
61  return;
62 
63  theDetid = input.detId();
64 
66  // Set separate cluster threshold for L1 (needed for phase1)
67  auto clusterThreshold = theClusterThreshold;
68  theLayer = (DetId(theDetid).subdetId() == 1) ? tTopo->pxbLayer(theDetid) : 0;
69  if (theLayer == 1)
70  clusterThreshold = theClusterThreshold_L1;
71 
72  // Copy PixelDigis to the buffer array; select the seed pixels
73  // on the way, and store them in theSeeds.
74  if (end > begin)
75  copy_to_buffer(begin, end);
76 
77  assert(output.empty());
78  // Loop over all seeds. TO DO: wouldn't using iterators be faster?
79  for (unsigned int i = 0; i < theSeeds.size(); i++) {
80  // Gavril : The charge of seeds that were already inlcuded in clusters is set to 1 electron
81  // so we don't want to call "make_cluster" for these cases
82  if (theBuffer(theSeeds[i]) >= theSeedThreshold) { // Is this seed still valid?
83  // Make a cluster around this seed
84  SiPixelCluster cluster;
85  if ((&pixDet->specificTopology())->isBricked()) {
86  cluster = make_cluster_bricked(theSeeds[i], output, isBarrel);
87  } else {
88  cluster = make_cluster(theSeeds[i], output);
89  }
90 
91  // Check if the cluster is above threshold
92  // (TO DO: one is signed, other unsigned, gcc warns...)
93  if (cluster.charge() >= clusterThreshold) {
94  // sort by row (x)
95  output.push_back(std::move(cluster));
96  std::push_heap(output.begin(), output.end(), [](SiPixelCluster const& cl1, SiPixelCluster const& cl2) {
97  return cl1.minPixelRow() < cl2.minPixelRow();
98  });
99  }
100  }
101  }
102  // sort by row (x) maybe sorting the seed would suffice....
103  std::sort_heap(output.begin(), output.end(), [](SiPixelCluster const& cl1, SiPixelCluster const& cl2) {
104  return cl1.minPixelRow() < cl2.minPixelRow();
105  });
106 
107  // Erase the seeds.
108  theSeeds.clear();
109 
110  // Need to clean unused pixels from the buffer array.
111  clear_buffer(begin, end);
112 
113  theFakePixels.clear();
114 }
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
Log< level::Error, false > LogError
assert(be >=bs)
static std::string const input
Definition: EdmProvDump.cc:47
int minPixelRow() const
def move
Definition: eostools.py:511
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
unsigned int pxbLayer(const DetId &id) const
Log< level::Info, false > LogInfo
Definition: DetId.h:17
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.
SiPixelCluster make_cluster_bricked(const SiPixelCluster::PixelPos &pix, edmNew::DetSetVector< SiPixelCluster >::FastFiller &output, bool isbarrel)
The actual clustering algorithm: group the neighboring pixels around the seed.
Pixel cluster – collection of neighboring pixels above threshold.
string end
Definition: dataset.py:937
bool setup(const PixelGeomDetUnit *pixDet)
Private helper methods:
std::vector< SiPixelCluster::PixelPos > theSeeds
void copy_to_buffer(DigiIterator begin, DigiIterator end)
Copy adc counts from PixelDigis into the buffer, identify seeds.
SiPixelCluster PixelThresholdClusterizerForBricked::make_cluster_bricked ( const SiPixelCluster::PixelPos pix,
edmNew::DetSetVector< SiPixelCluster >::FastFiller &  output,
bool  isbarrel 
)
private

The actual clustering algorithm: group the neighboring pixels around the seed.

Definition at line 119 of file PixelThresholdClusterizerForBricked.cc.

References PixelClusterizerBase::AccretionCluster::adc, PixelClusterizerBase::AccretionCluster::add(), SiPixelCluster::add(), edmNew::DetSetVector< T >::FastFiller::begin(), c, SiPixelCluster::charge(), GetRecoTauVFromDQM_MC_cff::cl2, SiPixelCluster::PixelPos::col(), SiPixelArrayBuffer::columns(), PixelThresholdClusterizer::doSplitClusters, PixelClusterizerBase::AccretionCluster::empty(), edmNew::DetSetVector< T >::FastFiller::end(), mps_fire::i, PixelClusterizerBase::AccretionCluster::isize, SiStripPI::max, SiStripPI::min, SiPixelCluster::minPixelRow(), SiPixelCluster::pixels(), PixelClusterizerBase::AccretionCluster::pop(), edmNew::DetSetVector< T >::FastFiller::push_back(), alignCSCRings::r, SiPixelCluster::PixelPos::row(), SiPixelArrayBuffer::rows(), SiPixelArrayBuffer::set_adc(), PixelThresholdClusterizer::theBuffer, PixelThresholdClusterizer::theClusterThreshold, PixelThresholdClusterizer::theClusterThreshold_L1, PixelThresholdClusterizer::theLayer, PixelThresholdClusterizer::thePixelThreshold, PixelClusterizerBase::AccretionCluster::top(), PixelClusterizerBase::AccretionCluster::x, PixelClusterizerBase::AccretionCluster::xmin, PixelClusterizerBase::AccretionCluster::y, and PixelClusterizerBase::AccretionCluster::ymin.

Referenced by clusterizeDetUnitT().

120  {
121  //First we acquire the seeds for the clusters
122  int seed_adc;
123  stack<SiPixelCluster::PixelPos, vector<SiPixelCluster::PixelPos> > dead_pixel_stack;
124 
125  //The individual modules have been loaded into a buffer.
126  //After each pixel has been considered by the clusterizer, we set the adc count to 1
127  //to mark that we have already considered it.
128  //The only difference between dead/noisy pixels and standard ones is that for dead/noisy pixels,
129  //We consider the charge of the pixel to always be zero.
130 
131  seed_adc = theBuffer(pix.row(), pix.col());
132  theBuffer.set_adc(pix, 1);
133 
134  AccretionCluster acluster;
135  acluster.add(pix, seed_adc);
136 
137  //Here we search all pixels adjacent to all pixels in the cluster.
138  bool dead_flag = false;
139  while (!acluster.empty()) {
140  //This is the standard algorithm to find and add a pixel
141  auto curInd = acluster.top();
142  acluster.pop();
143 
144  for (auto r = std::max(0, int(acluster.x[curInd]) - 1); r < std::min(int(acluster.x[curInd]) + 2, theBuffer.rows());
145  ++r) {
146  int LowerAccLimity = 0;
147  int UpperAccLimity = 0;
148 
149  if (r % 2 == int(acluster.x[curInd]) % 2) {
150  LowerAccLimity = std::max(0, int(acluster.y[curInd]) - 1);
151  UpperAccLimity = std::min(int(acluster.y[curInd]) + 2, theBuffer.columns());
152  }
153 
154  else {
155  int parity_curr = int(acluster.x[curInd]) % 2;
156  int parity_hit = r % 2;
157 
158  LowerAccLimity = std::max(0, int(acluster.y[curInd]) - parity_hit);
159  UpperAccLimity = std::min(int(acluster.y[curInd]) + parity_curr + 1, theBuffer.columns());
160  }
161 
162  /*
163  for (auto c = std::max(0, int(acluster.y[curInd]) - 1);
164  c < std::min(int(acluster.y[curInd]) + 2, theBuffer.columns());
165  ++c)
166  */
167  for (auto c = LowerAccLimity; c < UpperAccLimity; ++c) {
168  if (theBuffer(r, c) >= thePixelThreshold) {
169  SiPixelCluster::PixelPos newpix(r, c);
170  if (!acluster.add(newpix, theBuffer(r, c)))
171  goto endClus;
172  if (isbarrel)
173  edm::LogInfo("make_cluster_bricked()") << "add" << r << c << theBuffer(r, c);
174  theBuffer.set_adc(newpix, 1);
175  //std::cout<<"col "<<c<<" row "<<r<<std::endl;
176  }
177  }
178  }
179 
180  } // while accretion
181 endClus:
182  SiPixelCluster cluster(acluster.isize, acluster.adc, acluster.x, acluster.y, acluster.xmin, acluster.ymin);
183  //Here we split the cluster, if the flag to do so is set and we have found a dead or noisy pixel.
184 
185  if (dead_flag && doSplitClusters) {
186  // Set separate cluster threshold for L1 (needed for phase1)
187  auto clusterThreshold = theClusterThreshold;
188  if (theLayer == 1)
189  clusterThreshold = theClusterThreshold_L1;
190 
191  //Set the first cluster equal to the existing cluster.
192  SiPixelCluster first_cluster = cluster;
193  bool have_second_cluster = false;
194  while (!dead_pixel_stack.empty()) {
195  //consider each found dead pixel
196  SiPixelCluster::PixelPos deadpix = dead_pixel_stack.top();
197  dead_pixel_stack.pop();
198  theBuffer.set_adc(deadpix, 1);
199 
200  //Clusterize the split cluster using the dead pixel as a seed
201  SiPixelCluster second_cluster = make_cluster_bricked(deadpix, output, isbarrel);
202 
203  //If both clusters would normally have been found by the clusterizer, put them into output
204  if (second_cluster.charge() >= clusterThreshold && first_cluster.charge() >= clusterThreshold) {
205  output.push_back(second_cluster);
206  have_second_cluster = true;
207  }
208 
209  //We also want to keep the merged cluster in data and let the RecHit algorithm decide which set to keep
210  //This loop adds the second cluster to the first.
211  const std::vector<SiPixelCluster::Pixel>& branch_pixels = second_cluster.pixels();
212  for (unsigned int i = 0; i < branch_pixels.size(); i++) {
213  int temp_x = branch_pixels[i].x;
214  int temp_y = branch_pixels[i].y;
215  int temp_adc = branch_pixels[i].adc;
216  SiPixelCluster::PixelPos newpix(temp_x, temp_y);
217  cluster.add(newpix, temp_adc);
218  }
219  }
220 
221  //Remember to also add the first cluster if we added the second one.
222  if (first_cluster.charge() >= clusterThreshold && have_second_cluster) {
223  output.push_back(first_cluster);
224  std::push_heap(output.begin(), output.end(), [](SiPixelCluster const& cl1, SiPixelCluster const& cl2) {
225  return cl1.minPixelRow() < cl2.minPixelRow();
226  });
227  }
228  }
229 
230  return cluster;
231 }
void push_back(data_type const &d)
SiPixelArrayBuffer theBuffer
Data storage.
const edm::EventSetup & c
int charge() const
void set_adc(int row, int col, int adc)
int minPixelRow() const
constexpr int col() const
Log< level::Info, false > LogInfo
SiPixelCluster make_cluster_bricked(const SiPixelCluster::PixelPos &pix, edmNew::DetSetVector< SiPixelCluster >::FastFiller &output, bool isbarrel)
The actual clustering algorithm: group the neighboring pixels around the seed.
Pixel cluster – collection of neighboring pixels above threshold.
constexpr int row() const
const std::vector< Pixel > pixels() const