CMS 3D CMS Logo

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