Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // Package:    HLTCAWZTagFilter
0004 // Class:      HLTCAWZTagFilter
0005 //
0006 /**\class HLTCAWZTagFilter HLTCAWZTagFilter.cc UserCode/HLTCAWZTagFilter/plugins/HLTCAWZTagFilter.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/HLTCAWZTagFilter.h"
0021 
0022 using namespace std;
0023 using namespace reco;
0024 using namespace edm;
0025 
0026 //
0027 // constructors and destructor
0028 //
0029 
0030 HLTCAWZTagFilter::HLTCAWZTagFilter(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   minWMass_ = iConfig.getParameter<double>("minWMass");
0037   maxWMass_ = iConfig.getParameter<double>("maxWMass");
0038   massdropcut_ = iConfig.getParameter<double>("massdropcut");
0039 }
0040 
0041 HLTCAWZTagFilter::~HLTCAWZTagFilter() = default;
0042 
0043 void HLTCAWZTagFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0044   edm::ParameterSetDescription desc;
0045   makeHLTFilterDescription(desc);
0046   desc.add<double>("maxWMass", 130.);
0047   desc.add<double>("minWMass", 60.);
0048   desc.add<double>("massdropcut", 0.4);
0049   desc.add<edm::InputTag>("src", edm::InputTag("hltParticleFlow"));
0050   desc.add<edm::InputTag>("pfsrc", edm::InputTag("selectedPFJets"));
0051   desc.add<int>("triggerType", trigger::TriggerJet);
0052   descriptions.add("hltCA8WZTagFilter", desc);
0053 }
0054 
0055 // ------------ method called to for each event  ------------
0056 
0057 bool HLTCAWZTagFilter::hltFilter(edm::Event& iEvent,
0058                                  const edm::EventSetup& iSetup,
0059                                  trigger::TriggerFilterObjectWithRefs& filterobject) const {
0060   // Get the input list of basic jets corresponding to the hard jets
0061   Handle<reco::BasicJetCollection> pBasicJets;
0062   iEvent.getByToken(inputToken_, pBasicJets);
0063 
0064   //get corresponding pf jets
0065   Handle<reco::PFJetCollection> pfJets;
0066   iEvent.getByToken(inputPFToken_, pfJets);
0067 
0068   //add filter object
0069   if (saveTags()) {
0070     filterobject.addCollectionTag(pfsrc_);
0071   }
0072 
0073   //initialize the properties
0074   CAWZJetHelperUser helper(massdropcut_);
0075   CATopJetProperties properties;
0076 
0077   // Now loop over the hard jets and do kinematic cuts
0078   auto ihardJet = pBasicJets->begin(), ihardJetEnd = pBasicJets->end();
0079   auto ipfJet = pfJets->begin();
0080   bool pass = false;
0081 
0082   for (; ihardJet != ihardJetEnd; ++ihardJet, ++ipfJet) {
0083     //if (ihardJet->pt() < 150) continue;
0084 
0085     // Get properties
0086     properties = helper((reco::Jet&)*ihardJet);
0087 
0088     if (properties.nSubJets != 2 || properties.wMass < minWMass_ || properties.wMass > maxWMass_)
0089       continue;
0090     else {
0091       // Get a ref to the hard jet
0092       reco::PFJetRef ref = reco::PFJetRef(pfJets, distance(pfJets->begin(), ipfJet));
0093       //add ref to event
0094       filterobject.addObject(trigger::TriggerJet, ref);
0095       pass = true;
0096     }
0097 
0098   }  // end loop over hard jets
0099 
0100   return pass;
0101 }
0102 
0103 // declare this class as a framework plugin
0104 DEFINE_FWK_MODULE(HLTCAWZTagFilter);