File indexing completed on 2024-11-15 23:40:42
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #include "L1Trigger/L1TMuonBarrel/src/L1MuBMWedgeSorter.h"
0021
0022
0023
0024
0025
0026 #include <iostream>
0027 #include <algorithm>
0028
0029
0030
0031
0032
0033 #include "L1Trigger/L1TMuonBarrel/interface/L1MuBMTFConfig.h"
0034 #include "L1Trigger/L1TMuonBarrel/interface/L1MuBMTrackFinder.h"
0035 #include "DataFormats/L1TMuon/interface/L1MuBMTrack.h"
0036 #include "DataFormats/L1TMuon/interface/BMTF/L1MuBMSecProcId.h"
0037 #include "L1Trigger/L1TMuonBarrel/src/L1MuBMSectorProcessor.h"
0038 #include "L1Trigger/L1TMuonBarrel/src/L1MuBMEtaProcessor.h"
0039
0040 using namespace std;
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050 L1MuBMWedgeSorter::L1MuBMWedgeSorter(const L1MuBMTrackFinder& tf, int id) : m_tf(tf), m_wsid(id), m_TrackCands(3) {
0051 m_TrackCands.reserve(3);
0052 }
0053
0054
0055
0056
0057
0058 L1MuBMWedgeSorter::~L1MuBMWedgeSorter() {}
0059
0060
0061
0062
0063
0064
0065
0066
0067 void L1MuBMWedgeSorter::run() {
0068
0069 vector<L1MuBMTrack*> wedgecands;
0070 wedgecands.reserve(12);
0071
0072 int sector = m_wsid;
0073 for (int wheel = -3; wheel <= 3; wheel++) {
0074 if (wheel == 0)
0075 continue;
0076 L1MuBMSecProcId tmpspid(wheel, sector);
0077 for (int number = 0; number < 2; number++) {
0078 const L1MuBMTrack& cand = m_tf.sp(tmpspid)->track(number);
0079 if (!cand.empty()) {
0080
0081
0082 bool reject = false;
0083 if (wheel == -1) {
0084 reject = true;
0085 for (int stat = 2; stat <= 4; stat++) {
0086 int adr = cand.address(stat);
0087
0088 if (adr != 15)
0089 reject &= ((adr / 2) % 2 == 0);
0090 }
0091 }
0092 if (!reject)
0093 wedgecands.push_back(const_cast<L1MuBMTrack*>(&cand));
0094 }
0095 }
0096 }
0097
0098
0099 if (m_tf.config().Debug(5)) {
0100 cout << "Wedge Sorter " << m_wsid << " input: " << wedgecands.size() << endl;
0101 vector<L1MuBMTrack*>::const_iterator iter;
0102 for (iter = wedgecands.begin(); iter != wedgecands.end(); iter++) {
0103 if (*iter)
0104 (*iter)->print();
0105 }
0106 }
0107
0108
0109 runCOL(wedgecands);
0110
0111
0112 vector<L1MuBMTrack*>::iterator it = wedgecands.begin();
0113 while (it != wedgecands.end()) {
0114 if (*it && (*it)->empty()) {
0115 wedgecands.erase(it);
0116 it = wedgecands.begin();
0117 continue;
0118 }
0119 it++;
0120 }
0121
0122
0123 partial_sort_copy(wedgecands.begin(), wedgecands.end(), m_TrackCands.begin(), m_TrackCands.end(), L1MuBMTrack::rank);
0124
0125 if (m_tf.config().Debug(4)) {
0126 cout << "Wedge Sorter " << m_wsid << " output: " << endl;
0127 vector<const L1MuBMTrack*>::const_iterator iter;
0128 for (iter = m_TrackCands.begin(); iter != m_TrackCands.end(); iter++) {
0129 if (*iter)
0130 (*iter)->print();
0131 }
0132 }
0133 }
0134
0135
0136
0137
0138 void L1MuBMWedgeSorter::reset() {
0139 vector<const L1MuBMTrack*>::iterator iter;
0140 for (iter = m_TrackCands.begin(); iter != m_TrackCands.end(); iter++) {
0141 *iter = nullptr;
0142 }
0143 }
0144
0145
0146
0147
0148 void L1MuBMWedgeSorter::print() const {
0149 if (anyTrack()) {
0150 cout << "Muon candidates found in Wedge Sorter " << m_wsid << " : " << endl;
0151 vector<const L1MuBMTrack*>::const_iterator iter = m_TrackCands.begin();
0152 while (iter != m_TrackCands.end()) {
0153 if (*iter)
0154 cout << *(*iter) << " found in " << (*iter)->spid() << endl;
0155 iter++;
0156 }
0157 }
0158 }
0159
0160
0161
0162
0163 bool L1MuBMWedgeSorter::anyTrack() const {
0164 vector<const L1MuBMTrack*>::const_iterator iter = m_TrackCands.begin();
0165 while (iter != m_TrackCands.end()) {
0166 if (*iter && !(*iter)->empty())
0167 return true;
0168 iter++;
0169 }
0170
0171 return false;
0172 }
0173
0174
0175
0176
0177 void L1MuBMWedgeSorter::runCOL(vector<L1MuBMTrack*>& cands) const {
0178
0179
0180
0181
0182
0183 typedef vector<L1MuBMTrack*>::iterator TI;
0184 for (TI iter1 = cands.begin(); iter1 != cands.end(); iter1++) {
0185 if (*iter1 == nullptr)
0186 continue;
0187 if ((*iter1)->empty())
0188 continue;
0189 L1MuBMSecProcId sp1 = (*iter1)->spid();
0190 int qual1 = (*iter1)->quality();
0191 for (TI iter2 = cands.begin(); iter2 != cands.end(); iter2++) {
0192 if (*iter2 == nullptr)
0193 continue;
0194 if (*iter1 == *iter2)
0195 continue;
0196 if ((*iter2)->empty())
0197 continue;
0198 L1MuBMSecProcId sp2 = (*iter2)->spid();
0199 int qual2 = (*iter2)->quality();
0200 if (sp1 == sp2)
0201 continue;
0202 if (!neighbour(sp1, sp2))
0203 continue;
0204 int adr_shift = (sp2.wheel() == -1) ? 0 : 2;
0205 int countTS = 0;
0206 for (int stat = 2; stat <= 4; stat++) {
0207 int adr1 = (*iter1)->address(stat);
0208 int adr2 = (*iter2)->address(stat);
0209 if (adr1 == 15 || adr2 == 15)
0210 continue;
0211 if ((adr2 / 2) % 2 == 1)
0212 continue;
0213 if (adr1 == adr2 + adr_shift)
0214 countTS++;
0215 }
0216 if (countTS > 0) {
0217 if (qual1 < qual2) {
0218 if (m_tf.config().Debug(5)) {
0219 cout << "Wedge Sorter cancel : ";
0220 (*iter1)->print();
0221 }
0222 (*iter1)->disable();
0223 break;
0224 } else {
0225 if (m_tf.config().Debug(5)) {
0226 cout << "Wedge Sorter cancel : ";
0227 (*iter2)->print();
0228 }
0229 (*iter2)->disable();
0230 }
0231 }
0232 }
0233 }
0234 }
0235
0236
0237
0238
0239 bool L1MuBMWedgeSorter::neighbour(const L1MuBMSecProcId& spid1, const L1MuBMSecProcId& spid2) {
0240
0241
0242
0243
0244 bool neigh = false;
0245
0246 int sector1 = spid1.sector();
0247 int wheel1 = spid1.wheel();
0248
0249 int sector2 = spid2.sector();
0250 int wheel2 = spid2.wheel();
0251
0252 if (sector1 == sector2) {
0253 if ((wheel1 == -2 && wheel2 == -3) || (wheel1 == -1 && wheel2 == -2) || (wheel1 == +1 && wheel2 == -1) ||
0254 (wheel1 == +1 && wheel2 == +2) || (wheel1 == +2 && wheel2 == +3))
0255 neigh = true;
0256 }
0257
0258 return neigh;
0259 }