00001 #ifndef PhysicsTools_PFCandProducer_IsolatedPFCandidateSelectorDefinition 00002 #define PhysicsTools_PFCandProducer_IsolatedPFCandidateSelectorDefinition 00003 00004 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" 00005 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" 00006 #include "DataFormats/Common/interface/ValueMap.h" 00007 struct IsolatedPFCandidateSelectorDefinition { 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 typedef edm::ValueMap<double> isoFromDepositsMap; 00014 00015 IsolatedPFCandidateSelectorDefinition ( const edm::ParameterSet & cfg ) : 00016 isoDepositMap_(cfg.getParameter<edm::InputTag>("IsoDeposit") ), 00017 isolCut_(cfg.getParameter<double>("IsolationCut")) { } 00018 00019 const_iterator begin() const { return selected_.begin(); } 00020 00021 const_iterator end() const { return selected_.end(); } 00022 00023 void select( const HandleToCollection & hc, 00024 const edm::Event & e, 00025 const edm::EventSetup& s) { 00026 selected_.clear(); 00027 00028 assert( hc.isValid() ); 00029 00030 edm::Handle<isoFromDepositsMap > iso; 00031 e.getByLabel(isoDepositMap_,iso); 00032 const isoFromDepositsMap & qq= *(iso); 00033 00034 unsigned key=0; 00035 // for( unsigned i=0; i<collection->size(); i++ ) { 00036 for( collection::const_iterator pfc = hc->begin(); 00037 pfc != hc->end(); ++pfc, ++key) { 00038 reco::PFCandidateRef c(hc,key); 00039 float val = qq[c]; 00040 00041 00042 if (val<isolCut_) { 00043 00044 selected_.push_back( new reco::PFCandidate(*pfc) ); 00045 reco::PFCandidatePtr ptrToMother( hc, key ); 00046 00047 selected_.back()->setSourcePtr( ptrToMother ); 00048 } 00049 } 00050 } 00051 00052 size_t size() const { return selected_.size(); } 00053 00054 private: 00055 edm::InputTag isoDepositMap_; 00056 double isolCut_; 00057 container selected_; 00058 00059 }; 00060 00061 #endif