CMS 3D CMS Logo

MuonIDPFCandidateSelectorDefinition.h
Go to the documentation of this file.
1 #ifndef CommonTools_ParticleFlow_MuonIDPFCandidateSelectorDefinition
2 #define CommonTools_ParticleFlow_MuonIDPFCandidateSelectorDefinition
3 
21 
22 namespace pf2pat {
23 
26  : muonCut_(cfg.getParameter<std::string>("cut")) {}
27 
28  void select(const HandleToCollection& hc, const edm::Event& e, const edm::EventSetup& s) {
29  selected_.clear();
30 
31  unsigned key = 0;
32  for (collection::const_iterator pfc = hc->begin(); pfc != hc->end(); ++pfc, ++key) {
33  reco::MuonRef muR = pfc->muonRef();
34 
35  // skip ones without a ref to a reco::Muon: they won't be matched anyway
36  if (muR.isNull())
37  continue;
38 
39  // convert into a pat::Muon, so that the 'muonID' method is available
40  pat::Muon patMu(*muR);
41 
42  // apply muon id
43  if (muonCut_(patMu)) {
44  selected_.push_back(reco::PFCandidate(*pfc));
45  reco::PFCandidatePtr ptrToMother(hc, key);
46  selected_.back().setSourceCandidatePtr(ptrToMother);
47  }
48  }
49  }
50 
51  private:
53  };
54 } // namespace pf2pat
55 
56 #endif
MuonIDPFCandidateSelectorDefinition(const edm::ParameterSet &cfg, edm::ConsumesCollector &&iC)
bool isNull() const
Checks for null.
Definition: Ref.h:235
void select(const HandleToCollection &hc, const edm::Event &e, const edm::EventSetup &s)
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41
Analysis-level muon class.
Definition: Muon.h:51
Selects PFCandidates basing on cuts provided with string cut parser.