00001 #ifndef CommonTools_ParticleFlow_GenericPFCandidateSelectorDefinition 00002 #define CommonTools_ParticleFlow_GenericPFCandidateSelectorDefinition 00003 00012 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" 00013 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" 00014 #include "CommonTools/ParticleFlow/interface/PFCandidateSelectorDefinition.h" 00015 #include "CommonTools/Utils/interface/StringCutObjectSelector.h" 00016 00017 namespace pf2pat { 00018 00019 struct GenericPFCandidateSelectorDefinition : public PFCandidateSelectorDefinition { 00020 00021 GenericPFCandidateSelectorDefinition ( const edm::ParameterSet & cfg ) : 00022 selector_( cfg.getParameter< std::string >( "cut" ) ) { } 00023 00024 void select( const HandleToCollection & hc, 00025 const edm::Event & e, 00026 const edm::EventSetup& s) { 00027 selected_.clear(); 00028 00029 unsigned key=0; 00030 for( collection::const_iterator pfc = hc->begin(); 00031 pfc != hc->end(); ++pfc, ++key) { 00032 00033 if( selector_(*pfc) ) { 00034 selected_.push_back( reco::PFCandidate(*pfc) ); 00035 reco::PFCandidatePtr ptrToMother( hc, key ); 00036 selected_.back().setSourceCandidatePtr( ptrToMother ); 00037 00038 } 00039 } 00040 } 00041 00042 private: 00043 StringCutObjectSelector<reco::PFCandidate> selector_; 00044 }; 00045 } 00046 00047 #endif