1 |
#include "DataFormats/TrackReco/interface/Track.h"
|
2 |
#include "DataFormats/MuonReco/interface/MuonSelectors.h"
|
3 |
|
4 |
#include "PhysicsTools/PatUtils/interface/MuonSelector.h"
|
5 |
|
6 |
using pat::MuonSelector;
|
7 |
using namespace reco;
|
8 |
|
9 |
|
10 |
//______________________________________________________________________________
|
11 |
const pat::ParticleStatus
|
12 |
MuonSelector::filter( const unsigned int& index,
|
13 |
const edm::View<Muon>& muons ) const
|
14 |
{
|
15 |
|
16 |
// List of possible selections
|
17 |
if ( config_.selectionType == "none" )
|
18 |
{
|
19 |
return GOOD;
|
20 |
}
|
21 |
else if ( config_.selectionType == "globalMuons" )
|
22 |
{
|
23 |
if ( muons[index].isGlobalMuon() ) return GOOD;
|
24 |
else return BAD;
|
25 |
}
|
26 |
else if ( config_.selectionType == "muonPOG" )
|
27 |
{
|
28 |
return muIdSelection_( index, muons );
|
29 |
}
|
30 |
else if ( config_.selectionType == "custom" )
|
31 |
{
|
32 |
return customSelection_( index, muons );
|
33 |
}
|
34 |
|
35 |
// Throw! unknown configuration
|
36 |
throw edm::Exception(edm::errors::Configuration)
|
37 |
<< "Unknown electron ID selection " << config_.selectionType;
|
38 |
|
39 |
}
|
40 |
|
41 |
//______________________________________________________________________________
|
42 |
const pat::ParticleStatus
|
43 |
MuonSelector::customSelection_( const unsigned int& index,
|
44 |
const edm::View<Muon>& muons ) const
|
45 |
{
|
46 |
|
47 |
// Custom muon selection from SusyAnalyzer (TQAF has a subset of these cuts)
|
48 |
|
49 |
// Use global muon if possible
|
50 |
TrackRef muontrack;
|
51 |
if ( muons[index].isGlobalMuon() )
|
52 |
muontrack = muons[index].track();
|
53 |
else
|
54 |
muontrack = muons[index].combinedMuon();
|
55 |
|
56 |
float pt_track = muontrack->pt();
|
57 |
float dpt_track = muontrack->error(0)/muontrack->qoverp()*muontrack->pt();
|
58 |
float chisq = muontrack->normalizedChi2();
|
59 |
int nHitsValid = muontrack->numberOfValidHits();
|
60 |
|
61 |
if ( dpt_track >= config_.dPbyPmax * pt_track ) return BAD;
|
62 |
|
63 |
if ( chisq > config_.chi2max ) return BAD;
|
64 |
|
65 |
if ( nHitsValid < config_.nHitsMin ) return BAD;
|
66 |
|
67 |
return GOOD;
|
68 |
|
69 |
}
|
70 |
|
71 |
|
72 |
//______________________________________________________________________________
|
73 |
const pat::ParticleStatus
|
74 |
MuonSelector::muIdSelection_( const unsigned int& index,
|
75 |
const edm::View<Muon>& muons ) const
|
76 |
{
|
77 |
// MuonID algorithm
|
78 |
if ( muons[index].isGood(config_.flag))
|
79 |
{
|
80 |
return BAD;
|
81 |
}
|
82 |
|
83 |
// Direct cuts on compatibility
|
84 |
if ( muons[index].caloCompatibility() <= config_.minCaloCompatibility
|
85 |
|| muon::segmentCompatibility(muons[index]) <= config_.minSegmentCompatibility )
|
86 |
{
|
87 |
return BAD;
|
88 |
}
|
89 |
|
90 |
return GOOD;
|
91 |
}
|