7 : verbose_(settings.getParameter<bool>(
"verbose")),
9 initK_(settings.getParameter<std::
vector<double> >(
"initialK")),
10 initK2_(settings.getParameter<std::
vector<double> >(
"initialK2")),
11 eLoss_(settings.getParameter<std::
vector<double> >(
"eLoss")),
12 aPhi_(settings.getParameter<std::
vector<double> >(
"aPhi")),
13 aPhiB_(settings.getParameter<std::
vector<double> >(
"aPhiB")),
14 aPhiBNLO_(settings.getParameter<std::
vector<double> >(
"aPhiBNLO")),
15 bPhi_(settings.getParameter<std::
vector<double> >(
"bPhi")),
16 bPhiB_(settings.getParameter<std::
vector<double> >(
"bPhiB")),
17 phiAt2_(settings.getParameter<double>(
"phiAt2")),
19 chiSquare_(settings.getParameter<std::
vector<double> >(
"chiSquare")),
20 chiSquareCutPattern_(settings.getParameter<std::
vector<int> >(
"chiSquareCutPattern")),
21 chiSquareCutCurv_(settings.getParameter<std::
vector<int> >(
"chiSquareCutCurvMax")),
22 chiSquareCut_(settings.getParameter<std::
vector<int> >(
"chiSquareCut")),
23 trackComp_(settings.getParameter<std::
vector<double> >(
"trackComp")),
24 trackCompErr1_(settings.getParameter<std::
vector<double> >(
"trackCompErr1")),
25 trackCompErr2_(settings.getParameter<std::
vector<double> >(
"trackCompErr2")),
26 trackCompPattern_(settings.getParameter<std::
vector<int> >(
"trackCompCutPattern")),
27 trackCompCutCurv_(settings.getParameter<std::
vector<int> >(
"trackCompCutCurvMax")),
28 trackCompCut_(settings.getParameter<std::
vector<int> >(
"trackCompCut")),
29 chiSquareCutTight_(settings.getParameter<std::
vector<int> >(
"chiSquareCutTight")),
30 combos4_(settings.getParameter<std::
vector<int> >(
"combos4")),
31 combos3_(settings.getParameter<std::
vector<int> >(
"combos3")),
32 combos2_(settings.getParameter<std::
vector<int> >(
"combos2")),
33 combos1_(settings.getParameter<std::
vector<int> >(
"combos1")),
35 useOfflineAlgo_(settings.getParameter<bool>(
"useOfflineAlgo")),
36 mScatteringPhi_(settings.getParameter<std::
vector<double> >(
"mScatteringPhi")),
37 mScatteringPhiB_(settings.getParameter<std::
vector<double> >(
"mScatteringPhiB")),
38 pointResolutionPhi_(settings.getParameter<double>(
"pointResolutionPhi")),
39 pointResolutionPhiB_(settings.getParameter<double>(
"pointResolutionPhiB")),
40 pointResolutionPhiBH_(settings.getParameter<std::
vector<double> >(
"pointResolutionPhiBH")),
41 pointResolutionPhiBL_(settings.getParameter<std::
vector<double> >(
"pointResolutionPhiBL")),
42 pointResolutionVertex_(settings.getParameter<double>(
"pointResolutionVertex"))
47 for (
uint i = 0;
i < tracks.size(); ++
i) {
50 return std::make_pair(
true,
i);
52 return std::make_pair(
false, 0);
99 int processor = track.
sector();
118 word1 = word1 | quality << 9;
120 word1 = word1 | HF << 22;
123 uint32_t word2 =
sign;
124 word2 = word2 | signValid << 1;
125 word2 = word2 | dxy << 2;
126 word2 = word2 | trackAddr << 4;
128 word2 = word2 | pt2 << 23;
135 std::unique_ptr<l1t::RegionalMuonCandBxCollection>&
out) {
162 if (info[i] < info[j])
173 std::map<uint, uint> diffInfo;
174 for (
uint i = 0;
i < 12; ++
i) {
178 std::map<uint, uint> stubInfo;
180 int sector = seed->scNum();
181 int previousSector = sector - 1;
182 int nextSector = sector + 1;
190 int wheel = seed->whNum();
205 for (
const auto& stub : stubs) {
208 if (stub->stNum() !=
step)
214 if (stub->scNum() == previousSector) {
215 if (stub->whNum() == wheel) {
223 }
else if (stub->whNum() == innerWheel) {
232 }
else if (stub->scNum() == sector) {
233 if (stub->whNum() == wheel) {
241 }
else if (stub->whNum() == innerWheel) {
250 }
else if (stub->scNum() == nextSector) {
251 if (stub->whNum() == wheel) {
259 }
else if (stub->whNum() == innerWheel) {
262 stubInfo[10] = N - 1;
265 stubInfo[11] = N - 1;
286 if (diffInfo[s4] != 60000)
287 return std::make_pair(
true, stubInfo[s4]);
289 return std::make_pair(
false, 0);
294 return 8 * stub->phiB();
298 if (stub->scNum() == sector) {
300 }
else if ((stub->scNum() == sector - 1) || (stub->scNum() == 11 && sector == 0)) {
301 return stub->phi() - 2144;
302 }
else if ((stub->scNum() == sector + 1) || (stub->scNum() == 0 && sector == 11)) {
303 return stub->phi() + 2144;
309 unsigned int mask = 0;
310 for (
const auto& stub : track.
stubs()) {
311 mask = mask + round(
pow(2, stub->stNum() - 1));
317 return bit1 * 1 + bit2 * 2 + bit3 * 4 + bit4 * 8;
334 charge = K / fabs(K);
346 int addr = KBound / 2;
348 addr = (-KBound) / 2;
349 deltaK = 2 * addr - int(2 * addr / (1 +
eLoss_[step - 1] * addr));
352 printf(
"propagate to vertex K=%d deltaK=%d addr=%d\n", K, deltaK, addr);
361 ap_fixed<BITSCURV, BITSCURV> phi11 = ap_fixed<BITSPARAM + 1, 2>(
aPhi_[step - 1]) * ap_fixed<BITSCURV, BITSCURV>(K);
362 ap_fixed<BITSPHIB, BITSPHIB> phi12 =
363 ap_fixed<BITSPARAM + 1, 2>(-
bPhi_[step - 1]) * ap_fixed<BITSPHIB, BITSPHIB>(phiB);
366 printf(
"phi prop = %d * %f = %d, %d * %f = %d\n",
368 ap_fixed<BITSPARAM + 1, 2>(
aPhi_[step - 1]).to_float(),
371 ap_fixed<BITSPARAM + 1, 2>(-
bPhi_[step - 1]).to_float(),
374 int phiNew = ap_fixed<BITSPHI, BITSPHI>(phi + phi11 + phi12);
377 ap_fixed<BITSCURV, BITSCURV> phiB11 = ap_fixed<BITSPARAM, 1>(
aPhiB_[step - 1]) * ap_fixed<BITSCURV, BITSCURV>(K);
378 ap_fixed<BITSPHIB + 1, BITSPHIB + 1> phiB12 =
379 ap_ufixed<BITSPARAM + 1, 1>(
bPhiB_[step - 1]) * ap_fixed<BITSPHIB, BITSPHIB>(phiB);
380 int phiBNew = ap_fixed<13, 13>(phiB11 + phiB12);
382 printf(
"phiB prop = %d * %f = %d, %d * %f = %d\n",
384 ap_fixed<BITSPARAM + 1, 2>(
aPhiB_[step - 1]).to_float(),
387 ap_ufixed<BITSPARAM + 1, 1>(
bPhiB_[step - 1]).to_float(),
393 int addr = KBound / 2;
395 ap_ufixed<11, 11> dxyOffset = (int)fabs(
aPhiB_[step - 1] * addr / (1 + charge *
aPhiBNLO_[step - 1] * addr));
396 ap_fixed<12, 12> DXY;
401 phiBNew = ap_fixed<BITSPHIB, BITSPHIB>(DXY - ap_fixed<BITSPHIB, BITSPHIB>(phiB));
403 printf(
"Vertex phiB prop = %d - %d = %d\n", DXY.to_int(), ap_fixed<BITSPHIB, BITSPHIB>(phiB).to_int(), phiBNew);
415 a[3] =
aPhi_[step - 1];
418 a[5] = -
bPhi_[step - 1];
422 a[6] =
aPhiB_[step - 1] / 2.0;
427 ROOT::Math::SMatrix<double, 3>
P(a, 9);
429 const std::vector<double>& covLine = track.
covariance();
431 cov = ROOT::Math::Similarity(P, cov);
437 std::vector<double>
b(6);
450 printf(
"Covariance term for phiB = %f\n", cov(2, 2));
451 printf(
"Multiple scattering term for phiB = %f\n", MS(2, 2));
461 if (mask == 3 || mask == 5 || mask == 9 || mask == 6 || mask == 10 || mask == 12)
467 return updateLUT(track, stub, mask, seedQual);
480 residual[1] = phiB - trackPhiB;
494 if (stub->quality() < 4)
499 const std::vector<double>& covLine = track.
covariance();
505 Matrix32 Gain = cov * ROOT::Math::Transpose(H) *
S;
508 track.
step(), fabs(trackK), Gain(0, 0), Gain(0, 1), Gain(1, 0), Gain(1, 1), Gain(2, 0), Gain(2, 1));
510 int KNew = (trackK + int(Gain(0, 0) * residual(0) + Gain(0, 1) * residual(1)));
511 if (fabs(KNew) > 8192)
514 int phiNew =
wrapAround(trackPhi + residual(0), 8192);
515 int phiBNew =
wrapAround(trackPhiB +
int(Gain(2, 0) * residual(0) + Gain(2, 1) * residual(1)), 4096);
517 track.
setResidual(stub->stNum() - 1, fabs(phi - phiNew) + fabs(phiB - phiBNew) / 8);
520 printf(
"residual %d - %d = %d %d - %d = %d\n", phi, trackPhi,
int(residual[0]), phiB, trackPhiB,
int(residual[1]));
521 printf(
"Gains offline: %f %f %f %f\n", Gain(0, 0), Gain(0, 1), Gain(2, 0), Gain(2, 1));
522 printf(
" K = %d + %f * %f + %f * %f\n", trackK, Gain(0, 0), residual(0), Gain(0, 1), residual(1));
523 printf(
" phiB = %d + %f * %f + %f * %f\n", trackPhiB, Gain(2, 0), residual(0), Gain(2, 1), residual(1));
527 Matrix33 covNew = cov - Gain * (H * cov);
530 c(0, 0) = covNew(0, 0);
531 c(0, 1) = covNew(0, 1);
532 c(0, 2) = covNew(0, 2);
533 c(1, 0) = covNew(1, 0);
534 c(1, 1) = covNew(1, 1);
535 c(1, 2) = covNew(1, 2);
536 c(2, 0) = covNew(2, 0);
537 c(2, 1) = covNew(2, 1);
538 c(2, 2) = covNew(2, 2);
540 printf(
"Post Fit Covariance Matrix %f %f %f\n", cov(0, 0), cov(1, 1), cov(2, 2));
560 printf(
"residuals %d - %d = %d\n", phi, trackPhi,
int(residual));
567 const std::vector<double>& covLine = track.
covariance();
574 Matrix31 Gain = cov * ROOT::Math::Transpose(H) /
S;
576 track.
setKalmanGain(track.
step(), fabs(trackK), Gain(0, 0), 0.0, Gain(1, 0), 0.0, Gain(2, 0), 0.0);
578 printf(
"Gains: %f %f\n", Gain(0, 0), Gain(2, 0));
580 int KNew =
wrapAround(trackK +
int(Gain(0, 0) * residual), 8192);
581 int phiNew =
wrapAround(trackPhi + residual, 8192);
582 int phiBNew =
wrapAround(trackPhiB +
int(Gain(2, 0) * residual), 4096);
584 Matrix33 covNew = cov - Gain * (H * cov);
588 printf(
"phiUpdate: %d %d\n",
int(Gain(0, 0) * residual),
int(Gain(2, 0) * residual));
591 c(0, 0) = covNew(0, 0);
592 c(0, 1) = covNew(0, 1);
593 c(0, 2) = covNew(0, 2);
594 c(1, 0) = covNew(1, 0);
595 c(1, 1) = covNew(1, 1);
596 c(1, 2) = covNew(1, 2);
597 c(2, 0) = covNew(2, 0);
598 c(2, 1) = covNew(2, 1);
599 c(2, 2) = covNew(2, 2);
619 ap_fixed<BITSPHI + 1, BITSPHI + 1> residualPhi = phi -
trackPhi;
620 ap_fixed<BITSPHIB + 1, BITSPHIB + 1> residualPhiB = phiB - trackPhiB;
623 printf(
"residual %d - %d = %d %d - %d = %d\n",
626 residualPhi.to_int(),
629 residualPhiB.to_int());
631 uint absK = fabs(trackK);
635 std::vector<float> GAIN;
637 if (!(mask == 3 || mask == 5 || mask == 9 || mask == 6 || mask == 10 || mask == 12)) {
646 printf(
"Gains (fp): %f %f %f %f\n", GAIN[0], GAIN[1], GAIN[2], GAIN[3]);
647 if (!(mask == 3 || mask == 5 || mask == 9 || mask == 6 || mask == 10 || mask == 12))
648 printf(
"Addr=%d gain0=%f gain4=-%f\n",
650 ap_ufixed<GAIN_0, GAIN_0INT>(GAIN[0]).to_float(),
651 ap_ufixed<GAIN_4, GAIN_4INT>(GAIN[2]).to_float());
653 printf(
"Addr=%d %f -%f %f %f\n",
655 ap_fixed<GAIN2_0, GAIN2_0INT>(GAIN[0]).to_float(),
656 ap_ufixed<GAIN2_1, GAIN2_1INT>(GAIN[1]).to_float(),
657 ap_ufixed<GAIN2_4, GAIN2_4INT>(GAIN[2]).to_float(),
658 ap_ufixed<GAIN2_5, GAIN2_5INT>(GAIN[3]).to_float());
661 track.
setKalmanGain(track.
step(), fabs(trackK), GAIN[0], GAIN[1], 1, 0, GAIN[2], GAIN[3]);
664 if (!(mask == 3 || mask == 5 || mask == 9 || mask == 6 || mask == 10 || mask == 12)) {
665 KNew = ap_fixed<BITSPHI + 9, BITSPHI + 9>(ap_fixed<BITSCURV, BITSCURV>(trackK) +
666 ap_ufixed<GAIN_0, GAIN_0INT>(GAIN[0]) * residualPhi);
668 ap_fixed<BITSPHI + 7, BITSPHI + 7> k11 = ap_fixed<GAIN2_0, GAIN2_0INT>(GAIN[0]) * residualPhi;
669 ap_fixed<BITSPHIB + 4, BITSPHIB + 4> k12 = ap_ufixed<GAIN2_1, GAIN2_1INT>(GAIN[1]) * residualPhiB;
670 KNew = ap_fixed<BITSPHI + 9, BITSPHI + 9>(ap_fixed<BITSCURV, BITSCURV>(trackK) + k11 - k12);
672 if (fabs(KNew) >= 8191)
678 ap_fixed<BITSPHI + 5, BITSPHI + 5> pbdouble_0 = ap_ufixed<GAIN2_4, GAIN2_4INT>(GAIN[2]) * residualPhi;
679 ap_fixed<BITSPHIB + 24, BITSPHIB + 4> pb_1 = ap_ufixed<GAIN2_5, GAIN2_5INT>(GAIN[3]) * residualPhiB;
680 ap_fixed<BITSPHI + 9, BITSPHI + 5> pb_0 = ap_ufixed<GAIN_4, GAIN_4INT>(GAIN[2]) * residualPhi;
683 printf(
"phiupdate %f %f %f\n", pb_0.to_float(), pb_1.to_float(), pbdouble_0.to_float());
687 if (!(mask == 3 || mask == 5 || mask == 9 || mask == 6 || mask == 10 || mask == 12)) {
688 phiBNew = ap_fixed<BITSPHI + 8, BITSPHI + 8>(ap_fixed<BITSPHIB, BITSPHIB>(trackPhiB) -
689 ap_ufixed<GAIN_4, GAIN_4INT>(GAIN[2]) * residualPhi);
691 if (fabs(phiBNew) >= 4095)
694 phiBNew = ap_fixed<BITSPHI + 7, BITSPHI + 7>(ap_fixed<BITSPHIB, BITSPHIB>(trackPhiB) + pb_1 - pbdouble_0);
695 if (fabs(phiBNew) >= 4095)
714 double residual = -track.
dxy();
720 const std::vector<double>& covLine = track.
covariance();
725 Matrix31 Gain = cov * (ROOT::Math::Transpose(H)) * S;
729 printf(
"sigma3=%f sigma6=%f\n", cov(0, 3), cov(3, 3));
730 printf(
" K = %d + %f * %f\n", track.
curvature(), Gain(0, 0), residual);
735 int dxyNew =
wrapAround(
int(track.
dxy() + Gain(2, 0) * residual), 8192);
737 printf(
"Post fit impact parameter=%d\n", dxyNew);
739 Matrix33 covNew = cov - Gain * (H * cov);
741 c(0, 0) = covNew(0, 0);
742 c(0, 1) = covNew(0, 1);
743 c(0, 2) = covNew(0, 2);
744 c(1, 0) = covNew(1, 0);
745 c(1, 1) = covNew(1, 1);
746 c(1, 2) = covNew(1, 2);
747 c(2, 0) = covNew(2, 0);
748 c(2, 1) = covNew(2, 1);
749 c(2, 2) = covNew(2, 2);
755 double residual = -track.
dxy();
763 ap_fixed<BITSCURV, BITSCURV> k_0 =
764 -(ap_ufixed<GAIN_V0, GAIN_V0INT>(fabs(GAIN.first))) * ap_fixed<BITSPHIB, BITSPHIB>(residual);
765 int KNew = ap_fixed<BITSCURV, BITSCURV>(k_0 + ap_fixed<BITSCURV, BITSCURV>(track.
curvature()));
768 printf(
"VERTEX GAIN(%d)= -%f * %d = %d\n",
770 ap_ufixed<GAIN_V0, GAIN_V0INT>(fabs(GAIN.first)).to_float(),
771 ap_fixed<BITSPHIB, BITSPHIB>(residual).to_int(),
775 int p_0 =
fp_product(GAIN.second,
int(residual), 7);
788 double lsb = 1.25 / float(1 << 13);
789 double lsbEta = 0.010875;
799 double eta = etaINT * lsbEta;
808 K = 46 * K / fabs(K);
809 double pt = 1.0 / (lsb * fabs(K));
819 std::vector<int> combinatorics;
821 switch (seed->stNum()) {
838 printf(
"Something really bad happend\n");
842 seedQual = seed->quality();
843 for (
const auto& mask : combinatorics) {
850 charge = phiB / fabs(phiB);
853 if (
track.step() == 4 && (fabs(seed->phiB()) > 15))
854 address = charge * 15 * 8;
856 if (
track.step() == 3 && (fabs(seed->phiB()) > 30))
857 address = charge * 30 * 8;
858 if (
track.step() == 2 && (fabs(seed->phiB()) > 127))
859 address = charge * 127 * 8;
860 int initialK = int(
initK_[seed->stNum() - 1] * address / (1 +
initK2_[seed->stNum() - 1] * charge * address));
863 if (initialK < -8191)
866 track.setCoordinates(seed->stNum(), initialK,
correctedPhi(seed, seed->scNum()), phiB);
867 if (seed->quality() < 4) {
875 float DK = 512 * 512.;
876 covariance(0, 0) = DK;
877 covariance(0, 1) = 0;
878 covariance(0, 2) = 0;
879 covariance(1, 0) = 0;
881 covariance(1, 2) = 0;
882 covariance(2, 0) = 0;
883 covariance(2, 1) = 0;
884 if (!(mask == 3 || mask == 5 || mask == 9 || mask == 6 || mask == 10 || mask == 12))
887 if (seed->quality() < 4)
892 track.setCovariance(covariance);
896 printf(
"New Kalman fit staring at step=%d, phi=%d,phiB=%d with curvature=%d\n",
898 track.positionAngle(),
899 track.bendingAngle(),
902 for (
unsigned int i = 0;
i < 4; ++
i)
905 printf(
"------------------------------------------------------\n");
906 printf(
"------------------------------------------------------\n");
907 printf(
"------------------------------------------------------\n");
909 for (
const auto& stub : stubs)
910 printf(
"station=%d phi=%d phiB=%d qual=%d tag=%d sector=%d wheel=%d fineEta= %d %d\n",
920 printf(
"------------------------------------------------------\n");
921 printf(
"------------------------------------------------------\n");
924 int phiAtStation2 = 0;
926 while (
track.step() > 0) {
928 if (
track.step() == 1) {
940 printf(
"Unconstrained PT in Muon System: pt=%f\n",
track.ptUnconstrained());
945 printf(
"propagated Coordinates step:%d,phi=%d,phiB=%d,K=%d\n",
947 track.positionAngle(),
948 track.bendingAngle(),
951 if (
track.step() > 0)
953 std::pair<bool, uint> bestStub =
match(seed, stubs,
track.step());
954 if ((!bestStub.first) || (!
update(
track, stubs[bestStub.second], mask, seedQual)))
957 printf(
"updated Coordinates step:%d,phi=%d,phiB=%d,K=%d\n",
959 track.positionAngle(),
960 track.bendingAngle(),
965 if (
track.step() == 0) {
968 printf(
" Coordinates before vertex constraint step:%d,phi=%d,dxy=%d,K=%d\n",
972 track.curvatureAtVertex());
979 printf(
" Coordinates after vertex constraint step:%d,phi=%d,dxy=%d,K=%d maximum local chi2=%d\n",
983 track.curvatureAtVertex(),
985 printf(
"------------------------------------------------------\n");
986 printf(
"------------------------------------------------------\n");
990 track.setCoordinatesAtMuon(
track.curvatureAtMuon(), phiAtStation2,
track.phiBAtMuon());
993 printf(
"Floating point coordinates at vertex: pt=%f, eta=%f phi=%f\n",
track.pt(),
track.eta(),
track.phi());
994 pretracks.push_back(
track);
1002 if (!cleaned.empty()) {
1003 return std::make_pair(
true, cleaned[0]);
1005 return std::make_pair(
false, nullTrack);
1019 for (
const auto& stub : track.
stubs()) {
1022 int diff1 =
wrapAround(stubCoords - coords, 1024);
1026 printf(
"Chi Square stub for track with pattern=%d coords=%d -> AK=%d stubCoords=%d diff=%d delta=%d\n",
1057 if (track.
stubs().size() != 2) {
1063 if (track.
stubs()[0]->quality() > track.
stubs()[1]->quality())
1068 printf(
"stubsel %d phi=%d phiB=%d\n", stubSel, stub->phi(), stub->phiB());
1071 ap_ufixed<
BITSCURV - 5, BITSCURV - 5> absK;
1077 ap_fixed<12, 12>
diff = ap_int<10>(stub->phiB()) -
1078 ap_ufixed<5, 1>(
trackComp_[stub->stNum() - 1]) * ap_fixed<BITSCURV - 4, BITSCURV - 4>(K);
1079 ap_ufixed<11, 11>
delta;
1085 ap_ufixed<BITSCURV - 5, BITSCURV - 5>
err =
1089 int deltaMax = ap_ufixed<BITSCURV, BITSCURV>(err *
trackCompCut_[
i]);
1092 printf(
"delta = %d = abs(%d - %f*%d\n", delta.to_int(), stub->phiB(),
trackComp_[stub->stNum() - 1], K);
1093 printf(
"err = %d = %f + %f*%d\n",
1116 return 160 + (track.
stubs().size()) * 20 - chi;
1120 if (value > maximum - 1)
1121 return wrapAround(value - 2 * maximum, maximum);
1122 if (value < -maximum)
1123 return wrapAround(value + 2 * maximum, maximum);
1134 }
else if (sector == 1) {
1153 }
else if (sector == 1) {
1170 std::map<int, int>
out;
1173 if (track.
wheel() == -2)
1175 else if (track.
wheel() == -1)
1177 else if (track.
wheel() == 0)
1179 else if (track.
wheel() == 1)
1181 else if (track.
wheel() == 2)
1195 for (
const auto& stub : track.
stubs()) {
1196 bool ownwheel = stub->whNum() == track.
wheel();
1198 if ((stub->scNum() == track.
sector() + 1) || (stub->scNum() == 0 && track.
sector() == 11))
1200 if ((stub->scNum() == track.
sector() - 1) || (stub->scNum() == 11 && track.
sector() == 0))
1202 int addr =
encode(ownwheel, sector, stub->tag());
1204 if (stub->stNum() == 4) {
1211 if (stub->stNum() == 3) {
1214 if (stub->stNum() == 2) {
1217 if (stub->stNum() == 1) {
1240 return (
long((a * (1 << bits)) * b)) >> bits;
1244 int charge = (K >= 0) ? +1 : -1;
1245 float lsb = 1.25 / float(1 << 13);
1256 FK = .8569 * FK / (1.0 + 0.1144 * FK);
1258 FK = FK - charge * 1.23e-03;
1278 std::map<uint, int> infoRank;
1279 std::map<uint, L1MuKBMTrack> infoTrack;
1280 for (
uint i = 3;
i <= 15; ++
i) {
1281 if (
i == 4 ||
i == 8)
1286 for (
const auto&
track : tracks) {
1294 int sel6 = infoRank[10] >= infoRank[12] ? 10 : 12;
1295 int sel5 = infoRank[14] >= infoRank[9] ? 14 : 9;
1296 int sel4 = infoRank[11] >= infoRank[13] ? 11 : 13;
1297 int sel3 = infoRank[sel6] >= infoRank[sel5] ? sel6 : sel5;
1298 int sel2 = infoRank[sel4] >= infoRank[sel3] ? sel4 : sel3;
1299 selected = infoRank[15] >= infoRank[sel2] ? 15 : sel2;
1303 int sel2 = infoRank[5] >= infoRank[6] ? 5 : 6;
1304 selected = infoRank[7] >= infoRank[sel2] ? 7 : sel2;
1309 auto search = infoTrack.find(selected);
1310 if (
search != infoTrack.end())
1311 out.push_back(
search->second);
1317 if (stub->qeta1() != 0 && stub->qeta2() != 0) {
1320 if (stub->qeta1() == 0) {
1324 return (stub->qeta1());
1329 int wheel = track.
stubs()[0]->whNum();
1330 uint awheel = fabs(wheel);
1336 for (
unsigned int i = 0;
i < track.
stubs().size(); ++
i) {
1337 if (fabs(track.
stubs()[
i]->whNum()) != awheel)
1338 mask = mask | (1 <<
i);
1340 mask = (awheel << nstubs) | mask;
1345 for (
const auto& stub : track.
stubs()) {
1351 sums += rank * stub->eta1();
1355 if (sumweights == 1)
1357 else if (sumweights == 2)
1359 else if (sumweights == 3)
1361 else if (sumweights == 4)
1363 else if (sumweights == 5)
1365 else if (sumweights == 6)
1385 for (
const auto& stub : track.
stubs())
1386 if (stub->stNum() == 2)
1390 ap_fixed<BITSPHIB, BITSPHIB> phiB = track.
phiBAtMuon();
1392 int phiNew = ap_fixed<BITSPHI + 1, BITSPHI + 1, AP_TRN_ZERO, AP_SAT>(phi + phiAt2 * phiB);
1395 printf(
"Phi at second station=%d\n", phiNew);
std::vector< double > bPhiB_
int correctedPhiB(const L1MuKBMTCombinedStubRef &)
l1t::RegionalMuonCand convertToBMTF(const L1MuKBMTrack &track)
std::vector< double > aPhi_
std::vector< int > combos1_
const edm::EventSetup & c
void setCoordinatesAtVertex(int, int, int)
std::vector< double > aPhiB_
std::vector< double > aPhiBNLO_
L1TMuonBarrelKalmanAlgo(const edm::ParameterSet &settings)
uint coarseEta(uint, uint)
std::pair< bool, uint > match(const L1MuKBMTCombinedStubRef &, const L1MuKBMTCombinedStubRefVector &, int)
double pointResolutionPhiB_
std::vector< T >::const_iterator search(const cond::Time_t &val, const std::vector< T > &container)
std::vector< double > mScatteringPhiB_
uint32_t const *__restrict__ Quality * quality
void setTrackCompatibility(int)
int phiAt2(const L1MuKBMTrack &track)
bool update(L1MuKBMTrack &, const L1MuKBMTCombinedStubRef &, int, int)
auto const & tracks
cannot be loose
int rank(const L1MuKBMTrack &)
void setPtUnconstrained(float)
std::vector< int > trackCompPattern_
std::vector< edm::Ref< L1MuKBMTCombinedStubCollection > > L1MuKBMTCombinedStubRefVector
static const int BITSCURV
bool updateOffline1D(L1MuKBMTrack &, const L1MuKBMTCombinedStubRef &)
double pointResolutionVertex_
void estimateCompatibility(L1MuKBMTrack &)
void setPtEtaPhi(double, double, double)
bool updateLUT(L1MuKBMTrack &, const L1MuKBMTCombinedStubRef &, int, int)
void vertexConstraintLUT(L1MuKBMTrack &)
void setCharge(Charge q) final
set electric charge
std::pair< bool, uint > getByCode(const L1MuKBMTrackCollection &tracks, int mask)
int fp_product(float, int, uint)
std::vector< double > chiSquare_
int curvatureAtMuon() const
std::vector< double > pointResolutionPhiBH_
std::vector< double > initK2_
ROOT::Math::SMatrix< double, 1, 3 > Matrix13
std::pair< float, float > vertexGain(uint, uint)
void setCoordinates(int, int, int, int)
printf("params %d %f %f %f\n", minT, eps, errmax, chi2max)
std::vector< double > trackComp_
void setCovariance(const CovarianceMatrix &)
std::vector< double > mScatteringPhi_
Abs< T >::type abs(const T &t)
L1TMuonBarrelKalmanLUTs * lutService_
void setDataword(uint32_t msbs, uint32_t lsbs)
void setHwHF(bool bit)
Set HF (halo / fine eta) bit (EMTF: halo -> 1; BMTF: fine eta -> 1)
void vertexConstraint(L1MuKBMTrack &)
int customBitmask(unsigned int, unsigned int, unsigned int, unsigned int)
std::vector< double > eLoss_
ROOT::Math::SMatrix< double, 3, 1 > Matrix31
bool estimateChiSquare(L1MuKBMTrack &)
void vertexConstraintOffline(L1MuKBMTrack &)
const L1MuKBMTCombinedStubRefVector & stubs() const
ROOT::Math::SMatrix< double, 2, 2, ROOT::Math::MatRepSym< double, 2 > > CovarianceMatrix2
uint matchAbs(std::map< uint, uint > &, uint, uint)
std::vector< int > combos4_
std::vector< int > chiSquareCutTight_
std::vector< double > bPhi_
std::vector< double > initK_
void updateEta(L1MuKBMTrack &, const L1MuKBMTCombinedStubRef &)
void setFloatingPointValues(L1MuKBMTrack &, bool)
void setHwDXY(int bits)
Set compressed impact parameter with respect to beamspot (4 bits)
L1MuKBMTrackCollection clean(const L1MuKBMTrackCollection &, uint)
int encode(bool ownwheel, int sector, bool tag)
std::vector< int > chiSquareCutPattern_
const std::vector< double > & covariance() const
std::pair< bool, L1MuKBMTrack > chain(const L1MuKBMTCombinedStubRef &, const L1MuKBMTCombinedStubRefVector &)
void calculateEta(L1MuKBMTrack &track)
int curvatureAtVertex() const
std::pair< OmniClusterRef, TrackingParticleRef > P
std::vector< int > chiSquareCut_
double S(const TLorentzVector &, const TLorentzVector &)
void addBMTFMuon(int, const L1MuKBMTrack &, std::unique_ptr< l1t::RegionalMuonCandBxCollection > &)
int hitPattern(const L1MuKBMTrack &)
ROOT::Math::SVector< double, 2 > Vector2
void setKalmanGain(unsigned int step, unsigned int K, float a1, float a2, float a3, float a4=0, float a5=0, float a6=0)
std::vector< L1MuKBMTrack > L1MuKBMTrackCollection
ROOT::Math::SMatrix< double, 2, 3 > Matrix23
int correctedPhi(const L1MuKBMTCombinedStubRef &, int)
std::vector< double > trackCompErr1_
std::vector< float > trackGain2(uint, uint, uint, uint, uint)
void propagate(L1MuKBMTrack &)
ROOT::Math::SMatrix< double, 3, 2 > Matrix32
std::vector< int > chiSquareCutCurv_
ROOT::Math::SMatrix< double, 3, 3 > Matrix33
void addStub(const L1MuKBMTCombinedStubRef &)
std::vector< double > trackCompErr2_
void setResidual(uint, int)
std::vector< float > trackGain(uint, uint, uint)
math::Error< dimension >::type CovarianceMatrix
covariance error matrix (3x3)
double pointResolutionPhi_
std::vector< int > trackCompCut_
void setHwPtUnconstrained(int bits)
Set compressed second displaced pT as transmitted by hardware LSB = 1.0 (8 bits)
int positionAngle() const
bool updateOffline(L1MuKBMTrack &, const L1MuKBMTCombinedStubRef &)
Power< A, B >::type pow(const A &a, const B &b)
uint etaStubRank(const L1MuKBMTCombinedStubRef &)
std::vector< int > combos3_
std::vector< int > trackCompCutCurv_
std::vector< int > combos2_
std::map< int, int > trackAddress(const L1MuKBMTrack &, int &)
std::vector< double > pointResolutionPhiBL_