31 static constexpr
float mu_mass = 0.105658369;
62 enum AlgoType { kTP = 1, kDynamicWindows = 2, kMantra = 3 };
88 const std::vector<int>&
matches,
95 const std::vector<int>&
matches,
100 std::vector<L1TkMuMantraDF::track_df> product_to_trkvec(
const L1TTTrackCollectionType& l1tks);
121 std::unique_ptr<L1TkMuCorrDynamicWindows>
dwcorr_;
137 : etaMin_((
float)iConfig.getParameter<double>(
"ETAMIN")),
138 etaMax_((
float)iConfig.getParameter<double>(
"ETAMAX")),
139 zMax_((
float)iConfig.getParameter<double>(
"ZMAX")),
140 chi2Max_((
float)iConfig.getParameter<double>(
"CHI2MAX")),
141 pTMinTra_((
float)iConfig.getParameter<double>(
"PTMINTRA")),
142 dRMax_((
float)iConfig.getParameter<double>(
"DRmax")),
143 nStubsmin_(iConfig.getParameter<
int>(
"nStubsmin")),
145 mantra_n_trk_par_(iConfig.getParameter<
int>(
"mantra_n_trk_par")),
151 iConfig.getParameter<
edm::
InputTag>(
"L1TrackInputTag"))) {
156 bmtfMatchAlgoVersionString.end(),
157 bmtfMatchAlgoVersionString.begin(),
162 omtfMatchAlgoVersionString.end(),
163 omtfMatchAlgoVersionString.begin(),
168 emtfMatchAlgoVersionString.end(),
169 emtfMatchAlgoVersionString.begin(),
172 if (bmtfMatchAlgoVersionString ==
"tp")
174 else if (bmtfMatchAlgoVersionString ==
"mantra")
178 <<
"the ID " << bmtfMatchAlgoVersionString <<
" of the BMTF algo matcher passed is invalid\n";
182 if (omtfMatchAlgoVersionString ==
"tp")
184 else if (omtfMatchAlgoVersionString ==
"mantra")
188 <<
"the ID " << omtfMatchAlgoVersionString <<
" of the OMTF algo matcher passed is invalid\n";
192 if (emtfMatchAlgoVersionString ==
"tp")
194 else if (emtfMatchAlgoVersionString ==
"dynamicwindows")
196 else if (emtfMatchAlgoVersionString ==
"mantra")
200 <<
"the ID " << emtfMatchAlgoVersionString <<
" of the EMTF algo matcher passed is invalid\n";
206 produces<TkMuonCollection>();
215 TFile* fIn_theta = TFile::Open(fIn_theta_name.c_str());
216 TFile* fIn_phi = TFile::Open(fIn_phi_name.c_str());
217 dwcorr_ = std::make_unique<L1TkMuCorrDynamicWindows>(bounds, fIn_theta, fIn_phi);
238 dwcorr_->set_do_trk_qual_presel(
true);
248 TFile* fIn_theta = TFile::Open(fIn_theta_name.c_str());
249 TFile* fIn_phi = TFile::Open(fIn_phi_name.c_str());
251 mantracorr_barr_ = std::make_unique<L1TkMuMantra>(bounds, fIn_theta, fIn_phi,
"mantra_barrel");
268 TFile* fIn_theta = TFile::Open(fIn_theta_name.c_str());
269 TFile* fIn_phi = TFile::Open(fIn_phi_name.c_str());
271 mantracorr_ovrl_ = std::make_unique<L1TkMuMantra>(bounds, fIn_theta, fIn_phi,
"mantra_overlap");
288 TFile* fIn_theta = TFile::Open(fIn_theta_name.c_str());
289 TFile* fIn_phi = TFile::Open(fIn_phi_name.c_str());
291 mantracorr_endc_ = std::make_unique<L1TkMuMantra>(bounds, fIn_theta, fIn_phi,
"mantra_endcap");
325 std::vector<L1TkMuMantraDF::track_df> mantradf_tracks;
340 throw cms::Exception(
"TkMuAlgoConfig") <<
" barrel : trying to run an invalid algorithm version "
351 throw cms::Exception(
"TkMuAlgoConfig") <<
" overlap : trying to run an invalid algorithm version "
364 throw cms::Exception(
"TkMuAlgoConfig") <<
"endcap : trying to run an invalid algorithm version "
368 auto oc_tkmuon = std::make_unique<TkMuonCollection>();
369 for (
const auto&
p : {oc_bmtf_tkmuon, oc_omtf_tkmuon, oc_emtf_tkmuon}) {
370 oc_tkmuon->insert(oc_tkmuon->end(),
p.begin(),
p.end());
385 for (
auto l1mu = l1mtfs.
begin(0); l1mu != l1mtfs.
end(0); ++l1mu) {
390 float l1mu_eta = l1mu->hwEta() *
eta_scale;
393 MicroGMTConfiguration::calcGlobalPhi(l1mu->hwPhi(), l1mu->trackFinderType(), l1mu->processor()) *
phi_scale;
395 float l1mu_feta = fabs(l1mu_eta);
410 int nTracksMatch = 0;
412 for (
const auto& l1tk : l1tks) {
415 float l1tk_pt = l1tk.momentum().perp();
419 float l1tk_z = l1tk.POCA().z();
420 if (fabs(l1tk_z) >
zMax_)
423 float l1tk_chi2 = l1tk.chi2();
427 int l1tk_nstubs = l1tk.getStubRefs().size();
431 float l1tk_eta = l1tk.momentum().
eta();
432 float l1tk_phi = l1tk.momentum().phi();
434 float dr2 =
deltaR2(l1mu_eta, l1mu_phi, l1tk_eta, l1tk_phi);
444 float dr2prop =
deltaR2(l1mu_eta, l1mu_phi, pstate.
eta, pstate.
phi);
447 if (dr2prop < drmin) {
454 LogDebug(
"L1TkMuonProducer") <<
"matching index is " << match_idx;
455 if (match_idx >= 0) {
469 if (matchCondition) {
477 const auto& tkv3 = matchTk.
POCA();
480 float trkisol = -999;
482 TkMuon l1tkmu(l1tkp4, l1muRef, l1tkPtr, trkisol);
500 auto corr_mu_idxs =
dwcorr_->find_match(l1mus, l1trks);
506 if (corr_mu_idxs.size() != l1trks.size())
508 <<
"the size of tkmu indices does not match the size of input trk collection\n";
510 for (
uint il1ttrack = 0; il1ttrack < corr_mu_idxs.size(); ++il1ttrack) {
511 int emtf_idx = corr_mu_idxs.at(il1ttrack);
517 const auto& tkv3 = matchTk.
POCA();
523 float trkisol = -999;
524 TkMuon l1tkmu(l1tkp4, l1muRef, l1tkPtr, trkisol);
545 float tk_pt =
p3.perp();
546 float tk_p =
p3.mag();
547 float tk_eta =
p3.eta();
549 float tk_phi =
p3.phi();
550 float tk_q = tk.
rInv() > 0 ? 1. : -1.;
551 float tk_z = tk.
POCA().
z();
566 float dzCorrPhi = 1.;
568 float etaProp = tk_aeta;
572 deta = tk_z / 550. / cosh(tk_aeta);
574 float delta = tk_z / 850.;
577 dzCorrPhi = 1. +
delta;
579 float zOzs = tk_z / 850.;
581 deta = zOzs / (1. - zOzs);
583 deta = zOzs / (1. + zOzs);
584 deta = deta * tanh(tk_eta);
586 float resPhi = tk_phi - 1.464 * tk_q * cosh(1.7) / cosh(etaProp) / tk_pt * dzCorrPhi -
M_PI / 144.;
592 dest.eta = tk_eta + deta;
596 dest.sigmaEta = 0.100 / tk_pt;
597 dest.sigmaPhi = 0.106 / tk_pt;
617 std::vector<L1TkMuMantraDF::track_df>
result(l1tks.size());
618 for (
uint itrk = 0; itrk < l1tks.size(); ++itrk) {
619 auto& trk = l1tks.at(itrk);
621 result.at(itrk).pt = trk.momentum().perp();
622 result.at(itrk).eta = trk.momentum().eta();
624 result.at(itrk).phi = trk.momentum().phi();
625 result.at(itrk).nstubs = trk.getStubRefs().size();
626 result.at(itrk).chi2 = trk.chi2();
627 result.at(itrk).charge = (trk.rInv() > 0 ? 1 : -1);
634 std::vector<L1TkMuMantraDF::muon_df>
result;
635 for (
auto l1mu = l1mtfs.
begin(0); l1mu != l1mtfs.
end(0); ++l1mu)
638 this_mu.
pt = l1mu->hwPt() * 0.5;
642 MicroGMTConfiguration::calcGlobalPhi(l1mu->hwPhi(), l1mu->trackFinderType(), l1mu->processor()) *
phi_scale;
643 this_mu.
charge = (l1mu->hwSign() == 0 ? 1 : -1);
644 result.push_back(this_mu);
650 std::vector<L1TkMuMantraDF::muon_df>
result(l1mus.size());
651 for (
uint imu = 0; imu < l1mus.size(); ++imu) {
652 auto&
mu = l1mus.at(imu);
657 result.at(imu).charge =
mu.Charge();
663 const std::vector<int>&
matches,
667 for (
uint imatch = 0; imatch <
matches.size(); ++imatch) {
668 int match_trk_idx =
matches.at(imatch);
669 if (match_trk_idx < 0)
675 const auto& tkv3 = matchTk.
POCA();
682 float trkisol = -999;
683 TkMuon l1tkmu(l1tkp4, l1muRef, l1tkPtr, trkisol);
693 const std::vector<int>&
matches,
696 for (
uint imatch = 0; imatch <
matches.size(); ++imatch) {
697 int match_trk_idx =
matches.at(imatch);
698 if (match_trk_idx < 0)
704 const auto& tkv3 = matchTk.
POCA();
712 float trkisol = -999;
713 TkMuon l1tkmu(l1tkp4, l1muRef, l1tkPtr, trkisol);