Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:20:30

0001 #include "HLTrigger/JetMET/interface/AnyJetToCaloJetProducer.h"
0002 #include "DataFormats/Common/interface/Handle.h"
0003 
0004 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0005 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0006 #include "FWCore/Utilities/interface/InputTag.h"
0007 
0008 AnyJetToCaloJetProducer::AnyJetToCaloJetProducer(const edm::ParameterSet& iConfig) {
0009   jetSrc_ = iConfig.getParameter<edm::InputTag>("Source");
0010   m_theGenericJetToken = consumes<edm::View<reco::Jet>>(jetSrc_);
0011   produces<reco::CaloJetCollection>();
0012 }
0013 
0014 AnyJetToCaloJetProducer::~AnyJetToCaloJetProducer() = default;
0015 
0016 void AnyJetToCaloJetProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0017   edm::ParameterSetDescription desc;
0018   desc.add<edm::InputTag>("Source", edm::InputTag(""));
0019   descriptions.add("AnyJetToCaloJetProducer", desc);
0020 }
0021 
0022 void AnyJetToCaloJetProducer::produce(edm::Event& iEvent, const edm::EventSetup& iES) {
0023   std::unique_ptr<reco::CaloJetCollection> newjets(new reco::CaloJetCollection());
0024 
0025   edm::Handle<edm::View<reco::Jet>> jets;
0026   if (iEvent.getByToken(m_theGenericJetToken, jets)) {
0027     for (edm::View<reco::Jet>::const_iterator i = jets->begin(); i != jets->end(); i++) {
0028       reco::CaloJet jet(i->p4(), i->vertex(), reco::CaloJet::Specific());
0029       newjets->push_back(jet);
0030     }
0031   }
0032 
0033   iEvent.put(std::move(newjets));
0034 }