Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:25:31

0001 #include "CATopJetTagger.h"
0002 #include "RecoJets/JetAlgorithms/interface/CATopJetHelper.h"
0003 #include "DataFormats/BTauReco/interface/CATopJetTagInfo.h"
0004 
0005 using namespace std;
0006 using namespace reco;
0007 using namespace edm;
0008 //
0009 // constants, enums and typedefs
0010 //
0011 
0012 //
0013 // static data member definitions
0014 //
0015 
0016 //
0017 // constructors and destructor
0018 //
0019 CATopJetTagger::CATopJetTagger(const edm::ParameterSet& iConfig)
0020     : src_(iConfig.getParameter<InputTag>("src")),
0021       TopMass_(iConfig.getParameter<double>("TopMass")),
0022       WMass_(iConfig.getParameter<double>("WMass")),
0023       verbose_(iConfig.getParameter<bool>("verbose")),
0024       input_jet_token_(consumes<edm::View<reco::Jet> >(src_)) {
0025   produces<CATopJetTagInfoCollection>();
0026 }
0027 
0028 CATopJetTagger::~CATopJetTagger() {}
0029 
0030 //
0031 // member functions
0032 //
0033 
0034 // ------------ method called to for each event  ------------
0035 void CATopJetTagger::produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const {
0036   // Set up output list
0037   auto tagInfos = std::make_unique<CATopJetTagInfoCollection>();
0038 
0039   // Get the input list of basic jets corresponding to the hard jets
0040   Handle<View<Jet> > pBasicJets;
0041   iEvent.getByToken(input_jet_token_, pBasicJets);
0042 
0043   // Get a convenient handle
0044   View<Jet> const& hardJets = *pBasicJets;
0045 
0046   CATopJetHelper helper(TopMass_, WMass_);
0047 
0048   // Now loop over the hard jets and do kinematic cuts
0049   View<Jet>::const_iterator ihardJet = hardJets.begin(), ihardJetEnd = hardJets.end();
0050   size_t iihardJet = 0;
0051   for (; ihardJet != ihardJetEnd; ++ihardJet, ++iihardJet) {
0052     if (verbose_)
0053       edm::LogInfo("CATopJetTagger") << "Processing ihardJet with pt = " << ihardJet->pt() << endl;
0054 
0055     // Initialize output variables
0056     // Get a ref to the hard jet
0057     RefToBase<Jet> ref(pBasicJets, iihardJet);
0058     // Get properties
0059     CATopJetProperties properties = helper(*ihardJet);
0060 
0061     CATopJetTagInfo tagInfo;
0062     tagInfo.insert(ref, properties);
0063     tagInfos->push_back(tagInfo);
0064   }  // end loop over hard jets
0065 
0066   iEvent.put(std::move(tagInfos));
0067 
0068   return;
0069 }
0070 
0071 //define this as a plug-in
0072 DEFINE_FWK_MODULE(CATopJetTagger);