CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TTCluster.cc
Go to the documentation of this file.
1 
12 
14 template <>
16  int rowMin = 99999999;
17  int rowMax = 0;
19  for (unsigned int i = 0; i < theHits.size(); i++) {
20  int row = 0;
21  if (this->getRows().empty()) {
22  row = theHits[i]->row();
23  } else {
24  row = this->getRows()[i];
25  }
26  if (row < rowMin)
27  rowMin = row;
28  if (row > rowMax)
29  rowMax = row;
30  }
31  return abs(rowMax - rowMin + 1);
32 }
33 
35 template <>
37  unsigned int hitIdx) const {
40  if (this->getRows().empty() || this->getCols().empty()) {
41  MeasurementPoint mp(theHits[hitIdx]->row(), theHits[hitIdx]->column());
42  return mp;
43  } else {
44  int row = this->getRows()[hitIdx];
45  int col = this->getCols()[hitIdx];
46  MeasurementPoint mp(row, col);
47  return mp;
48  }
49 }
50 
52 template <>
54 TTCluster<edm::Ref<edm::DetSetVector<Phase2TrackerDigi>, Phase2TrackerDigi> >::findAverageLocalCoordinates() const {
55  double averageCol = 0.0;
56  double averageRow = 0.0;
57 
59  if (!theHits.empty()) {
60  if (this->getRows().empty() || this->getCols().empty()) {
61  typename std::vector<edm::Ref<edm::DetSetVector<Phase2TrackerDigi>, Phase2TrackerDigi> >::const_iterator hitIter;
62  for (hitIter = theHits.begin(); hitIter != theHits.end(); hitIter++) {
63  averageCol += (*hitIter)->column();
64  averageRow += (*hitIter)->row();
65  }
66  averageCol /= theHits.size();
67  averageRow /= theHits.size();
68  } else {
69  for (unsigned int j = 0; j < theHits.size(); j++) {
70  averageCol += theCols[j];
71  averageRow += theRows[j];
72  }
73  averageCol /= theHits.size();
74  averageRow /= theHits.size();
75  }
76  }
77  return MeasurementPoint(averageRow, averageCol);
78 }
79 
81 template <>
83  edm::Ref<edm::DetSetVector<Phase2TrackerDigi>, Phase2TrackerDigi> >::findAverageLocalCoordinatesCentered() const {
84  double averageCol = 0.0;
85  double averageRow = 0.0;
86 
88  if (!theHits.empty()) {
89  if (this->getRows().empty() || this->getCols().empty()) {
90  typename std::vector<edm::Ref<edm::DetSetVector<Phase2TrackerDigi>, Phase2TrackerDigi> >::const_iterator hitIter;
91  for (hitIter = theHits.begin(); hitIter != theHits.end(); hitIter++) {
92  averageCol += (*hitIter)->column() + 0.5;
93  averageRow += (*hitIter)->row() + 0.5;
94  }
95  averageCol /= theHits.size();
96  averageRow /= theHits.size();
97  } else {
98  for (unsigned int j = 0; j < theHits.size(); j++) {
99  averageCol += theCols[j] + 0.5;
100  averageRow += theRows[j] + 0.5;
101  }
102  averageCol /= theHits.size();
103  averageRow /= theHits.size();
104  }
105  }
106  return MeasurementPoint(averageRow, averageCol);
107 }
108 
110 template <>
111 std::vector<int> TTCluster<edm::Ref<edm::DetSetVector<Phase2TrackerDigi>, Phase2TrackerDigi> >::findRows() const {
112  std::vector<int> temp;
113  temp.reserve(theHits.size());
114  for (unsigned int i = 0; i < theHits.size(); i++) {
115  temp.push_back(theHits[i]->row());
116  }
117  return temp;
118 }
119 
120 template <>
121 std::vector<int> TTCluster<edm::Ref<edm::DetSetVector<Phase2TrackerDigi>, Phase2TrackerDigi> >::findCols() const {
122  std::vector<int> temp;
123  temp.reserve(theHits.size());
124  for (unsigned int i = 0; i < theHits.size(); i++) {
125  temp.push_back(theHits[i]->column());
126  }
127  return temp;
128 }
unsigned int row() const
Measurement2DPoint MeasurementPoint
Measurement points are two-dimensional by default.
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
hitCont::const_iterator hitIter
NOTE: this is needed even if it seems not.
Definition: TTCluster.h:27
int col
Definition: cuy.py:1009