CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
Phase2L1GMT::TrackMuonMatchAlgorithm Class Reference

#include <TrackMuonMatchAlgorithm.h>

Public Member Functions

std::vector< PreTrackMatchedMuoncleanNeighbor (const std::vector< PreTrackMatchedMuon > &muons, const std::vector< PreTrackMatchedMuon > &muonsPrevious, const std::vector< PreTrackMatchedMuon > &muonsNext, bool equality)
 
std::vector< l1t::TrackerMuonconvert (std::vector< PreTrackMatchedMuon > &muons, uint maximum)
 
bool outputGT (std::vector< l1t::TrackerMuon > &muons)
 
std::vector< PreTrackMatchedMuonprocessNonant (const std::vector< ConvertedTTTrack > &convertedTracks, const std::vector< MuonROI > &rois)
 
std::vector< l1t::TrackerMuonsort (std::vector< l1t::TrackerMuon > &muons, uint maximum)
 
 TrackMuonMatchAlgorithm (const edm::ParameterSet &iConfig)
 
 ~TrackMuonMatchAlgorithm ()
 

Private Member Functions

std::vector< PreTrackMatchedMuonclean (std::vector< PreTrackMatchedMuon > &muons)
 
ap_uint< 5 > cleanMuon (const PreTrackMatchedMuon &mu, const PreTrackMatchedMuon &other, bool eq)
 
ap_uint< BITSSIGMACOORD+1 > deltaCoord (const ap_int< BITSSTUBCOORD > &phi1, const ap_int< BITSSTUBCOORD > &phi2)
 
ap_uint< BITSSIGMAETA+1 > deltaEta (const ap_int< BITSSTUBETA > &eta1, const ap_int< BITSSTUBETA > &eta2)
 
match_t getBest (const std::vector< match_t > matches)
 
match_t match (const propagation_t prop, const l1t::MuonStubRef &stub)
 
PreTrackMatchedMuon processTrack (const ConvertedTTTrack &track, const std::vector< MuonROI > &rois)
 
propagation_t propagate (const ConvertedTTTrack &track, uint layer)
 
match_t propagateAndMatch (const ConvertedTTTrack &track, const l1t::MuonStubRef &stub)
 

Private Attributes

int verbose_
 

Detailed Description

Definition at line 47 of file TrackMuonMatchAlgorithm.h.

Constructor & Destructor Documentation

◆ TrackMuonMatchAlgorithm()

Phase2L1GMT::TrackMuonMatchAlgorithm::TrackMuonMatchAlgorithm ( const edm::ParameterSet iConfig)
inline

Definition at line 49 of file TrackMuonMatchAlgorithm.h.

49 : verbose_(iConfig.getParameter<int>("verbose")) {}
T getParameter(std::string const &) const
Definition: ParameterSet.h:307

◆ ~TrackMuonMatchAlgorithm()

Phase2L1GMT::TrackMuonMatchAlgorithm::~TrackMuonMatchAlgorithm ( )
inline

Definition at line 51 of file TrackMuonMatchAlgorithm.h.

51 {}

Member Function Documentation

◆ clean()

std::vector<PreTrackMatchedMuon> Phase2L1GMT::TrackMuonMatchAlgorithm::clean ( std::vector< PreTrackMatchedMuon > &  muons)
inlineprivate

Definition at line 594 of file TrackMuonMatchAlgorithm.h.

References cleanMuon(), mps_fire::i, dqmiolumiharvest::j, ALPAKA_ACCELERATOR_NAMESPACE::pixelClustering::pixelStatus::mask, DiMuonV_cfg::muons, MillePedeFileConverter_cfg::out, parallelization::uint, and verbose_.

Referenced by processNonant().

594  {
595  std::vector<PreTrackMatchedMuon> out;
596  if (muons.empty())
597  return out;
598  if (verbose_ == 1) {
599  printf("-----Cleaning Up Muons in the same Nonant\n");
600  printf("Before:\n");
601  }
602  for (uint i = 0; i < muons.size(); ++i) {
603  if (verbose_ == 1)
604  muons[i].print();
605 
606  ap_uint<5> mask = 0x1f;
607  for (uint j = 0; j < muons.size(); ++j) {
608  if (i == j)
609  continue;
610  mask = mask & cleanMuon(muons[i], muons[j], false);
611  }
612  if (mask) {
613  if (verbose_ == 1)
614  printf("kept\n");
615  out.push_back(muons[i]);
616  } else {
617  if (verbose_ == 1)
618  printf("discarded\n");
619  }
620  }
621  return out;
622  }
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
Definition: DiMuonV_cfg.py:214
ap_uint< 5 > cleanMuon(const PreTrackMatchedMuon &mu, const PreTrackMatchedMuon &other, bool eq)

◆ cleanMuon()

ap_uint<5> Phase2L1GMT::TrackMuonMatchAlgorithm::cleanMuon ( const PreTrackMatchedMuon mu,
const PreTrackMatchedMuon other,
bool  eq 
)
inlineprivate

Definition at line 559 of file TrackMuonMatchAlgorithm.h.

References amptDefaultParameters_cff::mu, trackingPlots::other, hltL1SingleMuFiltered5_cfi::overlap, and validateGeometry_cfg::valid.

Referenced by clean(), and cleanNeighbor().

559  {
560  ap_uint<5> valid = 0;
561  ap_uint<5> overlap = 0;
562  if (mu.stubID0() != 511) {
563  valid = valid | 0x1;
564  if (mu.stubID0() == other.stubID0())
565  overlap = overlap | 0x1;
566  }
567  if (mu.stubID1() != 511) {
568  valid = valid | 0x2;
569  if (mu.stubID1() == other.stubID1())
570  overlap = overlap | 0x2;
571  }
572  if (mu.stubID2() != 511) {
573  valid = valid | 0x4;
574  if (mu.stubID2() == other.stubID2())
575  overlap = overlap | 0x4;
576  }
577  if (mu.stubID3() != 511) {
578  valid = valid | 0x8;
579  if (mu.stubID3() == other.stubID3())
580  overlap = overlap | 0x8;
581  }
582  if (mu.stubID4() != 511) {
583  valid = valid | 0x10;
584  if (mu.stubID4() == other.stubID4())
585  overlap = overlap | 0x10;
586  }
587 
588  if (((mu.quality() < other.quality()) && (!eq)) || ((mu.quality() <= other.quality()) && (eq)))
589  return valid & (~overlap);
590  else
591  return valid;
592  }

◆ cleanNeighbor()

std::vector<PreTrackMatchedMuon> Phase2L1GMT::TrackMuonMatchAlgorithm::cleanNeighbor ( const std::vector< PreTrackMatchedMuon > &  muons,
const std::vector< PreTrackMatchedMuon > &  muonsPrevious,
const std::vector< PreTrackMatchedMuon > &  muonsNext,
bool  equality 
)
inline

Definition at line 65 of file TrackMuonMatchAlgorithm.h.

References cleanMuon(), mps_fire::i, dqmiolumiharvest::j, ALPAKA_ACCELERATOR_NAMESPACE::pixelClustering::pixelStatus::mask, DiMuonV_cfg::muons, MillePedeFileConverter_cfg::out, parallelization::uint, and verbose_.

68  {
69  std::vector<PreTrackMatchedMuon> out;
70 
71  if (muons.empty())
72  return out;
73 
74  if (verbose_ == 1) {
75  printf("-----Cleaning Up Muons in the neighbours\n");
76  printf("Before:\n");
77  }
78 
79  for (uint i = 0; i < muons.size(); ++i) {
80  if (verbose_ == 1) {
81  muons[i].print();
82  }
83  ap_uint<5> mask = 0x1f;
84  for (uint j = 0; j < muonsPrevious.size(); ++j) {
85  mask = mask & cleanMuon(muons[i], muonsPrevious[j], equality);
86  }
87  for (uint j = 0; j < muonsNext.size(); ++j) {
88  mask = mask & cleanMuon(muons[i], muonsNext[j], equality);
89  }
90  if (mask) {
91  if (verbose_ == 1)
92  printf("kept\n");
93  out.push_back(muons[i]);
94  } else {
95  if (verbose_ == 1)
96  printf("discarded\n");
97  }
98  }
99  return out;
100  }
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
Definition: DiMuonV_cfg.py:214
ap_uint< 5 > cleanMuon(const PreTrackMatchedMuon &mu, const PreTrackMatchedMuon &other, bool eq)

◆ convert()

std::vector<l1t::TrackerMuon> Phase2L1GMT::TrackMuonMatchAlgorithm::convert ( std::vector< PreTrackMatchedMuon > &  muons,
uint  maximum 
)
inline

Definition at line 102 of file TrackMuonMatchAlgorithm.h.

References amptDefaultParameters_cff::mu, HLT_2024v14_cff::muon, DiMuonV_cfg::muons, MillePedeFileConverter_cfg::out, and verbose_.

102  {
103  std::vector<l1t::TrackerMuon> out;
104  for (const auto& mu : muons) {
105  if (out.size() == maximum)
106  break;
107  l1t::TrackerMuon muon(mu.trkPtr(), mu.charge(), mu.pt(), mu.eta(), mu.phi(), mu.z0(), mu.d0(), mu.quality());
108  muon.setMuonRef(mu.muonRef());
109  for (const auto& stub : mu.stubs())
110  muon.addStub(stub);
111  out.push_back(muon);
112  if (verbose_ == 1) {
113  printf("Final Muon:");
114  muon.print();
115  }
116  }
117  return out;
118  }
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
Definition: DiMuonV_cfg.py:214

◆ deltaCoord()

ap_uint<BITSSIGMACOORD + 1> Phase2L1GMT::TrackMuonMatchAlgorithm::deltaCoord ( const ap_int< BITSSTUBCOORD > &  phi1,
const ap_int< BITSSTUBCOORD > &  phi2 
)
inlineprivate

Definition at line 300 of file TrackMuonMatchAlgorithm.h.

Referenced by match().

300  {
301  ap_int<BITSSTUBCOORD> dPhiRoll = phi1 - phi2;
302  ap_ufixed<BITSSIGMACOORD + 1, BITSSIGMACOORD + 1, AP_TRN_ZERO, AP_SAT_SYM> dPhi;
303  if (dPhiRoll < 0)
304  dPhi = ap_ufixed<BITSSIGMACOORD + 1, BITSSIGMACOORD + 1, AP_TRN_ZERO, AP_SAT_SYM>(-dPhiRoll);
305  else
306  dPhi = ap_ufixed<BITSSIGMACOORD + 1, BITSSIGMACOORD + 1, AP_TRN_ZERO, AP_SAT_SYM>(dPhiRoll);
307 
308  return ap_uint<BITSSIGMACOORD + 1>(dPhi);
309  }

◆ deltaEta()

ap_uint<BITSSIGMAETA + 1> Phase2L1GMT::TrackMuonMatchAlgorithm::deltaEta ( const ap_int< BITSSTUBETA > &  eta1,
const ap_int< BITSSTUBETA > &  eta2 
)
inlineprivate

Definition at line 292 of file TrackMuonMatchAlgorithm.h.

References HLT_2024v14_cff::dEta, HLT_2024v14_cff::eta1, and HLT_2024v14_cff::eta2.

Referenced by match().

292  {
293  ap_fixed<BITSSIGMAETA + 2, BITSSIGMAETA + 2, AP_TRN_ZERO, AP_SAT_SYM> dEta = eta1 - eta2;
294  if (dEta < 0)
295  return ap_uint<BITSSIGMAETA + 1>(-dEta);
296  else
297  return ap_uint<BITSSIGMAETA + 1>(dEta);
298  }

◆ getBest()

match_t Phase2L1GMT::TrackMuonMatchAlgorithm::getBest ( const std::vector< match_t matches)
inlineprivate

Definition at line 419 of file TrackMuonMatchAlgorithm.h.

References visualization-live-secondInstance_cfg::m, and oniaPATMuonsWithTrigger_cff::matches.

Referenced by processTrack().

419  {
420  match_t best = matches[0];
421  for (const auto& m : matches) {
422  if (m.quality > best.quality)
423  best = m;
424  }
425 
426  return best;
427  }

◆ match()

match_t Phase2L1GMT::TrackMuonMatchAlgorithm::match ( const propagation_t  prop,
const l1t::MuonStubRef stub 
)
inlineprivate

Definition at line 311 of file TrackMuonMatchAlgorithm.h.

References Phase2L1GMT::propagation_t::coord1, Phase2L1GMT::propagation_t::coord2, deltaCoord(), deltaEta(), Phase2L1GMT::propagation_t::eta, edm::Ref< C, T, F >::id(), Phase2L1GMT::propagation_t::is_barrel, MillePedeFileConverter_cfg::out, Phase2L1GMT::propagation_t::sigma_coord1, Phase2L1GMT::propagation_t::sigma_coord2, Phase2L1GMT::propagation_t::sigma_eta1, Phase2L1GMT::propagation_t::sigma_eta2, and verbose_.

Referenced by propagateAndMatch().

311  {
312  if (verbose_ == 1) {
313  printf("Matching to ");
314  stub->print();
315  }
316  //Matching of Coord1
317  ap_uint<1> coord1Matched;
318  ap_uint<BITSSIGMACOORD + 1> deltaCoord1 = deltaCoord(prop.coord1, stub->coord1());
319  if (deltaCoord1 <= prop.sigma_coord1 && (stub->quality() & 0x1)) {
320  coord1Matched = 1;
321  } else {
322  coord1Matched = 0;
323  }
324  if (verbose_ == 1)
325  printf("Coord1 matched=%d delta=%d res=%d\n",
326  coord1Matched.to_int(),
327  deltaCoord1.to_int(),
328  prop.sigma_coord1.to_int());
329 
330  //Matching of Coord2
331  ap_uint<1> coord2Matched;
332  ap_uint<BITSSIGMACOORD + 1> deltaCoord2 = deltaCoord(prop.coord2, stub->coord2());
333  if (deltaCoord2 <= prop.sigma_coord2 && (stub->quality() & 0x2)) {
334  coord2Matched = 1;
335  } else {
336  coord2Matched = 0;
337  }
338  if (verbose_ == 1)
339  printf("Coord2 matched=%d delta=%d res=%d\n",
340  coord2Matched.to_int(),
341  deltaCoord2.to_int(),
342  prop.sigma_coord2.to_int());
343 
344  //Matching of Eta1
345 
346  ap_uint<1> eta1Matched;
347 
348  //if we have really bad quality[Barrel no eta]
349  //increase the resolution
350  ap_ufixed<BITSSIGMAETA, BITSSIGMAETA, AP_TRN_ZERO, AP_SAT_SYM> prop_sigma_eta1;
351  if (stub->etaQuality() == 0)
352  prop_sigma_eta1 = prop.sigma_eta1 + 6;
353  else
354  prop_sigma_eta1 = prop.sigma_eta1;
355 
356  ap_uint<BITSSIGMAETA + 1> deltaEta1 = deltaEta(prop.eta, stub->eta1());
357  if (deltaEta1 <= prop_sigma_eta1 && (stub->etaQuality() == 0 || (stub->etaQuality() & 0x1)))
358  eta1Matched = 1;
359  else
360  eta1Matched = 0;
361 
362  if (verbose_ == 1)
363  printf("eta1 matched=%d delta=%d res=%d\n", eta1Matched.to_int(), deltaEta1.to_int(), prop_sigma_eta1.to_int());
364 
365  //Matching of Eta2
366 
367  ap_uint<1> eta2Matched;
368 
369  ap_uint<BITSSIGMAETA + 1> deltaEta2 = deltaEta(prop.eta, stub->eta2());
370  if (deltaEta2 <= prop.sigma_eta2 && (stub->etaQuality() & 0x2))
371  eta2Matched = 1;
372  else
373  eta2Matched = 0;
374  match_t out;
375  out.id = stub->id();
376 
377  if (verbose_ == 1)
378  printf("eta2 matched=%d delta=%d res=%d\n", eta2Matched.to_int(), deltaEta2.to_int(), prop.sigma_eta2.to_int());
379 
380  //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
381  if (prop.is_barrel) {
382  out.valid = (coord1Matched == 1 && (eta1Matched == 1 || eta2Matched == 1));
383  if (out.valid == 0) {
384  out.quality = 0;
385  } else {
386  out.quality = 32 - deltaCoord1;
387  if (coord2Matched == 1)
388  out.quality += 32 - deltaCoord2;
389  }
390  }
391  //if endcap each coordinate is independent except the case where phiQuality=1 and etaQuality==3
392  else {
393  bool match1 = (coord1Matched == 1 && eta1Matched == 1);
394  bool match2 = (coord2Matched == 1 && eta2Matched == 1);
395  bool match3 =
396  (coord1Matched == 1 && (eta1Matched || eta2Matched) && stub->etaQuality() == 3 && stub->quality() == 1);
397  out.valid = match1 || match2 || match3;
398  if (out.valid == 0)
399  out.quality = 0;
400  else {
401  out.quality = 0;
402  if (match1 || match3)
403  out.quality += 32 - deltaCoord1;
404  if (match2)
405  out.quality += 32 - deltaCoord2;
406  }
407  }
408  if (verbose_ == 1)
409  printf("GlobalMatchQuality = %d\n", out.quality.to_int());
410  out.stubRef = stub;
411  return out;
412  }
ProductID id() const
Accessor for product ID.
Definition: Ref.h:244
ap_uint< BITSSIGMAETA+1 > deltaEta(const ap_int< BITSSTUBETA > &eta1, const ap_int< BITSSTUBETA > &eta2)
ap_uint< BITSSIGMACOORD+1 > deltaCoord(const ap_int< BITSSTUBCOORD > &phi1, const ap_int< BITSSTUBCOORD > &phi2)

◆ outputGT()

bool Phase2L1GMT::TrackMuonMatchAlgorithm::outputGT ( std::vector< l1t::TrackerMuon > &  muons)
inline

Definition at line 120 of file TrackMuonMatchAlgorithm.h.

References Phase2L1GMT::BITSGTBETA, Phase2L1GMT::BITSGTD0, Phase2L1GMT::BITSGTETA, Phase2L1GMT::BITSGTISO, Phase2L1GMT::BITSGTPHI, Phase2L1GMT::BITSGTPT, Phase2L1GMT::BITSGTQUAL, Phase2L1GMT::BITSGTZ0, amptDefaultParameters_cff::mu, and DiMuonV_cfg::muons.

120  {
121  for (auto& mu : muons) {
122  wordtype word1 = 0;
123  wordtype word2 = 0;
124 
125  int bstart = 0;
126  bstart = wordconcat<wordtype>(word1, bstart, mu.hwPt(), BITSGTPT);
127  bstart = wordconcat<wordtype>(word1, bstart, mu.hwPhi(), BITSGTPHI);
128  bstart = wordconcat<wordtype>(word1, bstart, mu.hwEta(), BITSGTETA);
129  bstart = wordconcat<wordtype>(word1, bstart, mu.hwZ0(), BITSGTZ0);
130  bstart = wordconcat<wordtype>(word1, bstart, (mu.hwD0() >> 2), BITSGTD0);
131 
132  bstart = 0;
133  bstart = wordconcat<wordtype>(word2, bstart, mu.hwCharge(), 1);
134  bstart = wordconcat<wordtype>(word2, bstart, mu.hwQual(), BITSGTQUAL);
135  bstart = wordconcat<wordtype>(word2, bstart, mu.hwIso(), BITSGTISO);
136  bstart = wordconcat<wordtype>(word2, bstart, mu.hwBeta(), BITSGTBETA);
137 
138  std::array<uint64_t, 2> wordout = {{word1, word2}};
139  mu.setWord(wordout);
140  }
141  return true;
142  }
const int BITSGTZ0
Definition: Constants.h:63
const int BITSGTETA
Definition: Constants.h:62
const int BITSGTISO
Definition: Constants.h:66
const int BITSGTPHI
Definition: Constants.h:61
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
ap_uint< 64 > wordtype
Definition: Constants.h:99
const int BITSGTPT
Definition: Constants.h:60
const int BITSGTD0
Definition: Constants.h:64
const int BITSGTBETA
Definition: Constants.h:67

◆ processNonant()

std::vector<PreTrackMatchedMuon> Phase2L1GMT::TrackMuonMatchAlgorithm::processNonant ( const std::vector< ConvertedTTTrack > &  convertedTracks,
const std::vector< MuonROI > &  rois 
)
inline

Definition at line 53 of file TrackMuonMatchAlgorithm.h.

References clean(), l1tGTTFileWriter_cfi::convertedTracks, amptDefaultParameters_cff::mu, processTrack(), and HLT_2024v14_cff::track.

54  {
55  std::vector<PreTrackMatchedMuon> preMuons;
56  for (const auto& track : convertedTracks) {
57  PreTrackMatchedMuon mu = processTrack(track, rois);
58  if (mu.valid() && preMuons.size() < 16)
59  preMuons.push_back(mu);
60  }
61  std::vector<PreTrackMatchedMuon> cleanedMuons = clean(preMuons);
62  return cleanedMuons;
63  }
std::vector< PreTrackMatchedMuon > clean(std::vector< PreTrackMatchedMuon > &muons)
PreTrackMatchedMuon processTrack(const ConvertedTTTrack &track, const std::vector< MuonROI > &rois)

◆ processTrack()

PreTrackMatchedMuon Phase2L1GMT::TrackMuonMatchAlgorithm::processTrack ( const ConvertedTTTrack track,
const std::vector< MuonROI > &  rois 
)
inlineprivate

Definition at line 429 of file TrackMuonMatchAlgorithm.h.

References generateTowerEtThresholdLUT::addr, b, getBest(), mps_fire::i, Phase2L1GMT::lt_tpsID, visualization-live-secondInstance_cfg::m, HLT_2024v14_cff::muon, propagateAndMatch(), quality, HLT_2024v14_cff::track, parallelization::uint, and verbose_.

Referenced by processNonant().

429  {
430  std::vector<match_t> matchInfo0;
431  std::vector<match_t> matchInfo1;
432  std::vector<match_t> matchInfo2;
433  std::vector<match_t> matchInfo3;
434  std::vector<match_t> matchInfo4;
435 
436  if (verbose_ == 1 && !rois.empty()) {
437  printf("-----------processing new track----------");
438  track.print();
439  }
440  for (const auto& roi : rois) {
441  if (verbose_ == 1) {
442  printf("New ROI with %d stubs \n", int(roi.stubs().size()));
443  }
444  for (const auto& stub : roi.stubs()) {
445  match_t m = propagateAndMatch(track, stub);
446  if (m.valid == 1) {
447  if (roi.isGlobalMuon() && roi.muonRef().isNonnull()) {
448  m.isGlobal = true;
449  m.muRef = roi.muonRef();
450  }
451 
452  if (stub->tfLayer() == 0)
453  matchInfo0.push_back(m);
454  else if (stub->tfLayer() == 1)
455  matchInfo1.push_back(m);
456  else if (stub->tfLayer() == 2)
457  matchInfo2.push_back(m);
458  else if (stub->tfLayer() == 3)
459  matchInfo3.push_back(m);
460  else if (stub->tfLayer() == 4)
461  matchInfo4.push_back(m);
462  }
463  }
464  }
465 
466  ap_ufixed<6, 6, AP_TRN_ZERO, AP_SAT_SYM> ptPenalty = ap_ufixed<6, 6, AP_TRN_ZERO, AP_SAT_SYM>(track.pt() / 32);
467 
468  ap_uint<BITSMATCHQUALITY> quality = 0;
469  PreTrackMatchedMuon muon(track.charge(), track.pt(), track.eta(), track.phi(), track.z0(), track.d0());
470 
471  if (!matchInfo0.empty()) {
472  match_t b = getBest(matchInfo0);
473  if (b.valid) {
474  muon.addStub(b.stubRef);
475  if (b.isGlobal)
476  muon.addMuonRef(b.muRef);
477  quality += b.quality;
478  }
479  }
480  if (!matchInfo1.empty()) {
481  match_t b = getBest(matchInfo1);
482  if (b.valid) {
483  muon.addStub(b.stubRef);
484  if (b.isGlobal)
485  muon.addMuonRef(b.muRef);
486  quality += b.quality;
487  }
488  }
489  if (!matchInfo2.empty()) {
490  match_t b = getBest(matchInfo2);
491  if (b.valid) {
492  muon.addStub(b.stubRef);
493  if (b.isGlobal)
494  muon.addMuonRef(b.muRef);
495  quality += b.quality;
496  }
497  }
498  if (!matchInfo3.empty()) {
499  match_t b = getBest(matchInfo3);
500  if (b.valid) {
501  muon.addStub(b.stubRef);
502  if (b.isGlobal)
503  muon.addMuonRef(b.muRef);
504  quality += b.quality;
505  }
506  }
507  if (!matchInfo4.empty()) {
508  match_t b = getBest(matchInfo4);
509  if (b.valid) {
510  muon.addStub(b.stubRef);
511  if (b.isGlobal)
512  muon.addMuonRef(b.muRef);
513  quality += b.quality;
514  }
515  }
516 
517  muon.setOfflineQuantities(track.offline_pt(), track.offline_eta(), track.offline_phi());
518  muon.setTrkPtr(track.trkPtr());
519 
520  ap_uint<8> etaAddr = muon.eta() < 0 ? ap_uint<8>(-muon.eta() / 256) : ap_uint<8>((muon.eta()) / 256);
521  ap_uint<8> ptAddr = muon.pt() > 4095 ? ap_uint<8>(15) : ap_uint<8>(muon.pt() / 256);
522  ap_uint<8> addr = ptAddr | (etaAddr << 4);
523  ap_uint<8> qualityCut = lt_tpsID[addr];
524 
525  if (quality >= qualityCut) {
526  muon.setValid(true);
527  muon.setQuality(quality + ptPenalty);
528  } else {
529  muon.setValid(false);
530  muon.setQuality(0);
531  muon.resetGlobal();
532  }
533  if (verbose_ == 1)
534  muon.print();
535 
536  if (verbose_ == 1 && !rois.empty()) { //patterns for HLS
537 
538  printf("TPS %d", track.trkPtr()->phiSector());
539  track.printWord();
540 
541  for (uint i = 0; i < 16; ++i) {
542  if (rois.size() > i) {
543  rois[i].printROILine();
544  } else {
545  printf("%08x", 0);
546  printf("%016lx", 0x1ff000000000000);
547  printf("%016lx", 0x1ff000000000000);
548  printf("%016lx", 0x1ff000000000000);
549  printf("%016lx", 0x1ff000000000000);
550  printf("%016lx", 0x1ff000000000000);
551  }
552  }
553  muon.printWord();
554  printf("\n");
555  }
556  return muon;
557  }
string quality
match_t getBest(const std::vector< match_t > matches)
double b
Definition: hdecay.h:120
const ap_uint< 8 > lt_tpsID[256]
Definition: Constants.h:1210
match_t propagateAndMatch(const ConvertedTTTrack &track, const l1t::MuonStubRef &stub)

◆ propagate()

propagation_t Phase2L1GMT::TrackMuonMatchAlgorithm::propagate ( const ConvertedTTTrack track,
uint  layer 
)
inlineprivate

Definition at line 162 of file TrackMuonMatchAlgorithm.h.

References Phase2L1GMT::barrelLimit0_, Phase2L1GMT::barrelLimit1_, Phase2L1GMT::barrelLimit2_, Phase2L1GMT::barrelLimit3_, Phase2L1GMT::BITSPROPCOORD, Phase2L1GMT::BITSTTCURV, PixelRecoUtilities::curvature(), PVValHelper::eta, Phase2L1GMT::ETADIVIDER, Phase2L1GMT::lt_prop_coord1_0, Phase2L1GMT::lt_prop_coord1_1, Phase2L1GMT::lt_prop_coord1_2, Phase2L1GMT::lt_prop_coord1_3, Phase2L1GMT::lt_prop_coord1_4, Phase2L1GMT::lt_prop_coord2_0, Phase2L1GMT::lt_prop_coord2_1, Phase2L1GMT::lt_prop_coord2_2, Phase2L1GMT::lt_prop_coord2_3, Phase2L1GMT::lt_prop_coord2_4, Phase2L1GMT::lt_res0_coord1_0, Phase2L1GMT::lt_res0_coord1_1, Phase2L1GMT::lt_res0_coord1_2, Phase2L1GMT::lt_res0_coord1_3, Phase2L1GMT::lt_res0_coord1_4, Phase2L1GMT::lt_res0_coord2_0, Phase2L1GMT::lt_res0_coord2_1, Phase2L1GMT::lt_res0_coord2_2, Phase2L1GMT::lt_res0_coord2_3, Phase2L1GMT::lt_res0_coord2_4, Phase2L1GMT::lt_res0_eta1_0, Phase2L1GMT::lt_res0_eta1_1, Phase2L1GMT::lt_res0_eta1_2, Phase2L1GMT::lt_res0_eta1_3, Phase2L1GMT::lt_res0_eta1_4, Phase2L1GMT::lt_res0_eta2_0, Phase2L1GMT::lt_res0_eta2_1, Phase2L1GMT::lt_res0_eta2_2, Phase2L1GMT::lt_res0_eta2_3, Phase2L1GMT::lt_res0_eta2_4, Phase2L1GMT::lt_res1_coord1_0, Phase2L1GMT::lt_res1_coord1_1, Phase2L1GMT::lt_res1_coord1_2, Phase2L1GMT::lt_res1_coord1_3, Phase2L1GMT::lt_res1_coord1_4, Phase2L1GMT::lt_res1_coord2_0, Phase2L1GMT::lt_res1_coord2_1, Phase2L1GMT::lt_res1_coord2_2, Phase2L1GMT::lt_res1_coord2_3, Phase2L1GMT::lt_res1_coord2_4, Phase2L1GMT::lt_res1_eta_0, Phase2L1GMT::lt_res1_eta_1, Phase2L1GMT::lt_res1_eta_2, Phase2L1GMT::lt_res1_eta_3, Phase2L1GMT::lt_res1_eta_4, MillePedeFileConverter_cfg::out, Phase2L1GMT::PHIDIVIDER, HLT_2024v14_cff::track, parallelization::uint, and verbose_.

Referenced by propagateAndMatch().

162  {
163  ap_uint<BITSPROPCOORD> prop_coord1 = 0;
164  ap_uint<BITSPROPCOORD> prop_coord2 = 0;
165  ap_uint<BITSPROPSIGMACOORD_A> res0_coord1 = 0;
166  ap_uint<BITSPROPSIGMACOORD_B> res1_coord1 = 0;
167  ap_uint<BITSPROPSIGMACOORD_A> res0_coord2 = 0;
168  ap_uint<BITSPROPSIGMACOORD_B> res1_coord2 = 0;
169  ap_uint<BITSPROPSIGMAETA_A> res0_eta1 = 0;
170  ap_uint<BITSPROPSIGMAETA_B> res1_eta = 0;
171  ap_uint<BITSPROPSIGMAETA_A> res0_eta2 = 0;
172  ap_uint<1> is_barrel = 0;
173 
174  uint reducedAbsEta = track.abseta() / 8;
175 
176  if (layer == 0) {
177  prop_coord1 = lt_prop_coord1_0[reducedAbsEta];
178  prop_coord2 = lt_prop_coord2_0[reducedAbsEta];
179  res0_coord1 = lt_res0_coord1_0[reducedAbsEta];
180  res1_coord1 = lt_res1_coord1_0[reducedAbsEta];
181  res0_coord2 = lt_res0_coord2_0[reducedAbsEta];
182  res1_coord2 = lt_res1_coord2_0[reducedAbsEta];
183  res0_eta1 = lt_res0_eta1_0[reducedAbsEta];
184  res1_eta = lt_res1_eta_0[reducedAbsEta];
185  res0_eta2 = lt_res0_eta2_0[reducedAbsEta];
186  is_barrel = reducedAbsEta < barrelLimit0_ ? 1 : 0;
187  } else if (layer == 1) {
188  prop_coord1 = lt_prop_coord1_1[reducedAbsEta];
189  prop_coord2 = lt_prop_coord2_1[reducedAbsEta];
190  res0_coord1 = lt_res0_coord1_1[reducedAbsEta];
191  res1_coord1 = lt_res1_coord1_1[reducedAbsEta];
192  res0_coord2 = lt_res0_coord2_1[reducedAbsEta];
193  res1_coord2 = lt_res1_coord2_1[reducedAbsEta];
194  res0_eta1 = lt_res0_eta1_1[reducedAbsEta];
195  res1_eta = lt_res1_eta_1[reducedAbsEta];
196  res0_eta2 = lt_res0_eta2_1[reducedAbsEta];
197  is_barrel = reducedAbsEta < barrelLimit1_ ? 1 : 0;
198 
199  } else if (layer == 2) {
200  prop_coord1 = lt_prop_coord1_2[reducedAbsEta];
201  prop_coord2 = lt_prop_coord2_2[reducedAbsEta];
202  res0_coord1 = lt_res0_coord1_2[reducedAbsEta];
203  res1_coord1 = lt_res1_coord1_2[reducedAbsEta];
204  res0_coord2 = lt_res0_coord2_2[reducedAbsEta];
205  res1_coord2 = lt_res1_coord2_2[reducedAbsEta];
206  res0_eta1 = lt_res0_eta1_2[reducedAbsEta];
207  res1_eta = lt_res1_eta_2[reducedAbsEta];
208  res0_eta2 = lt_res0_eta2_2[reducedAbsEta];
209  is_barrel = reducedAbsEta < barrelLimit2_ ? 1 : 0;
210 
211  } else if (layer == 3) {
212  prop_coord1 = lt_prop_coord1_3[reducedAbsEta];
213  prop_coord2 = lt_prop_coord2_3[reducedAbsEta];
214  res0_coord1 = lt_res0_coord1_3[reducedAbsEta];
215  res1_coord1 = lt_res1_coord1_3[reducedAbsEta];
216  res0_coord2 = lt_res0_coord2_3[reducedAbsEta];
217  res1_coord2 = lt_res1_coord2_3[reducedAbsEta];
218  res0_eta1 = lt_res0_eta1_3[reducedAbsEta];
219  res1_eta = lt_res1_eta_3[reducedAbsEta];
220  res0_eta2 = lt_res0_eta2_3[reducedAbsEta];
221  is_barrel = reducedAbsEta < barrelLimit3_ ? 1 : 0;
222 
223  } else if (layer == 4) {
224  prop_coord1 = lt_prop_coord1_4[reducedAbsEta];
225  prop_coord2 = lt_prop_coord2_4[reducedAbsEta];
226  res0_coord1 = lt_res0_coord1_4[reducedAbsEta];
227  res1_coord1 = lt_res1_coord1_4[reducedAbsEta];
228  res0_coord2 = lt_res0_coord2_4[reducedAbsEta];
229  res1_coord2 = lt_res1_coord2_4[reducedAbsEta];
230  res0_eta1 = lt_res0_eta1_4[reducedAbsEta];
231  res1_eta = lt_res1_eta_4[reducedAbsEta];
232  res0_eta2 = lt_res0_eta2_4[reducedAbsEta];
233  is_barrel = 0;
234  }
235 
236  propagation_t out;
237  ap_int<BITSTTCURV> curvature = track.curvature();
238  ap_int<BITSPHI> phi = track.phi();
239  ap_int<BITSPROPCOORD + BITSTTCURV> c1kFull = prop_coord1 * curvature;
240  ap_int<BITSPROPCOORD + BITSTTCURV - 10> c1k = (c1kFull) / 1024;
241  ap_int<BITSPHI> coord1 = phi - c1k;
242 
243  out.coord1 = coord1 / PHIDIVIDER;
244 
245  ap_int<BITSPROPCOORD + BITSTTCURV> c2kFull = prop_coord2 * curvature;
246 
247  ap_int<BITSPROPCOORD + BITSTTCURV - 10> c2k = (c2kFull) / 1024;
248  if (is_barrel)
249  out.coord2 = -c2k / PHIDIVIDER;
250  else
251  out.coord2 = (phi - c2k) / PHIDIVIDER;
252 
253  ap_int<BITSETA> eta = track.eta();
254  out.eta = eta / ETADIVIDER;
255 
256  ap_uint<2 * BITSTTCURV - 2> curvature2All = curvature * curvature;
257  ap_uint<BITSTTCURV2> curvature2 = curvature2All / 2;
258 
259  //Remember to change emulator with new k2
260  ap_uint<BITSPROPSIGMACOORD_B + BITSTTCURV2> rescoord1k = (res1_coord1 * curvature2) >> 23;
261  ap_ufixed<BITSSIGMACOORD, BITSSIGMACOORD, AP_TRN_ZERO, AP_SAT_SYM> sigma_coord1 = res0_coord1 + rescoord1k;
262  out.sigma_coord1 = ap_uint<BITSSIGMACOORD>(sigma_coord1);
263 
264  ap_uint<BITSPROPSIGMACOORD_B + BITSTTCURV2> rescoord2k = (res1_coord2 * curvature2) >> 23;
265  ap_ufixed<BITSSIGMACOORD, BITSSIGMACOORD, AP_TRN_ZERO, AP_SAT_SYM> sigma_coord2 = res0_coord2 + rescoord2k;
266  out.sigma_coord2 = ap_uint<BITSSIGMACOORD>(sigma_coord2);
267 
268  ap_uint<BITSPROPSIGMAETA_B + BITSTTCURV2> resetak = (res1_eta * curvature2) >> 23;
269  ap_ufixed<BITSSIGMAETA, BITSSIGMAETA, AP_TRN_ZERO, AP_SAT_SYM> sigma_eta1 = res0_eta1 + resetak;
270  out.sigma_eta1 = ap_uint<BITSSIGMAETA>(sigma_eta1);
271  ap_ufixed<BITSSIGMAETA, BITSSIGMAETA, AP_TRN_ZERO, AP_SAT_SYM> sigma_eta2 = res0_eta2 + resetak;
272  out.sigma_eta2 = ap_uint<BITSSIGMAETA>(sigma_eta2);
273  out.valid = 1;
274  out.is_barrel = is_barrel;
275 
276  if (verbose_ == 1)
277 
278  printf("Propagating to layer %d:is barrel=%d coords=%d+-%d , %d +-%d etas = %d +- %d +-%d\n",
279  int(layer),
280  out.is_barrel.to_int(),
281  out.coord1.to_int(),
282  out.sigma_coord1.to_int(),
283  out.coord2.to_int(),
284  out.sigma_coord2.to_int(),
285  out.eta.to_int(),
286  out.sigma_eta1.to_int(),
287  out.sigma_eta2.to_int());
288 
289  return out;
290  }
const ap_uint< BITSPROPSIGMACOORD_A > lt_res0_coord1_3[512]
Definition: Constants.h:635
const ap_uint< BITSPROPSIGMACOORD_B > lt_res1_coord2_0[512]
Definition: Constants.h:1011
const int barrelLimit0_
Definition: Constants.h:84
const ap_uint< BITSPROPSIGMACOORD_B > lt_res1_coord2_4[512]
Definition: Constants.h:1092
const int barrelLimit1_
Definition: Constants.h:85
const int barrelLimit3_
Definition: Constants.h:87
const ap_uint< BITSPROPCOORD > lt_prop_coord1_0[512]
Definition: Constants.h:338
const ap_uint< BITSPROPSIGMAETA_B > lt_res1_eta_2[512]
Definition: Constants.h:1144
const ap_uint< BITSPROPCOORD > lt_prop_coord1_2[512]
Definition: Constants.h:388
const ap_uint< BITSPROPSIGMAETA_A > lt_res0_eta1_0[512]
Definition: Constants.h:752
const ap_uint< BITSPROPSIGMACOORD_B > lt_res1_coord1_2[512]
Definition: Constants.h:953
const ap_uint< BITSPROPSIGMAETA_B > lt_res1_eta_1[512]
Definition: Constants.h:1128
const ap_uint< BITSPROPSIGMACOORD_A > lt_res0_coord2_4[512]
Definition: Constants.h:736
const ap_uint< BITSPROPCOORD > lt_prop_coord2_1[512]
Definition: Constants.h:487
const ap_uint< BITSPROPSIGMACOORD_B > lt_res1_coord1_3[512]
Definition: Constants.h:969
const ap_uint< BITSPROPSIGMAETA_A > lt_res0_eta1_4[512]
Definition: Constants.h:816
const ap_uint< BITSPROPSIGMAETA_A > lt_res0_eta1_1[512]
Definition: Constants.h:768
const ap_uint< BITSPROPSIGMACOORD_A > lt_res0_coord2_1[512]
Definition: Constants.h:688
const ap_uint< BITSPROPCOORD > lt_prop_coord2_4[512]
Definition: Constants.h:562
const ap_uint< BITSPROPCOORD > lt_prop_coord2_0[512]
Definition: Constants.h:463
const ap_uint< BITSPROPSIGMAETA_A > lt_res0_eta2_3[512]
Definition: Constants.h:880
const ap_uint< BITSPROPCOORD > lt_prop_coord1_4[512]
Definition: Constants.h:438
T curvature(T InversePt, const MagneticField &field)
const int barrelLimit2_
Definition: Constants.h:86
const ap_uint< BITSPROPSIGMAETA_A > lt_res0_eta1_2[512]
Definition: Constants.h:784
const ap_uint< BITSPROPCOORD > lt_prop_coord1_1[512]
Definition: Constants.h:363
const ap_uint< BITSPROPCOORD > lt_prop_coord2_3[512]
Definition: Constants.h:537
const ap_uint< BITSPROPSIGMAETA_B > lt_res1_eta_4[512]
Definition: Constants.h:1176
const ap_uint< BITSPROPSIGMACOORD_A > lt_res0_coord2_2[512]
Definition: Constants.h:704
const ap_uint< BITSPROPSIGMACOORD_B > lt_res1_coord1_1[512]
Definition: Constants.h:933
const ap_uint< BITSPROPSIGMACOORD_A > lt_res0_coord1_1[512]
Definition: Constants.h:603
const ap_uint< BITSPROPSIGMAETA_A > lt_res0_eta2_0[512]
Definition: Constants.h:832
const ap_uint< BITSPROPSIGMACOORD_A > lt_res0_coord2_0[512]
Definition: Constants.h:672
const ap_uint< BITSPROPSIGMACOORD_B > lt_res1_coord1_0[512]
Definition: Constants.h:913
const ap_uint< BITSPROPSIGMAETA_A > lt_res0_eta2_2[512]
Definition: Constants.h:864
const int BITSTTCURV
Definition: Constants.h:10
const ap_uint< BITSPROPSIGMACOORD_A > lt_res0_coord2_3[512]
Definition: Constants.h:720
const ap_uint< BITSPROPSIGMAETA_A > lt_res0_eta2_4[512]
Definition: Constants.h:896
const unsigned int PHIDIVIDER
const ap_uint< BITSPROPSIGMACOORD_A > lt_res0_coord1_4[512]
Definition: Constants.h:656
const ap_uint< BITSPROPSIGMACOORD_B > lt_res1_coord2_2[512]
Definition: Constants.h:1053
const ap_uint< BITSPROPSIGMACOORD_B > lt_res1_coord2_3[512]
Definition: Constants.h:1074
const ap_uint< BITSPROPSIGMACOORD_B > lt_res1_coord1_4[512]
Definition: Constants.h:990
const ap_uint< BITSPROPCOORD > lt_prop_coord2_2[512]
Definition: Constants.h:512
const ap_uint< BITSPROPSIGMAETA_B > lt_res1_eta_0[512]
Definition: Constants.h:1112
const ap_uint< BITSPROPSIGMAETA_A > lt_res0_eta2_1[512]
Definition: Constants.h:848
const int BITSPROPCOORD
Definition: Constants.h:47
const ap_uint< BITSPROPSIGMAETA_A > lt_res0_eta1_3[512]
Definition: Constants.h:800
const ap_uint< BITSPROPSIGMAETA_B > lt_res1_eta_3[512]
Definition: Constants.h:1160
const ap_uint< BITSPROPSIGMACOORD_A > lt_res0_coord1_0[512]
Definition: Constants.h:587
const ap_uint< BITSPROPSIGMACOORD_A > lt_res0_coord1_2[512]
Definition: Constants.h:619
const ap_uint< BITSPROPCOORD > lt_prop_coord1_3[512]
Definition: Constants.h:413
const unsigned int ETADIVIDER
const ap_uint< BITSPROPSIGMACOORD_B > lt_res1_coord2_1[512]
Definition: Constants.h:1032

◆ propagateAndMatch()

match_t Phase2L1GMT::TrackMuonMatchAlgorithm::propagateAndMatch ( const ConvertedTTTrack track,
const l1t::MuonStubRef stub 
)
inlineprivate

Definition at line 414 of file TrackMuonMatchAlgorithm.h.

References match(), propagate(), and HLT_2024v14_cff::track.

Referenced by processTrack().

414  {
415  propagation_t prop = propagate(track, stub->tfLayer());
416  return match(prop, stub);
417  }
propagation_t propagate(const ConvertedTTTrack &track, uint layer)
match_t match(const propagation_t prop, const l1t::MuonStubRef &stub)

◆ sort()

std::vector<l1t::TrackerMuon> Phase2L1GMT::TrackMuonMatchAlgorithm::sort ( std::vector< l1t::TrackerMuon > &  muons,
uint  maximum 
)
inline

Definition at line 144 of file TrackMuonMatchAlgorithm.h.

References a, b, mps_fire::i, DiMuonV_cfg::muons, MillePedeFileConverter_cfg::out, and jetUpdater_cfi::sort.

144  {
145  if (muons.size() < 2)
146  return muons;
147 
148  std::sort(muons.begin(), muons.end(), [](l1t::TrackerMuon a, l1t::TrackerMuon b) { return a.hwPt() > b.hwPt(); });
149  std::vector<l1t::TrackerMuon> out;
150  for (unsigned int i = 0; i < muons.size(); ++i) {
151  out.push_back(muons[i]);
152  if (i == (maximum - 1))
153  break;
154  }
155 
156  return out;
157  }
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
Definition: DiMuonV_cfg.py:214
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121

Member Data Documentation

◆ verbose_

int Phase2L1GMT::TrackMuonMatchAlgorithm::verbose_
private

Definition at line 160 of file TrackMuonMatchAlgorithm.h.

Referenced by clean(), cleanNeighbor(), convert(), match(), processTrack(), and propagate().