11 std::vector<PreTrackMatchedMuon> preMuons;
14 if (
mu.valid() && preMuons.size() < 16)
15 preMuons.push_back(
mu);
17 std::vector<PreTrackMatchedMuon> cleanedMuons =
clean(preMuons);
22 const std::vector<PreTrackMatchedMuon>& muonsPrevious,
23 const std::vector<PreTrackMatchedMuon>& muonsNext,
25 std::vector<PreTrackMatchedMuon>
out;
31 edm::LogInfo(
"TPSAlgo") <<
"-----Cleaning Up Muons in the neighbours";
39 ap_uint<5>
mask = 0x1f;
40 for (
uint j = 0;
j < muonsPrevious.size(); ++
j) {
43 for (
uint j = 0;
j < muonsNext.size(); ++
j) {
59 std::vector<l1t::TrackerMuon>
out;
61 if (
out.size() == maximum)
64 muon.setMuonRef(
mu.muonRef());
65 for (
const auto& stub :
mu.stubs())
71 for (
uint i = 0;
i < 10;
i =
i + 1) {
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;
94 qualbit = (veryloose << 0) | (loose << 1) | (medium << 2) | (tight << 3);
95 mu.setHwQual(qualbit);
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);
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);
118 std::array<uint64_t, 2> wordout = {{word1, word2}};
125 if (
muons.size() < 2)
129 std::vector<l1t::TrackerMuon>
out;
130 for (
unsigned int i = 0;
i <
muons.size(); ++
i) {
132 if (
i == (maximum - 1))
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 = {
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 = {
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 = {
159 static const std::array<const ap_uint<BITSPROPSIGMAETA_A>*, 5> lt_res0_eta2 = {
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;
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;
192 ap_int<BITSPHI> phi =
track.phi();
193 ap_int<BITSPROPCOORD + BITSTTCURV> c1kFull = prop_coord1 *
curvature;
195 ap_int<BITSPHI> coord1 = phi - c1k;
199 ap_int<BITSPROPCOORD + BITSTTCURV> c2kFull = prop_coord2 *
curvature;
211 ap_uint<BITSTTCURV2> curvature2 = curvature2All / 2;
215 if (
track.curvature() < 0)
216 absK = ap_uint<BITSTTCURV - 1>(-
track.curvature());
227 out.sigma_coord1 = ap_uint<BITSSIGMACOORD>(sigma1 /
PHIDIVIDER);
232 out.sigma_coord2 = ap_uint<BITSSIGMACOORD>(sigma2 /
PHIDIVIDER);
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);
240 out.is_barrel = is_barrel;
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();
249 edm::LogInfo(
"TPSAlgo") <<
"----- breakout of sigma 1 : constant=" << res0_coord1.to_int()
250 <<
" slope=" << res1_coord1.to_int() <<
" before division=" << s1k.to_int();
252 edm::LogInfo(
"TPSAlgo") <<
"----- breakout of sigma 2 : constant=" << res0_coord2.to_int()
253 <<
" slope=" << res1_coord2.to_int() <<
" before division=" << s2k.to_int();
259 ap_fixed<BITSSIGMAETA + 2, BITSSIGMAETA + 2, AP_TRN_ZERO, AP_SAT_SYM>
dEta =
eta1 -
eta2;
261 return ap_uint<BITSSIGMAETA + 1>(-
dEta);
263 return ap_uint<BITSSIGMAETA + 1>(
dEta);
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;
271 dPhi = ap_ufixed<BITSSIGMACOORD + 1, BITSSIGMACOORD + 1, AP_TRN_ZERO, AP_SAT_SYM>(-dPhiRoll);
273 dPhi = ap_ufixed<BITSSIGMACOORD + 1, BITSSIGMACOORD + 1, AP_TRN_ZERO, AP_SAT_SYM>(dPhiRoll);
275 return ap_uint<BITSSIGMACOORD + 1>(dPhi);
280 edm::LogInfo(
"TPSAlgo") <<
"Matching to coord1=" << stub->coord1() <<
" coord2=" << stub->coord2()
281 <<
" eta1=" << stub->eta1() <<
" eta2=" << stub->eta2();
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)) {
294 edm::LogInfo(
"TPSAlgo") <<
"Coord1 matched=" << coord1Matched.to_int() <<
" delta=" << deltaCoord1.to_int()
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)) {
306 edm::LogInfo(
"TPSAlgo") <<
"Coord2 matched=" << coord2Matched.to_int() <<
" delta=" << deltaCoord2.to_int()
311 ap_uint<1> eta1Matched;
315 ap_ufixed<BITSSIGMAETA, BITSSIGMAETA, AP_TRN_ZERO, AP_SAT_SYM> prop_sigma_eta1;
316 if (stub->etaQuality() == 0)
321 ap_uint<BITSSIGMAETA + 1> deltaEta1 =
deltaEta(prop.
eta, stub->eta1());
322 if (deltaEta1 <= prop_sigma_eta1 && (stub->etaQuality() == 0 || (stub->etaQuality() & 0x1)))
328 edm::LogInfo(
"TPSAlgo") <<
"eta1 matched=" << eta1Matched.to_int() <<
" delta=" << deltaEta1.to_int()
329 <<
" res=" << prop_sigma_eta1.to_int();
333 ap_uint<1> eta2Matched;
335 ap_uint<BITSSIGMAETA + 1> deltaEta2 =
deltaEta(prop.
eta, stub->eta2());
336 if (deltaEta2 <= prop.
sigma_eta2 && (stub->etaQuality() & 0x2))
344 edm::LogInfo(
"TPSAlgo") <<
"eta2 matched=" << eta2Matched.to_int() <<
" delta=" << deltaEta2.to_int()
351 out.valid = (coord1Matched == 1 && (eta1Matched == 1 || eta2Matched == 1)) ? 1 : 0;
352 if (
out.valid == 0) {
355 out.quality = 32 - deltaCoord1 / 4;
356 if (coord2Matched == 1) {
357 out.quality += 32 - deltaCoord2 / 4;
364 bool match1 = (coord1Matched == 1 && eta1Matched == 1);
365 bool match2 = (coord2Matched == 1 && eta2Matched == 1);
367 (coord1Matched == 1 && (eta1Matched || eta2Matched) && stub->etaQuality() == 3 && stub->quality() == 1);
368 out.valid = (match1 || match2 || match3) ? 1 : 0;
373 if (match1 || match3)
374 out.quality += 32 - deltaCoord1 / 4;
376 out.quality += 32 - deltaCoord2 / 4;
377 if (match1 || match3)
383 edm::LogInfo(
"TPSAlgo") <<
"GlobalMatchQuality = " <<
out.quality.to_int();
390 return match(prop, stub, trackID);
396 if (
m.quality > best.quality)
405 ap_uint<BITSMATCHQUALITY>&
quality) {
406 if (!matchInfo.empty()) {
409 muon.addStub(
b.stubRef,
b.valid);
411 muon.addMuonRef(
b.muRef);
418 std::array<std::vector<match_t>, 6> matchInfos;
421 edm::LogInfo(
"TPSAlgo") <<
"-----------processing new track----------";
424 for (
const auto& stub :
stubs) {
426 if (
m.valid != 0 && stub->tfLayer() < 6) {
427 matchInfos[stub->tfLayer()].push_back(
m);
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);
433 ap_uint<BITSMATCHQUALITY>
quality = 0;
436 for (
auto&&
m : matchInfos)
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);
447 if (!
muon.stubs().empty()) {
451 muon.setValid(
false);
463 for (
uint i = 0;
i < 16; ++
i) {
465 edm::LogInfo(
"TPSAlgo") <<
"remember to implement printout of muon";
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;
482 ap_uint<5>
valid = 0;
485 if (
mu.stubID0() != bittest) {
487 if (
mu.stubID0() ==
other.stubID0())
490 if (
mu.stubID1() != bittest) {
492 if (
mu.stubID1() ==
other.stubID1())
495 if (
mu.stubID2() != bittest) {
497 if (
mu.stubID2() ==
other.stubID2())
500 if (
mu.stubID3() != bittest) {
502 if (
mu.stubID3() ==
other.stubID3())
505 if (
mu.stubID4() != bittest) {
507 if (
mu.stubID4() ==
other.stubID4())
511 if (((
mu.quality() <
other.quality()) && (!eq)) || ((
mu.quality() <=
other.quality()) && (eq)))
518 std::vector<PreTrackMatchedMuon>
out;
522 edm::LogInfo(
"TPSAlgo") <<
"-----Cleaning Up Muons in the same Nonant";
529 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
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]
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]
match_t propagateAndMatch(const ConvertedTTTrack &track, const l1t::MuonStubRef &stub, uint trackID)
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]
propagation_t propagate(const ConvertedTTTrack &track, uint layer)
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< edm::Ref< MuonStubCollection > > MuonStubRefVector
const ap_uint< BITSPROPSIGMAETA_A > lt_res0_eta1_2[512]
const ap_uint< BITSPROPCOORD > lt_prop_coord1_1[512]
const ap_uint< BITSPROPCOORD > lt_prop_coord2_3[512]
const ap_uint< BITSPROPSIGMAETA_B > lt_res1_eta_4[512]
bool outputGT(std::vector< l1t::TrackerMuon > &muons)
const ap_uint< BITSPROPSIGMACOORD_A > lt_res0_coord2_2[512]
const ap_uint< BITSPROPSIGMACOORD_B > lt_res1_coord1_1[512]
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]
void matchingInfos(std::vector< match_t > matchInfo, PreTrackMatchedMuon &muon, ap_uint< BITSMATCHQUALITY > &quality)
const ap_uint< BITSPROPSIGMAETA_A > lt_res0_eta2_0[512]
void SetQualityBits(std::vector< l1t::TrackerMuon > &muons)
const ap_uint< BITSPROPSIGMACOORD_A > lt_res0_coord2_0[512]
const ap_uint< BITSPROPSIGMACOORD_B > lt_res1_coord1_0[512]
match_t getBest(const std::vector< match_t > matches)
const ap_uint< BITSPROPSIGMAETA_A > lt_res0_eta2_2[512]
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)
ap_uint< BITSSIGMAETA > sigma_eta1
Log< level::Info, false > LogInfo
const int BITSPROPSIGMACOORD_A
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]
std::vector< l1t::TrackerMuon > convert(std::vector< PreTrackMatchedMuon > &muons, uint maximum)
const ap_uint< BITSPROPSIGMAETA_A > lt_res0_eta2_4[512]
std::vector< PreTrackMatchedMuon > cleanNeighbor(const std::vector< PreTrackMatchedMuon > &muons, const std::vector< PreTrackMatchedMuon > &muonsPrevious, const std::vector< PreTrackMatchedMuon > &muonsNext, bool equality)
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]
std::vector< PreTrackMatchedMuon > clean(std::vector< PreTrackMatchedMuon > &muons)
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]
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]
TPSAlgorithm(const edm::ParameterSet &iConfig)
const ap_uint< BITSPROPSIGMAETA_A > lt_res0_eta1_3[512]
match_t match(const propagation_t prop, const l1t::MuonStubRef &stub, uint trackID)
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]