9 std::vector<PreTrackMatchedMuon> preMuons;
12 if (
mu.valid() && preMuons.size() < 16)
13 preMuons.push_back(
mu);
15 std::vector<PreTrackMatchedMuon> cleanedMuons =
clean(preMuons);
20 const std::vector<PreTrackMatchedMuon>& muonsPrevious,
21 const std::vector<PreTrackMatchedMuon>& muonsNext,
22 bool equality)
const {
23 std::vector<PreTrackMatchedMuon>
out;
29 edm::LogInfo(
"TPSAlgo") <<
"-----Cleaning Up Muons in the neighbours";
37 ap_uint<5>
mask = 0x1f;
38 for (
uint j = 0;
j < muonsPrevious.size(); ++
j) {
41 for (
uint j = 0;
j < muonsNext.size(); ++
j) {
57 std::vector<l1t::TrackerMuon>
out;
59 if (
out.size() == maximum)
62 muon.setMuonRef(
mu.muonRef());
63 for (
const auto& stub :
mu.stubs())
69 for (
uint i = 0;
i < 10;
i =
i + 1) {
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;
92 qualbit = (veryloose << 0) | (loose << 1) | (medium << 2) | (tight << 3);
93 mu.setHwQual(qualbit);
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);
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);
116 std::array<uint64_t, 2> wordout = {{word1, word2}};
123 if (
muons.size() < 2)
127 std::vector<l1t::TrackerMuon>
out{
muons.begin(),
muons.begin() + (maximum <
muons.size() ? maximum :
muons.size())};
133 static const std::array<const ap_uint<BITSPROPCOORD>*, 5> lt_prop1_coord1 = {
135 static const std::array<const ap_uint<BITSPROPCOORD>*, 5> lt_prop1_coord2 = {
137 static const std::array<const ap_uint<BITSPROPCOORD>*, 5> lt_prop2_coord1 = {
139 static const std::array<const ap_uint<BITSPROPCOORD>*, 5> lt_prop2_coord2 = {
142 static const std::array<const ap_uint<BITSPROPSIGMACOORD_A>*, 5> lt_res0_coord1 = {
144 static const std::array<const ap_uint<BITSPROPSIGMACOORD_B>*, 5> lt_res1_coord1 = {
146 static const std::array<const ap_uint<BITSPROPSIGMACOORD_A>*, 5> lt_res0_coord2 = {
148 static const std::array<const ap_uint<BITSPROPSIGMACOORD_B>*, 5> lt_res1_coord2 = {
151 static const std::array<const ap_uint<BITSPROPSIGMAETA_A>*, 5> lt_res0_eta1 = {
153 static const std::array<const ap_uint<BITSPROPSIGMAETA_A>*, 5> lt_res1_eta1 = {
156 static const std::array<const ap_uint<BITSPROPSIGMAETA_A>*, 5> lt_res0_eta2 = {
161 ap_uint<BITSPROPCOORD> prop1_coord1 = 0;
162 ap_uint<BITSPROPCOORD> prop1_coord2 = 0;
163 ap_uint<BITSPROPCOORD> prop2_coord1 = 0;
164 ap_uint<BITSPROPCOORD> prop2_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;
178 prop1_coord1 = lt_prop1_coord1[layer][reducedAbsEta];
179 prop1_coord2 = lt_prop1_coord2[layer][reducedAbsEta];
180 prop2_coord1 = lt_prop2_coord1[layer][reducedAbsEta];
181 prop2_coord2 = lt_prop2_coord2[layer][reducedAbsEta];
182 res0_coord1 = lt_res0_coord1[layer][reducedAbsEta];
183 res1_coord1 = lt_res1_coord1[layer][reducedAbsEta];
184 res0_coord2 = lt_res0_coord2[layer][reducedAbsEta];
185 res1_coord2 = lt_res1_coord2[layer][reducedAbsEta];
186 res0_eta1 = lt_res0_eta1[layer][reducedAbsEta];
187 res1_eta = lt_res1_eta1[layer][reducedAbsEta];
188 res0_eta2 = lt_res0_eta2[layer][reducedAbsEta];
189 is_barrel = reducedAbsEta < barrellimit[layer] ? 1 : 0;
197 ap_int<BITSPHI> phi =
track.phi();
201 ap_int<BITSPROP + 1> dphi;
204 ap_uint<1> negativeCurv;
205 if (
track.curvature() < 0) {
220 absDphiOverflow = c1k + d1kabsK;
224 dphi = absDphiOverflow;
226 if (negativeCurv == 1)
238 absDphiOverflow = c2k + d2kabsK;
242 dphi = absDphiOverflow;
244 if (negativeCurv == 1)
256 ap_uint<BITSTTCURV2> curvature2 = curvature2All / 2;
269 ap_uint<BITSPROPSIGMAETA_B + BITSTTCURV2> resetak = (res1_eta * curvature2) >> 23;
270 ap_ufixed<BITSSIGMAETA, BITSSIGMAETA, AP_TRN_ZERO, AP_SAT_SYM> sigma_eta1 = res0_eta1 + resetak;
271 out.sigma_eta1 = ap_uint<BITSSIGMAETA>(sigma_eta1);
272 ap_ufixed<BITSSIGMAETA, BITSSIGMAETA, AP_TRN_ZERO, AP_SAT_SYM> sigma_eta2 = res0_eta2 + resetak;
273 out.sigma_eta2 = ap_uint<BITSSIGMAETA>(sigma_eta2);
278 out.sigma_coord1 = ~ap_uint<BITSSIGMACOORD>(0);
280 out.sigma_coord1 = 1;
287 out.sigma_coord2 = ~ap_uint<BITSSIGMACOORD>(0);
289 out.sigma_coord2 = 1;
294 out.is_barrel = is_barrel;
297 edm::LogInfo(
"TPSAlgo") <<
"Propagating to layer " <<
int(layer) <<
":is barrel=" <<
out.is_barrel.to_int()
298 <<
" coords=" <<
out.coord1.to_int() <<
"+-" <<
out.sigma_coord1.to_int() <<
" , " 299 <<
out.coord2.to_int() <<
" +-" <<
out.sigma_coord2.to_int()
300 <<
" etas = " <<
out.eta.to_int() <<
" +- " <<
out.sigma_eta1.to_int() <<
" +-" 301 <<
out.sigma_eta2.to_int();
303 edm::LogInfo(
"TPSAlgo") <<
"----- breakout of sigma 1 : constant=" << res0_coord1.to_int()
304 <<
" slope=" << res1_coord1.to_int() <<
" before division=" << s1k.to_int();
306 edm::LogInfo(
"TPSAlgo") <<
"----- breakout of sigma 2 : constant=" << res0_coord2.to_int()
307 <<
" slope=" << res1_coord2.to_int() <<
" before division=" << s2k.to_int();
313 const ap_int<BITSSTUBETA>&
eta2)
const {
314 ap_fixed<BITSSIGMAETA + 2, BITSSIGMAETA + 2, AP_TRN_ZERO, AP_SAT_SYM>
dEta =
eta1 -
eta2;
316 return ap_uint<BITSSIGMAETA + 1>(-
dEta);
318 return ap_uint<BITSSIGMAETA + 1>(
dEta);
322 const ap_int<BITSSTUBCOORD>& phi2)
const {
323 ap_int<BITSSTUBCOORD> dPhiRoll = phi1 - phi2;
324 ap_ufixed<BITSSIGMACOORD + 1, BITSSIGMACOORD + 1, AP_TRN_ZERO, AP_SAT_SYM> dPhi;
326 dPhi = ap_ufixed<BITSSIGMACOORD + 1, BITSSIGMACOORD + 1, AP_TRN_ZERO, AP_SAT_SYM>(-dPhiRoll);
328 dPhi = ap_ufixed<BITSSIGMACOORD + 1, BITSSIGMACOORD + 1, AP_TRN_ZERO, AP_SAT_SYM>(dPhiRoll);
330 return ap_uint<BITSSIGMACOORD + 1>(dPhi);
335 edm::LogInfo(
"TPSAlgo") <<
"Matching to coord1=" << stub->coord1() <<
" coord2=" << stub->coord2()
336 <<
" eta1=" << stub->eta1() <<
" eta2=" << stub->eta2();
341 ap_uint<1> coord1Matched;
342 ap_uint<BITSSIGMACOORD + 1> deltaCoord1 =
deltaCoord(prop.
coord1, stub->coord1());
343 if (deltaCoord1 <= prop.
sigma_coord1 && (stub->quality() & 0x1)) {
349 edm::LogInfo(
"TPSAlgo") <<
"Coord1 matched=" << coord1Matched.to_int() <<
" delta=" << deltaCoord1.to_int()
353 ap_uint<1> coord2Matched;
354 ap_uint<BITSSIGMACOORD + 1> deltaCoord2 =
deltaCoord(prop.
coord2, stub->coord2());
355 if (deltaCoord2 <= prop.
sigma_coord2 && (stub->quality() & 0x2)) {
361 edm::LogInfo(
"TPSAlgo") <<
"Coord2 matched=" << coord2Matched.to_int() <<
" delta=" << deltaCoord2.to_int()
366 ap_uint<1> eta1Matched;
370 ap_ufixed<BITSSIGMAETA, BITSSIGMAETA, AP_TRN_ZERO, AP_SAT_SYM> prop_sigma_eta1;
371 if (stub->etaQuality() == 0)
376 ap_uint<BITSSIGMAETA + 1> deltaEta1 =
deltaEta(prop.
eta, stub->eta1());
377 if (deltaEta1 <= prop_sigma_eta1 && (stub->etaQuality() == 0 || (stub->etaQuality() & 0x1)))
383 edm::LogInfo(
"TPSAlgo") <<
"eta1 matched=" << eta1Matched.to_int() <<
" delta=" << deltaEta1.to_int()
384 <<
" res=" << prop_sigma_eta1.to_int();
388 ap_uint<1> eta2Matched;
390 ap_uint<BITSSIGMAETA + 1> deltaEta2 =
deltaEta(prop.
eta, stub->eta2());
391 if (deltaEta2 <= prop.
sigma_eta2 && (stub->etaQuality() & 0x2))
399 edm::LogInfo(
"TPSAlgo") <<
"eta2 matched=" << eta2Matched.to_int() <<
" delta=" << deltaEta2.to_int()
406 out.valid = (coord1Matched == 1 && (eta1Matched == 1 || eta2Matched == 1)) ? 1 : 0;
407 if (
out.valid == 0) {
410 out.quality = 32 - deltaCoord1 / 4;
411 if (coord2Matched == 1) {
412 out.quality += 32 - deltaCoord2 / 4;
419 bool match1 = (coord1Matched == 1 && eta1Matched == 1);
420 bool match2 = (coord2Matched == 1 && eta2Matched == 1);
422 (coord1Matched == 1 && (eta1Matched || eta2Matched) && stub->etaQuality() == 3 && stub->quality() == 1);
423 out.valid = (match1 || match2 || match3) ? 1 : 0;
428 if (match1 || match3)
429 out.quality += 32 - deltaCoord1 / 4;
431 out.quality += 32 - deltaCoord2 / 4;
432 if (match1 || match3)
438 edm::LogInfo(
"TPSAlgo") <<
"GlobalMatchQuality = " <<
out.quality.to_int();
445 uint trackID)
const {
447 return match(prop, stub, trackID);
453 if (
m.quality > best.quality)
462 ap_uint<BITSMATCHQUALITY>&
quality)
const {
463 if (!matchInfo.empty()) {
466 muon.addStub(
b.stubRef,
b.valid);
468 muon.addMuonRef(
b.muRef);
476 std::array<std::vector<match_t>, 6> matchInfos;
479 edm::LogInfo(
"TPSAlgo") <<
"-----------processing new track----------";
482 for (
const auto& stub :
stubs) {
484 if (
m.valid != 0 && stub->tfLayer() < 6) {
485 matchInfos[stub->tfLayer()].push_back(
m);
489 ap_ufixed<6, 6, AP_TRN_ZERO, AP_SAT_SYM> ptPenalty = ap_ufixed<6, 6, AP_TRN_ZERO, AP_SAT_SYM>(
track.pt() / 32);
491 ap_uint<BITSMATCHQUALITY>
quality = 0;
494 for (
auto&&
m : matchInfos)
500 ap_uint<8> etaAddr =
muon.eta() < 0 ? ap_uint<8>(-
muon.eta() / 256) : ap_uint<8>((
muon.eta()) / 256);
501 ap_uint<8> ptAddr =
muon.pt() > 4095 ? ap_uint<8>(15) : ap_uint<8>(
muon.pt() / 256);
502 ap_uint<8>
addr = ptAddr | (etaAddr << 4);
505 if (!
muon.stubs().empty()) {
509 muon.setValid(
false);
521 for (
uint i = 0;
i < 16; ++
i) {
523 edm::LogInfo(
"TPSAlgo") <<
"remember to implement printout of muon";
525 edm::LogInfo(
"TPSAlgo") << std::hex << std::setw(8) << 0 << std::flush;
526 edm::LogInfo(
"TPSAlgo") << std::hex << std::setw(16) << 0x1ff000000000000 << std::flush;
527 edm::LogInfo(
"TPSAlgo") << std::hex << std::setw(16) << 0x1ff000000000000 << std::flush;
528 edm::LogInfo(
"TPSAlgo") << std::hex << std::setw(16) << 0x1ff000000000000 << std::flush;
529 edm::LogInfo(
"TPSAlgo") << std::hex << std::setw(16) << 0x1ff000000000000 << std::flush;
530 edm::LogInfo(
"TPSAlgo") << std::hex << std::setw(16) << 0x1ff000000000000 << std::flush;
541 ap_uint<5>
valid = 0;
544 if (
mu.stubID0() != bittest) {
546 if (
mu.stubID0() ==
other.stubID0())
549 if (
mu.stubID1() != bittest) {
551 if (
mu.stubID1() ==
other.stubID1())
554 if (
mu.stubID2() != bittest) {
556 if (
mu.stubID2() ==
other.stubID2())
559 if (
mu.stubID3() != bittest) {
561 if (
mu.stubID3() ==
other.stubID3())
564 if (
mu.stubID4() != bittest) {
566 if (
mu.stubID4() ==
other.stubID4())
570 if (((
mu.quality() <
other.quality()) && (!eq)) || ((
mu.quality() <=
other.quality()) && (eq)))
577 std::vector<PreTrackMatchedMuon>
out;
581 edm::LogInfo(
"TPSAlgo") <<
"-----Cleaning Up Muons in the same Nonant";
588 ap_uint<5>
mask = 0x1f;
const ap_uint< BITSPROPCOORD > lt_prop1_coord2_1[512]
const ap_uint< BITSPROPSIGMACOORD_A > lt_res0_coord1_3[512]
const ap_uint< BITSPROPSIGMACOORD_B > lt_res1_coord2_0[512]
const ap_uint< BITSPROPSIGMACOORD_B > lt_res1_coord2_4[512]
const ap_uint< BITSPROPCOORD > lt_prop1_coord1_3[512]
ap_uint< BITSSIGMACOORD > sigma_coord1
const unsigned int PROPMAX
ap_uint< BITSSIGMAETA+1 > deltaEta(const ap_int< BITSSTUBETA > &eta1, const ap_int< BITSSTUBETA > &eta2) const
const ap_uint< BITSPROPSIGMAETA_B > lt_res1_eta_2[512]
const ap_uint< BITSPROPCOORD > lt_prop2_coord2_1[512]
ap_uint< BITSSIGMACOORD+1 > deltaCoord(const ap_int< BITSSTUBCOORD > &phi1, const ap_int< BITSSTUBCOORD > &phi2) const
const ap_uint< BITSPROPSIGMAETA_A > lt_res0_eta1_0[512]
const ap_uint< BITSPROPSIGMACOORD_B > lt_res1_coord1_2[512]
ap_int< BITSSTUBCOORD > coord1
const ap_uint< BITSPROPSIGMAETA_B > lt_res1_eta_1[512]
const ap_uint< BITSPROPSIGMACOORD_A > lt_res0_coord2_4[512]
const ap_uint< BITSPROPSIGMACOORD_B > lt_res1_coord1_3[512]
const ap_uint< BITSPROPSIGMAETA_A > lt_res0_eta1_4[512]
const ap_uint< BITSPROPSIGMAETA_A > lt_res0_eta1_1[512]
const ap_uint< BITSPROPSIGMACOORD_A > lt_res0_coord2_1[512]
const ap_uint< BITSPROPCOORD > lt_prop1_coord2_3[512]
const ap_uint< BITSPROPCOORD > lt_prop2_coord2_0[512]
const int BITSPROPSIGMACOORD_B
const ap_uint< BITSPROPSIGMAETA_A > lt_res0_eta2_3[512]
const ap_uint< BITSPROPCOORD > lt_prop2_coord2_4[512]
const ap_uint< BITSPROPCOORD > lt_prop2_coord1_2[512]
const ap_uint< BITSPROPCOORD > lt_prop2_coord1_0[512]
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
ap_uint< BITSSIGMAETA > sigma_eta2
T curvature(T InversePt, const MagneticField &field)
ap_uint< BITSSIGMACOORD > sigma_coord2
std::vector< PreTrackMatchedMuon > cleanNeighbor(const std::vector< PreTrackMatchedMuon > &muons, const std::vector< PreTrackMatchedMuon > &muonsPrevious, const std::vector< PreTrackMatchedMuon > &muonsNext, bool equality) const
std::vector< edm::Ref< MuonStubCollection > > MuonStubRefVector
const ap_uint< BITSPROPSIGMAETA_A > lt_res0_eta1_2[512]
void SetQualityBits(std::vector< l1t::TrackerMuon > &muons) const
std::vector< PreTrackMatchedMuon > clean(const std::vector< PreTrackMatchedMuon > &muons) const
const ap_uint< BITSPROPSIGMAETA_B > lt_res1_eta_4[512]
const ap_uint< BITSPROPSIGMACOORD_A > lt_res0_coord2_2[512]
const ap_uint< BITSPROPCOORD > lt_prop2_coord1_4[512]
const ap_uint< BITSPROPSIGMACOORD_B > lt_res1_coord1_1[512]
const ap_uint< BITSPROPSIGMACOORD_A > lt_res0_coord1_1[512]
PreTrackMatchedMuon processTrack(const ConvertedTTTrack &, const l1t::MuonStubRefVector &) const
match_t match(const propagation_t prop, const l1t::MuonStubRef &stub, uint trackID) const
const ap_uint< BITSPROPSIGMAETA_A > lt_res0_eta2_0[512]
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]
bool outputGT(std::vector< l1t::TrackerMuon > &muons) const
const ap_uint< BITSPROPCOORD > lt_prop1_coord2_0[512]
const ap_uint< BITSPROPSIGMACOORD_B > lt_res1_coord1_0[512]
std::vector< PreTrackMatchedMuon > processNonant(const std::vector< ConvertedTTTrack > &convertedTracks, const l1t::MuonStubRefVector &stubs) const
const ap_uint< BITSPROPSIGMAETA_A > lt_res0_eta2_2[512]
ap_uint< 5 > cleanMuon(const PreTrackMatchedMuon &mu, const PreTrackMatchedMuon &other, bool eq) const
ap_uint< BITSSIGMAETA > sigma_eta1
match_t propagateAndMatch(const ConvertedTTTrack &track, const l1t::MuonStubRef &stub, uint trackID) const
const ap_uint< BITSPROPCOORD > lt_prop1_coord2_4[512]
Log< level::Info, false > LogInfo
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
const ap_uint< BITSPROPSIGMACOORD_A > lt_res0_coord2_3[512]
const ap_uint< BITSPROPSIGMAETA_A > lt_res0_eta2_4[512]
ap_int< BITSSTUBETA > eta
const unsigned int PHIDIVIDER
const ap_uint< BITSPROPSIGMACOORD_A > lt_res0_coord1_4[512]
const ap_uint< BITSPROPSIGMACOORD_B > lt_res1_coord2_2[512]
const ap_uint< BITSPROPCOORD > lt_prop2_coord2_2[512]
match_t getBest(const std::vector< match_t > &matches) const
const ap_uint< BITSPROPSIGMACOORD_B > lt_res1_coord2_3[512]
const ap_uint< 8 > lt_tpsID[256]
const ap_uint< BITSPROPSIGMACOORD_B > lt_res1_coord1_4[512]
const ap_uint< BITSPROPSIGMAETA_B > lt_res1_eta_0[512]
const ap_uint< BITSPROPCOORD > lt_prop1_coord1_1[512]
const ap_uint< BITSPROPCOORD > lt_prop1_coord1_0[512]
const ap_uint< BITSPROPSIGMAETA_A > lt_res0_eta2_1[512]
const ap_uint< BITSPROPCOORD > lt_prop1_coord2_2[512]
const ap_uint< BITSPROPCOORD > lt_prop2_coord2_3[512]
const ap_uint< BITSPROPCOORD > lt_prop1_coord1_2[512]
propagation_t propagate(const ConvertedTTTrack &track, uint layer) const
const ap_uint< BITSPROPSIGMAETA_A > lt_res0_eta1_3[512]
const ap_uint< BITSPROPSIGMAETA_B > lt_res1_eta_3[512]
const ap_uint< BITSPROPCOORD > lt_prop2_coord1_1[512]
const ap_uint< BITSPROPSIGMACOORD_A > lt_res0_coord1_0[512]
const ap_uint< BITSPROPSIGMACOORD_A > lt_res0_coord1_2[512]
const ap_uint< BITSPROPCOORD > lt_prop2_coord1_3[512]
ap_int< BITSSTUBCOORD > coord2
const ap_uint< BITSPROPCOORD > lt_prop1_coord1_4[512]
const unsigned int ETADIVIDER
const ap_uint< BITSPROPSIGMACOORD_B > lt_res1_coord2_1[512]