Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:24:53

0001 /*
0002   Author: Swagata Mukherjee
0003 
0004   Date: Feb 2021
0005 
0006   At the time of writing this new module, it is intended to be used mainly for
0007   phase-2. Before feeding in the L1 e/g collection to
0008   HLTEcalRecHitInAllL1RegionsProducer, it can pass through this module which
0009   will filter the collection based on hardware quality and pT.
0010 
0011   The most generic L1 e/g phase-2 collections are:
0012   TkEm, which is std::vector<l1t::TkEm>
0013   &
0014   StaEG, which is l1t::P2GTCandidateCollection
0015 
0016   Despite this technical difference, the objects are almost identical, for all
0017   practical purposes. So any of these two collections could have been used.
0018   Currently, l1t::P2GTCandidateCollection is recognised by the next step
0019   HLTEcalRecHitInAllL1RegionsProducer, while std::vector<l1t::TkEm> is not. So
0020   using l1t::P2GTCandidateCollection is straightforward. If for some reason one need to
0021   use std::vector<l1t::TkEm>, changes in HLTEcalRecHitInAllL1RegionsProducer
0022   would also be necesary.
0023 */
0024 
0025 #include "DataFormats/L1TCorrelator/interface/TkEm.h"
0026 #include "DataFormats/L1Trigger/interface/P2GTCandidate.h"
0027 #include "FWCore/Framework/interface/ESHandle.h"
0028 #include "FWCore/Framework/interface/Event.h"
0029 #include "FWCore/Framework/interface/EventSetup.h"
0030 #include "FWCore/Framework/interface/EventSetupRecord.h"
0031 #include "FWCore/Framework/interface/Frameworkfwd.h"
0032 #include "FWCore/Framework/interface/MakerMacros.h"
0033 #include "FWCore/Framework/interface/global/EDProducer.h"
0034 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0035 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0036 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0037 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0038 
0039 class L1TEGammaFilteredCollectionProducer : public edm::global::EDProducer<> {
0040 public:
0041   explicit L1TEGammaFilteredCollectionProducer(const edm::ParameterSet&);
0042   ~L1TEGammaFilteredCollectionProducer() override;
0043   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0044   void produce(edm::StreamID sid, edm::Event& iEvent, const edm::EventSetup& iSetup) const override;
0045 
0046 private:
0047   edm::InputTag l1EgTag_;
0048   edm::EDGetTokenT<l1t::P2GTCandidateCollection> l1EgToken_;
0049   int quality_;
0050   bool qualIsMask_;
0051   bool applyQual_;
0052   int minBX_;
0053   int maxBX_;
0054   double minPt_;
0055 };
0056 
0057 L1TEGammaFilteredCollectionProducer::L1TEGammaFilteredCollectionProducer(const edm::ParameterSet& iConfig)
0058     : l1EgTag_(iConfig.getParameter<edm::InputTag>("inputTag")),
0059       l1EgToken_(consumes<l1t::P2GTCandidateCollection>(l1EgTag_)) {
0060   quality_ = iConfig.getParameter<int>("quality");
0061   qualIsMask_ = iConfig.getParameter<bool>("qualIsMask");
0062   applyQual_ = iConfig.getParameter<bool>("applyQual");
0063   minBX_ = iConfig.getParameter<int>("minBX");
0064   maxBX_ = iConfig.getParameter<int>("maxBX");
0065   minPt_ = iConfig.getParameter<double>("minPt");
0066 
0067   produces<l1t::P2GTCandidateCollection>();
0068 }
0069 
0070 L1TEGammaFilteredCollectionProducer::~L1TEGammaFilteredCollectionProducer() = default;
0071 
0072 void L1TEGammaFilteredCollectionProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0073   edm::ParameterSetDescription desc;
0074   desc.add<edm::InputTag>("inputTag", edm::InputTag("L1EGammaClusterEmuProducer"));
0075   desc.add<int>("quality", 0x2);
0076   desc.add<bool>("qualIsMask", true);
0077   desc.add<bool>("applyQual", true);
0078   desc.add<int>("minBX", -1);
0079   desc.add<int>("maxBX", 1);
0080   desc.add<double>("minPt", 5.0);
0081   descriptions.add("L1TEGammaFilteredCollectionProducer", desc);
0082 }
0083 
0084 void L1TEGammaFilteredCollectionProducer::produce(edm::StreamID sid,
0085                                                   edm::Event& iEvent,
0086                                                   const edm::EventSetup& iSetup) const {
0087   auto outEgs = std::make_unique<l1t::P2GTCandidateCollection>();
0088   auto l1Egs = iEvent.getHandle(l1EgToken_);
0089 
0090   for (l1t::P2GTCandidateCollection::const_iterator iEg = (*l1Egs).begin(); iEg != (*l1Egs).end(); iEg++) {
0091     double offlineEt = (*iEg).pt();
0092     bool passQuality(false);
0093     if (applyQual_) {
0094       if (qualIsMask_)
0095         passQuality = ((*iEg).hwQual() & quality_);
0096       else
0097         passQuality = ((*iEg).hwQual() == quality_);
0098     } else
0099       passQuality = true;
0100 
0101     // if quality is passed, put the object in filtered collection
0102     if (passQuality && (offlineEt > minPt_)) {
0103       outEgs->push_back(*iEg);
0104     }
0105   }  // l1EG loop ends
0106   iEvent.put(std::move(outEgs));
0107 }
0108 
0109 DEFINE_FWK_MODULE(L1TEGammaFilteredCollectionProducer);