30 static constexpr
float mu_mass = 0.105658369;
51 PropState() :
pt(-99),
eta(-99), phi(-99), sigmaPt(-99), sigmaEta(-99), sigmaPhi(-99), valid(
false) {}
61 enum AlgoType { kTP = 1, kDynamicWindows = 2, kMantra = 3 };
78 const int detector)
const;
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);
230 dwcorr_->set_safety_factor(iConfig.
getParameter<
double>(
"final_window_factor"));
231 dwcorr_->set_sf_initialrelax(iConfig.
getParameter<
double>(
"initial_window_factor"));
233 dwcorr_->set_relaxation_pattern(iConfig.
getParameter<
double>(
"pt_start_relax"),
236 dwcorr_->set_do_relax_factor(iConfig.
getParameter<
bool>(
"do_relax_factors"));
238 dwcorr_->set_n_trk_par(iConfig.
getParameter<
int>(
"n_trk_par"));
239 dwcorr_->set_min_trk_p(iConfig.
getParameter<
double>(
"min_trk_p"));
240 dwcorr_->set_max_trk_aeta(iConfig.
getParameter<
double>(
"max_trk_aeta"));
241 dwcorr_->set_max_trk_chi2(iConfig.
getParameter<
double>(
"max_trk_chi2"));
242 dwcorr_->set_min_trk_nstubs(iConfig.
getParameter<
int>(
"min_trk_nstubs"));
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");
262 mantracorr_barr_->set_safety_factor(0.5, 0.5);
263 mantracorr_barr_->setArbitrationType(
"MaxPt");
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");
282 mantracorr_ovrl_->set_safety_factor(0.5, 0.5);
283 mantracorr_ovrl_->setArbitrationType(
"MaxPt");
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");
302 mantracorr_endc_->set_safety_factor(0.5, 0.5);
303 mantracorr_endc_->setArbitrationType(
"MaxPt");
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());
392 const int detector)
const {
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) {
481 const auto& p3 = matchTk.
momentum();
486 const auto& tkv3 = matchTk.
POCA();
489 float trkisol = -999;
491 TkMuon l1tkmu(l1tkp4, l1muRef, l1tkPtr, trkisol);
513 tkMuons.push_back(l1tkmu);
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];
540 const auto& p3 = matchTk.
momentum();
541 const auto& tkv3 = matchTk.
POCA();
547 float trkisol = -999;
548 TkMuon l1tkmu(l1tkp4, l1muRef, l1tkPtr, trkisol);
557 tkMuons.push_back(l1tkmu);
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;
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,
699 int detector)
const {
700 for (
uint imatch = 0; imatch < matches.size(); ++imatch) {
701 int match_trk_idx = matches[imatch];
702 if (match_trk_idx < 0)
707 const auto& p3 = matchTk.
momentum();
708 const auto& tkv3 = matchTk.
POCA();
716 float trkisol = -999;
717 TkMuon l1tkmu(l1tkp4, l1muRef, l1tkPtr, trkisol);
739 tkMuons.push_back(l1tkmu);
745 const std::vector<int>& matches,
748 int detector)
const {
749 for (
uint imatch = 0; imatch < matches.size(); ++imatch) {
750 int match_trk_idx = matches[imatch];
751 if (match_trk_idx < 0)
756 const auto& p3 = matchTk.
momentum();
757 const auto& tkv3 = matchTk.
POCA();
766 float trkisol = -999;
767 TkMuon l1tkmu(l1tkp4, l1emtfTrk, l1tkPtr, trkisol);
776 tkMuons.push_back(l1tkmu);
static constexpr float matching_factor_eta
const_iterator end(int bx) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
static constexpr float min_mu_propagator_barrel_pT
static double eta_to_theta(double x)
constexpr double convertDegToRad(NumType degrees)
static double to_mpio2_pio2(double x)
GlobalVector momentum() const
Track momentum.
constexpr T reduceRange(T x)
void setQuality(unsigned int q)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
std::unique_ptr< L1TkMuMantra > mantracorr_barr_
std::unique_ptr< L1TkMuMantra > mantracorr_endc_
void produce(edm::Event &, const edm::EventSetup &) override
std::vector< L1TkMuMantraDF::muon_df > product_to_muvec(const RegionalMuonCandBxCollection &l1mtfs) const
bool exists(std::string const ¶meterName) const
checks if a parameter exists
GlobalPoint POCA() const
POCA.
static constexpr int endcap_MTF_region
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
double sigmaEtaTP(const RegionalMuonCand &mu) const
etaMax_(conf.getParameter< double >("etaMax"))
void runOnMTFCollection_v1(const edm::Handle< RegionalMuonCandBxCollection > &, const edm::Handle< L1TTTrackCollectionType > &, TkMuonCollection &tkMuons, const int detector) const
AlgoType emtfMatchAlgoVersion_
static constexpr float min_mu_propagator_p
bool useRegionEtaMatching_
void build_tkMuons_from_idxs(TkMuonCollection &tkMuons, const std::vector< int > &matches, const edm::Handle< L1TTTrackCollectionType > &l1tksH, const edm::Handle< RegionalMuonCandBxCollection > &muonH, int detector) const
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
static constexpr int barrel_MTF_region
static std::vector< double > prepare_corr_bounds(std::string fname, std::string hname)
void addDefault(ParameterSetDescription const &psetDescription)
double rInv() const
Track curvature.
double sigmaPhiTP(const RegionalMuonCand &mu) const
const edm::EDGetTokenT< RegionalMuonCandBxCollection > omtfToken_
void setTrkzVtx(float TrkzVtx)
void setNTracksMatched(int nTracksMatch)
std::vector< L1TkMuMantraDF::track_df > product_to_trkvec(const L1TTTrackCollectionType &l1tks) const
Abs< T >::type abs(const T &t)
const edm::EDGetTokenT< RegionalMuonCandBxCollection > bmtfToken_
const int hwEta() const
Get compressed eta (returned int * 0.010875 = eta)
bool correctGMTPropForTkZ_
std::vector< TkMuon > TkMuonCollection
const edm::EDGetTokenT< RegionalMuonCandBxCollection > emtfToken_
std::vector< L1TTTrackType > L1TTTrackCollectionType
const edm::EDGetTokenT< EMTFTrackCollection > emtfTCToken_
std::unique_ptr< L1TkMuCorrDynamicWindows > dwcorr_
void setTrackCurvature(double trackCurvature)
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
T const * product() const
static constexpr float phi_scale
TTTrack< Ref_Phase2TrackerDigi_ > L1TTTrackType
std::unique_ptr< L1TkMuMantra > mantracorr_ovrl_
static constexpr float eta_scale
XYZPointD XYZPoint
point in space with cartesian internal representation
Class to store the L1 Track Trigger tracks.
static constexpr float dr2_cutoff
T getParameter(std::string const &) const
static std::vector< double > prepare_corr_bounds(const string &fname, const string &hname)
void runOnMTFCollection_v2(const edm::Handle< EMTFTrackCollection > &, const edm::Handle< L1TTTrackCollectionType > &, TkMuonCollection &tkMuons) const
const edm::EDGetTokenT< std::vector< TTTrack< Ref_Phase2TrackerDigi_ > > > trackToken_
AlgoType omtfMatchAlgoVersion_
std::vector< EMTFTrack > EMTFTrackCollection
L1TkMuonProducer(const edm::ParameterSet &)
void setMuonDetector(unsigned int detector)
static constexpr float matching_factor_phi
static constexpr float mu_mass
const_iterator begin(int bx) const
static constexpr int overlap_MTF_region
AlgoType bmtfMatchAlgoVersion_
etaMin_(conf.getParameter< double >("etaMin"))
PropState propagateToGMT(const L1TTTrackType &l1tk) const
static constexpr float max_mu_propagator_eta
double eta() const final
momentum pseudorapidity
~L1TkMuonProducer() override