Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:33:13

0001 #include "DataFormats/TrackReco/interface/Track.h"
0002 #include "DataFormats/MuonReco/interface/MuonSelectors.h"
0003 
0004 #include "PhysicsTools/PatUtils/interface/MuonSelector.h"
0005 
0006 using pat::MuonSelector;
0007 using namespace reco;
0008 
0009 //______________________________________________________________________________
0010 const pat::ParticleStatus MuonSelector::filter(const unsigned int& index, const edm::View<Muon>& muons) const {
0011   // List of possible selections
0012   if (config_.selectionType == "none") {
0013     return GOOD;
0014   } else if (config_.selectionType == "globalMuons") {
0015     if (muons[index].isGlobalMuon())
0016       return GOOD;
0017     else
0018       return BAD;
0019   } else if (config_.selectionType == "muonPOG") {
0020     return muIdSelection_(index, muons);
0021   } else if (config_.selectionType == "custom") {
0022     return customSelection_(index, muons);
0023   }
0024 
0025   // Throw! unknown configuration
0026   throw edm::Exception(edm::errors::Configuration) << "Unknown electron ID selection " << config_.selectionType;
0027 }
0028 
0029 //______________________________________________________________________________
0030 const pat::ParticleStatus MuonSelector::customSelection_(const unsigned int& index,
0031                                                          const edm::View<Muon>& muons) const {
0032   // Custom muon selection from SusyAnalyzer (TQAF has a subset of these cuts)
0033 
0034   // Use global muon if possible
0035   TrackRef muontrack;
0036   if (muons[index].isGlobalMuon())
0037     muontrack = muons[index].track();
0038   else
0039     muontrack = muons[index].combinedMuon();
0040 
0041   float pt_track = muontrack->pt();
0042   float dpt_track = muontrack->error(0) / muontrack->qoverp() * muontrack->pt();
0043   float chisq = muontrack->normalizedChi2();
0044   int nHitsValid = muontrack->numberOfValidHits();
0045 
0046   if (dpt_track >= config_.dPbyPmax * pt_track)
0047     return BAD;
0048 
0049   if (chisq > config_.chi2max)
0050     return BAD;
0051 
0052   if (nHitsValid < config_.nHitsMin)
0053     return BAD;
0054 
0055   return GOOD;
0056 }
0057 
0058 //______________________________________________________________________________
0059 const pat::ParticleStatus MuonSelector::muIdSelection_(const unsigned int& index, const edm::View<Muon>& muons) const {
0060   // MuonID algorithm
0061   if (muon::isGoodMuon((muons[index]), config_.flag)) {
0062     return BAD;
0063   }
0064 
0065   // Direct cuts on compatibility
0066   if (muons[index].caloCompatibility() <= config_.minCaloCompatibility ||
0067       muon::segmentCompatibility(muons[index]) <= config_.minSegmentCompatibility) {
0068     return BAD;
0069   }
0070 
0071   return GOOD;
0072 }