File indexing completed on 2023-05-13 00:07:06
0001 #include <memory>
0002 #include "FWCore/Framework/interface/Frameworkfwd.h"
0003 #include "FWCore/Framework/interface/stream/EDProducer.h"
0004
0005 #include "FWCore/Framework/interface/Event.h"
0006 #include "FWCore/Framework/interface/MakerMacros.h"
0007
0008 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0009 #include "FWCore/Utilities/interface/StreamID.h"
0010 #include "DataFormats/L1TMuonPhase2/interface/TrackerMuon.h"
0011 #include "DataFormats/L1TMuonPhase2/interface/SAMuon.h"
0012 #include "Node.h"
0013
0014
0015
0016
0017 using namespace Phase2L1GMT;
0018 using namespace l1t;
0019
0020 class Phase2L1TGMTFilter : public edm::stream::EDProducer<> {
0021 public:
0022 explicit Phase2L1TGMTFilter(const edm::ParameterSet&);
0023 ~Phase2L1TGMTFilter() override;
0024
0025 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0026
0027 private:
0028 void beginStream(edm::StreamID) override;
0029 void produce(edm::Event&, const edm::EventSetup&) override;
0030 void endStream() override;
0031 edm::EDGetTokenT<std::vector<l1t::TrackerMuon> > srcMuons_;
0032 bool applyLowPtFilter_;
0033 int ptBarrelMin_;
0034 int ptEndcapMin_;
0035 double etaBE_;
0036 };
0037
0038 Phase2L1TGMTFilter::Phase2L1TGMTFilter(const edm::ParameterSet& iConfig)
0039 : srcMuons_(consumes<std::vector<l1t::TrackerMuon> >(iConfig.getParameter<edm::InputTag>("srcMuons"))),
0040 applyLowPtFilter_(iConfig.getParameter<bool>("applyLowPtFilter")),
0041 ptBarrelMin_(iConfig.getParameter<int>("ptBarrelMin")),
0042 ptEndcapMin_(iConfig.getParameter<int>("ptEndcapMin")),
0043 etaBE_(iConfig.getParameter<double>("etaBE")) {
0044 produces<std::vector<l1t::TrackerMuon> >("l1tTkMuonsGmtLowPtFix").setBranchAlias("tkMuLowPtFix");
0045 }
0046
0047 Phase2L1TGMTFilter::~Phase2L1TGMTFilter() {
0048
0049
0050 }
0051
0052
0053
0054
0055
0056
0057 void Phase2L1TGMTFilter::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0058 using namespace edm;
0059 Handle<std::vector<l1t::TrackerMuon> > muonHandle;
0060 iEvent.getByToken(srcMuons_, muonHandle);
0061
0062 std::vector<l1t::TrackerMuon> out;
0063
0064 for (uint i = 0; i < muonHandle->size(); ++i) {
0065 auto mu = muonHandle->at(i);
0066 bool noSAMatch = true;
0067 if (applyLowPtFilter_) {
0068 if ((fabs(mu.phEta()) < etaBE_ && mu.phPt() < ptBarrelMin_) ||
0069 (fabs(mu.phEta()) > etaBE_ && mu.phPt() < ptEndcapMin_)) {
0070
0071 for (const auto& r : mu.muonRef()) {
0072 if (r.isNonnull()) {
0073 noSAMatch = false;
0074 break;
0075 }
0076 }
0077 if (noSAMatch)
0078 mu.setHwQual(0);
0079 }
0080 }
0081 out.push_back(mu);
0082 }
0083
0084
0085 std::unique_ptr<std::vector<l1t::TrackerMuon> > out1 = std::make_unique<std::vector<l1t::TrackerMuon> >(out);
0086 iEvent.put(std::move(out1), "l1tTkMuonsGmtLowPtFix");
0087 }
0088
0089
0090 void Phase2L1TGMTFilter::beginStream(edm::StreamID) {}
0091
0092
0093 void Phase2L1TGMTFilter::endStream() {}
0094
0095 void Phase2L1TGMTFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0096
0097
0098 edm::ParameterSetDescription desc;
0099 desc.setUnknown();
0100 descriptions.addDefault(desc);
0101 }
0102
0103
0104 DEFINE_FWK_MODULE(Phase2L1TGMTFilter);