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  // Do not bother for empty detectors
53  if (begin == end)
54  edm::LogWarning("clusterizeDetUnit()") << "No digis to clusterize";
55 
56  // Set up the clusterization on this DetId.
57  if (!setup(pixDet))
58  return;
59 
60  theDetid = input.detId();
61 
63  // Set separate cluster threshold for L1 (needed for phase1)
64  auto clusterThreshold = theClusterThreshold;
65  theLayer = (DetId(theDetid).subdetId() == 1) ? tTopo->pxbLayer(theDetid) : 0;
66  if (theLayer == 1)
67  clusterThreshold = theClusterThreshold_L1;
68 
69  // Copy PixelDigis to the buffer array; select the seed pixels
70  // on the way, and store them in theSeeds.
71  if (end > begin)
72  copy_to_buffer(begin, end);
73 
74  assert(output.empty());
75  // Loop over all seeds. TO DO: wouldn't using iterators be faster?
76  for (unsigned int i = 0; i < theSeeds.size(); i++) {
77  // Gavril : The charge of seeds that were already inlcuded in clusters is set to 1 electron
78  // so we don't want to call "make_cluster" for these cases
79  if (theBuffer(theSeeds[i]) >= theSeedThreshold) { // Is this seed still valid?
80  // Make a cluster around this seed
81  SiPixelCluster cluster;
82  if ((&pixDet->specificTopology())->isBricked()) {
83  cluster = make_cluster_bricked(theSeeds[i], output, isBarrel);
84  } else {
85  cluster = make_cluster(theSeeds[i], output);
86  }
87 
88  // Check if the cluster is above threshold
89  // (TO DO: one is signed, other unsigned, gcc warns...)
90  if (cluster.charge() >= clusterThreshold) {
91  // sort by row (x)
92  output.push_back(std::move(cluster));
93  std::push_heap(output.begin(), output.end(), [](SiPixelCluster const& cl1, SiPixelCluster const& cl2) {
94  return cl1.minPixelRow() < cl2.minPixelRow();
95  });
96  }
97  }
98  }
99  // sort by row (x) maybe sorting the seed would suffice....
100  std::sort_heap(output.begin(), output.end(), [](SiPixelCluster const& cl1, SiPixelCluster const& cl2) {
101  return cl1.minPixelRow() < cl2.minPixelRow();
102  });
103 
104  // Erase the seeds.
105  theSeeds.clear();
106 
107  // Need to clean unused pixels from the buffer array.
108  clear_buffer(begin, end);
109 
110  theFakePixels.clear();
111 }
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
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:
Log< level::Warning, false > LogWarning
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 116 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, 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().

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