CMS 3D CMS Logo

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