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 
19 
20 namespace pf2pat {
21 
23 
25  muonCut_( cfg.getParameter< std::string >( "cut" ) )
26  {
27  }
28 
29  void select( const HandleToCollection & hc,
30  const edm::Event & e,
31  const edm::EventSetup& s) {
32  selected_.clear();
33 
34  unsigned key=0;
35  for( collection::const_iterator pfc = hc->begin();
36  pfc != hc->end(); ++pfc, ++key) {
37 
38  reco::MuonRef muR = pfc->muonRef();
39 
40  // skip ones without a ref to a reco::Muon: they won't be matched anyway
41  if (muR.isNull()) continue;
42 
43  // convert into a pat::Muon, so that the 'muonID' method is available
44  pat::Muon patMu(*muR);
45 
46  // apply muon id
47  if (muonCut_(patMu)) {
48  selected_.push_back( reco::PFCandidate(*pfc) );
49  reco::PFCandidatePtr ptrToMother( hc, key );
50  selected_.back().setSourceCandidatePtr( ptrToMother );
51  }
52  }
53  }
54 
55  private:
57  };
58 }
59 
60 #endif
MuonIDPFCandidateSelectorDefinition(const edm::ParameterSet &cfg, edm::ConsumesCollector &&iC)
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:39
list key
Definition: combine.py:13
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.