00001 #ifndef PhysicsTools_PFCandProducer_PtMinPFCandidateSelectorDefinition 00002 #define PhysicsTools_PFCandProducer_PtMinPFCandidateSelectorDefinition 00003 00004 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" 00005 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" 00006 00007 struct PtMinPFCandidateSelectorDefinition { 00008 00009 typedef reco::PFCandidateCollection collection; 00010 typedef edm::Handle< collection > HandleToCollection; 00011 typedef std::vector< reco::PFCandidate *> container; 00012 typedef container::const_iterator const_iterator; 00013 00014 PtMinPFCandidateSelectorDefinition ( const edm::ParameterSet & cfg ) : 00015 ptMin_( cfg.getParameter< double >( "ptMin" ) ) { } 00016 00017 const_iterator begin() const { return selected_.begin(); } 00018 00019 const_iterator end() const { return selected_.end(); } 00020 00021 void select( const HandleToCollection & hc, 00022 const edm::Event & e, 00023 const edm::EventSetup& s) { 00024 selected_.clear(); 00025 00026 assert( hc.isValid() ); 00027 00028 00029 unsigned key=0; 00030 for( collection::const_iterator pfc = hc->begin(); 00031 pfc != hc->end(); ++pfc, ++key) { 00032 00033 if( pfc->pt() > ptMin_ ) { 00034 selected_.push_back( new reco::PFCandidate(*pfc) ); 00035 reco::PFCandidatePtr ptrToMother( hc, key ); 00036 selected_.back()->setSourcePtr( ptrToMother ); 00037 } 00038 } 00039 } 00040 00041 size_t size() const { return selected_.size(); } 00042 00043 private: 00044 container selected_; 00045 double ptMin_; 00046 }; 00047 00048 #endif