Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:45:20

0001 #ifndef CommonTools_ParticleFlow_GenericPFJetSelectorDefinition
0002 #define CommonTools_ParticleFlow_GenericPFJetSelectorDefinition
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/JetReco/interface/PFJet.h"
0008 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"
0009 #include "CommonTools/ParticleFlow/interface/PFJetSelectorDefinition.h"
0010 #include "CommonTools/Utils/interface/StringCutObjectSelector.h"
0011 
0012 namespace pf2pat {
0013 
0014   struct GenericPFJetSelectorDefinition : public PFJetSelectorDefinition {
0015     GenericPFJetSelectorDefinition(const edm::ParameterSet& cfg, edm::ConsumesCollector&& iC)
0016         : selector_(cfg.getParameter<std::string>("cut")) {}
0017 
0018     void select(const HandleToCollection& hc, const edm::Event& e, const edm::EventSetup& s) {
0019       selected_.clear();
0020 
0021       unsigned key = 0;
0022       for (collection::const_iterator pfc = hc->begin(); pfc != hc->end(); ++pfc, ++key) {
0023         if (selector_(*pfc)) {
0024           selected_.push_back(reco::PFJet(*pfc));
0025           reco::CandidatePtr ptrToMother(hc, key);
0026           selected_.back().setSourceCandidatePtr(ptrToMother);
0027         }
0028       }
0029     }
0030 
0031   private:
0032     StringCutObjectSelector<reco::PFJet> selector_;
0033   };
0034 }  // namespace pf2pat
0035 
0036 #endif