Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-02-05 23:51:09

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