Go to the documentation of this file.00001 #include "DataFormats/TrackReco/interface/Track.h"
00002 #include "DataFormats/MuonReco/interface/MuonSelectors.h"
00003
00004 #include "PhysicsTools/PatUtils/interface/MuonSelector.h"
00005
00006 using pat::MuonSelector;
00007 using namespace reco;
00008
00009
00010
00011 const pat::ParticleStatus
00012 MuonSelector::filter( const unsigned int& index,
00013 const edm::View<Muon>& muons ) const
00014 {
00015
00016
00017 if ( config_.selectionType == "none" )
00018 {
00019 return GOOD;
00020 }
00021 else if ( config_.selectionType == "globalMuons" )
00022 {
00023 if ( muons[index].isGlobalMuon() ) return GOOD;
00024 else return BAD;
00025 }
00026 else if ( config_.selectionType == "muonPOG" )
00027 {
00028 return muIdSelection_( index, muons );
00029 }
00030 else if ( config_.selectionType == "custom" )
00031 {
00032 return customSelection_( index, muons );
00033 }
00034
00035
00036 throw edm::Exception(edm::errors::Configuration)
00037 << "Unknown electron ID selection " << config_.selectionType;
00038
00039 }
00040
00041
00042 const pat::ParticleStatus
00043 MuonSelector::customSelection_( const unsigned int& index,
00044 const edm::View<Muon>& muons ) const
00045 {
00046
00047
00048
00049
00050 TrackRef muontrack;
00051 if ( muons[index].isGlobalMuon() )
00052 muontrack = muons[index].track();
00053 else
00054 muontrack = muons[index].combinedMuon();
00055
00056 float pt_track = muontrack->pt();
00057 float dpt_track = muontrack->error(0)/muontrack->qoverp()*muontrack->pt();
00058 float chisq = muontrack->normalizedChi2();
00059 int nHitsValid = muontrack->numberOfValidHits();
00060
00061 if ( dpt_track >= config_.dPbyPmax * pt_track ) return BAD;
00062
00063 if ( chisq > config_.chi2max ) return BAD;
00064
00065 if ( nHitsValid < config_.nHitsMin ) return BAD;
00066
00067 return GOOD;
00068
00069 }
00070
00071
00072
00073 const pat::ParticleStatus
00074 MuonSelector::muIdSelection_( const unsigned int& index,
00075 const edm::View<Muon>& muons ) const
00076 {
00077
00078 if ( muon::isGoodMuon((muons[index]),config_.flag) )
00079 {
00080 return BAD;
00081 }
00082
00083
00084 if ( muons[index].caloCompatibility() <= config_.minCaloCompatibility
00085 || muon::segmentCompatibility(muons[index]) <= config_.minSegmentCompatibility )
00086 {
00087 return BAD;
00088 }
00089
00090 return GOOD;
00091 }