diff --git a/reco/L1/L1Algo/L1CATrackFinder.cxx b/reco/L1/L1Algo/L1CATrackFinder.cxx index 5641dac75474f7a9e9d5f7589bd7bd824bc01225..47a0d8d15b3ccd08ccd033ef0c3117d85562aaad 100644 --- a/reco/L1/L1Algo/L1CATrackFinder.cxx +++ b/reco/L1/L1Algo/L1CATrackFinder.cxx @@ -1124,26 +1124,30 @@ inline void L1Algo::f4( // input #endif if (!finite(chi2) || chi2 < 0 || chi2 > TRIPLET_CHI2_CUT) continue; - // TODO: SG: simplify calculations for qp & Cqp below - // prepare data - fscal MaxInvMomS = MaxInvMom[0]; - fscal scale = 255 / (MaxInvMomS * 2); - fscal qp = MaxInvMomS + T3.qp[i3_4]; - if (qp < 0) qp = 0; - if (qp > MaxInvMomS * 2) qp = MaxInvMomS * 2; - qp = (static_cast<unsigned int>(qp * scale)) % 256; - qp = static_cast<unsigned char>(qp); + fscal qp = T3.qp[i3_4]; + + //TODO: SG: why multiplying by 5? To simplify the triplet comparison? + //TODO: why sqrt's? Wouldn't it be faster to skip sqrt() here and + //TODO: compare the squared differences dqr*dqp later? fscal Cqp = 5. * sqrt(fabs(T3.C44[i3_4])); - Cqp = (static_cast<unsigned int>(Cqp * scale)) % 256; - Cqp += 1.f; - if (Cqp < 0.f) Cqp = 0.f; - if (Cqp > 20.f) Cqp = 20.f; + { // legacy - //fscal& time = T3.t[i3_4]; - // int n = T3.n[i3_4]; + // TODO: SG: The magic cuts below are the rest from an old conversion of the momentum to char. + // TODO: They came from the truncation to the 0-255 range and had no other meaning. + // TODO: But for some reason, the efficiency degrades without them. + // TODO: It needs to be investigated. If the cuts are necessary, they need to be adjusted. + + fscal Cmax = 0.2 * MaxInvMom[0]; // minimal momentum: 0.05 - 0.1 + //if ( isec == kAllPrimJumpIter ) { + if (Cqp > Cmax) { + //cout << "isec " << isec << " Cqp " << Cqp << " max " << Cmax << " add " << 0.05 * Cmax << endl; + Cqp = Cmax; + } + Cqp += 0.05 * Cmax; // TODO: without this line the ghost ratio increases, why? + } fTriplets[istal][Thread].emplace_back(ihitl, ihitm, ihitr, istal, istam, istar, 0, 0, 0, chi2, qp, Cqp, sqrt(fabs(T3.tx[i3_4])), // TODO: SG: why sqrt(tx)??? @@ -2187,7 +2191,7 @@ void L1Algo::CATrackFinder() } } #endif - best_tr.Set(istaF, best_L, best_chi2, first_trip.GetQpOrig()); + best_tr.Set(istaF, best_L, best_chi2, first_trip.GetQp()); fTrackCandidates[thread_num].push_back(best_tr); L1Branch& tr = fTrackCandidates[thread_num].back(); @@ -2652,9 +2656,11 @@ inline void L1Algo::CAFindTrack(int ista, L1Branch& best_tr, unsigned char& best fscal Cqp = curr_trip->GetCqp(); Cqp += new_trip.GetCqp(); - if (!fmCBMmode) - if (dqp > PickNeighbour * Cqp) + if (!fmCBMmode) { + if (dqp > PickNeighbour * Cqp) { continue; // bad neighbour // CHECKME why do we need recheck it?? (it really change result) + } + } fscal tx1 = curr_trip->GetTx(); fscal tx2 = new_trip.GetTx(); @@ -2697,7 +2703,9 @@ inline void L1Algo::CAFindTrack(int ista, L1Branch& best_tr, unsigned char& best new_tr[ista].fStsHits.push_back((*RealIHitP)[new_trip.GetLHit()]); new_tr[ista].NHits++; new_L += 1; - dqp = dqp / Cqp * 5.; // CHECKME: understand 5, why no sqrt(5)? + // CHECKME: understand 5, why no sqrt(5)? + // SG: because Cqp is stored as 5*sqrt( cov<qp> ) + dqp = dqp / Cqp * 5.; dtx = dtx / Ctx; dty = dty / Cty; diff --git a/reco/L1/L1Algo/L1Triplet.h b/reco/L1/L1Algo/L1Triplet.h index 4f629cecc976cceb1e3ba43e5dd9d5492d4601db..aaf4c3cc55c2acf80344b8bad6cbfc2a52c9adbc 100644 --- a/reco/L1/L1Algo/L1Triplet.h +++ b/reco/L1/L1Algo/L1Triplet.h @@ -18,7 +18,7 @@ class L1Triplet { public: /// default constructor - L1Triplet() {} + L1Triplet() = default; /// constructor L1Triplet(unsigned int iHitL, unsigned int iHitM, unsigned int iHitR, unsigned int iStaL, unsigned int iStaM, @@ -60,8 +60,6 @@ public: fscal GetChi2() const { return fChi2; } fscal GetTime() const { return -111.; } - fscal GetQpOrig() const { return fQp; } //TODO: SG: return unscaled qp!! - int GetLSta() const { return fSta >> 4; } int GetMSta() const { return ((fSta % 16) >> 2) + GetLSta() + 1; } int GetRSta() const { return (fSta % 4) + GetLSta() + 2; } @@ -91,12 +89,12 @@ public: private: fscal fChi2 = 0.f; // chi^2 - fscal fQp = 0.f; // q/p packed - fscal fCqp = 0.f; // covariance of q/p, packed + fscal fQp = 0.f; // q/p + fscal fCqp = 0.f; // 5 * RMS of q/p fscal fTx = 0.f; // tx at the left hit - fscal fCtx = 0.f; // covariance of tx + fscal fCtx = 0.f; // RMS of tx fscal fTy = 0.f; // ty at the left hit - fscal fCty = 0.f; // covariance of ty + fscal fCty = 0.f; // RMS of ty unsigned int fFirstNeighbour = 0; // ID of the first neighbouring triplet THitI fHitL = 0; // left hit index (16b) in vStsHits array