Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:35:02

0001 // -*- C++ -*-
0002 //
0003 // Package:    BasicToPFJet
0004 // Class:      BasicToPFJet
0005 //
0006 /**\class BasicToPFJet BasicToPFJet.cc UserCode/BasicToPFJet/plugins/BasicToPFJet.cc
0007 
0008  Description: converts reco::BasicJets to reco::PFJets and adds the new PFJetCollection to the event. Originally designed
0009               to be a work around for a way to store reco::BasicJets at HLT level
0010 
0011  Implementation:
0012      [Notes on implementation]
0013 */
0014 //
0015 // Original Author:  clint richardson
0016 //         Created:  Thu, 6 Mar 2014 12:00:00 GMT
0017 //
0018 //
0019 // system include files
0020 #include <memory>
0021 #include <vector>
0022 #include <sstream>
0023 
0024 // user include files
0025 #include "FWCore/PluginManager/interface/ModuleDef.h"
0026 #include "FWCore/Framework/interface/MakerMacros.h"
0027 #include "FWCore/Framework/interface/Event.h"
0028 #include "DataFormats/BTauReco/interface/CATopJetTagInfo.h"
0029 #include "DataFormats/JetReco/interface/PFJetCollection.h"
0030 
0031 //include header file
0032 #include "RecoJets/JetProducers/plugins/BasicToPFJet.h"
0033 
0034 BasicToPFJet::BasicToPFJet(const edm::ParameterSet& PSet)
0035     : src_(PSet.getParameter<edm::InputTag>("src")), inputToken_(consumes<reco::BasicJetCollection>(src_)) {
0036   produces<reco::PFJetCollection>();
0037 }
0038 
0039 BasicToPFJet::~BasicToPFJet() {}
0040 
0041 void BasicToPFJet::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0042   edm::ParameterSetDescription desc;
0043   desc.add<edm::InputTag>("src", edm::InputTag(""));
0044   descriptions.add("BasicToPFJet", desc);
0045 }
0046 
0047 void BasicToPFJet::produce(edm::Event& Event, const edm::EventSetup& EventSetup) {
0048   //first get the basic jet collection
0049   edm::Handle<reco::BasicJetCollection> BasicJetColl;
0050   Event.getByToken(inputToken_, BasicJetColl);
0051 
0052   //now make the new pf jet collection
0053   auto PFJetColl = std::make_unique<reco::PFJetCollection>();
0054   //reco::PFJetCollection* PFJetColl = new reco::PFJetCollection;
0055   //make the 'specific'
0056   reco::PFJet::Specific specific;
0057 
0058   //now get iterator
0059   reco::BasicJetCollection::const_iterator i = BasicJetColl->begin();
0060 
0061   //loop over basic jets and convert them to pfjets
0062   for (; i != BasicJetColl->end(); i++) {
0063     reco::PFJet pfjet(i->p4(), i->vertex(), specific);
0064     PFJetColl->push_back(pfjet);
0065   }
0066 
0067   //std::unique_ptr<reco::PFJetCollection> selectedPFJets(PFJetColl);
0068   Event.put(std::move(PFJetColl));
0069 }
0070 
0071 //define as plug-in for the framework
0072 DEFINE_FWK_MODULE(BasicToPFJet);