-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Refactore PropagateToMuon and add propagation to L3 muon filters at HLT #37180
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,6 +35,7 @@ using namespace trigger; | |
|
|
||
| HLTMuonL3PreFilter::HLTMuonL3PreFilter(const ParameterSet& iConfig) | ||
| : HLTFilter(iConfig), | ||
| propSetup_(iConfig, consumesCollector()), | ||
| beamspotTag_(iConfig.getParameter<edm::InputTag>("BeamSpotTag")), | ||
| beamspotToken_(consumes<reco::BeamSpot>(beamspotTag_)), | ||
| candTag_(iConfig.getParameter<InputTag>("CandTag")), | ||
|
|
@@ -66,11 +67,16 @@ HLTMuonL3PreFilter::HLTMuonL3PreFilter(const ParameterSet& iConfig) | |
| maxNormalizedChi2_L3fromL1_(iConfig.getParameter<double>("MaxNormalizedChi2_L3FromL1")), | ||
| trkMuonId_(muon::SelectionType(iConfig.getParameter<unsigned int>("trkMuonId"))), | ||
| L1MatchingdR_(iConfig.getParameter<double>("L1MatchingdR")), | ||
| L1MatchingdR2_(L1MatchingdR_ * L1MatchingdR_), | ||
| matchPreviousCand_(iConfig.getParameter<bool>("MatchToPreviousCand")), | ||
|
|
||
| devDebug_(false), | ||
| theL3LinksLabel(iConfig.getParameter<InputTag>("InputLinks")), | ||
| linkToken_(consumes<reco::MuonTrackLinksCollection>(theL3LinksLabel)) { | ||
| if (L1MatchingdR_ <= 0.) { | ||
| throw cms::Exception("HLTMuonL3PreFilterConfiguration") | ||
| << "invalid value for parameter \"L1MatchingdR\" (must be > 0): " << L1MatchingdR_; | ||
| } | ||
| LogDebug("HLTMuonL3PreFilter") << " CandTag/MinN/MaxEta/MinNhits/MaxDr/MinDr/MaxDz/MinDxySig/MinPt/NSigmaPt : " | ||
| << candTag_.encode() << " " << min_N_ << " " << max_Eta_ << " " << min_Nhits_ << " " | ||
| << max_Dr_ << " " << min_Dr_ << " " << max_Dz_ << " " << min_DxySig_ << " " << min_Pt_ | ||
|
|
@@ -113,6 +119,7 @@ void HLTMuonL3PreFilter::fillDescriptions(edm::ConfigurationDescriptions& descri | |
| desc.add<double>("L1MatchingdR", 0.3); | ||
| desc.add<bool>("MatchToPreviousCand", true); | ||
| desc.add<edm::InputTag>("InputLinks", edm::InputTag("")); | ||
| PropagateToMuonSetup::fillPSetDescription(desc); | ||
| descriptions.add("hltMuonL3PreFilter", desc); | ||
| } | ||
|
|
||
|
|
@@ -128,6 +135,8 @@ bool HLTMuonL3PreFilter::hltFilter(Event& iEvent, | |
| // recording any reconstructed physics objects satisfying (or not) | ||
| // this HLT filter, and place it in the Event. | ||
|
|
||
| auto const prop = propSetup_.init(iSetup); | ||
|
|
||
| if (saveTags()) | ||
| filterproduct.addCollectionTag(candTag_); | ||
|
|
||
|
|
@@ -224,11 +233,14 @@ bool HLTMuonL3PreFilter::hltFilter(Event& iEvent, | |
| } //MTL loop | ||
|
|
||
| if (!l1CandTag_.label().empty() && check_l1match) { | ||
| auto const propagated = prop.extrapolate(*tk); | ||
| auto const etaForMatch = propagated.isValid() ? propagated.globalPosition().eta() : cand->eta(); | ||
| auto const phiForMatch = propagated.isValid() ? (double)propagated.globalPosition().phi() : cand->phi(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as above (
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above. |
||
| iEvent.getByToken(l1CandToken_, level1Cands); | ||
| level1Cands->getObjects(trigger::TriggerL1Mu, vl1cands); | ||
| const unsigned int nL1Muons(vl1cands.size()); | ||
| for (unsigned int il1 = 0; il1 != nL1Muons; ++il1) { | ||
| if (deltaR(cand->eta(), cand->phi(), vl1cands[il1]->eta(), vl1cands[il1]->phi()) < L1MatchingdR_) { | ||
| if (deltaR2(etaForMatch, phiForMatch, vl1cands[il1]->eta(), vl1cands[il1]->phi()) < L1MatchingdR2_) { | ||
| MuonToL3s[i] = RecoChargedCandidateRef(cand); | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,23 +27,31 @@ | |
|
|
||
| #include "DataFormats/Math/interface/deltaR.h" | ||
|
|
||
| HLTMuonTrkFilter::HLTMuonTrkFilter(const edm::ParameterSet& iConfig) : HLTFilter(iConfig) { | ||
| m_muonsTag = iConfig.getParameter<edm::InputTag>("inputMuonCollection"); | ||
| m_muonsToken = consumes<reco::MuonCollection>(m_muonsTag); | ||
| m_candsTag = iConfig.getParameter<edm::InputTag>("inputCandCollection"); | ||
| m_candsToken = consumes<reco::RecoChargedCandidateCollection>(m_candsTag); | ||
| m_previousCandTag = iConfig.getParameter<edm::InputTag>("previousCandTag"); | ||
| m_previousCandToken = consumes<trigger::TriggerFilterObjectWithRefs>(m_previousCandTag); | ||
| m_minTrkHits = iConfig.getParameter<int>("minTrkHits"); | ||
| m_minMuonHits = iConfig.getParameter<int>("minMuonHits"); | ||
| m_minMuonStations = iConfig.getParameter<int>("minMuonStations"); | ||
| m_maxNormalizedChi2 = iConfig.getParameter<double>("maxNormalizedChi2"); | ||
| m_allowedTypeMask = iConfig.getParameter<unsigned int>("allowedTypeMask"); | ||
| m_requiredTypeMask = iConfig.getParameter<unsigned int>("requiredTypeMask"); | ||
| m_trkMuonId = muon::SelectionType(iConfig.getParameter<unsigned int>("trkMuonId")); | ||
| m_minPt = iConfig.getParameter<double>("minPt"); | ||
| m_minN = iConfig.getParameter<unsigned int>("minN"); | ||
| m_maxAbsEta = iConfig.getParameter<double>("maxAbsEta"); | ||
| HLTMuonTrkFilter::HLTMuonTrkFilter(const edm::ParameterSet& iConfig) | ||
| : HLTFilter(iConfig), | ||
| propSetup_(iConfig, consumesCollector()), | ||
| m_muonsTag(iConfig.getParameter<edm::InputTag>("inputMuonCollection")), | ||
| m_muonsToken(consumes<reco::MuonCollection>(m_muonsTag)), | ||
| m_candsTag(iConfig.getParameter<edm::InputTag>("inputCandCollection")), | ||
| m_candsToken(consumes<reco::RecoChargedCandidateCollection>(m_candsTag)), | ||
| m_previousCandTag(iConfig.getParameter<edm::InputTag>("previousCandTag")), | ||
| m_previousCandToken(consumes<trigger::TriggerFilterObjectWithRefs>(m_previousCandTag)), | ||
| m_minTrkHits(iConfig.getParameter<int>("minTrkHits")), | ||
| m_minMuonHits(iConfig.getParameter<int>("minMuonHits")), | ||
| m_minMuonStations(iConfig.getParameter<int>("minMuonStations")), | ||
| m_maxNormalizedChi2(iConfig.getParameter<double>("maxNormalizedChi2")), | ||
| m_allowedTypeMask(iConfig.getParameter<unsigned int>("allowedTypeMask")), | ||
| m_requiredTypeMask(iConfig.getParameter<unsigned int>("requiredTypeMask")), | ||
| m_trkMuonId(muon::SelectionType(iConfig.getParameter<unsigned int>("trkMuonId"))), | ||
| m_minPt(iConfig.getParameter<double>("minPt")), | ||
| m_minN(iConfig.getParameter<unsigned int>("minN")), | ||
| m_maxAbsEta(iConfig.getParameter<double>("maxAbsEta")), | ||
| m_l1MatchingdR(iConfig.getParameter<double>("L1MatchingdR")), | ||
| m_l1MatchingdR2(m_l1MatchingdR * m_l1MatchingdR) { | ||
| if (m_l1MatchingdR <= 0.) { | ||
| throw cms::Exception("HLTMuonTrkFilterConfiguration") | ||
| << "invalid value for parameter \"L1MatchingdR\" (must be > 0): " << m_l1MatchingdR; | ||
| } | ||
| } | ||
|
|
||
| void HLTMuonTrkFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { | ||
|
|
@@ -62,12 +70,16 @@ void HLTMuonTrkFilter::fillDescriptions(edm::ConfigurationDescriptions& descript | |
| desc.add<double>("minPt", 24); | ||
| desc.add<unsigned int>("minN", 1); | ||
| desc.add<double>("maxAbsEta", 1e99); | ||
| desc.add<double>("L1MatchingdR", 0.3); | ||
| PropagateToMuonSetup::fillPSetDescription(desc); | ||
| descriptions.add("hltMuonTrkFilter", desc); | ||
| } | ||
|
|
||
| bool HLTMuonTrkFilter::hltFilter(edm::Event& iEvent, | ||
| const edm::EventSetup& iSetup, | ||
| trigger::TriggerFilterObjectWithRefs& filterproduct) const { | ||
| auto const prop = propSetup_.init(iSetup); | ||
|
|
||
| edm::Handle<reco::MuonCollection> muons; | ||
| iEvent.getByToken(m_muonsToken, muons); | ||
| edm::Handle<reco::RecoChargedCandidateCollection> cands; | ||
|
|
@@ -96,11 +108,22 @@ bool HLTMuonTrkFilter::hltFilter(edm::Event& iEvent, | |
| std::vector<unsigned int> filteredMuons; | ||
| for (unsigned int i = 0; i < muons->size(); ++i) { | ||
| const reco::Muon& muon(muons->at(i)); | ||
| // check for dR match to L1 muons | ||
| if (check_l1match) { | ||
| const reco::RecoChargedCandidateRef cand(cands, i); | ||
| const reco::TrackRef tk = cand->track(); | ||
| auto etaForMatch = cand->eta(); | ||
| auto phiForMatch = cand->phi(); | ||
| // check for dR match to L1 muons | ||
| if (tk.isNonnull()) { | ||
| auto const propagated = prop.extrapolate(*tk); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Didn't we also have a check on
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oops, yes that got lost. Fixed. |
||
| if (propagated.isValid()) { | ||
| etaForMatch = propagated.globalPosition().eta(); | ||
| phiForMatch = propagated.globalPosition().phi(); | ||
| } | ||
| } | ||
| bool matchl1 = false; | ||
| for (auto l1cand = vl1cands_begin; l1cand != vl1cands_end; ++l1cand) { | ||
| if (deltaR(muon, **l1cand) < 0.3) { | ||
| if (deltaR2(etaForMatch, phiForMatch, (*l1cand)->eta(), (*l1cand)->phi()) < m_l1MatchingdR2) { | ||
| matchl1 = true; | ||
| break; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why
(double)? (and why only forphi?)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the
phi()here does not return a simpledoublebut aGeom::Phi<float, Geom::MinusPiToPi>, which usually just gets implicitly converted when the function is used. But in this case, the compiler requires the types on both sides of the?to be of the same type explicitly, hence the conversion. This does not happen foreta().