30 static constexpr
float mu_mass = 0.105658369;
61 enum AlgoType { kTP = 1, kDynamicWindows = 2, kMantra = 3 };
87 const std::vector<int>&
matches,
93 std::vector<L1TkMuMantraDF::track_df> product_to_trkvec(
const L1TTTrackCollectionType& l1tks)
const;
97 std::vector<L1TkMuMantraDF::muon_df> product_to_muvec(
const EMTFTrackCollection& l1mus)
const;
114 std::unique_ptr<L1TkMuCorrDynamicWindows>
dwcorr_;
130 : etaMin_((
float)iConfig.getParameter<double>(
"ETAMIN")),
131 etaMax_((
float)iConfig.getParameter<double>(
"ETAMAX")),
132 zMax_((
float)iConfig.getParameter<double>(
"ZMAX")),
133 chi2Max_((
float)iConfig.getParameter<double>(
"CHI2MAX")),
134 pTMinTra_((
float)iConfig.getParameter<double>(
"PTMINTRA")),
135 dRMax_((
float)iConfig.getParameter<double>(
"DRmax")),
136 nStubsmin_(iConfig.getParameter<
int>(
"nStubsmin")),
138 mantra_n_trk_par_(iConfig.getParameter<
int>(
"mantra_n_trk_par")),
144 iConfig.getParameter<
edm::
InputTag>(
"L1TrackInputTag"))) {
149 bmtfMatchAlgoVersionString.end(),
150 bmtfMatchAlgoVersionString.begin(),
155 omtfMatchAlgoVersionString.end(),
156 omtfMatchAlgoVersionString.begin(),
161 emtfMatchAlgoVersionString.end(),
162 emtfMatchAlgoVersionString.begin(),
165 if (bmtfMatchAlgoVersionString ==
"tp")
167 else if (bmtfMatchAlgoVersionString ==
"mantra")
171 <<
"the ID " << bmtfMatchAlgoVersionString <<
" of the BMTF algo matcher passed is invalid\n";
173 if (omtfMatchAlgoVersionString ==
"tp")
175 else if (omtfMatchAlgoVersionString ==
"mantra")
179 <<
"the ID " << omtfMatchAlgoVersionString <<
" of the OMTF algo matcher passed is invalid\n";
181 if (emtfMatchAlgoVersionString ==
"tp")
183 else if (emtfMatchAlgoVersionString ==
"dynamicwindows")
185 else if (emtfMatchAlgoVersionString ==
"mantra")
189 <<
"the ID " << emtfMatchAlgoVersionString <<
" of the EMTF algo matcher passed is invalid\n";
195 produces<TkMuonCollection>();
204 TFile* fIn_theta = TFile::Open(fIn_theta_name.c_str());
205 TFile* fIn_phi = TFile::Open(fIn_phi_name.c_str());
206 dwcorr_ = std::make_unique<L1TkMuCorrDynamicWindows>(bounds, fIn_theta, fIn_phi);
226 dwcorr_->set_do_trk_qual_presel(
true);
236 TFile* fIn_theta = TFile::Open(fIn_theta_name.c_str());
237 TFile* fIn_phi = TFile::Open(fIn_phi_name.c_str());
239 mantracorr_barr_ = std::make_unique<L1TkMuMantra>(bounds, fIn_theta, fIn_phi,
"mantra_barrel");
256 TFile* fIn_theta = TFile::Open(fIn_theta_name.c_str());
257 TFile* fIn_phi = TFile::Open(fIn_phi_name.c_str());
259 mantracorr_ovrl_ = std::make_unique<L1TkMuMantra>(bounds, fIn_theta, fIn_phi,
"mantra_overlap");
276 TFile* fIn_theta = TFile::Open(fIn_theta_name.c_str());
277 TFile* fIn_phi = TFile::Open(fIn_phi_name.c_str());
279 mantracorr_endc_ = std::make_unique<L1TkMuMantra>(bounds, fIn_theta, fIn_phi,
"mantra_endcap");
313 std::vector<L1TkMuMantraDF::track_df> mantradf_tracks;
328 throw cms::Exception(
"TkMuAlgoConfig") <<
" barrel : trying to run an invalid algorithm version "
339 throw cms::Exception(
"TkMuAlgoConfig") <<
" overlap : trying to run an invalid algorithm version "
354 throw cms::Exception(
"TkMuAlgoConfig") <<
"endcap : trying to run an invalid algorithm version "
358 auto oc_tkmuon = std::make_unique<TkMuonCollection>();
359 for (
const auto&
p : {oc_bmtf_tkmuon, oc_omtf_tkmuon, oc_emtf_tkmuon}) {
360 oc_tkmuon->insert(oc_tkmuon->end(),
p.begin(),
p.end());
375 for (
auto l1mu = l1mtfs.
begin(0); l1mu != l1mtfs.
end(0); ++l1mu) {
380 float l1mu_eta = l1mu->hwEta() *
eta_scale;
383 MicroGMTConfiguration::calcGlobalPhi(l1mu->hwPhi(), l1mu->trackFinderType(), l1mu->processor()) *
phi_scale;
385 float l1mu_feta =
std::abs(l1mu_eta);
397 int nTracksMatch = 0;
399 for (
const auto& l1tk : l1tks) {
402 float l1tk_pt = l1tk.momentum().perp();
406 float l1tk_z = l1tk.POCA().z();
410 float l1tk_chi2 = l1tk.chi2();
414 int l1tk_nstubs = l1tk.getStubRefs().size();
418 float l1tk_eta = l1tk.momentum().
eta();
419 float l1tk_phi = l1tk.momentum().phi();
421 float dr2 =
reco::deltaR2(l1mu_eta, l1mu_phi, l1tk_eta, l1tk_phi);
434 if (dr2prop < drmin) {
441 LogDebug(
"L1TkMuonProducer") <<
"matching index is " << match_idx;
442 if (match_idx >= 0) {
456 if (matchCondition) {
464 const auto& tkv3 = matchTk.
POCA();
467 float trkisol = -999;
469 TkMuon l1tkmu(l1tkp4, l1muRef, l1tkPtr, trkisol);
487 const auto& corr_mu_idxs =
dwcorr_->find_match(l1mus, l1trks);
493 if (corr_mu_idxs.size() != l1trks.size())
495 <<
"the size of tkmu indices does not match the size of input trk collection\n";
497 for (
uint il1ttrack = 0; il1ttrack < corr_mu_idxs.size(); ++il1ttrack) {
498 int emtf_idx = corr_mu_idxs[il1ttrack];
504 const auto& tkv3 = matchTk.
POCA();
510 float trkisol = -999;
511 TkMuon l1tkmu(l1tkp4, l1muRef, l1tkPtr, trkisol);
532 float tk_pt =
p3.perp();
533 float tk_p =
p3.mag();
534 float tk_eta =
p3.eta();
536 float tk_phi =
p3.phi();
537 float tk_q = tk.
rInv() > 0 ? 1. : -1.;
538 float tk_z = tk.
POCA().
z();
553 float dzCorrPhi = 1.;
555 float etaProp = tk_aeta;
559 deta = tk_z / 550. / cosh(tk_aeta);
561 float delta = tk_z / 850.;
564 dzCorrPhi = 1. +
delta;
566 float zOzs = tk_z / 850.;
568 deta = zOzs / (1. - zOzs);
570 deta = zOzs / (1. + zOzs);
571 deta = deta * tanh(tk_eta);
573 float resPhi = tk_phi - 1.464 * tk_q * cosh(1.7) / cosh(etaProp) / tk_pt * dzCorrPhi -
M_PI / 144.;
576 dest.eta = tk_eta + deta;
580 dest.sigmaEta = 0.100 / tk_pt;
581 dest.sigmaPhi = 0.106 / tk_pt;
601 std::vector<L1TkMuMantraDF::track_df>
result(l1tks.size());
602 for (
uint itrk = 0; itrk < l1tks.size(); ++itrk) {
603 auto& trk = l1tks[itrk];
605 result[itrk].pt = trk.momentum().perp();
606 result[itrk].eta = trk.momentum().eta();
608 result[itrk].phi = trk.momentum().phi();
609 result[itrk].nstubs = trk.getStubRefs().size();
610 result[itrk].chi2 = trk.chi2();
611 result[itrk].charge = (trk.rInv() > 0 ? 1 : -1);
619 std::vector<L1TkMuMantraDF::muon_df>
result;
620 for (
auto l1mu = l1mtfs.
begin(0); l1mu != l1mtfs.
end(0); ++l1mu)
623 this_mu.
pt = l1mu->hwPt() * 0.5;
627 MicroGMTConfiguration::calcGlobalPhi(l1mu->hwPhi(), l1mu->trackFinderType(), l1mu->processor()) *
phi_scale;
628 this_mu.
charge = (l1mu->hwSign() == 0 ? 1 : -1);
629 result.push_back(this_mu);
635 std::vector<L1TkMuMantraDF::muon_df>
result(l1mus.size());
636 for (
uint imu = 0; imu < l1mus.size(); ++imu) {
637 auto&
mu = l1mus[imu];
648 const std::vector<int>&
matches,
652 for (
uint imatch = 0; imatch <
matches.size(); ++imatch) {
653 int match_trk_idx =
matches[imatch];
654 if (match_trk_idx < 0)
660 const auto& tkv3 = matchTk.
POCA();
668 float trkisol = -999;
669 TkMuon l1tkmu(l1tkp4, l1muRef, l1tkPtr, trkisol);