CMS 3D CMS Logo

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