Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Follow-up of #32699 (Phase 2 Muon HLT) #32713

Merged
merged 7 commits into from Jan 27, 2021
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
83 changes: 33 additions & 50 deletions HLTrigger/HLTfilters/plugins/HLT2L1TkMuonL1TkMuonMuRefDR.cc
@@ -1,23 +1,18 @@
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "HLT2L1TkMuonL1TkMuonMuRefDR.h"
#include <cmath>

#include "DataFormats/Common/interface/Handle.h"

#include "DataFormats/Common/interface/Ref.h"
#include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"

#include "DataFormats/L1TCorrelator/interface/TkMuon.h"
#include "DataFormats/L1TCorrelator/interface/TkMuonFwd.h"

#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include "FWCore/Framework/interface/MakerMacros.h"

#include "DataFormats/Math/interface/deltaR.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "HLTrigger/HLTcore/interface/defaultModuleLabel.h"
#include "L1Trigger/L1TMuon/interface/MicroGMTConfiguration.h"

#include "HLTrigger/HLTcore/interface/defaultModuleLabel.h"
#include <cmath>
#include "HLT2L1TkMuonL1TkMuonMuRefDR.h"

//
// constructors and destructor
Expand All @@ -32,8 +27,7 @@ HLT2L1TkMuonL1TkMuonMuRefDR::HLT2L1TkMuonL1TkMuonMuRefDR(const edm::ParameterSet
inputToken2_(consumes<trigger::TriggerFilterObjectWithRefs>(inputTag2_)),
minDR_(iConfig.getParameter<double>("MinDR")),
min_N_(iConfig.getParameter<int>("MinN")),
same_(inputTag1_.encode() == inputTag2_.encode()) // same collections to be compared?
{}
same_(inputTag1_.encode() == inputTag2_.encode()) {} // same collections to be compared?

HLT2L1TkMuonL1TkMuonMuRefDR::~HLT2L1TkMuonL1TkMuonMuRefDR() {}

Expand All @@ -49,7 +43,7 @@ void HLT2L1TkMuonL1TkMuonMuRefDR::fillDescriptions(edm::ConfigurationDescription
desc.add<double>("MinDR", -1.0);
desc.add<int>("MinN", 1);

descriptions.add("HLT2L1TkMuonL1TkMuonMuRefDR", desc);
descriptions.add("hlt2L1TkMuonL1TkMuonMuRefDR", desc);
}

bool HLT2L1TkMuonL1TkMuonMuRefDR::getCollections(edm::Event& iEvent,
Expand Down Expand Up @@ -103,49 +97,38 @@ bool HLT2L1TkMuonL1TkMuonMuRefDR::getCollections(edm::Event& iEvent,
return false;
}

bool HLT2L1TkMuonL1TkMuonMuRefDR::computeDR(edm::Event& iEvent, l1t::TkMuonRef& r1, l1t::TkMuonRef& r2) const {
float muRef1_eta = 0.;
float muRef1_phi = 0.;
if (r1->muonDetector() != 3) {
if (r1->muRef().isNull())
return false;

muRef1_eta = r1->muRef()->hwEta() * 0.010875;
muRef1_phi = static_cast<float>(l1t::MicroGMTConfiguration::calcGlobalPhi(
r1->muRef()->hwPhi(), r1->muRef()->trackFinderType(), r1->muRef()->processor()));
muRef1_phi = muRef1_phi * 2. * M_PI / 576.;
} else {
if (r1->emtfTrk().isNull())
return false;
std::pair<float, float> HLT2L1TkMuonL1TkMuonMuRefDR::convertEtaPhi(l1t::TkMuonRef& tkmu) const {
float muRefEta = 0.;
float muRefPhi = 0.;

muRef1_eta = r1->emtfTrk()->Eta();
muRef1_phi = angle_units::operators::convertDegToRad(r1->emtfTrk()->Phi_glob());
}
muRef1_phi = reco::reduceRange(muRef1_phi);

float muRef2_eta = 0.;
float muRef2_phi = 0.;
if (r2->muonDetector() != 3) {
if (r2->muRef().isNull())
return false;

muRef2_eta = r2->muRef()->hwEta() * 0.010875;
muRef2_phi = static_cast<float>(l1t::MicroGMTConfiguration::calcGlobalPhi(
r2->muRef()->hwPhi(), r2->muRef()->trackFinderType(), r2->muRef()->processor()));
muRef2_phi = muRef2_phi * 2. * M_PI / 576.;
if (tkmu->muonDetector() != emtfRegion_) {
if (tkmu->muRef().isNull())
return std::make_pair(muRefEta, muRefPhi);

muRefEta = tkmu->muRef()->hwEta() * etaScale_;
muRefPhi = static_cast<float>(l1t::MicroGMTConfiguration::calcGlobalPhi(
tkmu->muRef()->hwPhi(), tkmu->muRef()->trackFinderType(), tkmu->muRef()->processor()));
muRefPhi = muRefPhi * phiScale_;
} else {
if (r2->emtfTrk().isNull())
return false;
if (tkmu->emtfTrk().isNull())
return std::make_pair(muRefEta, muRefPhi);

muRef2_eta = r2->emtfTrk()->Eta();
muRef2_phi = angle_units::operators::convertDegToRad(r2->emtfTrk()->Phi_glob());
muRefEta = tkmu->emtfTrk()->Eta();
muRefPhi = angle_units::operators::convertDegToRad(tkmu->emtfTrk()->Phi_glob());
}
muRef2_phi = reco::reduceRange(muRef2_phi);
muRefPhi = reco::reduceRange(muRefPhi);

return std::make_pair(muRefEta, muRefPhi);
}

if (reco::deltaR(muRef1_eta, muRef1_phi, muRef2_eta, muRef2_phi) > minDR_)
bool HLT2L1TkMuonL1TkMuonMuRefDR::computeDR(edm::Event& iEvent, l1t::TkMuonRef& r1, l1t::TkMuonRef& r2) const {
if (minDR_ < 0.)
return true;

return false;
std::pair<float, float> muRef1 = convertEtaPhi(r1);
std::pair<float, float> muRef2 = convertEtaPhi(r2);

return (reco::deltaR2(muRef1.first, muRef1.second, muRef2.first, muRef2.second) > minDR_ * minDR_);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a suggestion, if you think it would be more clear:

Suggested change
std::pair<float, float> muRef1 = convertEtaPhi(r1);
std::pair<float, float> muRef2 = convertEtaPhi(r2);
return (reco::deltaR2(muRef1.first, muRef1.second, muRef2.first, muRef2.second) > minDR_ * minDR_);
auto [eta1, phi1] = convertEtaPhi(r1);
auto [eta2, phi2] = convertEtaPhi(r2);
return (reco::deltaR2(eta1, phi1, eta2, phi2) > minDR_ * minDR_);

}

// ------------ method called to produce the data ------------
Expand Down
6 changes: 6 additions & 0 deletions HLTrigger/HLTfilters/plugins/HLT2L1TkMuonL1TkMuonMuRefDR.h
Expand Up @@ -33,6 +33,7 @@ class HLT2L1TkMuonL1TkMuonMuRefDR : public HLTFilter {
std::vector<l1t::TkMuonRef>& coll2,
trigger::TriggerFilterObjectWithRefs& filterproduct) const;
bool computeDR(edm::Event& iEvent, l1t::TkMuonRef& c1, l1t::TkMuonRef& c2) const;
std::pair<float, float> convertEtaPhi(l1t::TkMuonRef& tkmu) const;

private:
// configuration
Expand All @@ -45,6 +46,11 @@ class HLT2L1TkMuonL1TkMuonMuRefDR : public HLTFilter {
const double minDR_; // minimum dR between two muon regional candidates linked to L1TkMuon
const int min_N_; // number of pairs passing cuts required
const bool same_; // 1st and 2nd product are one and the same

// eta and phi scaling for RegionalMuonCand
static constexpr unsigned int emtfRegion_{3};
static constexpr float etaScale_{0.010875};
static constexpr float phiScale_{2. * M_PI / 576.};
};

#endif //HLT2L1TkMuonL1TkMuonMuRefDR_h
20 changes: 7 additions & 13 deletions HLTrigger/Muon/plugins/HLTMuonTrkL1TkMuFilter.cc
@@ -1,15 +1,13 @@
#include "DataFormats/Common/interface/Handle.h"
#include "HLTMuonTrkL1TkMuFilter.h"

#include "DataFormats/Common/interface/Handle.h"
#include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"
#include "DataFormats/HLTReco/interface/TriggerRefsCollections.h"

#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include "DataFormats/Math/interface/deltaR.h"
#include "DataFormats/TrackReco/interface/Track.h"
#include "DataFormats/RecoCandidate/interface/RecoChargedCandidate.h"
#include "DataFormats/RecoCandidate/interface/RecoChargedCandidateFwd.h"
#include "DataFormats/MuonReco/interface/MuonFwd.h"
#include "HLTMuonTrkL1TkMuFilter.h"
#include "DataFormats/BeamSpot/interface/BeamSpot.h"
#include "DataFormats/MuonSeed/interface/L3MuonTrajectorySeed.h"
#include "DataFormats/MuonSeed/interface/L3MuonTrajectorySeedCollection.h"
Expand All @@ -18,13 +16,13 @@
#include "TrackingTools/TransientTrack/interface/TransientTrack.h"
#include "MagneticField/Engine/interface/MagneticField.h"
#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"

#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/Utilities/interface/EDMException.h"

#include "DataFormats/Math/interface/deltaR.h"

HLTMuonTrkL1TkMuFilter::HLTMuonTrkL1TkMuFilter(const edm::ParameterSet& iConfig) : HLTFilter(iConfig) {
m_muonsTag = iConfig.getParameter<edm::InputTag>("inputMuonCollection");
m_muonsToken = consumes<reco::MuonCollection>(m_muonsTag);
Expand Down Expand Up @@ -73,17 +71,13 @@ bool HLTMuonTrkL1TkMuFilter::hltFilter(edm::Event& iEvent,

edm::Handle<trigger::TriggerFilterObjectWithRefs> previousLevelCands;
std::vector<l1t::TkMuonRef> vl1cands;
std::vector<l1t::TkMuonRef>::iterator vl1cands_begin;
std::vector<l1t::TkMuonRef>::iterator vl1cands_end;

bool check_l1match = true;
if (m_previousCandTag == edm::InputTag(""))
check_l1match = false;
if (check_l1match) {
iEvent.getByToken(m_previousCandToken, previousLevelCands);
previousLevelCands->getObjects(trigger::TriggerL1TkMu, vl1cands);
vl1cands_begin = vl1cands.begin();
vl1cands_end = vl1cands.end();
}

std::vector<unsigned int> filteredMuons;
Expand All @@ -92,8 +86,8 @@ bool HLTMuonTrkL1TkMuFilter::hltFilter(edm::Event& iEvent,
// check for dR match to L1 muons
if (check_l1match) {
bool matchl1 = false;
for (auto l1cand = vl1cands_begin; l1cand != vl1cands_end; ++l1cand) {
if (deltaR(muon, **l1cand) < 0.3) {
for (auto const& l1cand : vl1cands) {
if (deltaR2(muon, *l1cand) < 0.3 * 0.3) {
matchl1 = true;
break;
}
Expand Down
3 changes: 0 additions & 3 deletions RecoMuon/L2MuonSeedGenerator/BuildFile.xml
Expand Up @@ -15,8 +15,5 @@
<use name="TrackingTools/KalmanUpdators"/>
<use name="TrackingTools/TrajectoryParametrization"/>
<use name="TrackingTools/TrajectoryState"/>
<use name="TrackingTools/TrackAssociator"/>
<use name="Geometry/CommonTopologies"/>
<use name="DataFormats/L1TrackTrigger"/>
<use name="clhep"/>
<flags EDM_PLUGIN="1"/>
20 changes: 20 additions & 0 deletions RecoMuon/L2MuonSeedGenerator/plugins/BuildFile.xml
@@ -0,0 +1,20 @@
<library name="RecoMuonL2MuonSeedGeneratorPlugins" file="*.cc">
<use name="DataFormats/Common"/>
<use name="DataFormats/GeometrySurface"/>
<use name="DataFormats/L1Trigger"/>
<use name="DataFormats/MuonDetId"/>
<use name="DataFormats/MuonSeed"/>
<use name="DataFormats/TrajectoryState"/>
<use name="FWCore/Framework"/>
<use name="FWCore/MessageLogger"/>
<use name="FWCore/ParameterSet"/>
<use name="FWCore/PluginManager"/>
<use name="Geometry/CommonDetUnit"/>
<use name="RecoMuon/TrackingTools"/>
<use name="TrackingTools/DetLayers"/>
<use name="TrackingTools/KalmanUpdators"/>
<use name="TrackingTools/TrajectoryParametrization"/>
<use name="TrackingTools/TrajectoryState"/>
<use name="clhep"/>
<flags EDM_PLUGIN="1"/>
</library>