CMS 3D CMS Logo

TPSAlgorithm.cc
Go to the documentation of this file.
2 
3 using namespace Phase2L1GMT;
4 
5 TPSAlgorithm::TPSAlgorithm(const edm::ParameterSet& iConfig) : verbose_(iConfig.getParameter<int>("verbose")) {}
6 
7 std::vector<PreTrackMatchedMuon> TPSAlgorithm::processNonant(const std::vector<ConvertedTTTrack>& convertedTracks,
8  const l1t::MuonStubRefVector& stubs) const {
9  std::vector<PreTrackMatchedMuon> preMuons;
10  for (const auto& track : convertedTracks) {
12  if (mu.valid() && preMuons.size() < 16)
13  preMuons.push_back(mu);
14  }
15  std::vector<PreTrackMatchedMuon> cleanedMuons = clean(preMuons);
16  return cleanedMuons;
17 }
18 
19 std::vector<PreTrackMatchedMuon> TPSAlgorithm::cleanNeighbor(const std::vector<PreTrackMatchedMuon>& muons,
20  const std::vector<PreTrackMatchedMuon>& muonsPrevious,
21  const std::vector<PreTrackMatchedMuon>& muonsNext,
22  bool equality) const {
23  std::vector<PreTrackMatchedMuon> out;
24 
25  if (muons.empty())
26  return out;
27 
28  if (verbose_ == 1) {
29  edm::LogInfo("TPSAlgo") << "-----Cleaning Up Muons in the neighbours";
30  edm::LogInfo("TPSAlgo") << "Before:";
31  }
32 
33  for (uint i = 0; i < muons.size(); ++i) {
34  if (verbose_ == 1) {
35  muons[i].print();
36  }
37  ap_uint<5> mask = 0x1f;
38  for (uint j = 0; j < muonsPrevious.size(); ++j) {
39  mask = mask & cleanMuon(muons[i], muonsPrevious[j], equality);
40  }
41  for (uint j = 0; j < muonsNext.size(); ++j) {
42  mask = mask & cleanMuon(muons[i], muonsNext[j], equality);
43  }
44  if (mask) {
45  if (verbose_ == 1)
46  edm::LogInfo("TPSAlgo") << "kept";
47  out.push_back(muons[i]);
48  } else {
49  if (verbose_ == 1)
50  edm::LogInfo("TPSAlgo") << "discarded";
51  }
52  }
53  return out;
54 }
55 
56 std::vector<l1t::TrackerMuon> TPSAlgorithm::convert(const std::vector<PreTrackMatchedMuon>& muons, uint maximum) const {
57  std::vector<l1t::TrackerMuon> out;
58  for (const auto& mu : muons) {
59  if (out.size() == maximum)
60  break;
61  l1t::TrackerMuon muon(mu.trkPtr(), mu.charge(), mu.pt(), mu.eta(), mu.phi(), mu.z0(), mu.d0(), mu.quality());
62  muon.setMuonRef(mu.muonRef());
63  for (const auto& stub : mu.stubs())
64  muon.addStub(stub);
65 
66  uint matches = 0;
67  uint mask = mu.matchMask();
68 
69  for (uint i = 0; i < 10; i = i + 1) {
70  if (mask & (1 << i))
71  matches++;
72  }
73  muon.setNumberOfMatches(matches);
74  out.push_back(muon);
75 
76  if (verbose_ == 1) {
77  edm::LogInfo("TPSAlgo") << "Final Muon:" << std::flush;
78  muon.print();
79  }
80  }
81  return out;
82 }
83 
84 void TPSAlgorithm::SetQualityBits(std::vector<l1t::TrackerMuon>& muons) const {
85  for (auto& mu : muons) {
86  // A preliminary suggestion. Need feedback from the menu group
87  bool veryloose = mu.numberOfMatches() > 0;
88  bool loose = mu.numberOfMatches() > 1;
89  bool medium = mu.stubs().size() > 1;
90  bool tight = mu.numberOfMatches() > 2;
91  int qualbit = 0;
92  qualbit = (veryloose << 0) | (loose << 1) | (medium << 2) | (tight << 3);
93  mu.setHwQual(qualbit);
94  }
95 }
96 
97 bool TPSAlgorithm::outputGT(std::vector<l1t::TrackerMuon>& muons) const {
98  for (auto& mu : muons) {
99  wordtype word1 = 0;
100  wordtype word2 = 0;
101 
102  int bstart = 0;
103  bstart = wordconcat<wordtype>(word1, bstart, mu.hwPt() > 0, 1);
104  bstart = wordconcat<wordtype>(word1, bstart, mu.hwPt(), BITSGTPT);
105  bstart = wordconcat<wordtype>(word1, bstart, mu.hwPhi(), BITSGTPHI);
106  bstart = wordconcat<wordtype>(word1, bstart, mu.hwEta(), BITSGTETA);
107  bstart = wordconcat<wordtype>(word1, bstart, mu.hwZ0(), BITSGTZ0);
108  wordconcat<wordtype>(word1, bstart, (mu.hwD0() >> 2), BITSGTD0);
109 
110  bstart = 0;
111  bstart = wordconcat<wordtype>(word2, bstart, mu.hwCharge(), 1);
112  bstart = wordconcat<wordtype>(word2, bstart, mu.hwQual(), BITSGTQUAL);
113  bstart = wordconcat<wordtype>(word2, bstart, mu.hwIso(), BITSGTISO);
114  wordconcat<wordtype>(word2, bstart, mu.hwBeta(), BITSGTBETA);
115 
116  std::array<uint64_t, 2> wordout = {{word1, word2}};
117  mu.setWord(wordout);
118  }
119  return true;
120 }
121 
122 std::vector<l1t::TrackerMuon> TPSAlgorithm::sort(std::vector<l1t::TrackerMuon>& muons, uint maximum) const {
123  if (muons.size() < 2)
124  return muons;
125 
126  std::sort(muons.begin(), muons.end(), [](l1t::TrackerMuon a, l1t::TrackerMuon b) { return a.hwPt() > b.hwPt(); });
127  std::vector<l1t::TrackerMuon> out{muons.begin(), muons.begin() + (maximum < muons.size() ? maximum : muons.size())};
128 
129  return out;
130 }
131 
133  static const std::array<const ap_uint<BITSPROPCOORD>*, 5> lt_prop_coord1 = {
135  static const std::array<const ap_uint<BITSPROPCOORD>*, 5> lt_prop_coord2 = {
137 
138  static const std::array<const ap_uint<BITSPROPSIGMACOORD_A>*, 5> lt_res0_coord1 = {
140  static const std::array<const ap_uint<BITSPROPSIGMACOORD_B>*, 5> lt_res1_coord1 = {
142  static const std::array<const ap_uint<BITSPROPSIGMACOORD_A>*, 5> lt_res0_coord2 = {
144  static const std::array<const ap_uint<BITSPROPSIGMACOORD_B>*, 5> lt_res1_coord2 = {
146 
147  static const std::array<const ap_uint<BITSPROPSIGMAETA_A>*, 5> lt_res0_eta1 = {
149  static const std::array<const ap_uint<BITSPROPSIGMAETA_A>*, 5> lt_res1_eta1 = {
151 
152  static const std::array<const ap_uint<BITSPROPSIGMAETA_A>*, 5> lt_res0_eta2 = {
154 
155  static const uint barrellimit[5] = {barrelLimit0_, barrelLimit1_, barrelLimit2_, barrelLimit3_, barrelLimit4_};
156 
157  ap_uint<BITSPROPCOORD> prop_coord1 = 0;
158  ap_uint<BITSPROPCOORD> prop_coord2 = 0;
159  ap_uint<BITSPROPSIGMACOORD_A> res0_coord1 = 0;
160  ap_uint<BITSPROPSIGMACOORD_B> res1_coord1 = 0;
161  ap_uint<BITSPROPSIGMACOORD_A> res0_coord2 = 0;
162  ap_uint<BITSPROPSIGMACOORD_B> res1_coord2 = 0;
163  ap_uint<BITSPROPSIGMAETA_A> res0_eta1 = 0;
164  ap_uint<BITSPROPSIGMAETA_B> res1_eta = 0;
165  ap_uint<BITSPROPSIGMAETA_A> res0_eta2 = 0;
166  ap_uint<1> is_barrel = 0;
167 
168  uint reducedAbsEta = track.abseta() / 8;
169 
170  //Propagate to layers
171  assert(layer < 5);
172  prop_coord1 = lt_prop_coord1[layer][reducedAbsEta];
173  prop_coord2 = lt_prop_coord2[layer][reducedAbsEta];
174  res0_coord1 = lt_res0_coord1[layer][reducedAbsEta];
175  res1_coord1 = lt_res1_coord1[layer][reducedAbsEta];
176  res0_coord2 = lt_res0_coord2[layer][reducedAbsEta];
177  res1_coord2 = lt_res1_coord2[layer][reducedAbsEta];
178  res0_eta1 = lt_res0_eta1[layer][reducedAbsEta];
179  res1_eta = lt_res1_eta1[layer][reducedAbsEta];
180  res0_eta2 = lt_res0_eta2[layer][reducedAbsEta];
181  is_barrel = reducedAbsEta < barrellimit[layer] ? 1 : 0;
182 
184  ap_int<BITSTTCURV> curvature = track.curvature();
185  ap_int<BITSPHI> phi = track.phi();
186  ap_int<BITSPROPCOORD + BITSTTCURV> c1kFull = prop_coord1 * curvature;
187  ap_int<BITSPROPCOORD + BITSTTCURV - 10> c1k = (c1kFull) / 1024;
188  ap_int<BITSPHI> coord1 = phi - c1k;
189 
190  out.coord1 = coord1 / PHIDIVIDER;
191 
192  ap_int<BITSPROPCOORD + BITSTTCURV> c2kFull = prop_coord2 * curvature;
193 
194  ap_int<BITSPROPCOORD + BITSTTCURV - 10> c2k = (c2kFull) / 1024;
195  if (is_barrel)
196  out.coord2 = -c2k / PHIDIVIDER;
197  else
198  out.coord2 = (phi - c2k) / PHIDIVIDER;
199 
200  ap_int<BITSETA> eta = track.eta();
201  out.eta = eta / ETADIVIDER;
202 
203  ap_uint<2 * BITSTTCURV - 2> curvature2All = curvature * curvature;
204  ap_uint<BITSTTCURV2> curvature2 = curvature2All / 2;
205 
207  ap_uint<BITSTTCURV - 1> absK = 0;
208  if (track.curvature() < 0)
209  absK = ap_uint<BITSTTCURV - 1>(-track.curvature());
210  else
211  absK = ap_uint<BITSTTCURV - 1>(track.curvature());
212 
213  //bound the resolution propagation
214  if (absK > 6000)
215  absK = 6000;
216 
217  ap_uint<BITSPROPSIGMACOORD_B + BITSTTCURV - 1> s1kFull = res1_coord1 * absK;
218  ap_uint<BITSPROPSIGMACOORD_B + BITSTTCURV - 1 - 10> s1k = s1kFull / 1024;
219  ap_uint<BITSPROPSIGMACOORD_A + BITSPROPSIGMACOORD_B + BITSTTCURV - 1 - 10> sigma1 = res0_coord1 + s1k;
220  out.sigma_coord1 = ap_uint<BITSSIGMACOORD>(sigma1 / PHIDIVIDER);
221 
222  ap_uint<BITSPROPSIGMACOORD_B + BITSTTCURV - 1> s2kFull = res1_coord2 * absK;
223  ap_uint<BITSPROPSIGMACOORD_B + BITSTTCURV - 1 - 10> s2k = s2kFull / 1024;
224  ap_uint<BITSPROPSIGMACOORD_A + BITSPROPSIGMACOORD_B + BITSTTCURV - 1 - 10> sigma2 = res0_coord2 + s2k;
225  out.sigma_coord2 = ap_uint<BITSSIGMACOORD>(sigma2 / PHIDIVIDER);
226 
227  ap_uint<BITSPROPSIGMAETA_B + BITSTTCURV2> resetak = (res1_eta * curvature2) >> 23;
228  ap_ufixed<BITSSIGMAETA, BITSSIGMAETA, AP_TRN_ZERO, AP_SAT_SYM> sigma_eta1 = res0_eta1 + resetak;
229  out.sigma_eta1 = ap_uint<BITSSIGMAETA>(sigma_eta1);
230  ap_ufixed<BITSSIGMAETA, BITSSIGMAETA, AP_TRN_ZERO, AP_SAT_SYM> sigma_eta2 = res0_eta2 + resetak;
231  out.sigma_eta2 = ap_uint<BITSSIGMAETA>(sigma_eta2);
232  out.valid = 1;
233  out.is_barrel = is_barrel;
234 
235  if (verbose_ == 1) {
236  edm::LogInfo("TPSAlgo") << "Propagating to layer " << int(layer) << ":is barrel=" << out.is_barrel.to_int()
237  << " coords=" << out.coord1.to_int() << "+-" << out.sigma_coord1.to_int() << " , "
238  << out.coord2.to_int() << " +-" << out.sigma_coord2.to_int()
239  << " etas = " << out.eta.to_int() << " +- " << out.sigma_eta1.to_int() << " +-"
240  << out.sigma_eta2.to_int();
241 
242  edm::LogInfo("TPSAlgo") << "----- breakout of sigma 1 : constant=" << res0_coord1.to_int()
243  << " slope=" << res1_coord1.to_int() << " before division=" << s1k.to_int();
244 
245  edm::LogInfo("TPSAlgo") << "----- breakout of sigma 2 : constant=" << res0_coord2.to_int()
246  << " slope=" << res1_coord2.to_int() << " before division=" << s2k.to_int();
247  }
248  return out;
249 }
250 
251 ap_uint<BITSSIGMAETA + 1> TPSAlgorithm::deltaEta(const ap_int<BITSSTUBETA>& eta1,
252  const ap_int<BITSSTUBETA>& eta2) const {
253  ap_fixed<BITSSIGMAETA + 2, BITSSIGMAETA + 2, AP_TRN_ZERO, AP_SAT_SYM> dEta = eta1 - eta2;
254  if (dEta < 0)
255  return ap_uint<BITSSIGMAETA + 1>(-dEta);
256  else
257  return ap_uint<BITSSIGMAETA + 1>(dEta);
258 }
259 
260 ap_uint<BITSSIGMACOORD + 1> TPSAlgorithm::deltaCoord(const ap_int<BITSSTUBCOORD>& phi1,
261  const ap_int<BITSSTUBCOORD>& phi2) const {
262  ap_int<BITSSTUBCOORD> dPhiRoll = phi1 - phi2;
263  ap_ufixed<BITSSIGMACOORD + 1, BITSSIGMACOORD + 1, AP_TRN_ZERO, AP_SAT_SYM> dPhi;
264  if (dPhiRoll < 0)
265  dPhi = ap_ufixed<BITSSIGMACOORD + 1, BITSSIGMACOORD + 1, AP_TRN_ZERO, AP_SAT_SYM>(-dPhiRoll);
266  else
267  dPhi = ap_ufixed<BITSSIGMACOORD + 1, BITSSIGMACOORD + 1, AP_TRN_ZERO, AP_SAT_SYM>(dPhiRoll);
268 
269  return ap_uint<BITSSIGMACOORD + 1>(dPhi);
270 }
271 
272 match_t TPSAlgorithm::match(const propagation_t prop, const l1t::MuonStubRef& stub, uint trackID) const {
273  if (verbose_ == 1) {
274  edm::LogInfo("TPSAlgo") << "Matching to coord1=" << stub->coord1() << " coord2=" << stub->coord2()
275  << " eta1=" << stub->eta1() << " eta2=" << stub->eta2();
276 
277  stub->print();
278  }
279  //Matching of Coord1
280  ap_uint<1> coord1Matched;
281  ap_uint<BITSSIGMACOORD + 1> deltaCoord1 = deltaCoord(prop.coord1, stub->coord1());
282  if (deltaCoord1 <= prop.sigma_coord1 && (stub->quality() & 0x1)) {
283  coord1Matched = 1;
284  } else {
285  coord1Matched = 0;
286  }
287  if (verbose_ == 1)
288  edm::LogInfo("TPSAlgo") << "Coord1 matched=" << coord1Matched.to_int() << " delta=" << deltaCoord1.to_int()
289  << " res=" << prop.sigma_coord1.to_int();
290 
291  //Matching of Coord2
292  ap_uint<1> coord2Matched;
293  ap_uint<BITSSIGMACOORD + 1> deltaCoord2 = deltaCoord(prop.coord2, stub->coord2());
294  if (deltaCoord2 <= prop.sigma_coord2 && (stub->quality() & 0x2)) {
295  coord2Matched = 1;
296  } else {
297  coord2Matched = 0;
298  }
299  if (verbose_ == 1)
300  edm::LogInfo("TPSAlgo") << "Coord2 matched=" << coord2Matched.to_int() << " delta=" << deltaCoord2.to_int()
301  << " res=" << prop.sigma_coord2.to_int();
302 
303  //Matching of Eta1
304 
305  ap_uint<1> eta1Matched;
306 
307  //if we have really bad quality[Barrel no eta]
308  //increase the resolution
309  ap_ufixed<BITSSIGMAETA, BITSSIGMAETA, AP_TRN_ZERO, AP_SAT_SYM> prop_sigma_eta1;
310  if (stub->etaQuality() == 0)
311  prop_sigma_eta1 = prop.sigma_eta1 + 6;
312  else
313  prop_sigma_eta1 = prop.sigma_eta1;
314 
315  ap_uint<BITSSIGMAETA + 1> deltaEta1 = deltaEta(prop.eta, stub->eta1());
316  if (deltaEta1 <= prop_sigma_eta1 && (stub->etaQuality() == 0 || (stub->etaQuality() & 0x1)))
317  eta1Matched = 1;
318  else
319  eta1Matched = 0;
320 
321  if (verbose_ == 1)
322  edm::LogInfo("TPSAlgo") << "eta1 matched=" << eta1Matched.to_int() << " delta=" << deltaEta1.to_int()
323  << " res=" << prop_sigma_eta1.to_int();
324 
325  //Matching of Eta2
326 
327  ap_uint<1> eta2Matched;
328 
329  ap_uint<BITSSIGMAETA + 1> deltaEta2 = deltaEta(prop.eta, stub->eta2());
330  if (deltaEta2 <= prop.sigma_eta2 && (stub->etaQuality() & 0x2))
331  eta2Matched = 1;
332  else
333  eta2Matched = 0;
334  match_t out;
335  out.id = trackID;
336 
337  if (verbose_ == 1)
338  edm::LogInfo("TPSAlgo") << "eta2 matched=" << eta2Matched.to_int() << " delta=" << deltaEta2.to_int()
339  << " res=" << prop.sigma_eta2.to_int();
340 
341  //Note I divided by 4 because of the new coordinate. Make it automatic
342 
343  //if barrel, coord1 has to always be matched, coord2 maybe and eta1 is needed if etaQ=0 or then the one that depends on eta quality
344  if (prop.is_barrel) {
345  out.valid = (coord1Matched == 1 && (eta1Matched == 1 || eta2Matched == 1)) ? 1 : 0;
346  if (out.valid == 0) {
347  out.quality = 0;
348  } else {
349  out.quality = 32 - deltaCoord1 / 4;
350  if (coord2Matched == 1) {
351  out.quality += 32 - deltaCoord2 / 4;
352  out.valid = 3;
353  }
354  }
355  }
356  //if endcap each coordinate is independent except the case where phiQuality=1 and etaQuality==3
357  else {
358  bool match1 = (coord1Matched == 1 && eta1Matched == 1);
359  bool match2 = (coord2Matched == 1 && eta2Matched == 1);
360  bool match3 =
361  (coord1Matched == 1 && (eta1Matched || eta2Matched) && stub->etaQuality() == 3 && stub->quality() == 1);
362  out.valid = (match1 || match2 || match3) ? 1 : 0;
363  if (out.valid == 0)
364  out.quality = 0;
365  else {
366  out.quality = 0;
367  if (match1 || match3)
368  out.quality += 32 - deltaCoord1 / 4;
369  if (match2) {
370  out.quality += 32 - deltaCoord2 / 4;
371  if (match1 || match3)
372  out.valid = 3;
373  }
374  }
375  }
376  if (verbose_ == 1)
377  edm::LogInfo("TPSAlgo") << "GlobalMatchQuality = " << out.quality.to_int();
378  out.stubRef = stub;
379  return out;
380 }
381 
383  const l1t::MuonStubRef& stub,
384  uint trackID) const {
385  propagation_t prop = propagate(track, stub->tfLayer());
386  return match(prop, stub, trackID);
387 }
388 
389 match_t TPSAlgorithm::getBest(const std::vector<match_t>& matches) const {
390  match_t best = matches[0];
391  for (const auto& m : matches) {
392  if (m.quality > best.quality)
393  best = m;
394  }
395 
396  return best;
397 }
398 
399 void TPSAlgorithm::matchingInfos(const std::vector<match_t>& matchInfo,
401  ap_uint<BITSMATCHQUALITY>& quality) const {
402  if (!matchInfo.empty()) {
403  match_t b = getBest(matchInfo);
404  if (b.valid != 0) {
405  muon.addStub(b.stubRef, b.valid);
406  if (b.isGlobal)
407  muon.addMuonRef(b.muRef);
408  quality += b.quality;
409  }
410  }
411 }
412 
414  const l1t::MuonStubRefVector& stubs) const {
415  std::array<std::vector<match_t>, 6> matchInfos;
416 
417  if (verbose_ == 1 && !stubs.empty()) {
418  edm::LogInfo("TPSAlgo") << "-----------processing new track----------";
419  track.print();
420  }
421  for (const auto& stub : stubs) {
422  match_t m = propagateAndMatch(track, stub, 0);
423  if (m.valid != 0 && stub->tfLayer() < 6) {
424  matchInfos[stub->tfLayer()].push_back(m);
425  }
426  }
427 
428  ap_ufixed<6, 6, AP_TRN_ZERO, AP_SAT_SYM> ptPenalty = ap_ufixed<6, 6, AP_TRN_ZERO, AP_SAT_SYM>(track.pt() / 32);
429 
430  ap_uint<BITSMATCHQUALITY> quality = 0;
431  PreTrackMatchedMuon muon(track.charge(), track.pt(), track.eta(), track.phi(), track.z0(), track.d0());
432 
433  for (auto&& m : matchInfos)
435 
436  muon.setOfflineQuantities(track.offline_pt(), track.offline_eta(), track.offline_phi());
437  muon.setTrkPtr(track.trkPtr());
438 
439  ap_uint<8> etaAddr = muon.eta() < 0 ? ap_uint<8>(-muon.eta() / 256) : ap_uint<8>((muon.eta()) / 256);
440  ap_uint<8> ptAddr = muon.pt() > 4095 ? ap_uint<8>(15) : ap_uint<8>(muon.pt() / 256);
441  ap_uint<8> addr = ptAddr | (etaAddr << 4);
442  ap_uint<8> qualityCut = lt_tpsID[addr];
443 
444  if (!muon.stubs().empty()) { //change the ID for now
445  muon.setValid(true);
446  muon.setQuality(quality + ptPenalty);
447  } else {
448  muon.setValid(false);
449  muon.setQuality(0);
450  muon.resetGlobal();
451  }
452  if (verbose_ == 1)
453  muon.print();
454 
455  if (verbose_ == 1 && !stubs.empty()) { //patterns for HLS
456 
457  edm::LogInfo("TPSAlgo") << "TPS " << track.trkPtr()->phiSector() << std::flush;
458  track.printWord();
459 
460  for (uint i = 0; i < 16; ++i) {
461  if (stubs.size() > i) {
462  edm::LogInfo("TPSAlgo") << "remember to implement printout of muon";
463  } else {
464  edm::LogInfo("TPSAlgo") << std::hex << std::setw(8) << 0 << std::flush;
465  edm::LogInfo("TPSAlgo") << std::hex << std::setw(16) << 0x1ff000000000000 << std::flush;
466  edm::LogInfo("TPSAlgo") << std::hex << std::setw(16) << 0x1ff000000000000 << std::flush;
467  edm::LogInfo("TPSAlgo") << std::hex << std::setw(16) << 0x1ff000000000000 << std::flush;
468  edm::LogInfo("TPSAlgo") << std::hex << std::setw(16) << 0x1ff000000000000 << std::flush;
469  edm::LogInfo("TPSAlgo") << std::hex << std::setw(16) << 0x1ff000000000000 << std::flush;
470  }
471  }
472  muon.printWord();
473  edm::LogInfo("TPSAlgo") << std::endl;
474  }
475  return muon;
476 }
477 
478 ap_uint<5> TPSAlgorithm::cleanMuon(const PreTrackMatchedMuon& mu, const PreTrackMatchedMuon& other, bool eq) const {
479  ap_uint<5> valid = 0;
480  ap_uint<5> overlap = 0;
481  constexpr int bittest = 0xfff; // 4095, corresponding to 11bits
482  if (mu.stubID0() != bittest) {
483  valid = valid | 0x1;
484  if (mu.stubID0() == other.stubID0())
485  overlap = overlap | 0x1;
486  }
487  if (mu.stubID1() != bittest) {
488  valid = valid | 0x2;
489  if (mu.stubID1() == other.stubID1())
490  overlap = overlap | 0x2;
491  }
492  if (mu.stubID2() != bittest) {
493  valid = valid | 0x4;
494  if (mu.stubID2() == other.stubID2())
495  overlap = overlap | 0x4;
496  }
497  if (mu.stubID3() != bittest) {
498  valid = valid | 0x8;
499  if (mu.stubID3() == other.stubID3())
500  overlap = overlap | 0x8;
501  }
502  if (mu.stubID4() != bittest) {
503  valid = valid | 0x10;
504  if (mu.stubID4() == other.stubID4())
505  overlap = overlap | 0x10;
506  }
507 
508  if (((mu.quality() < other.quality()) && (!eq)) || ((mu.quality() <= other.quality()) && (eq)))
509  return valid & (~overlap);
510  else
511  return valid;
512 }
513 
514 std::vector<PreTrackMatchedMuon> TPSAlgorithm::clean(const std::vector<PreTrackMatchedMuon>& muons) const {
515  std::vector<PreTrackMatchedMuon> out;
516  if (muons.empty())
517  return out;
518  if (verbose_ == 1) {
519  edm::LogInfo("TPSAlgo") << "-----Cleaning Up Muons in the same Nonant";
520  edm::LogInfo("TPSAlgo") << "Before:";
521  }
522  for (uint i = 0; i < muons.size(); ++i) {
523  if (verbose_ == 1)
524  muons[i].print();
525 
526  ap_uint<5> mask = 0x1f;
527  for (uint j = 0; j < muons.size(); ++j) {
528  if (i == j)
529  continue;
530  mask = mask & cleanMuon(muons[i], muons[j], false);
531  }
532  if (mask) {
533  if (verbose_ == 1)
534  edm::LogInfo("TPSAlgo") << "kept";
535  out.push_back(muons[i]);
536  } else {
537  if (verbose_ == 1)
538  edm::LogInfo("TPSAlgo") << "discarded";
539  }
540  }
541  return out;
542 }
const ap_uint< BITSPROPSIGMACOORD_A > lt_res0_coord1_3[512]
Definition: TPSLUTs.h:655
const ap_uint< BITSPROPSIGMACOORD_B > lt_res1_coord2_0[512]
Definition: TPSLUTs.h:891
const int barrelLimit0_
Definition: Constants.h:85
const ap_uint< BITSPROPSIGMACOORD_B > lt_res1_coord2_4[512]
Definition: TPSLUTs.h:971
ap_uint< BITSSIGMACOORD > sigma_coord1
Definition: TPSAlgorithm.h:25
const int BITSGTZ0
Definition: Constants.h:63
const int barrelLimit1_
Definition: Constants.h:86
ap_uint< BITSSIGMAETA+1 > deltaEta(const ap_int< BITSSTUBETA > &eta1, const ap_int< BITSSTUBETA > &eta2) const
const int barrelLimit3_
Definition: Constants.h:88
const ap_uint< BITSPROPCOORD > lt_prop_coord1_0[512]
Definition: TPSLUTs.h:359
const ap_uint< BITSPROPSIGMAETA_B > lt_res1_eta_2[512]
Definition: TPSLUTs.h:1184
const ap_uint< BITSPROPCOORD > lt_prop_coord1_2[512]
Definition: TPSLUTs.h:407
const int BITSGTETA
Definition: Constants.h:62
ap_uint< BITSSIGMACOORD+1 > deltaCoord(const ap_int< BITSSTUBCOORD > &phi1, const ap_int< BITSSTUBCOORD > &phi2) const
const int BITSGTISO
Definition: Constants.h:67
const ap_uint< BITSPROPSIGMAETA_A > lt_res0_eta1_0[512]
Definition: TPSLUTs.h:992
const int BITSGTPHI
Definition: Constants.h:61
const ap_uint< BITSPROPSIGMACOORD_B > lt_res1_coord1_2[512]
Definition: TPSLUTs.h:831
ap_int< BITSSTUBCOORD > coord1
Definition: TPSAlgorithm.h:24
const ap_uint< BITSPROPSIGMAETA_B > lt_res1_eta_1[512]
Definition: TPSLUTs.h:1168
const ap_uint< BITSPROPSIGMACOORD_A > lt_res0_coord2_4[512]
Definition: TPSLUTs.h:775
const ap_uint< BITSPROPCOORD > lt_prop_coord2_1[512]
Definition: TPSLUTs.h:499
const ap_uint< BITSPROPSIGMACOORD_B > lt_res1_coord1_3[512]
Definition: TPSLUTs.h:851
const ap_uint< BITSPROPSIGMAETA_A > lt_res0_eta1_4[512]
Definition: TPSLUTs.h:1056
const ap_uint< BITSPROPSIGMAETA_A > lt_res0_eta1_1[512]
Definition: TPSLUTs.h:1008
const ap_uint< BITSPROPSIGMACOORD_A > lt_res0_coord2_1[512]
Definition: TPSLUTs.h:715
const ap_uint< BITSPROPCOORD > lt_prop_coord2_4[512]
Definition: TPSLUTs.h:570
const int BITSPROPSIGMACOORD_B
Definition: Constants.h:49
const ap_uint< BITSPROPCOORD > lt_prop_coord2_0[512]
Definition: TPSLUTs.h:479
const ap_uint< BITSPROPSIGMAETA_A > lt_res0_eta2_3[512]
Definition: TPSLUTs.h:1120
const int BITSGTQUAL
Definition: Constants.h:65
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
Definition: DiMuonV_cfg.py:214
assert(be >=bs)
ap_uint< BITSSIGMAETA > sigma_eta2
Definition: TPSAlgorithm.h:30
const ap_uint< BITSPROPCOORD > lt_prop_coord1_4[512]
Definition: TPSLUTs.h:455
T curvature(T InversePt, const MagneticField &field)
ap_uint< BITSSIGMACOORD > sigma_coord2
Definition: TPSAlgorithm.h:27
std::vector< PreTrackMatchedMuon > cleanNeighbor(const std::vector< PreTrackMatchedMuon > &muons, const std::vector< PreTrackMatchedMuon > &muonsPrevious, const std::vector< PreTrackMatchedMuon > &muonsNext, bool equality) const
Definition: TPSAlgorithm.cc:19
std::vector< edm::Ref< MuonStubCollection > > MuonStubRefVector
Definition: MuonStub.h:44
ap_uint< 64 > wordtype
Definition: Constants.h:101
const int barrelLimit2_
Definition: Constants.h:87
const ap_uint< BITSPROPSIGMAETA_A > lt_res0_eta1_2[512]
Definition: TPSLUTs.h:1024
const ap_uint< BITSPROPCOORD > lt_prop_coord1_1[512]
Definition: TPSLUTs.h:383
void SetQualityBits(std::vector< l1t::TrackerMuon > &muons) const
Definition: TPSAlgorithm.cc:84
string quality
const ap_uint< BITSPROPCOORD > lt_prop_coord2_3[512]
Definition: TPSLUTs.h:546
std::vector< PreTrackMatchedMuon > clean(const std::vector< PreTrackMatchedMuon > &muons) const
const ap_uint< BITSPROPSIGMAETA_B > lt_res1_eta_4[512]
Definition: TPSLUTs.h:1216
const ap_uint< BITSPROPSIGMACOORD_A > lt_res0_coord2_2[512]
Definition: TPSLUTs.h:735
const ap_uint< BITSPROPSIGMACOORD_B > lt_res1_coord1_1[512]
Definition: TPSLUTs.h:811
const ap_uint< BITSPROPSIGMACOORD_A > lt_res0_coord1_1[512]
Definition: TPSLUTs.h:615
PreTrackMatchedMuon processTrack(const ConvertedTTTrack &, const l1t::MuonStubRefVector &) const
match_t match(const propagation_t prop, const l1t::MuonStubRef &stub, uint trackID) const
const int barrelLimit4_
Definition: Constants.h:89
const ap_uint< BITSPROPSIGMAETA_A > lt_res0_eta2_0[512]
Definition: TPSLUTs.h:1072
void matchingInfos(const std::vector< match_t > &matchInfo, PreTrackMatchedMuon &muon, ap_uint< BITSMATCHQUALITY > &quality) const
const ap_uint< BITSPROPSIGMACOORD_A > lt_res0_coord2_0[512]
Definition: TPSLUTs.h:695
bool outputGT(std::vector< l1t::TrackerMuon > &muons) const
Definition: TPSAlgorithm.cc:97
const ap_uint< BITSPROPSIGMACOORD_B > lt_res1_coord1_0[512]
Definition: TPSLUTs.h:796
const int BITSGTPT
Definition: Constants.h:60
std::vector< PreTrackMatchedMuon > processNonant(const std::vector< ConvertedTTTrack > &convertedTracks, const l1t::MuonStubRefVector &stubs) const
Definition: TPSAlgorithm.cc:7
const ap_uint< BITSPROPSIGMAETA_A > lt_res0_eta2_2[512]
Definition: TPSLUTs.h:1104
const int BITSTTCURV
Definition: Constants.h:10
ap_uint< 5 > cleanMuon(const PreTrackMatchedMuon &mu, const PreTrackMatchedMuon &other, bool eq) const
ap_uint< BITSSIGMAETA > sigma_eta1
Definition: TPSAlgorithm.h:29
match_t propagateAndMatch(const ConvertedTTTrack &track, const l1t::MuonStubRef &stub, uint trackID) const
Log< level::Info, false > LogInfo
const int BITSPROPSIGMACOORD_A
Definition: Constants.h:48
std::vector< l1t::TrackerMuon > sort(std::vector< l1t::TrackerMuon > &muons, uint maximum) const
std::vector< l1t::TrackerMuon > convert(const std::vector< PreTrackMatchedMuon > &muons, uint maximum) const
Definition: TPSAlgorithm.cc:56
const int BITSGTD0
Definition: Constants.h:64
const ap_uint< BITSPROPSIGMACOORD_A > lt_res0_coord2_3[512]
Definition: TPSLUTs.h:755
double b
Definition: hdecay.h:120
const ap_uint< BITSPROPSIGMAETA_A > lt_res0_eta2_4[512]
Definition: TPSLUTs.h:1136
ap_int< BITSSTUBETA > eta
Definition: TPSAlgorithm.h:28
const unsigned int PHIDIVIDER
Definition: TPSAlgorithm.h:20
const ap_uint< BITSPROPSIGMACOORD_A > lt_res0_coord1_4[512]
Definition: TPSLUTs.h:675
const ap_uint< BITSPROPSIGMACOORD_B > lt_res1_coord2_2[512]
Definition: TPSLUTs.h:931
match_t getBest(const std::vector< match_t > &matches) const
double a
Definition: hdecay.h:121
const ap_uint< BITSPROPSIGMACOORD_B > lt_res1_coord2_3[512]
Definition: TPSLUTs.h:951
const ap_uint< 8 > lt_tpsID[256]
Definition: TPSLUTs.h:1238
const ap_uint< BITSPROPSIGMACOORD_B > lt_res1_coord1_4[512]
Definition: TPSLUTs.h:871
const ap_uint< BITSPROPCOORD > lt_prop_coord2_2[512]
Definition: TPSLUTs.h:522
const ap_uint< BITSPROPSIGMAETA_B > lt_res1_eta_0[512]
Definition: TPSLUTs.h:1152
const ap_uint< BITSPROPSIGMAETA_A > lt_res0_eta2_1[512]
Definition: TPSLUTs.h:1088
const int BITSPROPCOORD
Definition: Constants.h:47
propagation_t propagate(const ConvertedTTTrack &track, uint layer) const
const ap_uint< BITSPROPSIGMAETA_A > lt_res0_eta1_3[512]
Definition: TPSLUTs.h:1040
const ap_uint< BITSPROPSIGMAETA_B > lt_res1_eta_3[512]
Definition: TPSLUTs.h:1200
const ap_uint< BITSPROPSIGMACOORD_A > lt_res0_coord1_0[512]
Definition: TPSLUTs.h:595
const ap_uint< BITSPROPSIGMACOORD_A > lt_res0_coord1_2[512]
Definition: TPSLUTs.h:635
ap_int< BITSSTUBCOORD > coord2
Definition: TPSAlgorithm.h:26
const ap_uint< BITSPROPCOORD > lt_prop_coord1_3[512]
Definition: TPSLUTs.h:431
const int BITSGTBETA
Definition: Constants.h:68
const unsigned int ETADIVIDER
Definition: TPSAlgorithm.h:21
const ap_uint< BITSPROPSIGMACOORD_B > lt_res1_coord2_1[512]
Definition: TPSLUTs.h:911