30 static constexpr
float mu_mass = 0.105658369;
61 enum AlgoType { kTP = 1, kDynamicWindows = 2, kMantra = 3 };
87 const std::vector<int>&
matches,
93 const std::vector<int>&
matches,
99 std::vector<L1TkMuMantraDF::track_df> product_to_trkvec(
const L1TTTrackCollectionType& l1tks)
const;
103 std::vector<L1TkMuMantraDF::muon_df> product_to_muvec(
const EMTFTrackCollection& l1mus)
const;
124 std::unique_ptr<L1TkMuCorrDynamicWindows>
dwcorr_;
140 : etaMin_((
float)iConfig.getParameter<double>(
"ETAMIN")),
141 etaMax_((
float)iConfig.getParameter<double>(
"ETAMAX")),
142 etaBO_(iConfig.exists(
"ETABARRELOVERLAP") ? (
float)iConfig.getParameter<double>(
"ETABARRELOVERLAP") : 0.83),
143 etaOE_(iConfig.exists(
"ETAOVERLAPENDCAP") ? (
float)iConfig.getParameter<double>(
"ETAOVERLAPENDCAP") : 1.24),
144 useRegionEtaMatching_(iConfig.exists(
"useRegionEtaMatching") ? iConfig.getParameter<
bool>(
"useRegionEtaMatching")
146 zMax_((
float)iConfig.getParameter<double>(
"ZMAX")),
147 chi2Max_((
float)iConfig.getParameter<double>(
"CHI2MAX")),
148 pTMinTra_((
float)iConfig.getParameter<double>(
"PTMINTRA")),
149 dRMax_((
float)iConfig.getParameter<double>(
"DRmax")),
150 nStubsmin_(iConfig.getParameter<
int>(
"nStubsmin")),
153 mantra_n_trk_par_(iConfig.getParameter<
int>(
"mantra_n_trk_par")),
159 iConfig.getParameter<
edm::
InputTag>(
"L1TrackInputTag"))) {
164 bmtfMatchAlgoVersionString.end(),
165 bmtfMatchAlgoVersionString.begin(),
170 omtfMatchAlgoVersionString.end(),
171 omtfMatchAlgoVersionString.begin(),
176 emtfMatchAlgoVersionString.end(),
177 emtfMatchAlgoVersionString.begin(),
180 if (bmtfMatchAlgoVersionString ==
"tp")
182 else if (bmtfMatchAlgoVersionString ==
"mantra")
186 <<
"the ID " << bmtfMatchAlgoVersionString <<
" of the BMTF algo matcher passed is invalid\n";
188 if (omtfMatchAlgoVersionString ==
"tp")
190 else if (omtfMatchAlgoVersionString ==
"mantra")
194 <<
"the ID " << omtfMatchAlgoVersionString <<
" of the OMTF algo matcher passed is invalid\n";
196 if (emtfMatchAlgoVersionString ==
"tp")
198 else if (emtfMatchAlgoVersionString ==
"dynamicwindows")
200 else if (emtfMatchAlgoVersionString ==
"mantra")
204 <<
"the ID " << emtfMatchAlgoVersionString <<
" of the EMTF algo matcher passed is invalid\n";
212 produces<TkMuonCollection>();
221 TFile* fIn_theta = TFile::Open(fIn_theta_name.c_str());
222 TFile* fIn_phi = TFile::Open(fIn_phi_name.c_str());
223 dwcorr_ = std::make_unique<L1TkMuCorrDynamicWindows>(bounds, fIn_theta, fIn_phi);
243 dwcorr_->set_do_trk_qual_presel(
true);
253 TFile* fIn_theta = TFile::Open(fIn_theta_name.c_str());
254 TFile* fIn_phi = TFile::Open(fIn_phi_name.c_str());
256 mantracorr_barr_ = std::make_unique<L1TkMuMantra>(bounds, fIn_theta, fIn_phi,
"mantra_barrel");
273 TFile* fIn_theta = TFile::Open(fIn_theta_name.c_str());
274 TFile* fIn_phi = TFile::Open(fIn_phi_name.c_str());
276 mantracorr_ovrl_ = std::make_unique<L1TkMuMantra>(bounds, fIn_theta, fIn_phi,
"mantra_overlap");
293 TFile* fIn_theta = TFile::Open(fIn_theta_name.c_str());
294 TFile* fIn_phi = TFile::Open(fIn_phi_name.c_str());
296 mantracorr_endc_ = std::make_unique<L1TkMuMantra>(bounds, fIn_theta, fIn_phi,
"mantra_endcap");
330 std::vector<L1TkMuMantraDF::track_df> mantradf_tracks;
345 throw cms::Exception(
"TkMuAlgoConfig") <<
" barrel : trying to run an invalid algorithm version "
358 throw cms::Exception(
"TkMuAlgoConfig") <<
" overlap : trying to run an invalid algorithm version "
374 throw cms::Exception(
"TkMuAlgoConfig") <<
"endcap : trying to run an invalid algorithm version "
380 auto oc_tkmuon = std::make_unique<TkMuonCollection>();
381 for (
const auto&
p : {oc_bmtf_tkmuon, oc_omtf_tkmuon, oc_emtf_tkmuon}) {
382 oc_tkmuon->insert(oc_tkmuon->end(),
p.begin(),
p.end());
397 for (
auto l1mu = l1mtfs.
begin(0); l1mu != l1mtfs.
end(0); ++l1mu) {
402 float l1mu_eta = l1mu->hwEta() *
eta_scale;
405 MicroGMTConfiguration::calcGlobalPhi(l1mu->hwPhi(), l1mu->trackFinderType(), l1mu->processor()) *
phi_scale;
407 float l1mu_feta =
std::abs(l1mu_eta);
419 int nTracksMatch = 0;
421 for (
const auto& l1tk : l1tks) {
424 float l1tk_pt = l1tk.momentum().perp();
428 float l1tk_z = l1tk.POCA().z();
432 float l1tk_chi2 = l1tk.chi2();
436 int l1tk_nstubs = l1tk.getStubRefs().size();
440 float l1tk_eta = l1tk.momentum().
eta();
441 float l1tk_phi = l1tk.momentum().phi();
443 float dr2 =
reco::deltaR2(l1mu_eta, l1mu_phi, l1tk_eta, l1tk_phi);
456 if (dr2prop < drmin) {
463 LogDebug(
"L1TkMuonProducer") <<
"matching index is " << match_idx;
464 if (match_idx >= 0) {
478 if (matchCondition) {
486 const auto& tkv3 = matchTk.
POCA();
489 float trkisol = -999;
491 TkMuon l1tkmu(l1tkp4, l1muRef, l1tkPtr, trkisol);
524 const auto& corr_mu_idxs =
dwcorr_->find_match(l1mus, l1trks);
530 if (corr_mu_idxs.size() != l1trks.size())
532 <<
"the size of tkmu indices does not match the size of input trk collection\n";
534 for (
uint il1ttrack = 0; il1ttrack < corr_mu_idxs.size(); ++il1ttrack) {
535 int emtf_idx = corr_mu_idxs[il1ttrack];
541 const auto& tkv3 = matchTk.
POCA();
547 float trkisol = -999;
548 TkMuon l1tkmu(l1tkp4, l1muRef, l1tkPtr, trkisol);
574 float tk_pt =
p3.perp();
575 float tk_p =
p3.mag();
576 float tk_eta =
p3.eta();
578 float tk_phi =
p3.phi();
579 float tk_q = tk.
rInv() > 0 ? 1. : -1.;
580 float tk_z = tk.
POCA().
z();
595 float dzCorrPhi = 1.;
597 float etaProp = tk_aeta;
601 deta = tk_z / 550. / cosh(tk_aeta);
603 float delta = tk_z / 850.;
606 dzCorrPhi = 1. +
delta;
608 float zOzs = tk_z / 850.;
610 deta = zOzs / (1. - zOzs);
612 deta = zOzs / (1. + zOzs);
613 deta = deta * tanh(tk_eta);
615 float resPhi = tk_phi - 1.464 * tk_q * cosh(1.7) / cosh(etaProp) / tk_pt * dzCorrPhi -
M_PI / 144.;
618 dest.eta = tk_eta + deta;
622 dest.sigmaEta = 0.100 / tk_pt;
623 dest.sigmaPhi = 0.106 / tk_pt;
643 std::vector<L1TkMuMantraDF::track_df>
result(l1tks.size());
644 for (
uint itrk = 0; itrk < l1tks.size(); ++itrk) {
645 auto& trk = l1tks[itrk];
647 result[itrk].pt = trk.momentum().perp();
648 result[itrk].eta = trk.momentum().eta();
650 result[itrk].phi = trk.momentum().phi();
651 result[itrk].nstubs = trk.getStubRefs().size();
652 result[itrk].chi2 = trk.chi2();
653 result[itrk].charge = (trk.rInv() > 0 ? 1 : -1);
661 std::vector<L1TkMuMantraDF::muon_df>
result;
662 for (
auto l1mu = l1mtfs.
begin(0); l1mu != l1mtfs.
end(0); ++l1mu)
665 this_mu.
pt = l1mu->hwPt() * 0.5;
669 MicroGMTConfiguration::calcGlobalPhi(l1mu->hwPhi(), l1mu->trackFinderType(), l1mu->processor()) *
phi_scale;
670 this_mu.
charge = (l1mu->hwSign() == 0 ? 1 : -1);
671 result.push_back(this_mu);
677 std::vector<L1TkMuMantraDF::muon_df>
result(l1mus.size());
678 for (
uint imu = 0; imu < l1mus.size(); ++imu) {
679 auto&
mu = l1mus[imu];
682 int emtfQual = (
mu.Mode() == 11 ||
mu.Mode() == 13 ||
mu.Mode() == 14 ||
mu.Mode() == 15);
696 const std::vector<int>&
matches,
700 for (
uint imatch = 0; imatch <
matches.size(); ++imatch) {
701 int match_trk_idx =
matches[imatch];
702 if (match_trk_idx < 0)
708 const auto& tkv3 = matchTk.
POCA();
716 float trkisol = -999;
717 TkMuon l1tkmu(l1tkp4, l1muRef, l1tkPtr, trkisol);
745 const std::vector<int>&
matches,
749 for (
uint imatch = 0; imatch <
matches.size(); ++imatch) {
750 int match_trk_idx =
matches[imatch];
751 if (match_trk_idx < 0)
757 const auto& tkv3 = matchTk.
POCA();
766 float trkisol = -999;
767 TkMuon l1tkmu(l1tkp4, l1emtfTrk, l1tkPtr, trkisol);