test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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_.setSize(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 
37  // Loop over the Digis
38  // for the S modules, 1 column = 1 strip, so adjacent digis are along the rows
39  // same for P modules
40  for (unsigned int col(0); col < ncols_; ++col) {
41  for (unsigned int row(0); row < nrows_; ++row) {
42 
43  // If the Digi is hit
44  if (matrix_(row, col)) {
45  // No cluster is open, create a new one
46  if (sizeCluster == 0) {
47  // Define first digi
48  firstDigi = Phase2TrackerDigi(row, col);
49  sizeCluster = 1;
50  }
51  // A cluster is open, increase its size
52  else ++sizeCluster;
53  // Check if we reached the maximum size of the cluster and need to close it
54  closeCluster = ((maxClusterSize_ != 0 and sizeCluster >= maxClusterSize_) ? true : false);
55  }
56  // Otherwise check if we need to close a cluster (end of cluster)
57  else closeCluster = ((sizeCluster != 0) ? true : false);
58 
59  // Always close a cluster if we reach the end of the loop
60  if (sizeCluster != 0 and row == (nrows_ - 1)) closeCluster = true;
61 
62  // If we have to close a cluster, do it
63  if (closeCluster) {
64  // Add the cluster to the list
65  clusters.push_back(Phase2TrackerCluster1D(firstDigi, sizeCluster));
66  // Reset the variables
67  sizeCluster = 0;
68  // Increase the number of clusters
69  ++numberClusters;
70  }
71 
72  // Check if we hit the maximum number of clusters per module
73  if (maxNumberClusters_ != 0 and numberClusters > maxNumberClusters_) return;
74  }
75  }
76 
77  // Reset the matrix
78  clearMatrix(digis.begin(), digis.end());
79 }
80 
81 /*
82  * Copy the value of the Digis to the 2D matrix (hit or not).
83  */
84 
86  for (edm::DetSet< Phase2TrackerDigi >::const_iterator di(begin); di != end; ++di) matrix_.set(di->row(), di->column(), true);
87 }
88 
89 /*
90  * Clear the array of hits
91  */
92 
94  for (edm::DetSet< Phase2TrackerDigi >::const_iterator di(begin); di != end; ++di) matrix_.set(di->row(), di->column(), false);
95 }
96 
iterator end()
Definition: DetSet.h:60
void push_back(data_type const &d)
void set(unsigned int, unsigned int, bool)
void clusterizeDetUnit(const edm::DetSet< Phase2TrackerDigi > &, Phase2TrackerCluster1DCollectionNew::FastFiller &)
void fillMatrix(edm::DetSet< Phase2TrackerDigi >::const_iterator, edm::DetSet< Phase2TrackerDigi >::const_iterator)
void setSize(unsigned int, unsigned int)
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
collection_type::const_iterator const_iterator
Definition: DetSet.h:33
int col
Definition: cuy.py:1008