Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // Package:    HLTCATopTagFilter
0004 // Class:      HLTCATopTagFilter
0005 //
0006 /**\class HLTCATopTagFilter HLTCATopTagFilter.cc UserCode/HLTCATopTagFilter/plugins/HLTCATopTagFilter.cc
0007 
0008  Description: [one line class summary]
0009 
0010  Implementation:
0011      [Notes on implementation]
0012 */
0013 //
0014 // Original Author:  dylan rankin
0015 //         Created:  Wed, 17 Jul 2013 22:11:30 GMT
0016 // $Id$
0017 //
0018 //
0019 
0020 #include "HLTrigger/JetMET/interface/HLTCATopTagFilter.h"
0021 
0022 using namespace std;
0023 using namespace reco;
0024 using namespace edm;
0025 
0026 //
0027 // constructors and destructor
0028 //
0029 
0030 HLTCATopTagFilter::HLTCATopTagFilter(const edm::ParameterSet& iConfig)
0031     : HLTFilter(iConfig),
0032       src_(iConfig.getParameter<edm::InputTag>("src")),
0033       pfsrc_(iConfig.getParameter<edm::InputTag>("pfsrc")),
0034       inputToken_(consumes<reco::BasicJetCollection>(src_)),
0035       inputPFToken_(consumes<reco::PFJetCollection>(pfsrc_)) {
0036   TopMass_ = iConfig.getParameter<double>("TopMass");
0037   minTopMass_ = iConfig.getParameter<double>("minTopMass");
0038   maxTopMass_ = iConfig.getParameter<double>("maxTopMass");
0039   minMinMass_ = iConfig.getParameter<double>("minMinMass");
0040 }
0041 
0042 HLTCATopTagFilter::~HLTCATopTagFilter() = default;
0043 
0044 void HLTCATopTagFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0045   edm::ParameterSetDescription desc;
0046   makeHLTFilterDescription(desc);
0047   desc.add<double>("TopMass", 171.);
0048   desc.add<double>("maxTopMass", 230.);
0049   desc.add<double>("minTopMass", 140.);
0050   desc.add<double>("minMinMass", 50.);
0051   desc.add<edm::InputTag>("src", edm::InputTag("hltParticleFlow"));
0052   desc.add<edm::InputTag>("pfsrc", edm::InputTag("selectedPFJets"));
0053   desc.add<int>("triggerType", trigger::TriggerJet);
0054   descriptions.add("hltCA8TopTagFilter", desc);
0055 }
0056 // ------------ method called to for each event  ------------
0057 
0058 bool HLTCATopTagFilter::hltFilter(edm::Event& iEvent,
0059                                   const edm::EventSetup& iSetup,
0060                                   trigger::TriggerFilterObjectWithRefs& filterobject) const {
0061   //get basic jets
0062   Handle<reco::BasicJetCollection> pBasicJets;
0063   iEvent.getByToken(inputToken_, pBasicJets);
0064 
0065   //get corresponding pf jets
0066   Handle<reco::PFJetCollection> pfJets;
0067   iEvent.getByToken(inputPFToken_, pfJets);
0068 
0069   //add filter object
0070   if (saveTags()) {
0071     filterobject.addCollectionTag(pfsrc_);
0072   }
0073 
0074   //initialize the properties
0075   CATopJetHelperUser helper(TopMass_);
0076   CATopJetProperties properties;
0077 
0078   // Now loop over the hard jets and do kinematic cuts
0079   auto ihardJet = pBasicJets->begin(), ihardJetEnd = pBasicJets->end();
0080   auto ipfJet = pfJets->begin();
0081   bool pass = false;
0082 
0083   for (; ihardJet != ihardJetEnd; ++ihardJet, ++ipfJet) {
0084     //if (ihardJet->pt() < 350) continue;
0085 
0086     // Get properties
0087     properties = helper((reco::Jet&)*ihardJet);
0088 
0089     if (properties.nSubJets < 3 || properties.minMass < minMinMass_ || properties.topMass < minTopMass_ ||
0090         properties.topMass > maxTopMass_)
0091       continue;
0092     else {
0093       // Get a ref to the hard jet
0094       reco::PFJetRef ref = reco::PFJetRef(pfJets, distance(pfJets->begin(), ipfJet));
0095       //add ref to event
0096       filterobject.addObject(trigger::TriggerJet, ref);
0097       pass = true;
0098     }
0099 
0100   }  // end loop over hard jets
0101 
0102   return pass;
0103 }
0104 // ------------ method called once each job just before starting event loop  ------------
0105 
0106 // declare this class as a framework plugin
0107 DEFINE_FWK_MODULE(HLTCATopTagFilter);