CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/CommonTools/ParticleFlow/interface/PdgIdPFCandidateSelectorDefinition.h

Go to the documentation of this file.
00001 #ifndef CommonTools_ParticleFlow_PdgIdPFCandidateSelectorDefinition
00002 #define CommonTools_ParticleFlow_PdgIdPFCandidateSelectorDefinition
00003 
00004 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"
00005 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
00006 #include "CommonTools/ParticleFlow/interface/PFCandidateSelectorDefinition.h"
00007 
00008 namespace pf2pat {
00009 
00010   class PdgIdPFCandidateSelectorDefinition : public PFCandidateSelectorDefinition {
00011     
00012   public:
00013     PdgIdPFCandidateSelectorDefinition ( const edm::ParameterSet & cfg ) :
00014       pdgIds_( cfg.getParameter< std::vector<int> >( "pdgId" ) ) { }
00015       
00016     void select( const HandleToCollection & hc, 
00017                  const edm::EventBase & e,
00018                  const edm::EventSetup& s) {
00019       selected_.clear();
00020       
00021       unsigned key=0;
00022       for( collection::const_iterator pfc = hc->begin(); 
00023            pfc != hc->end(); ++pfc, ++key) {
00024         
00025         for(unsigned iId=0; iId<pdgIds_.size(); iId++) {
00026           if ( pfc->pdgId() == pdgIds_[iId] ) {
00027             selected_.push_back( reco::PFCandidate(*pfc) );
00028             reco::PFCandidatePtr ptrToMother( hc, key );
00029             selected_.back().setSourceCandidatePtr( ptrToMother );
00030             break;
00031           }
00032         }
00033       }
00034     }
00035 
00036     private:
00037     std::vector<int> pdgIds_;
00038   };
00039 
00040 }
00041 
00042 #endif