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