Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:21:29

0001 #include "DataFormats/L1TParticleFlow/interface/PFJet.h"
0002 #include "DataFormats/JetReco/interface/Jet.h"
0003 #include "DataFormats/Candidate/interface/Candidate.h"
0004 
0005 #include "FWCore/Framework/interface/global/EDProducer.h"
0006 #include "FWCore/Framework/interface/Event.h"
0007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0008 #include "FWCore/Utilities/interface/InputTag.h"
0009 
0010 #include "L1Trigger/Phase2L1ParticleFlow/interface/corrector.h"
0011 
0012 #include <vector>
0013 
0014 class L1TCorrectedPFJetProducer : public edm::global::EDProducer<> {
0015 public:
0016   explicit L1TCorrectedPFJetProducer(const edm::ParameterSet&);
0017   ~L1TCorrectedPFJetProducer() override;
0018 
0019 private:
0020   void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
0021 
0022   edm::EDGetTokenT<edm::View<l1t::PFJet>> jets_;
0023   l1tpf::corrector corrector_;
0024 };
0025 
0026 L1TCorrectedPFJetProducer::L1TCorrectedPFJetProducer(const edm::ParameterSet& iConfig)
0027     : jets_(consumes<edm::View<l1t::PFJet>>(iConfig.getParameter<edm::InputTag>("jets"))),
0028       corrector_(iConfig.getParameter<std::string>("correctorFile"),
0029                  iConfig.getParameter<std::string>("correctorDir"),
0030                  -1,
0031                  false,
0032                  iConfig.getParameter<bool>("emulate")) {
0033   produces<std::vector<l1t::PFJet>>();
0034 }
0035 
0036 L1TCorrectedPFJetProducer::~L1TCorrectedPFJetProducer() {}
0037 
0038 void L1TCorrectedPFJetProducer::produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup&) const {
0039   edm::Handle<edm::View<l1t::PFJet>> jets;
0040   iEvent.getByToken(jets_, jets);
0041   auto out = std::make_unique<std::vector<l1t::PFJet>>();
0042 
0043   for (const auto& srcjet : *jets) {
0044     // start out as copy
0045     out->emplace_back(srcjet.p4());
0046     auto& jet = out->back();
0047     // copy daughters
0048     for (const auto& dau : srcjet.constituents()) {
0049       jet.addConstituent(dau);
0050     }
0051     // apply corrections
0052     jet.calibratePt(corrector_.correctedPt(jet.pt(), jet.eta()));
0053   }
0054 
0055   iEvent.put(std::move(out));
0056 }
0057 
0058 #include "FWCore/Framework/interface/MakerMacros.h"
0059 DEFINE_FWK_MODULE(L1TCorrectedPFJetProducer);