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_prop_coord1 = {
135 static const std::array<const ap_uint<BITSPROPCOORD>*, 5> lt_prop_coord2 = {
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 = {
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 = {
152 static const std::array<const ap_uint<BITSPROPSIGMAETA_A>*, 5> lt_res0_eta2 = {
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;
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;
185 ap_int<BITSPHI> phi =
track.phi();
186 ap_int<BITSPROPCOORD + BITSTTCURV> c1kFull = prop_coord1 *
curvature;
188 ap_int<BITSPHI> coord1 = phi - c1k;
192 ap_int<BITSPROPCOORD + BITSTTCURV> c2kFull = prop_coord2 *
curvature;
204 ap_uint<BITSTTCURV2> curvature2 = curvature2All / 2;
208 if (
track.curvature() < 0)
209 absK = ap_uint<BITSTTCURV - 1>(-
track.curvature());
220 out.sigma_coord1 = ap_uint<BITSSIGMACOORD>(sigma1 /
PHIDIVIDER);
225 out.sigma_coord2 = ap_uint<BITSSIGMACOORD>(sigma2 /
PHIDIVIDER);
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);
233 out.is_barrel = is_barrel;
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();
242 edm::LogInfo(
"TPSAlgo") <<
"----- breakout of sigma 1 : constant=" << res0_coord1.to_int()
243 <<
" slope=" << res1_coord1.to_int() <<
" before division=" << s1k.to_int();
245 edm::LogInfo(
"TPSAlgo") <<
"----- breakout of sigma 2 : constant=" << res0_coord2.to_int()
246 <<
" slope=" << res1_coord2.to_int() <<
" before division=" << s2k.to_int();
252 const ap_int<BITSSTUBETA>&
eta2)
const {
253 ap_fixed<BITSSIGMAETA + 2, BITSSIGMAETA + 2, AP_TRN_ZERO, AP_SAT_SYM>
dEta =
eta1 -
eta2;
255 return ap_uint<BITSSIGMAETA + 1>(-
dEta);
257 return ap_uint<BITSSIGMAETA + 1>(
dEta);
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;
265 dPhi = ap_ufixed<BITSSIGMACOORD + 1, BITSSIGMACOORD + 1, AP_TRN_ZERO, AP_SAT_SYM>(-dPhiRoll);
267 dPhi = ap_ufixed<BITSSIGMACOORD + 1, BITSSIGMACOORD + 1, AP_TRN_ZERO, AP_SAT_SYM>(dPhiRoll);
269 return ap_uint<BITSSIGMACOORD + 1>(dPhi);
274 edm::LogInfo(
"TPSAlgo") <<
"Matching to coord1=" << stub->coord1() <<
" coord2=" << stub->coord2()
275 <<
" eta1=" << stub->eta1() <<
" eta2=" << stub->eta2();
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)) {
288 edm::LogInfo(
"TPSAlgo") <<
"Coord1 matched=" << coord1Matched.to_int() <<
" delta=" << deltaCoord1.to_int()
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)) {
300 edm::LogInfo(
"TPSAlgo") <<
"Coord2 matched=" << coord2Matched.to_int() <<
" delta=" << deltaCoord2.to_int()
305 ap_uint<1> eta1Matched;
309 ap_ufixed<BITSSIGMAETA, BITSSIGMAETA, AP_TRN_ZERO, AP_SAT_SYM> prop_sigma_eta1;
310 if (stub->etaQuality() == 0)
315 ap_uint<BITSSIGMAETA + 1> deltaEta1 =
deltaEta(prop.
eta, stub->eta1());
316 if (deltaEta1 <= prop_sigma_eta1 && (stub->etaQuality() == 0 || (stub->etaQuality() & 0x1)))
322 edm::LogInfo(
"TPSAlgo") <<
"eta1 matched=" << eta1Matched.to_int() <<
" delta=" << deltaEta1.to_int()
323 <<
" res=" << prop_sigma_eta1.to_int();
327 ap_uint<1> eta2Matched;
329 ap_uint<BITSSIGMAETA + 1> deltaEta2 =
deltaEta(prop.
eta, stub->eta2());
330 if (deltaEta2 <= prop.
sigma_eta2 && (stub->etaQuality() & 0x2))
338 edm::LogInfo(
"TPSAlgo") <<
"eta2 matched=" << eta2Matched.to_int() <<
" delta=" << deltaEta2.to_int()
345 out.valid = (coord1Matched == 1 && (eta1Matched == 1 || eta2Matched == 1)) ? 1 : 0;
346 if (
out.valid == 0) {
349 out.quality = 32 - deltaCoord1 / 4;
350 if (coord2Matched == 1) {
351 out.quality += 32 - deltaCoord2 / 4;
358 bool match1 = (coord1Matched == 1 && eta1Matched == 1);
359 bool match2 = (coord2Matched == 1 && eta2Matched == 1);
361 (coord1Matched == 1 && (eta1Matched || eta2Matched) && stub->etaQuality() == 3 && stub->quality() == 1);
362 out.valid = (match1 || match2 || match3) ? 1 : 0;
367 if (match1 || match3)
368 out.quality += 32 - deltaCoord1 / 4;
370 out.quality += 32 - deltaCoord2 / 4;
371 if (match1 || match3)
377 edm::LogInfo(
"TPSAlgo") <<
"GlobalMatchQuality = " <<
out.quality.to_int();
384 uint trackID)
const {
386 return match(prop, stub, trackID);
392 if (
m.quality > best.quality)
401 ap_uint<BITSMATCHQUALITY>&
quality)
const {
402 if (!matchInfo.empty()) {
405 muon.addStub(
b.stubRef,
b.valid);
407 muon.addMuonRef(
b.muRef);
415 std::array<std::vector<match_t>, 6> matchInfos;
418 edm::LogInfo(
"TPSAlgo") <<
"-----------processing new track----------";
421 for (
const auto& stub :
stubs) {
423 if (
m.valid != 0 && stub->tfLayer() < 6) {
424 matchInfos[stub->tfLayer()].push_back(
m);
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);
430 ap_uint<BITSMATCHQUALITY>
quality = 0;
433 for (
auto&&
m : matchInfos)
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);
444 if (!
muon.stubs().empty()) {
448 muon.setValid(
false);
460 for (
uint i = 0;
i < 16; ++
i) {
462 edm::LogInfo(
"TPSAlgo") <<
"remember to implement printout of muon";
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;
479 ap_uint<5>
valid = 0;
482 if (
mu.stubID0() != bittest) {
484 if (
mu.stubID0() ==
other.stubID0())
487 if (
mu.stubID1() != bittest) {
489 if (
mu.stubID1() ==
other.stubID1())
492 if (
mu.stubID2() != bittest) {
494 if (
mu.stubID2() ==
other.stubID2())
497 if (
mu.stubID3() != bittest) {
499 if (
mu.stubID3() ==
other.stubID3())
502 if (
mu.stubID4() != bittest) {
504 if (
mu.stubID4() ==
other.stubID4())
508 if (((
mu.quality() <
other.quality()) && (!eq)) || ((
mu.quality() <=
other.quality()) && (eq)))
515 std::vector<PreTrackMatchedMuon>
out;
519 edm::LogInfo(
"TPSAlgo") <<
"-----Cleaning Up Muons in the same Nonant";
526 ap_uint<5>
mask = 0x1f;
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]
ap_uint< BITSSIGMACOORD > sigma_coord1
ap_uint< BITSSIGMAETA+1 > deltaEta(const ap_int< BITSSTUBETA > &eta1, const ap_int< BITSSTUBETA > &eta2) const
const ap_uint< BITSPROPCOORD > lt_prop_coord1_0[512]
const ap_uint< BITSPROPSIGMAETA_B > lt_res1_eta_2[512]
const ap_uint< BITSPROPCOORD > lt_prop_coord1_2[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< BITSPROPCOORD > lt_prop_coord2_1[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_prop_coord2_4[512]
const int BITSPROPSIGMACOORD_B
const ap_uint< BITSPROPCOORD > lt_prop_coord2_0[512]
const ap_uint< BITSPROPSIGMAETA_A > lt_res0_eta2_3[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
const ap_uint< BITSPROPCOORD > lt_prop_coord1_4[512]
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]
const ap_uint< BITSPROPCOORD > lt_prop_coord1_1[512]
void SetQualityBits(std::vector< l1t::TrackerMuon > &muons) const
const ap_uint< BITSPROPCOORD > lt_prop_coord2_3[512]
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< 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< 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
Log< level::Info, false > LogInfo
const int BITSPROPSIGMACOORD_A
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]
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< BITSPROPCOORD > lt_prop_coord2_2[512]
const ap_uint< BITSPROPSIGMAETA_B > lt_res1_eta_0[512]
const ap_uint< BITSPROPSIGMAETA_A > lt_res0_eta2_1[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< BITSPROPSIGMACOORD_A > lt_res0_coord1_0[512]
const ap_uint< BITSPROPSIGMACOORD_A > lt_res0_coord1_2[512]
ap_int< BITSSTUBCOORD > coord2
const ap_uint< BITSPROPCOORD > lt_prop_coord1_3[512]
const unsigned int ETADIVIDER
const ap_uint< BITSPROPSIGMACOORD_B > lt_res1_coord2_1[512]