CMS 3D CMS Logo

Phase2TrackerClusterizerAlgorithm.cc
Go to the documentation of this file.
2 
4 
5 /*
6  * Initialise the clusterizer algorithm
7  */
8 
9 Phase2TrackerClusterizerAlgorithm::Phase2TrackerClusterizerAlgorithm(unsigned int maxClusterSize, unsigned int maxNumberClusters) : maxClusterSize_(maxClusterSize), maxNumberClusters_(maxNumberClusters), nrows_(0), ncols_(0) { }
10 
11 /*
12  * Change the size of the 2D matrix for this module (varies from pixel to strip modules)
13  */
14 
16  const PixelTopology& topol(pixDet->specificTopology());
17  nrows_ = topol.nrows();
18  ncols_ = topol.ncolumns();
19  matrix_ = decltype(matrix_)(nrows_, ncols_);
20 }
21 
22 /*
23  * Go over the Digis and create clusters
24  */
25 
27 
28  // Fill the 2D matrix with the hit information : (hit or not)
29  fillMatrix(digis.begin(), digis.end());
30 
31  // Number of clusters
32  unsigned int numberClusters(0);
33  Phase2TrackerDigi firstDigi;
34  unsigned int sizeCluster(0);
35  bool closeCluster(false);
36  bool HIPbit(false);
37 
38  // Loop over the Digis
39  // for the S modules, 1 column = 1 strip, so adjacent digis are along the rows
40  // same for P modules
41  for (unsigned int col(0); col < ncols_; ++col) {
42  for (unsigned int row(0); row < nrows_; ++row) {
43 
44  // If the Digi is hit
45  if (matrix_(row, col)) {
46  // No cluster is open, create a new one
47  if (sizeCluster == 0) {
48  // Define first digi
49  firstDigi = Phase2TrackerDigi(row, col);
50  sizeCluster = 1;
51  }
52  // A cluster is open, increase its size
53  else ++sizeCluster;
54  // Check if we reached the maximum size of the cluster and need to close it
55  closeCluster = ((maxClusterSize_ != 0 and sizeCluster >= maxClusterSize_) ? true : false);
56  }
57  // Otherwise check if we need to close a cluster (end of cluster)
58  else closeCluster = ((sizeCluster != 0) ? true : false);
59 
60  // update the HIP bit
61  HIPbit |= (matrix_(row, col)==2);
62 
63  // Always close a cluster if we reach the end of the loop
64  if (sizeCluster != 0 and row == (nrows_ - 1)) closeCluster = true;
65 
66  // If we have to close a cluster, do it
67  if (closeCluster) {
68  // Add the cluster to the list
69  clusters.push_back(Phase2TrackerCluster1D(firstDigi, sizeCluster, HIPbit));
70  // Reset the variables
71  sizeCluster = 0;
72  // Increase the number of clusters
73  ++numberClusters;
74  HIPbit = false;
75  }
76 
77  // Check if we hit the maximum number of clusters per module
78  if (maxNumberClusters_ != 0 and numberClusters > maxNumberClusters_) return;
79  }
80  }
81 
82  // Reset the matrix
83  clearMatrix(digis.begin(), digis.end());
84 }
85 
86 /*
87  * Copy the value of the Digis to the 2D matrix (hit or not).
88  */
89 
91  for (edm::DetSet< Phase2TrackerDigi >::const_iterator di(begin); di != end; ++di) matrix_.set(di->row(), di->column(), true, di->overThreshold());
92 }
93 
94 /*
95  * Clear the array of hits
96  */
97 
99  for (edm::DetSet< Phase2TrackerDigi >::const_iterator di(begin); di != end; ++di) matrix_.set(di->row(), di->column(), false, false);
100 }
101 
iterator end()
Definition: DetSet.h:60
void push_back(data_type const &d)
void set(unsigned int, unsigned int, bool, bool)
void clusterizeDetUnit(const edm::DetSet< Phase2TrackerDigi > &, Phase2TrackerCluster1DCollectionNew::FastFiller &)
void fillMatrix(edm::DetSet< Phase2TrackerDigi >::const_iterator, edm::DetSet< Phase2TrackerDigi >::const_iterator)
void clearMatrix(edm::DetSet< Phase2TrackerDigi >::const_iterator, edm::DetSet< Phase2TrackerDigi >::const_iterator)
#define end
Definition: vmac.h:37
Phase2TrackerClusterizerAlgorithm(unsigned int, unsigned int)
iterator begin()
Definition: DetSet.h:59
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
#define begin
Definition: vmac.h:30
col
Definition: cuy.py:1008
collection_type::const_iterator const_iterator
Definition: DetSet.h:33