From fc72a1d682ae0c0fd846dbbb4d0506557e8a0fb8 Mon Sep 17 00:00:00 2001 From: Santiago Date: Wed, 19 Apr 2023 16:46:47 +0200 Subject: [PATCH 1/3] Low-pt muon fix --- .../Configuration/python/SimL1Emulator_cff.py | 6 ++ .../Phase2L1GMT/plugins/Phase2L1TGMTFilter.cc | 102 ++++++++++++++++++ L1Trigger/Phase2L1GMT/python/gmt_cfi.py | 9 ++ 3 files changed, 117 insertions(+) create mode 100644 L1Trigger/Phase2L1GMT/plugins/Phase2L1TGMTFilter.cc diff --git a/L1Trigger/Configuration/python/SimL1Emulator_cff.py b/L1Trigger/Configuration/python/SimL1Emulator_cff.py index 17600bf2e63a9..f39779d30271d 100644 --- a/L1Trigger/Configuration/python/SimL1Emulator_cff.py +++ b/L1Trigger/Configuration/python/SimL1Emulator_cff.py @@ -144,6 +144,12 @@ _phase2_siml1emulator.add( l1tTkMuonsGmt ) _phase2_siml1emulator.add( l1tSAMuonsGmt ) +## fix for low-pt muons, this collection is a copy of the l1tTkMuonsGmt collection +## in which we only keep those low pt muons with an SA muon associated to it. Threshold +## for this cutoff is configurable. +l1tTkMuonsGmtLowPtFix = l1tGMTFilteredMuons.clone() +_phase2_siml1emulator.add( l1tTkMuonsGmtLowPtFix ) + # Tracker Objects # ######################################################################## from L1Trigger.L1TTrackMatch.l1tTrackJets_cfi import * diff --git a/L1Trigger/Phase2L1GMT/plugins/Phase2L1TGMTFilter.cc b/L1Trigger/Phase2L1GMT/plugins/Phase2L1TGMTFilter.cc new file mode 100644 index 0000000000000..a9077b37ee8cf --- /dev/null +++ b/L1Trigger/Phase2L1GMT/plugins/Phase2L1TGMTFilter.cc @@ -0,0 +1,102 @@ +#include +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Utilities/interface/StreamID.h" +#include "DataFormats/L1TMuonPhase2/interface/TrackerMuon.h" +#include "DataFormats/L1TMuonPhase2/interface/SAMuon.h" +#include "Node.h" + +// +// class declaration +// +using namespace Phase2L1GMT; +using namespace l1t; + +class Phase2L1TGMTFilter : public edm::stream::EDProducer<> { +public: + explicit Phase2L1TGMTFilter(const edm::ParameterSet&); + ~Phase2L1TGMTFilter() override; + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + +private: + void beginStream(edm::StreamID) override; + void produce(edm::Event&, const edm::EventSetup&) override; + void endStream() override; + edm::EDGetTokenT > srcMuons_; + bool applyLowPtFilter_; + int ptBarrelMin_; + int ptEndcapMin_; +}; + +Phase2L1TGMTFilter::Phase2L1TGMTFilter(const edm::ParameterSet& iConfig) + : srcMuons_(consumes >(iConfig.getParameter("srcMuons"))), + applyLowPtFilter_(iConfig.getParameter("applyLowPtFilter")), + ptBarrelMin_(iConfig.getParameter("ptBarrelMin")), + ptEndcapMin_(iConfig.getParameter("ptEndcapMin")) { + produces >("l1tTkMuonsGmtLowPtFix"); +} + +Phase2L1TGMTFilter::~Phase2L1TGMTFilter() { + // do anything here that needs to be done at destruction time + // (e.g. close files, deallocate resources etc.) +} + +// +// member functions +// + +// ------------ method called to produce the data ------------ +void Phase2L1TGMTFilter::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { + using namespace edm; + Handle > muonHandle; + iEvent.getByToken(srcMuons_, muonHandle); + + std::vector out; + + for (uint i = 0; i < muonHandle->size(); ++i) { + auto mu = muonHandle->at(i); + bool noSAMatch = true; + if (applyLowPtFilter_) { + if ((fabs(mu.phEta()) < 0.9 && mu.phPt() < ptBarrelMin_) || + (fabs(mu.phEta()) > 0.9 && mu.phPt() < ptEndcapMin_)) { + // if quality is already set to 0 don't continue the loop. + for (const auto& r : mu.muonRef()) { + if (r.isNonnull()) { + noSAMatch = false; + break; + } + } + if (noSAMatch) + mu.setHwQual(0); + } + } + out.push_back(mu); // store all muons otherwise + } + + // store results + std::unique_ptr > out1 = std::make_unique >(out); + iEvent.put(std::move(out1)); +} + +// ------------ method called once each stream before processing any runs, lumis or events ------------ +void Phase2L1TGMTFilter::beginStream(edm::StreamID) {} + +// ------------ method called once each stream after processing all runs, lumis and events ------------ +void Phase2L1TGMTFilter::endStream() {} + +void Phase2L1TGMTFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + //The following says we do not know what parameters are allowed so do no validation + // Please change this to state exactly what you do use, even if it is no parameters + edm::ParameterSetDescription desc; + desc.setUnknown(); + descriptions.addDefault(desc); +} + +//define this as a plug-in +DEFINE_FWK_MODULE(Phase2L1TGMTFilter); diff --git a/L1Trigger/Phase2L1GMT/python/gmt_cfi.py b/L1Trigger/Phase2L1GMT/python/gmt_cfi.py index e5d24cf7bd955..f9a7b65b353b3 100644 --- a/L1Trigger/Phase2L1GMT/python/gmt_cfi.py +++ b/L1Trigger/Phase2L1GMT/python/gmt_cfi.py @@ -76,6 +76,15 @@ ) + +l1tGMTFilteredMuons = cms.EDProducer('Phase2L1TGMTFilter', + srcMuons = cms.InputTag("l1tTkMuonsGmt",""), + applyLowPtFilter = cms.bool(True), + ptBarrelMin = cms.int32(8), + ptEndcapMin = cms.int32(8) +) + + l1tStandaloneMuons = cms.EDProducer('Phase2L1TGMTSAMuonProducer', muonToken = cms.InputTag('simGmtStage2Digis'), Nprompt = cms.uint32(12), From d39280c3d6eadb809f8b41c6884c3795c3753cd2 Mon Sep 17 00:00:00 2001 From: Santiago Date: Fri, 12 May 2023 12:18:12 +0200 Subject: [PATCH 2/3] switched to double to accomodate getparameter --- L1Trigger/Phase2L1GMT/plugins/Phase2L1TGMTFilter.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/L1Trigger/Phase2L1GMT/plugins/Phase2L1TGMTFilter.cc b/L1Trigger/Phase2L1GMT/plugins/Phase2L1TGMTFilter.cc index a9077b37ee8cf..57e2fcc5b0124 100644 --- a/L1Trigger/Phase2L1GMT/plugins/Phase2L1TGMTFilter.cc +++ b/L1Trigger/Phase2L1GMT/plugins/Phase2L1TGMTFilter.cc @@ -32,14 +32,16 @@ class Phase2L1TGMTFilter : public edm::stream::EDProducer<> { bool applyLowPtFilter_; int ptBarrelMin_; int ptEndcapMin_; + double etaBE_; }; Phase2L1TGMTFilter::Phase2L1TGMTFilter(const edm::ParameterSet& iConfig) : srcMuons_(consumes >(iConfig.getParameter("srcMuons"))), applyLowPtFilter_(iConfig.getParameter("applyLowPtFilter")), ptBarrelMin_(iConfig.getParameter("ptBarrelMin")), - ptEndcapMin_(iConfig.getParameter("ptEndcapMin")) { - produces >("l1tTkMuonsGmtLowPtFix"); + ptEndcapMin_(iConfig.getParameter("ptEndcapMin")), + etaBE_(iConfig.getParameter("etaBE")) { + produces >("l1tTkMuonsGmtLowPtFix").setBranchAlias("tkMuLowPtFix"); } Phase2L1TGMTFilter::~Phase2L1TGMTFilter() { From b6a2d43f56abc21cf5f99b458b75cab8519643bd Mon Sep 17 00:00:00 2001 From: Santiago Date: Fri, 12 May 2023 11:46:00 +0200 Subject: [PATCH 3/3] make eta parameter configurable --- L1Trigger/Phase2L1GMT/plugins/Phase2L1TGMTFilter.cc | 4 ++-- L1Trigger/Phase2L1GMT/python/gmt_cfi.py | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/L1Trigger/Phase2L1GMT/plugins/Phase2L1TGMTFilter.cc b/L1Trigger/Phase2L1GMT/plugins/Phase2L1TGMTFilter.cc index 57e2fcc5b0124..88f2557788058 100644 --- a/L1Trigger/Phase2L1GMT/plugins/Phase2L1TGMTFilter.cc +++ b/L1Trigger/Phase2L1GMT/plugins/Phase2L1TGMTFilter.cc @@ -65,8 +65,8 @@ void Phase2L1TGMTFilter::produce(edm::Event& iEvent, const edm::EventSetup& iSet auto mu = muonHandle->at(i); bool noSAMatch = true; if (applyLowPtFilter_) { - if ((fabs(mu.phEta()) < 0.9 && mu.phPt() < ptBarrelMin_) || - (fabs(mu.phEta()) > 0.9 && mu.phPt() < ptEndcapMin_)) { + if ((fabs(mu.phEta()) < etaBE_ && mu.phPt() < ptBarrelMin_) || + (fabs(mu.phEta()) > etaBE_ && mu.phPt() < ptEndcapMin_)) { // if quality is already set to 0 don't continue the loop. for (const auto& r : mu.muonRef()) { if (r.isNonnull()) { diff --git a/L1Trigger/Phase2L1GMT/python/gmt_cfi.py b/L1Trigger/Phase2L1GMT/python/gmt_cfi.py index f9a7b65b353b3..af95f691ec255 100644 --- a/L1Trigger/Phase2L1GMT/python/gmt_cfi.py +++ b/L1Trigger/Phase2L1GMT/python/gmt_cfi.py @@ -81,7 +81,9 @@ srcMuons = cms.InputTag("l1tTkMuonsGmt",""), applyLowPtFilter = cms.bool(True), ptBarrelMin = cms.int32(8), - ptEndcapMin = cms.int32(8) + ptEndcapMin = cms.int32(8), + etaBE = cms.double(0.9) + )