CMS 3D CMS Logo

TTClusterAlgorithm_official.cc
Go to the documentation of this file.
1 
11 
13 template <>
15  const Ref_Phase2TrackerDigi_& b) {
16  return (a->row() < b->row());
17 }
18 
20 template <>
22  std::vector<std::vector<Ref_Phase2TrackerDigi_> >& output,
23  const std::vector<Ref_Phase2TrackerDigi_>& input,
24  bool isPS) const {
26  output.clear();
27 
29  std::map<unsigned int, std::vector<Ref_Phase2TrackerDigi_> > mapHitsByColumn;
30 
32  typename std::vector<Ref_Phase2TrackerDigi_>::const_iterator inputIterator;
33  inputIterator = input.begin();
34  while (inputIterator != input.end()) {
35  mapHitsByColumn[(**inputIterator).column()].push_back(*inputIterator);
36  ++inputIterator;
37  }
38 
40  std::map<std::pair<unsigned int, unsigned int>, std::vector<Ref_Phase2TrackerDigi_> > map1DCluByColRow;
41 
43  typename std::map<unsigned int, std::vector<Ref_Phase2TrackerDigi_> >::iterator mapIterHbC;
44  mapIterHbC = mapHitsByColumn.begin();
45  while (mapIterHbC != mapHitsByColumn.end()) {
48  typename std::vector<Ref_Phase2TrackerDigi_>::iterator inputIterator;
49  inputIterator = mapIterHbC->second.begin();
50 
52  while (inputIterator != mapIterHbC->second.end()) {
53  std::vector<Ref_Phase2TrackerDigi_> temp;
54  temp.push_back(*inputIterator);
55  inputIterator = mapIterHbC->second.erase(inputIterator);
56  typename std::vector<Ref_Phase2TrackerDigi_>::iterator inputIterator2;
57  inputIterator2 = inputIterator;
58 
60  while (inputIterator2 != mapIterHbC->second.end()) {
62  if ((temp.back()->column() == (**inputIterator2).column()) &&
63  ((**inputIterator2).row() - temp.back()->row() == 1)) {
64  temp.push_back(*inputIterator2);
65  inputIterator2 = mapIterHbC->second.erase(inputIterator2);
66  } else
67  break;
68 
69  }
70 
72  std::sort(temp.begin(), temp.end(), CompareClusters);
73 
75  map1DCluByColRow.insert(std::make_pair(std::make_pair(mapIterHbC->first, temp.at(0)->row()), temp));
76 
77  inputIterator = inputIterator2;
78 
79  }
80  ++mapIterHbC;
81 
82  }
83 
86  typename std::map<std::pair<unsigned int, unsigned int>, std::vector<Ref_Phase2TrackerDigi_> >::iterator
87  mapIter1DCbCR0;
88  typename std::map<std::pair<unsigned int, unsigned int>, std::vector<Ref_Phase2TrackerDigi_> >::iterator
89  mapIter1DCbCR1;
90  mapIter1DCbCR0 = map1DCluByColRow.begin();
91  unsigned int lastCol = mapIter1DCbCR0->first.first;
92 
93  while (mapIter1DCbCR0 != map1DCluByColRow.end()) {
95  std::vector<Ref_Phase2TrackerDigi_> candCluster;
96  candCluster.insert(candCluster.end(), mapIter1DCbCR0->second.begin(), mapIter1DCbCR0->second.end());
97 
98  if (isPS) {
100  mapIter1DCbCR1 = map1DCluByColRow.begin();
101 
102  while (mapIter1DCbCR1 != map1DCluByColRow.end()) {
104  if (mapIter1DCbCR1 == mapIter1DCbCR0) {
105  ++mapIter1DCbCR1;
106  continue;
107  }
108 
110  if (std::abs((int)(mapIter1DCbCR1->first.first) - (int)lastCol) != 1) {
111  ++mapIter1DCbCR1;
112  continue;
113  }
114 
118  lastCol = mapIter1DCbCR1->first.first;
119 
122  unsigned int iRow0 = mapIter1DCbCR0->first.second;
123  unsigned int iRow1 = mapIter1DCbCR1->first.second;
124 
126  unsigned int jRow0 = mapIter1DCbCR0->second.back()->row();
127  unsigned int jRow1 = mapIter1DCbCR1->second.back()->row();
128 
130  if ((iRow1 >= iRow0 && iRow1 <= jRow0) || (jRow1 >= iRow0 && jRow1 <= jRow0)) {
132  candCluster.insert(candCluster.end(), mapIter1DCbCR1->second.begin(), mapIter1DCbCR1->second.end());
133  map1DCluByColRow.erase(mapIter1DCbCR1++);
134  } else {
135  ++mapIter1DCbCR1;
136  }
137  }
138 
139  map1DCluByColRow.erase(mapIter1DCbCR0++);
140 
143  std::sort(candCluster.begin(), candCluster.end(), CompareClusters);
144  /*
145  std::cout << candCluster.at(0)->row() - candCluster.back()->row() << " / "
146  << static_cast<int>(candCluster.at(0)->row() - candCluster.back()->row()) << " / "
147  << abs( candCluster.at(0)->row() - candCluster.back()->row() ) << " / "
148  << std::abs( candCluster.at(0)->row() - candCluster.back()->row() ) << " / "
149  << mWidthCut << std::endl;
150  */
151  if (std::abs(static_cast<int>(candCluster.at(0)->row() - candCluster.back()->row())) <
152  mWidthCut ||
153  mWidthCut < 1) {
154  output.push_back(candCluster);
155  }
156  }
157  else {
158  map1DCluByColRow.erase(mapIter1DCbCR0++);
159 
162  std::sort(candCluster.begin(), candCluster.end(), CompareClusters);
163 
164  if (std::abs(static_cast<int>(candCluster.at(0)->row() - candCluster.back()->row())) <
165  mWidthCut ||
166  mWidthCut < 1) {
167  output.push_back(candCluster);
168  }
169  }
170  }
171 }
TTClusterAlgorithm_official::Cluster
void Cluster(std::vector< std::vector< T > > &output, const std::vector< T > &input, bool isPS) const override
Clustering operations.
input
static const std::string input
Definition: EdmProvDump.cc:48
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:32
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
edm::Ref
Definition: AssociativeIterator.h:58
TTClusterAlgorithm_official.h
b
double b
Definition: hdecay.h:118
a
double a
Definition: hdecay.h:119
TTClusterAlgorithm_official::CompareClusters
static bool CompareClusters(const T &a, const T &b)
Cluster max width.
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22