CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/TopQuarkAnalysis/TopSkimming/plugins/JetTagCountFilter.cc

Go to the documentation of this file.
00001 #include <cmath>
00002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00003 #include "DataFormats/Common/interface/Handle.h"
00004 //#include "PluginManager/ModuleDef.h"
00005 #include "FWCore/Framework/interface/MakerMacros.h"
00006 #include "DataFormats/JetReco/interface/Jet.h"
00007 #include "DataFormats/JetReco/interface/JetFloatAssociation.h"
00008 #include "DataFormats/BTauReco/interface/JetTag.h"
00009 #include "DataFormats/JetReco/interface/CaloJetCollection.h"
00010 #include "TopQuarkAnalysis/TopSkimming/plugins/JetTagCountFilter.h"
00011 
00012 // --------------------------------------------------------------------------------
00013 
00014 JetTagCountFilter::JetTagCountFilter(const edm::ParameterSet& cfg)
00015 {
00016     src_ = cfg.getParameter<edm::InputTag>("src");
00017     minDiscriminator_ = cfg.getParameter<double>("minDiscriminator");
00018     minJetEt_ = cfg.getParameter<double>("minJetEt");
00019     maxJetEta_ = cfg.getParameter<double>("maxJetEta");
00020     minNumber_ = cfg.getParameter<unsigned int>("minNumber");
00021 }
00022 
00023 // --------------------------------------------------------------------------------
00024 
00025 JetTagCountFilter::~JetTagCountFilter()
00026 {
00027 }
00028 
00029 // --------------------------------------------------------------------------------
00030 
00031 bool
00032 JetTagCountFilter::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)
00033 {
00034     unsigned int numberOfJets = 0;
00035     edm::Handle<reco::JetFloatAssociation::Container> jFA;
00036     iEvent.getByLabel(src_, jFA);
00037     std::vector<reco::JetBaseRef> jets = reco::JetFloatAssociation::allJets(*jFA);
00038 
00039     for( std::vector<reco::JetBaseRef>::const_iterator jet = jets.begin(); jet != jets.end(); ++jet )
00040     {
00041         if (
00042             (reco::JetFloatAssociation::getValue(*jFA, **jet) > minDiscriminator_) &&
00043             ((*jet)->et() > minJetEt_) &&
00044             (fabs((*jet)->eta()) < maxJetEta_)
00045             ) numberOfJets++;
00046     }
00047     if ( numberOfJets < minNumber_ ) return false;
00048     return true;
00049 }
00050 
00051 // --------------------------------------------------------------------------------
00052 
00053 DEFINE_FWK_MODULE(JetTagCountFilter);