Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-06-10 01:53:54

0001 #include "FWCore/Framework/interface/Frameworkfwd.h"
0002 #include "FWCore/Framework/interface/stream/EDProducer.h"
0003 #include "FWCore/Framework/interface/Event.h"
0004 #include "FWCore/Framework/interface/MakerMacros.h"
0005 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0006 
0007 #include "DataFormats/L1TParticleFlow/interface/PFCluster.h"
0008 #include "L1Trigger/Phase2L1ParticleFlow/src/corrector.h"
0009 #include "L1Trigger/Phase2L1ParticleFlow/interface/ParametricResolution.h"
0010 #include "DataFormats/L1Trigger/interface/EGamma.h"
0011 
0012 namespace l1tpf {
0013   class PFClusterProducerFromL1EGClusters : public edm::stream::EDProducer<> {
0014   public:
0015     explicit PFClusterProducerFromL1EGClusters(const edm::ParameterSet &);
0016     ~PFClusterProducerFromL1EGClusters() override {}
0017 
0018   private:
0019     edm::EDGetTokenT<BXVector<l1t::EGamma>> src_;
0020     double etCut_;
0021     l1tpf::corrector corrector_;
0022     l1tpf::ParametricResolution resol_;
0023 
0024     void produce(edm::Event &, const edm::EventSetup &) override;
0025 
0026   };  // class
0027 }  // namespace l1tpf
0028 
0029 l1tpf::PFClusterProducerFromL1EGClusters::PFClusterProducerFromL1EGClusters(const edm::ParameterSet &iConfig)
0030     : src_(consumes<BXVector<l1t::EGamma>>(iConfig.getParameter<edm::InputTag>("src"))),
0031       etCut_(iConfig.getParameter<double>("etMin")),
0032       corrector_(iConfig.getParameter<std::string>("corrector"), -1),
0033       resol_(iConfig.getParameter<edm::ParameterSet>("resol")) {
0034   produces<l1t::PFClusterCollection>();
0035 }
0036 
0037 void l1tpf::PFClusterProducerFromL1EGClusters::produce(edm::Event &iEvent, const edm::EventSetup &) {
0038   std::unique_ptr<l1t::PFClusterCollection> out(new l1t::PFClusterCollection());
0039   edm::Handle<BXVector<l1t::EGamma>> clusters;
0040   iEvent.getByToken(src_, clusters);
0041 
0042   unsigned int index = 0;
0043   for (auto it = clusters->begin(), ed = clusters->end(); it != ed; ++it, ++index) {
0044     if (it->pt() <= etCut_)
0045       continue;
0046 
0047     l1t::PFCluster cluster(
0048         it->pt(), it->eta(), it->phi(), /*hOverE=*/0., /*isEM=*/true);  // it->hovere() seems to return random values
0049     if (corrector_.valid())
0050       corrector_.correctPt(cluster);
0051     cluster.setPtError(resol_(cluster.pt(), std::abs(cluster.eta())));
0052     cluster.setHwQual(it->hwQual());
0053     out->push_back(cluster);
0054     out->back().addConstituent(edm::Ptr<l1t::L1Candidate>(clusters, index));
0055   }
0056 
0057   iEvent.put(std::move(out));
0058 }
0059 using l1tpf::PFClusterProducerFromL1EGClusters;
0060 DEFINE_FWK_MODULE(PFClusterProducerFromL1EGClusters);