Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:01:05

0001 #ifndef CommonTools_ParticleFlow_PtMinPFCandidateSelectorDefinition
0002 #define CommonTools_ParticleFlow_PtMinPFCandidateSelectorDefinition
0003 
0004 #include "FWCore/Framework/interface/Event.h"
0005 #include "FWCore/Framework/interface/ConsumesCollector.h"
0006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0007 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"
0008 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
0009 #include "CommonTools/ParticleFlow/interface/PFCandidateSelectorDefinition.h"
0010 
0011 namespace pf2pat {
0012 
0013   class PtMinPFCandidateSelectorDefinition : public PFCandidateSelectorDefinition {
0014   public:
0015     PtMinPFCandidateSelectorDefinition(const edm::ParameterSet& cfg, edm::ConsumesCollector&& iC)
0016         : ptMin_(cfg.getParameter<double>("ptMin")) {}
0017 
0018     void select(const HandleToCollection& hc, const edm::EventBase& e, const edm::EventSetup& s) {
0019       selected_.clear();
0020 
0021       assert(hc.isValid());
0022 
0023       unsigned key = 0;
0024       for (collection::const_iterator pfc = hc->begin(); pfc != hc->end(); ++pfc, ++key) {
0025         if (pfc->pt() > ptMin_) {
0026           selected_.push_back(reco::PFCandidate(*pfc));
0027           reco::PFCandidatePtr ptrToMother(hc, key);
0028           selected_.back().setSourceCandidatePtr(ptrToMother);
0029         }
0030       }
0031     }
0032 
0033     /*     const container& selected() const {return selected_;} */
0034 
0035   private:
0036     double ptMin_;
0037   };
0038 
0039 }  // namespace pf2pat
0040 
0041 #endif