CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/CommonTools/ParticleFlow/interface/GenericPFJetSelectorDefinition.h

Go to the documentation of this file.
00001 #ifndef CommonTools_ParticleFlow_GenericPFJetSelectorDefinition
00002 #define CommonTools_ParticleFlow_GenericPFJetSelectorDefinition
00003 
00004 
00005 #include "DataFormats/JetReco/interface/PFJet.h"
00006 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"
00007 #include "CommonTools/ParticleFlow/interface/PFJetSelectorDefinition.h"
00008 #include "CommonTools/Utils/interface/StringCutObjectSelector.h"
00009 
00010 namespace pf2pat {
00011 
00012   struct GenericPFJetSelectorDefinition : public PFJetSelectorDefinition {
00013     
00014     GenericPFJetSelectorDefinition ( const edm::ParameterSet & cfg ) :
00015       selector_( cfg.getParameter< std::string >( "cut" ) ) { }
00016     
00017     void select( const HandleToCollection & hc, 
00018                  const edm::Event & e,
00019                  const edm::EventSetup& s) {
00020       selected_.clear();
00021       
00022       unsigned key=0;
00023       for( collection::const_iterator pfc = hc->begin(); 
00024            pfc != hc->end(); ++pfc, ++key) {
00025         
00026         if( selector_(*pfc) ) {
00027           selected_.push_back( reco::PFJet(*pfc) );
00028           reco::CandidatePtr ptrToMother( hc, key );
00029           selected_.back().setSourceCandidatePtr( ptrToMother );
00030           
00031         }
00032       }
00033     }
00034     
00035     private:
00036     StringCutObjectSelector<reco::PFJet> selector_;
00037   };
00038 }
00039 
00040 #endif