File indexing completed on 2024-09-07 04:37:08
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include "L1Trigger/TrackTrigger/interface/TTClusterAlgorithm_official.h"
0011
0012
0013 template <>
0014 bool TTClusterAlgorithm_official<Ref_Phase2TrackerDigi_>::CompareClusters(const Ref_Phase2TrackerDigi_& a,
0015 const Ref_Phase2TrackerDigi_& b) {
0016 return (a->row() < b->row());
0017 }
0018
0019
0020 template <>
0021 void TTClusterAlgorithm_official<Ref_Phase2TrackerDigi_>::Cluster(
0022 std::vector<std::vector<Ref_Phase2TrackerDigi_> >& output,
0023 const std::vector<Ref_Phase2TrackerDigi_>& input,
0024 bool isPS) const {
0025
0026 output.clear();
0027
0028
0029 std::map<unsigned int, std::vector<Ref_Phase2TrackerDigi_> > mapHitsByColumn;
0030
0031
0032 typename std::vector<Ref_Phase2TrackerDigi_>::const_iterator inputIterator;
0033 inputIterator = input.begin();
0034 while (inputIterator != input.end()) {
0035 mapHitsByColumn[(**inputIterator).column()].push_back(*inputIterator);
0036 ++inputIterator;
0037 }
0038
0039
0040 std::map<std::pair<unsigned int, unsigned int>, std::vector<Ref_Phase2TrackerDigi_> > map1DCluByColRow;
0041
0042
0043 typename std::map<unsigned int, std::vector<Ref_Phase2TrackerDigi_> >::iterator mapIterHbC;
0044 mapIterHbC = mapHitsByColumn.begin();
0045 while (mapIterHbC != mapHitsByColumn.end()) {
0046
0047
0048 typename std::vector<Ref_Phase2TrackerDigi_>::iterator inputIterator;
0049 inputIterator = mapIterHbC->second.begin();
0050
0051
0052 while (inputIterator != mapIterHbC->second.end()) {
0053 std::vector<Ref_Phase2TrackerDigi_> temp;
0054 temp.push_back(*inputIterator);
0055 inputIterator = mapIterHbC->second.erase(inputIterator);
0056 typename std::vector<Ref_Phase2TrackerDigi_>::iterator inputIterator2;
0057 inputIterator2 = inputIterator;
0058
0059
0060 while (inputIterator2 != mapIterHbC->second.end()) {
0061
0062 if ((temp.back()->column() == (**inputIterator2).column()) &&
0063 ((**inputIterator2).row() - temp.back()->row() == 1)) {
0064 temp.push_back(*inputIterator2);
0065 inputIterator2 = mapIterHbC->second.erase(inputIterator2);
0066 } else
0067 break;
0068
0069 }
0070
0071
0072 std::sort(temp.begin(), temp.end(), CompareClusters);
0073
0074
0075 map1DCluByColRow.insert(std::make_pair(std::make_pair(mapIterHbC->first, temp.at(0)->row()), temp));
0076
0077 inputIterator = inputIterator2;
0078
0079 }
0080 ++mapIterHbC;
0081
0082 }
0083
0084
0085
0086 typename std::map<std::pair<unsigned int, unsigned int>, std::vector<Ref_Phase2TrackerDigi_> >::iterator
0087 mapIter1DCbCR0;
0088 typename std::map<std::pair<unsigned int, unsigned int>, std::vector<Ref_Phase2TrackerDigi_> >::iterator
0089 mapIter1DCbCR1;
0090 mapIter1DCbCR0 = map1DCluByColRow.begin();
0091 unsigned int lastCol = mapIter1DCbCR0->first.first;
0092
0093 while (mapIter1DCbCR0 != map1DCluByColRow.end()) {
0094
0095 std::vector<Ref_Phase2TrackerDigi_> candCluster;
0096 candCluster.insert(candCluster.end(), mapIter1DCbCR0->second.begin(), mapIter1DCbCR0->second.end());
0097
0098 if (isPS) {
0099
0100 mapIter1DCbCR1 = map1DCluByColRow.begin();
0101
0102 while (mapIter1DCbCR1 != map1DCluByColRow.end()) {
0103
0104 if (mapIter1DCbCR1 == mapIter1DCbCR0) {
0105 ++mapIter1DCbCR1;
0106 continue;
0107 }
0108
0109
0110 if (std::abs((int)(mapIter1DCbCR1->first.first) - (int)lastCol) != 1) {
0111 ++mapIter1DCbCR1;
0112 continue;
0113 }
0114
0115
0116
0117
0118 lastCol = mapIter1DCbCR1->first.first;
0119
0120
0121
0122 unsigned int iRow0 = mapIter1DCbCR0->first.second;
0123 unsigned int iRow1 = mapIter1DCbCR1->first.second;
0124
0125
0126 unsigned int jRow0 = mapIter1DCbCR0->second.back()->row();
0127 unsigned int jRow1 = mapIter1DCbCR1->second.back()->row();
0128
0129
0130 if ((iRow1 >= iRow0 && iRow1 <= jRow0) || (jRow1 >= iRow0 && jRow1 <= jRow0)) {
0131
0132 candCluster.insert(candCluster.end(), mapIter1DCbCR1->second.begin(), mapIter1DCbCR1->second.end());
0133 map1DCluByColRow.erase(mapIter1DCbCR1++);
0134 } else {
0135 ++mapIter1DCbCR1;
0136 }
0137 }
0138
0139 map1DCluByColRow.erase(mapIter1DCbCR0++);
0140
0141
0142
0143 std::sort(candCluster.begin(), candCluster.end(), CompareClusters);
0144
0145
0146
0147
0148
0149
0150
0151 if (std::abs(static_cast<int>(candCluster.at(0)->row() - candCluster.back()->row())) <
0152 mWidthCut ||
0153 mWidthCut < 1) {
0154 output.push_back(candCluster);
0155 }
0156 }
0157 else {
0158 map1DCluByColRow.erase(mapIter1DCbCR0++);
0159
0160
0161
0162 std::sort(candCluster.begin(), candCluster.end(), CompareClusters);
0163
0164 if (std::abs(static_cast<int>(candCluster.at(0)->row() - candCluster.back()->row())) <
0165 mWidthCut ||
0166 mWidthCut < 1) {
0167 output.push_back(candCluster);
0168 }
0169 }
0170 }
0171 }