Skip to content

Commit

Permalink
A fix for L1TPhase2MuonOffline::matchMuonsToGen
Browse files Browse the repository at this point in the history
  • Loading branch information
perrotta committed Sep 10, 2022
1 parent 6cc53e1 commit 1ce48c8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion DQMOffline/L1Trigger/interface/L1TPhase2MuonOffline.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class GenMuonGMTPair {
GenMuonGMTPair(const GenMuonGMTPair& muongmtPair);
~GenMuonGMTPair(){};

float dR();
float dR2();
float pt() const { return mu_->pt(); };
float eta() const { return mu_->eta(); };
float phi() const { return mu_->phi(); };
Expand Down
26 changes: 19 additions & 7 deletions DQMOffline/L1Trigger/src/L1TPhase2MuonOffline.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ GenMuonGMTPair::GenMuonGMTPair(const GenMuonGMTPair& muonGmtPair) {
muPhi_ = muonGmtPair.muPhi_;
}

float GenMuonGMTPair::dR() {
float GenMuonGMTPair::dR2() {
if (!gmtmu_)
return 9999.;
return 999.;
float dEta = gmtEta_ - muEta_;
float dPhi = reco::deltaPhi(gmtPhi_, muPhi_);
return std::sqrt(dEta * dEta + dPhi * dPhi);
return dEta * dEta + dPhi * dPhi;
}

L1TPhase2MuonOffline::EtaRegion GenMuonGMTPair::etaRegion() const {
Expand Down Expand Up @@ -372,22 +372,34 @@ void L1TPhase2MuonOffline::matchMuonsToGen(std::vector<const reco::GenParticle*>
for (const reco::GenParticle* gen : genmus) {
edm::LogInfo("L1TPhase2MuonOffline") << "Looping on genmus: " << gen << endl;
GenMuonGMTPair pairBestCand(&(*gen), nullptr);
float dr2Best = maxGmtMuonDR_ * maxGmtMuonDR_;
bool matchFound = false;
for (auto& muIt : *gmtSAMuon_) {
GenMuonGMTPair pairTmpCand(&(*gen), &(muIt));
if ((pairTmpCand.dR() < maxGmtMuonDR_) && (pairTmpCand.dR() < pairBestCand.dR())) {
float dr2Tmp = pairTmpCand.dR2();
if (dr2Tmp < dr2Best) {
dr2Best = dr2Tmp;
pairBestCand = pairTmpCand;
matchFound = true;
}
}
gmtSAMuonPairs_.emplace_back(pairBestCand);
if (matchFound)
gmtSAMuonPairs_.emplace_back(pairBestCand);

GenMuonGMTPair pairBestCand2(&(*gen), nullptr);
dr2Best = maxGmtMuonDR_ * maxGmtMuonDR_;
matchFound = false;
for (auto& tkmuIt : *gmtTkMuon_) {
GenMuonGMTPair pairTmpCand(&(*gen), &(tkmuIt));
if ((pairTmpCand.dR() < maxGmtMuonDR_) && (pairTmpCand.dR() < pairBestCand2.dR())) {
float dr2Tmp = pairTmpCand.dR2();
if (dr2Tmp < dr2Best) {
dr2Best = dr2Tmp;
pairBestCand2 = pairTmpCand;
matchFound = true;
}
}
gmtTkMuonPairs_.emplace_back(pairBestCand2);
if (matchFound)
gmtTkMuonPairs_.emplace_back(pairBestCand2);
}
edm::LogInfo("L1TPhase2MuonOffline") << "L1TPhase2MuonOffline::matchMuonsToGen() gmtSAMuons: "
<< gmtSAMuonPairs_.size() << endl;
Expand Down

0 comments on commit 1ce48c8

Please sign in to comment.